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
objcio/pygments
pygments/lexers/prolog.py
25
12066
# -*- coding: utf-8 -*- """ pygments.lexers.prolog ~~~~~~~~~~~~~~~~~~~~~~ Lexers for Prolog and Prolog-like languages. :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re from pygments.lexer import RegexLexer, bygroups from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation __all__ = ['PrologLexer', 'LogtalkLexer'] class PrologLexer(RegexLexer): """ Lexer for Prolog files. """ name = 'Prolog' aliases = ['prolog'] filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl'] mimetypes = ['text/x-prolog'] flags = re.UNICODE | re.MULTILINE tokens = { 'root': [ (r'^#.*', Comment.Single), (r'/\*', Comment.Multiline, 'nested-comment'), (r'%.*', Comment.Single), # character literal (r'0\'.', String.Char), (r'0b[01]+', Number.Bin), (r'0o[0-7]+', Number.Oct), (r'0x[0-9a-fA-F]+', Number.Hex), # literal with prepended base (r'\d\d?\'[a-zA-Z0-9]+', Number.Integer), (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'\d+', Number.Integer), (r'[\[\](){}|.,;!]', Punctuation), (r':-|-->', Punctuation), (r'"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|' r'\\[0-7]+\\|\\["\nabcefnrstv]|[^\\"])*"', String.Double), (r"'(?:''|[^'])*'", String.Atom), # quoted atom # Needs to not be followed by an atom. # (r'=(?=\s|[a-zA-Z\[])', Operator), (r'is\b', Operator), (r'(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])', Operator), (r'(mod|div|not)\b', Operator), (r'_', Keyword), # The don't-care variable (r'([a-z]+)(:)', bygroups(Name.Namespace, Punctuation)), (u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]' u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)' u'(\\s*)(:-|-->)', bygroups(Name.Function, Text, Operator)), # function defn (u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]' u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)' u'(\\s*)(\\()', bygroups(Name.Function, Text, Punctuation)), (u'[a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]' u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*', String.Atom), # atom, characters # This one includes ! (u'[#&*+\\-./:<=>?@\\\\^~\u00a1-\u00bf\u2010-\u303f]+', String.Atom), # atom, graphics (r'[A-Z_]\w*', Name.Variable), (u'\\s+|[\u2000-\u200f\ufff0-\ufffe\uffef]', Text), ], 'nested-comment': [ (r'\*/', Comment.Multiline, '#pop'), (r'/\*', Comment.Multiline, '#push'), (r'[^*/]+', Comment.Multiline), (r'[*/]', Comment.Multiline), ], } def analyse_text(text): return ':-' in text class LogtalkLexer(RegexLexer): """ For `Logtalk <http://logtalk.org/>`_ source code. .. versionadded:: 0.10 """ name = 'Logtalk' aliases = ['logtalk'] filenames = ['*.lgt', '*.logtalk'] mimetypes = ['text/x-logtalk'] tokens = { 'root': [ # Directives (r'^\s*:-\s', Punctuation, 'directive'), # Comments (r'%.*?\n', Comment), (r'/\*(.|\n)*?\*/', Comment), # Whitespace (r'\n', Text), (r'\s+', Text), # Numbers (r"0'.", Number), (r'0b[01]+', Number.Bin), (r'0o[0-7]+', Number.Oct), (r'0x[0-9a-fA-F]+', Number.Hex), (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number), # Variables (r'([A-Z_]\w*)', Name.Variable), # Event handlers (r'(after|before)(?=[(])', Keyword), # Message forwarding handler (r'forward(?=[(])', Keyword), # Execution-context methods (r'(parameter|this|se(lf|nder))(?=[(])', Keyword), # Reflection (r'(current_predicate|predicate_property)(?=[(])', Keyword), # DCGs and term expansion (r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])', Keyword), # Entity (r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])', Keyword), (r'(object|protocol|category)_property(?=[(])', Keyword), # Entity relations (r'co(mplements_object|nforms_to_protocol)(?=[(])', Keyword), (r'extends_(object|protocol|category)(?=[(])', Keyword), (r'imp(lements_protocol|orts_category)(?=[(])', Keyword), (r'(instantiat|specializ)es_class(?=[(])', Keyword), # Events (r'(current_event|(abolish|define)_events)(?=[(])', Keyword), # Flags (r'(current|set)_logtalk_flag(?=[(])', Keyword), # Compiling, loading, and library paths (r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make)(?=[(])', Keyword), (r'\blogtalk_make\b', Keyword), # Database (r'(clause|retract(all)?)(?=[(])', Keyword), (r'a(bolish|ssert(a|z))(?=[(])', Keyword), # Control constructs (r'(ca(ll|tch)|throw)(?=[(])', Keyword), (r'(fa(il|lse)|true)\b', Keyword), # All solutions (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword), # Multi-threading meta-predicates (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword), # Term unification (r'(subsumes_term|unify_with_occurs_check)(?=[(])', Keyword), # Term creation and decomposition (r'(functor|arg|copy_term|numbervars|term_variables)(?=[(])', Keyword), # Evaluable functors (r'(div|rem|m(ax|in|od)|abs|sign)(?=[(])', Keyword), (r'float(_(integer|fractional)_part)?(?=[(])', Keyword), (r'(floor|t(an|runcate)|round|ceiling)(?=[(])', Keyword), # Other arithmetic functors (r'(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=[(])', Keyword), # Term testing (r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|' r'ground|acyclic_term)(?=[(])', Keyword), # Term comparison (r'compare(?=[(])', Keyword), # Stream selection and control (r'(curren|se)t_(in|out)put(?=[(])', Keyword), (r'(open|close)(?=[(])', Keyword), (r'flush_output(?=[(])', Keyword), (r'(at_end_of_stream|flush_output)\b', Keyword), (r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])', Keyword), # Character and byte input/output (r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword), (r'\bnl\b', Keyword), # Term input/output (r'read(_term)?(?=[(])', Keyword), (r'write(q|_(canonical|term))?(?=[(])', Keyword), (r'(current_)?op(?=[(])', Keyword), (r'(current_)?char_conversion(?=[(])', Keyword), # Atomic term processing (r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword), (r'(char_code|sub_atom)(?=[(])', Keyword), (r'number_c(har|ode)s(?=[(])', Keyword), # Implementation defined hooks functions (r'(se|curren)t_prolog_flag(?=[(])', Keyword), (r'\bhalt\b', Keyword), (r'halt(?=[(])', Keyword), # Message sending operators (r'(::|:|\^\^)', Operator), # External call (r'[{}]', Keyword), # Logic and control (r'(ignore|once)(?=[(])', Keyword), (r'\brepeat\b', Keyword), # Sorting (r'(key)?sort(?=[(])', Keyword), # Bitwise functors (r'(>>|<<|/\\|\\\\|\\)', Operator), # Predicate aliases (r'\bas\b', Operator), # Arithemtic evaluation (r'\bis\b', Keyword), # Arithemtic comparison (r'(=:=|=\\=|<|=<|>=|>)', Operator), # Term creation and decomposition (r'=\.\.', Operator), # Term unification (r'(=|\\=)', Operator), # Term comparison (r'(==|\\==|@=<|@<|@>=|@>)', Operator), # Evaluable functors (r'(//|[-+*/])', Operator), (r'\b(e|pi|div|mod|rem)\b', Operator), # Other arithemtic functors (r'\b\*\*\b', Operator), # DCG rules (r'-->', Operator), # Control constructs (r'([!;]|->)', Operator), # Logic and control (r'\\+', Operator), # Mode operators (r'[?@]', Operator), # Existential quantifier (r'\^', Operator), # Strings (r'"(\\\\|\\"|[^"])*"', String), # Ponctuation (r'[()\[\],.|]', Text), # Atoms (r"[a-z]\w*", Text), (r"'", String, 'quoted_atom'), ], 'quoted_atom': [ (r"''", String), (r"'", String, '#pop'), (r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape), (r"[^\\'\n]+", String), (r'\\', String), ], 'directive': [ # Conditional compilation directives (r'(el)?if(?=[(])', Keyword, 'root'), (r'(e(lse|ndif))[.]', Keyword, 'root'), # Entity directives (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'), (r'(end_(category|object|protocol))[.]', Keyword, 'root'), # Predicate scope directives (r'(public|protected|private)(?=[(])', Keyword, 'root'), # Other directives (r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'), (r'in(clude|itialization|fo)(?=[(])', Keyword, 'root'), (r'(built_in|dynamic|synchronized|threaded)[.]', Keyword, 'root'), (r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|' r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'), (r'op(?=[(])', Keyword, 'root'), (r'(c(alls|oinductive)|module|reexport|use(s|_module))(?=[(])', Keyword, 'root'), (r'[a-z]\w*(?=[(])', Text, 'root'), (r'[a-z]\w*[.]', Text, 'root'), ], 'entityrelations': [ (r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', Keyword), # Numbers (r"0'.", Number), (r'0b[01]+', Number.Bin), (r'0o[0-7]+', Number.Oct), (r'0x[0-9a-fA-F]+', Number.Hex), (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number), # Variables (r'([A-Z_]\w*)', Name.Variable), # Atoms (r"[a-z]\w*", Text), (r"'", String, 'quoted_atom'), # Strings (r'"(\\\\|\\"|[^"])*"', String), # End of entity-opening directive (r'([)]\.)', Text, 'root'), # Scope operator (r'(::)', Operator), # Ponctuation (r'[()\[\],.|]', Text), # Comments (r'%.*?\n', Comment), (r'/\*(.|\n)*?\*/', Comment), # Whitespace (r'\n', Text), (r'\s+', Text), ] } def analyse_text(text): if ':- object(' in text: return 1.0 elif ':- protocol(' in text: return 1.0 elif ':- category(' in text: return 1.0 elif re.search('^:-\s[a-z]', text, re.M): return 0.9 else: return 0.0
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 14, 496, 793, 272, 18294, 2878, 1714, 339, 491, 476, 1192, 367, 2165, 793, 436, 2165, 793, 13, 2930, 10815, 14, 339, 520, 7307, 26, 1898, 8315, 13, 7806, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 199, 504, 13277, 14, 11729, 492, 12939, 5838, 12, 10259, 199, 504, 13277, 14, 1418, 492, 4516, 12, 6819, 12, 11013, 12, 6431, 12, 2812, 12, 2624, 12, 971, 272, 4860, 12, 10357, 199, 199, 363, 452, 363, 275, 788, 919, 793, 5838, 297, 283, 2445, 21890, 5838, 418, 421, 199, 533, 2165, 793, 5838, 8, 19856, 304, 272, 408, 272, 21125, 367, 2165, 793, 1584, 14, 272, 408, 272, 536, 275, 283, 919, 793, 7, 272, 5481, 275, 788, 496, 793, 418, 272, 6203, 275, 17855, 69, 429, 297, 11937, 496, 793, 297, 11937, 496, 297, 11937, 1168, 418, 272, 13290, 275, 788, 505, 15, 88, 13, 496, 793, 418, 339, 3285, 275, 295, 14, 12819, 1204, 295, 14, 16661, 339, 4645, 275, 469, 267, 283, 1231, 356, 359, 288, 334, 82, 4289, 3, 16110, 6819, 14, 7200, 395, 288, 334, 82, 32575, 7693, 6819, 14, 18933, 12, 283, 6376, 13, 3349, 659, 288, 334, 82, 5956, 16110, 6819, 14, 7200, 395, 288, 327, 4528, 8785, 288, 334, 82, 7, 16, 60, 1370, 297, 2624, 14, 1610, 395, 288, 334, 82, 7, 16, 66, 59, 614, 11529, 4860, 14, 13394, 395, 288, 334, 82, 7, 16, 79, 59, 16, 13, 23, 11529, 4860, 14, 17584, 395, 288, 334, 82, 7, 16, 88, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 11529, 4860, 14, 10373, 395, 288, 327, 8785, 543, 20247, 1300, 288, 334, 82, 1154, 68, 60, 68, 8995, 3894, 65, 13, 6353, 13, 58, 16, 13, 25, 11529, 4860, 14, 2674, 395, 288, 334, 82, 13445, 68, 23294, 68, 10, 6113, 68, 7590, 3134, 68, 8771, 779, 20565, 1527, 16341, 21852, 16, 13, 25, 23763, 297, 4860, 14, 5136, 395, 288, 334, 82, 1154, 68, 7386, 4860, 14, 2674, 395, 288, 334, 82, 22123, 7023, 32702, 2440, 92, 2020, 27, 1, 4300, 10357, 395, 288, 334, 82, 356, 13, 92, 306, 4206, 10357, 395, 288, 334, 82, 4065, 5169, 1103, 88, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 2807, 1103, 17780, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 20, 93, 17780, 53, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 24, 93, 5227, 1467, 519, 8124, 59, 16, 13, 23, 2807, 1103, 17780, 905, 60, 78, 371, 301, 2324, 8332, 86, 11752, 4735, 1103, 3135, 10, 6949, 2624, 14, 7281, 395, 288, 334, 82, 4507, 5169, 891, 23629, 1105, 10, 4662, 2624, 14, 12097, 395, 221, 327, 10999, 6222, 288, 327, 29613, 370, 440, 506, 9437, 701, 376, 6222, 14, 288, 327, 334, 82, 7, 29, 2229, 9529, 83, 17884, 65, 13, 6353, 13, 58, 25621, 22206, 11013, 395, 288, 334, 82, 7, 374, 60, 66, 297, 11013, 395, 288, 334, 82, 6774, 28, 92, 21521, 18987, 92, 8119, 92, 389, 92, 29, 26, 26777, 26777, 15, 92, 501, 6113, 10, 6113, 21449, 13, 18168, 9529, 83, 17884, 65, 13, 6353, 13, 58, 16, 13, 25, 25621, 22206, 1467, 11013, 395, 288, 334, 82, 6774, 1494, 92, 3015, 92, 1397, 2862, 66, 297, 11013, 395, 288, 334, 82, 7, 14474, 6431, 395, 221, 327, 710, 2793, 1133, 13, 28654, 1750, 288, 334, 82, 21731, 65, 13, 90, 2807, 5130, 26, 3196, 10259, 8, 985, 14, 8814, 12, 10357, 1826, 288, 334, 85, 21731, 65, 13, 90, 60, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 6616, 1467, 399, 22123, 87, 16827, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 3672, 3171, 1467, 399, 6774, 1103, 83, 28304, 6809, 92, 31647, 3196, 1467, 10259, 8, 985, 14, 3481, 12, 4516, 12, 11013, 1826, 221, 327, 805, 347, 78, 288, 334, 85, 21731, 65, 13, 90, 60, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 6616, 1467, 399, 22123, 87, 16827, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 3672, 3171, 1467, 399, 6774, 1103, 83, 28304, 1103, 19633, 1467, 10259, 8, 985, 14, 3481, 12, 4516, 12, 10357, 1826, 288, 334, 85, 3894, 65, 13, 90, 60, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 6616, 1467, 399, 22123, 87, 16827, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 22952, 1467, 2624, 14, 12097, 395, 221, 327, 6222, 12, 4110, 288, 327, 961, 1373, 6952, 8546, 288, 334, 85, 3894, 3, 6, 10, 11, 1103, 13, 13186, 26, 12932, 30, 31, 32, 8712, 62, 94, 60, 85, 383, 65, 17, 2696, 85, 383, 4361, 60, 85, 6542, 2696, 85, 11810, 70, 11529, 1467, 2624, 14, 12097, 395, 221, 327, 6222, 12, 24348, 288, 334, 82, 3894, 33, 13, 58, 29588, 87, 7693, 2812, 14, 2773, 395, 288, 334, 85, 8124, 83, 21449, 7023, 85, 8269, 2696, 85, 1840, 70, 60, 3043, 70, 16, 2696, 13871, 60, 85, 2026, 70, 4300, 4516, 395, 267, 2156, 267, 283, 6376, 13, 3349, 356, 359, 288, 334, 82, 1154, 10, 3678, 6819, 14, 18933, 12, 3943, 1935, 659, 288, 334, 82, 32575, 7693, 6819, 14, 18933, 12, 3943, 5335, 659, 288, 334, 82, 16122, 15870, 11529, 6819, 14, 18933, 395, 288, 334, 82, 3894, 15870, 4300, 6819, 14, 18933, 395, 267, 2156, 272, 789, 339, 347, 21297, 63, 505, 8, 505, 304, 267, 372, 283, 6809, 7, 315, 1318, 421, 199, 533, 5297, 21890, 5838, 8, 19856, 304, 272 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 14, 496, 793, 272, 18294, 2878, 1714, 339, 491, 476, 1192, 367, 2165, 793, 436, 2165, 793, 13, 2930, 10815, 14, 339, 520, 7307, 26, 1898, 8315, 13, 7806, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 199, 504, 13277, 14, 11729, 492, 12939, 5838, 12, 10259, 199, 504, 13277, 14, 1418, 492, 4516, 12, 6819, 12, 11013, 12, 6431, 12, 2812, 12, 2624, 12, 971, 272, 4860, 12, 10357, 199, 199, 363, 452, 363, 275, 788, 919, 793, 5838, 297, 283, 2445, 21890, 5838, 418, 421, 199, 533, 2165, 793, 5838, 8, 19856, 304, 272, 408, 272, 21125, 367, 2165, 793, 1584, 14, 272, 408, 272, 536, 275, 283, 919, 793, 7, 272, 5481, 275, 788, 496, 793, 418, 272, 6203, 275, 17855, 69, 429, 297, 11937, 496, 793, 297, 11937, 496, 297, 11937, 1168, 418, 272, 13290, 275, 788, 505, 15, 88, 13, 496, 793, 418, 339, 3285, 275, 295, 14, 12819, 1204, 295, 14, 16661, 339, 4645, 275, 469, 267, 283, 1231, 356, 359, 288, 334, 82, 4289, 3, 16110, 6819, 14, 7200, 395, 288, 334, 82, 32575, 7693, 6819, 14, 18933, 12, 283, 6376, 13, 3349, 659, 288, 334, 82, 5956, 16110, 6819, 14, 7200, 395, 288, 327, 4528, 8785, 288, 334, 82, 7, 16, 60, 1370, 297, 2624, 14, 1610, 395, 288, 334, 82, 7, 16, 66, 59, 614, 11529, 4860, 14, 13394, 395, 288, 334, 82, 7, 16, 79, 59, 16, 13, 23, 11529, 4860, 14, 17584, 395, 288, 334, 82, 7, 16, 88, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 11529, 4860, 14, 10373, 395, 288, 327, 8785, 543, 20247, 1300, 288, 334, 82, 1154, 68, 60, 68, 8995, 3894, 65, 13, 6353, 13, 58, 16, 13, 25, 11529, 4860, 14, 2674, 395, 288, 334, 82, 13445, 68, 23294, 68, 10, 6113, 68, 7590, 3134, 68, 8771, 779, 20565, 1527, 16341, 21852, 16, 13, 25, 23763, 297, 4860, 14, 5136, 395, 288, 334, 82, 1154, 68, 7386, 4860, 14, 2674, 395, 288, 334, 82, 22123, 7023, 32702, 2440, 92, 2020, 27, 1, 4300, 10357, 395, 288, 334, 82, 356, 13, 92, 306, 4206, 10357, 395, 288, 334, 82, 4065, 5169, 1103, 88, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 2807, 1103, 17780, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 20, 93, 17780, 53, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 24, 93, 5227, 1467, 519, 8124, 59, 16, 13, 23, 2807, 1103, 17780, 905, 60, 78, 371, 301, 2324, 8332, 86, 11752, 4735, 1103, 3135, 10, 6949, 2624, 14, 7281, 395, 288, 334, 82, 4507, 5169, 891, 23629, 1105, 10, 4662, 2624, 14, 12097, 395, 221, 327, 10999, 6222, 288, 327, 29613, 370, 440, 506, 9437, 701, 376, 6222, 14, 288, 327, 334, 82, 7, 29, 2229, 9529, 83, 17884, 65, 13, 6353, 13, 58, 25621, 22206, 11013, 395, 288, 334, 82, 7, 374, 60, 66, 297, 11013, 395, 288, 334, 82, 6774, 28, 92, 21521, 18987, 92, 8119, 92, 389, 92, 29, 26, 26777, 26777, 15, 92, 501, 6113, 10, 6113, 21449, 13, 18168, 9529, 83, 17884, 65, 13, 6353, 13, 58, 16, 13, 25, 25621, 22206, 1467, 11013, 395, 288, 334, 82, 6774, 1494, 92, 3015, 92, 1397, 2862, 66, 297, 11013, 395, 288, 334, 82, 7, 14474, 6431, 395, 221, 327, 710, 2793, 1133, 13, 28654, 1750, 288, 334, 82, 21731, 65, 13, 90, 2807, 5130, 26, 3196, 10259, 8, 985, 14, 8814, 12, 10357, 1826, 288, 334, 85, 21731, 65, 13, 90, 60, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 6616, 1467, 399, 22123, 87, 16827, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 3672, 3171, 1467, 399, 6774, 1103, 83, 28304, 6809, 92, 31647, 3196, 1467, 10259, 8, 985, 14, 3481, 12, 4516, 12, 11013, 1826, 221, 327, 805, 347, 78, 288, 334, 85, 21731, 65, 13, 90, 60, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 6616, 1467, 399, 22123, 87, 16827, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 3672, 3171, 1467, 399, 6774, 1103, 83, 28304, 1103, 19633, 1467, 10259, 8, 985, 14, 3481, 12, 4516, 12, 10357, 1826, 288, 334, 85, 3894, 65, 13, 90, 60, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 6616, 1467, 399, 22123, 87, 16827, 85, 383, 67, 16, 2696, 85, 17, 18190, 60, 85, 8533, 16, 2696, 1181, 23, 556, 60, 310, 1493, 2696, 85, 2026, 70, 22952, 1467, 2624, 14, 12097, 395, 221, 327, 6222, 12, 4110, 288, 327, 961, 1373, 6952, 8546, 288, 334, 85, 3894, 3, 6, 10, 11, 1103, 13, 13186, 26, 12932, 30, 31, 32, 8712, 62, 94, 60, 85, 383, 65, 17, 2696, 85, 383, 4361, 60, 85, 6542, 2696, 85, 11810, 70, 11529, 1467, 2624, 14, 12097, 395, 221, 327, 6222, 12, 24348, 288, 334, 82, 3894, 33, 13, 58, 29588, 87, 7693, 2812, 14, 2773, 395, 288, 334, 85, 8124, 83, 21449, 7023, 85, 8269, 2696, 85, 1840, 70, 60, 3043, 70, 16, 2696, 13871, 60, 85, 2026, 70, 4300, 4516, 395, 267, 2156, 267, 283, 6376, 13, 3349, 356, 359, 288, 334, 82, 1154, 10, 3678, 6819, 14, 18933, 12, 3943, 1935, 659, 288, 334, 82, 32575, 7693, 6819, 14, 18933, 12, 3943, 5335, 659, 288, 334, 82, 16122, 15870, 11529, 6819, 14, 18933, 395, 288, 334, 82, 3894, 15870, 4300, 6819, 14, 18933, 395, 267, 2156, 272, 789, 339, 347, 21297, 63, 505, 8, 505, 304, 267, 372, 283, 6809, 7, 315, 1318, 421, 199, 533, 5297, 21890, 5838, 8, 19856, 304, 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, 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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 ]
tarthy6/dozer-thesis
scripts/test-OLD/periodic-grow.py
3
1320
"""Script that shrinks the periodic cell progressively. It prints strain and average stress (computed from total volume force) once in a while.""" from woo import log,timing log.setLevel("InsertionSortCollider",log.TRACE) O.engines=[ ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb()]), InteractionLoop( [Ig2_Sphere_Sphere_Dem3DofGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_Dem3DofGeom_FrictPhys_CundallStrack()], ), NewtonIntegrator(damping=.6,homotheticCellResize=1) ] import random for i in xrange(250): O.bodies.append(utils.sphere(Vector3(10*random.random(),10*random.random(),10*random.random()),.5+random.random())) cubeSize=20 # absolute positioning of the cell is not important O.periodic=True O.cell.refSize=(cubeSize,cubeSize,cubeSize) O.dt=utils.PWaveTimeStep() O.saveTmp() from woo import qt qt.Controller(); qt.View() O.run(200,True) rate=-1e-3*cubeSize/(O.dt*200)*Matrix3.Identity O.cell.velGrad=rate for i in range(0,25): O.run(2000,True) F,stiff=utils.totalForceInVolume() dim=O.cell.refSize; A=Vector3(dim[1]*dim[2],dim[0]*dim[2],dim[0]*dim[1]) avgStress=sum([F[i]/A[i] for i in 0,1,2])/3. print 'strain',(cubeSize-dim[0])/cubeSize,'avg. stress ',avgStress,'unbalanced ',utils.unbalancedForce() #O.timingEnabled=True; timing.reset(); O.run(200000,True); timing.stats()
gpl-2.0
[ 624, 5229, 626, 19790, 83, 314, 18745, 4917, 557, 7266, 9840, 14, 199, 7940, 14767, 410, 6322, 436, 8095, 31692, 334, 14378, 687, 3141, 3301, 3542, 9, 199, 5089, 315, 282, 1830, 1041, 199, 504, 336, 1534, 492, 943, 12, 14639, 199, 793, 14, 13548, 480, 607, 4535, 14376, 2001, 11306, 401, 793, 14, 20112, 9, 199, 47, 14, 30378, 1524, 199, 198, 13606, 497, 8345, 1062, 199, 198, 607, 4535, 14376, 2001, 11306, 779, 2208, 17, 63, 22385, 63, 33, 12198, 342, 2522, 199, 198, 31900, 7382, 8, 507, 198, 59, 27061, 18, 63, 22385, 63, 22385, 63, 872, 77, 19, 36, 1618, 13427, 15618, 507, 198, 59, 6583, 18, 63, 22533, 319, 14817, 63, 22533, 319, 14817, 63, 22533, 319, 5663, 588, 15618, 507, 198, 59, 7833, 87, 18, 63, 872, 77, 19, 36, 1618, 13427, 63, 22533, 319, 5663, 588, 63, 35, 725, 452, 933, 8085, 15618, 199, 198, 395, 199, 198, 4665, 1860, 8309, 2587, 707, 8, 31218, 316, 15856, 22, 12, 526, 573, 21231, 8108, 24559, 29, 17, 9, 199, 61, 199, 646, 2196, 199, 509, 284, 315, 4945, 8, 7991, 304, 199, 198, 47, 14, 656, 18245, 14, 740, 8, 1208, 14, 14980, 8, 3646, 19, 8, 709, 10, 2355, 14, 2355, 1062, 709, 10, 2355, 14, 2355, 1062, 709, 10, 2355, 14, 2355, 4000, 14, 21, 11, 2355, 14, 2355, 4059, 199, 11477, 2320, 29, 1165, 199, 3, 3679, 3421, 316, 402, 314, 4917, 365, 440, 11012, 199, 47, 14, 20339, 29, 549, 199, 47, 14, 3890, 14, 1121, 2320, 2687, 11477, 2320, 12, 11477, 2320, 12, 11477, 2320, 9, 199, 47, 14, 3583, 29, 1208, 14, 10780, 811, 1366, 7801, 342, 199, 47, 14, 2117, 52, 311, 342, 199, 504, 336, 1534, 492, 19227, 199, 8440, 14, 7506, 7303, 19227, 14, 2768, 342, 199, 47, 14, 1065, 8, 1840, 12, 549, 9, 199, 1866, 4022, 17, 69, 13, 19, 10, 11477, 2320, 7985, 47, 14, 3583, 10, 1840, 3342, 6443, 19, 14, 10193, 199, 47, 14, 3890, 14, 1090, 14812, 29, 1866, 199, 509, 284, 315, 1425, 8, 16, 12, 821, 304, 199, 198, 47, 14, 1065, 8, 8269, 12, 549, 9, 199, 198, 38, 12, 270, 15126, 29, 1208, 14, 2923, 13606, 607, 6464, 342, 199, 198, 3572, 29, 47, 14, 3890, 14, 1121, 2320, 27, 437, 29, 3646, 19, 8, 3572, 59, 17, 3672, 3572, 59, 18, 467, 3572, 59, 16, 3672, 3572, 59, 18, 467, 3572, 59, 16, 3672, 3572, 59, 17, 566, 199, 198, 8595, 933, 753, 29, 1838, 779, 38, 59, 73, 12978, 33, 59, 73, 61, 367, 284, 315, 378, 12, 17, 12, 18, 23067, 19, 14, 199, 198, 1361, 283, 270, 6322, 297, 8, 11477, 2320, 13, 3572, 59, 16, 23067, 11477, 2320, 2584, 8595, 14, 31692, 1656, 8595, 933, 753, 2584, 324, 18923, 1656, 1208, 14, 324, 18923, 13606, 342, 199, 3, 47, 14, 14639, 6589, 29, 549, 27, 20542, 14, 3958, 7303, 593, 14, 1065, 8, 18, 5345, 12, 549, 2736, 20542, 14, 3200, 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 ]
[ 5229, 626, 19790, 83, 314, 18745, 4917, 557, 7266, 9840, 14, 199, 7940, 14767, 410, 6322, 436, 8095, 31692, 334, 14378, 687, 3141, 3301, 3542, 9, 199, 5089, 315, 282, 1830, 1041, 199, 504, 336, 1534, 492, 943, 12, 14639, 199, 793, 14, 13548, 480, 607, 4535, 14376, 2001, 11306, 401, 793, 14, 20112, 9, 199, 47, 14, 30378, 1524, 199, 198, 13606, 497, 8345, 1062, 199, 198, 607, 4535, 14376, 2001, 11306, 779, 2208, 17, 63, 22385, 63, 33, 12198, 342, 2522, 199, 198, 31900, 7382, 8, 507, 198, 59, 27061, 18, 63, 22385, 63, 22385, 63, 872, 77, 19, 36, 1618, 13427, 15618, 507, 198, 59, 6583, 18, 63, 22533, 319, 14817, 63, 22533, 319, 14817, 63, 22533, 319, 5663, 588, 15618, 507, 198, 59, 7833, 87, 18, 63, 872, 77, 19, 36, 1618, 13427, 63, 22533, 319, 5663, 588, 63, 35, 725, 452, 933, 8085, 15618, 199, 198, 395, 199, 198, 4665, 1860, 8309, 2587, 707, 8, 31218, 316, 15856, 22, 12, 526, 573, 21231, 8108, 24559, 29, 17, 9, 199, 61, 199, 646, 2196, 199, 509, 284, 315, 4945, 8, 7991, 304, 199, 198, 47, 14, 656, 18245, 14, 740, 8, 1208, 14, 14980, 8, 3646, 19, 8, 709, 10, 2355, 14, 2355, 1062, 709, 10, 2355, 14, 2355, 1062, 709, 10, 2355, 14, 2355, 4000, 14, 21, 11, 2355, 14, 2355, 4059, 199, 11477, 2320, 29, 1165, 199, 3, 3679, 3421, 316, 402, 314, 4917, 365, 440, 11012, 199, 47, 14, 20339, 29, 549, 199, 47, 14, 3890, 14, 1121, 2320, 2687, 11477, 2320, 12, 11477, 2320, 12, 11477, 2320, 9, 199, 47, 14, 3583, 29, 1208, 14, 10780, 811, 1366, 7801, 342, 199, 47, 14, 2117, 52, 311, 342, 199, 504, 336, 1534, 492, 19227, 199, 8440, 14, 7506, 7303, 19227, 14, 2768, 342, 199, 47, 14, 1065, 8, 1840, 12, 549, 9, 199, 1866, 4022, 17, 69, 13, 19, 10, 11477, 2320, 7985, 47, 14, 3583, 10, 1840, 3342, 6443, 19, 14, 10193, 199, 47, 14, 3890, 14, 1090, 14812, 29, 1866, 199, 509, 284, 315, 1425, 8, 16, 12, 821, 304, 199, 198, 47, 14, 1065, 8, 8269, 12, 549, 9, 199, 198, 38, 12, 270, 15126, 29, 1208, 14, 2923, 13606, 607, 6464, 342, 199, 198, 3572, 29, 47, 14, 3890, 14, 1121, 2320, 27, 437, 29, 3646, 19, 8, 3572, 59, 17, 3672, 3572, 59, 18, 467, 3572, 59, 16, 3672, 3572, 59, 18, 467, 3572, 59, 16, 3672, 3572, 59, 17, 566, 199, 198, 8595, 933, 753, 29, 1838, 779, 38, 59, 73, 12978, 33, 59, 73, 61, 367, 284, 315, 378, 12, 17, 12, 18, 23067, 19, 14, 199, 198, 1361, 283, 270, 6322, 297, 8, 11477, 2320, 13, 3572, 59, 16, 23067, 11477, 2320, 2584, 8595, 14, 31692, 1656, 8595, 933, 753, 2584, 324, 18923, 1656, 1208, 14, 324, 18923, 13606, 342, 199, 3, 47, 14, 14639, 6589, 29, 549, 27, 20542, 14, 3958, 7303, 593, 14, 1065, 8, 18, 5345, 12, 549, 2736, 20542, 14, 3200, 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, 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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################## # 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 ######################### # Big5 frequency table # 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 # # Ideal 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 BIG5_TYPICAL_DISTRIBUTION_RATIO = 0.75 #Char to FreqOrder table BIG5_TABLE_SIZE = 5376 Big5CharToFreqOrder = ( 1,1801,1506, 255,1431, 198, 9, 82, 6,5008, 177, 202,3681,1256,2821, 110, # 16 3814, 33,3274, 261, 76, 44,2114, 16,2946,2187,1176, 659,3971, 26,3451,2653, # 32 1198,3972,3350,4202, 410,2215, 302, 590, 361,1964, 8, 204, 58,4510,5009,1932, # 48 63,5010,5011, 317,1614, 75, 222, 159,4203,2417,1480,5012,3555,3091, 224,2822, # 64 3682, 3, 10,3973,1471, 29,2787,1135,2866,1940, 873, 130,3275,1123, 312,5013, # 80 4511,2052, 507, 252, 682,5014, 142,1915, 124, 206,2947, 34,3556,3204, 64, 604, # 96 5015,2501,1977,1978, 155,1991, 645, 641,1606,5016,3452, 337, 72, 406,5017, 80, # 112 630, 238,3205,1509, 263, 939,1092,2654, 756,1440,1094,3453, 449, 69,2987, 591, # 128 179,2096, 471, 115,2035,1844, 60, 50,2988, 134, 806,1869, 734,2036,3454, 180, # 144 995,1607, 156, 537,2907, 688,5018, 319,1305, 779,2145, 514,2379, 298,4512, 359, # 160 2502, 90,2716,1338, 663, 11, 906,1099,2553, 20,2441, 182, 532,1716,5019, 732, # 176 1376,4204,1311,1420,3206, 25,2317,1056, 113, 399, 382,1950, 242,3455,2474, 529, # 192 3276, 475,1447,3683,5020, 117, 21, 656, 810,1297,2300,2334,3557,5021, 126,4205, # 208 706, 456, 150, 613,4513, 71,1118,2037,4206, 145,3092, 85, 835, 486,2115,1246, # 224 1426, 428, 727,1285,1015, 800, 106, 623, 303,1281,5022,2128,2359, 347,3815, 221, # 240 3558,3135,5023,1956,1153,4207, 83, 296,1199,3093, 192, 624, 93,5024, 822,1898, # 256 2823,3136, 795,2065, 991,1554,1542,1592, 27, 43,2867, 859, 139,1456, 860,4514, # 272 437, 712,3974, 164,2397,3137, 695, 211,3037,2097, 195,3975,1608,3559,3560,3684, # 288 3976, 234, 811,2989,2098,3977,2233,1441,3561,1615,2380, 668,2077,1638, 305, 228, # 304 1664,4515, 467, 415,5025, 262,2099,1593, 239, 108, 300, 200,1033, 512,1247,2078, # 320 5026,5027,2176,3207,3685,2682, 593, 845,1062,3277, 88,1723,2038,3978,1951, 212, # 336 266, 152, 149, 468,1899,4208,4516, 77, 187,5028,3038, 37, 5,2990,5029,3979, # 352 5030,5031, 39,2524,4517,2908,3208,2079, 55, 148, 74,4518, 545, 483,1474,1029, # 368 1665, 217,1870,1531,3138,1104,2655,4209, 24, 172,3562, 900,3980,3563,3564,4519, # 384 32,1408,2824,1312, 329, 487,2360,2251,2717, 784,2683, 4,3039,3351,1427,1789, # 400 188, 109, 499,5032,3686,1717,1790, 888,1217,3040,4520,5033,3565,5034,3352,1520, # 416 3687,3981, 196,1034, 775,5035,5036, 929,1816, 249, 439, 38,5037,1063,5038, 794, # 432 3982,1435,2301, 46, 178,3278,2066,5039,2381,5040, 214,1709,4521, 804, 35, 707, # 448 324,3688,1601,2554, 140, 459,4210,5041,5042,1365, 839, 272, 978,2262,2580,3456, # 464 2129,1363,3689,1423, 697, 100,3094, 48, 70,1231, 495,3139,2196,5043,1294,5044, # 480 2080, 462, 586,1042,3279, 853, 256, 988, 185,2382,3457,1698, 434,1084,5045,3458, # 496 314,2625,2788,4522,2335,2336, 569,2285, 637,1817,2525, 757,1162,1879,1616,3459, # 512 287,1577,2116, 768,4523,1671,2868,3566,2526,1321,3816, 909,2418,5046,4211, 933, # 528 3817,4212,2053,2361,1222,4524, 765,2419,1322, 786,4525,5047,1920,1462,1677,2909, # 544 1699,5048,4526,1424,2442,3140,3690,2600,3353,1775,1941,3460,3983,4213, 309,1369, # 560 1130,2825, 364,2234,1653,1299,3984,3567,3985,3986,2656, 525,1085,3041, 902,2001, # 576 1475, 964,4527, 421,1845,1415,1057,2286, 940,1364,3141, 376,4528,4529,1381, 7, # 592 2527, 983,2383, 336,1710,2684,1846, 321,3461, 559,1131,3042,2752,1809,1132,1313, # 608 265,1481,1858,5049, 352,1203,2826,3280, 167,1089, 420,2827, 776, 792,1724,3568, # 624 4214,2443,3281,5050,4215,5051, 446, 229, 333,2753, 901,3818,1200,1557,4530,2657, # 640 1921, 395,2754,2685,3819,4216,1836, 125, 916,3209,2626,4531,5052,5053,3820,5054, # 656 5055,5056,4532,3142,3691,1133,2555,1757,3462,1510,2318,1409,3569,5057,2146, 438, # 672 2601,2910,2384,3354,1068, 958,3043, 461, 311,2869,2686,4217,1916,3210,4218,1979, # 688 383, 750,2755,2627,4219, 274, 539, 385,1278,1442,5058,1154,1965, 384, 561, 210, # 704 98,1295,2556,3570,5059,1711,2420,1482,3463,3987,2911,1257, 129,5060,3821, 642, # 720 523,2789,2790,2658,5061, 141,2235,1333, 68, 176, 441, 876, 907,4220, 603,2602, # 736 710, 171,3464, 404, 549, 18,3143,2398,1410,3692,1666,5062,3571,4533,2912,4534, # 752 5063,2991, 368,5064, 146, 366, 99, 871,3693,1543, 748, 807,1586,1185, 22,2263, # 768 379,3822,3211,5065,3212, 505,1942,2628,1992,1382,2319,5066, 380,2362, 218, 702, # 784 1818,1248,3465,3044,3572,3355,3282,5067,2992,3694, 930,3283,3823,5068, 59,5069, # 800 585, 601,4221, 497,3466,1112,1314,4535,1802,5070,1223,1472,2177,5071, 749,1837, # 816 690,1900,3824,1773,3988,1476, 429,1043,1791,2236,2117, 917,4222, 447,1086,1629, # 832 5072, 556,5073,5074,2021,1654, 844,1090, 105, 550, 966,1758,2828,1008,1783, 686, # 848 1095,5075,2287, 793,1602,5076,3573,2603,4536,4223,2948,2302,4537,3825, 980,2503, # 864 544, 353, 527,4538, 908,2687,2913,5077, 381,2629,1943,1348,5078,1341,1252, 560, # 880 3095,5079,3467,2870,5080,2054, 973, 886,2081, 143,4539,5081,5082, 157,3989, 496, # 896 4224, 57, 840, 540,2039,4540,4541,3468,2118,1445, 970,2264,1748,1966,2082,4225, # 912 3144,1234,1776,3284,2829,3695, 773,1206,2130,1066,2040,1326,3990,1738,1725,4226, # 928 279,3145, 51,1544,2604, 423,1578,2131,2067, 173,4542,1880,5083,5084,1583, 264, # 944 610,3696,4543,2444, 280, 154,5085,5086,5087,1739, 338,1282,3096, 693,2871,1411, # 960 1074,3826,2445,5088,4544,5089,5090,1240, 952,2399,5091,2914,1538,2688, 685,1483, # 976 4227,2475,1436, 953,4228,2055,4545, 671,2400, 79,4229,2446,3285, 608, 567,2689, # 992 3469,4230,4231,1691, 393,1261,1792,2401,5092,4546,5093,5094,5095,5096,1383,1672, # 1008 3827,3213,1464, 522,1119, 661,1150, 216, 675,4547,3991,1432,3574, 609,4548,2690, # 1024 2402,5097,5098,5099,4232,3045, 0,5100,2476, 315, 231,2447, 301,3356,4549,2385, # 1040 5101, 233,4233,3697,1819,4550,4551,5102, 96,1777,1315,2083,5103, 257,5104,1810, # 1056 3698,2718,1139,1820,4234,2022,1124,2164,2791,1778,2659,5105,3097, 363,1655,3214, # 1072 5106,2993,5107,5108,5109,3992,1567,3993, 718, 103,3215, 849,1443, 341,3357,2949, # 1088 1484,5110,1712, 127, 67, 339,4235,2403, 679,1412, 821,5111,5112, 834, 738, 351, # 1104 2994,2147, 846, 235,1497,1881, 418,1993,3828,2719, 186,1100,2148,2756,3575,1545, # 1120 1355,2950,2872,1377, 583,3994,4236,2581,2995,5113,1298,3699,1078,2557,3700,2363, # 1136 78,3829,3830, 267,1289,2100,2002,1594,4237, 348, 369,1274,2197,2178,1838,4552, # 1152 1821,2830,3701,2757,2288,2003,4553,2951,2758, 144,3358, 882,4554,3995,2759,3470, # 1168 4555,2915,5114,4238,1726, 320,5115,3996,3046, 788,2996,5116,2831,1774,1327,2873, # 1184 3997,2832,5117,1306,4556,2004,1700,3831,3576,2364,2660, 787,2023, 506, 824,3702, # 1200 534, 323,4557,1044,3359,2024,1901, 946,3471,5118,1779,1500,1678,5119,1882,4558, # 1216 165, 243,4559,3703,2528, 123, 683,4239, 764,4560, 36,3998,1793, 589,2916, 816, # 1232 626,1667,3047,2237,1639,1555,1622,3832,3999,5120,4000,2874,1370,1228,1933, 891, # 1248 2084,2917, 304,4240,5121, 292,2997,2720,3577, 691,2101,4241,1115,4561, 118, 662, # 1264 5122, 611,1156, 854,2386,1316,2875, 2, 386, 515,2918,5123,5124,3286, 868,2238, # 1280 1486, 855,2661, 785,2216,3048,5125,1040,3216,3578,5126,3146, 448,5127,1525,5128, # 1296 2165,4562,5129,3833,5130,4242,2833,3579,3147, 503, 818,4001,3148,1568, 814, 676, # 1312 1444, 306,1749,5131,3834,1416,1030, 197,1428, 805,2834,1501,4563,5132,5133,5134, # 1328 1994,5135,4564,5136,5137,2198, 13,2792,3704,2998,3149,1229,1917,5138,3835,2132, # 1344 5139,4243,4565,2404,3580,5140,2217,1511,1727,1120,5141,5142, 646,3836,2448, 307, # 1360 5143,5144,1595,3217,5145,5146,5147,3705,1113,1356,4002,1465,2529,2530,5148, 519, # 1376 5149, 128,2133, 92,2289,1980,5150,4003,1512, 342,3150,2199,5151,2793,2218,1981, # 1392 3360,4244, 290,1656,1317, 789, 827,2365,5152,3837,4566, 562, 581,4004,5153, 401, # 1408 4567,2252, 94,4568,5154,1399,2794,5155,1463,2025,4569,3218,1944,5156, 828,1105, # 1424 4245,1262,1394,5157,4246, 605,4570,5158,1784,2876,5159,2835, 819,2102, 578,2200, # 1440 2952,5160,1502, 436,3287,4247,3288,2836,4005,2919,3472,3473,5161,2721,2320,5162, # 1456 5163,2337,2068, 23,4571, 193, 826,3838,2103, 699,1630,4248,3098, 390,1794,1064, # 1472 3581,5164,1579,3099,3100,1400,5165,4249,1839,1640,2877,5166,4572,4573, 137,4250, # 1488 598,3101,1967, 780, 104, 974,2953,5167, 278, 899, 253, 402, 572, 504, 493,1339, # 1504 5168,4006,1275,4574,2582,2558,5169,3706,3049,3102,2253, 565,1334,2722, 863, 41, # 1520 5170,5171,4575,5172,1657,2338, 19, 463,2760,4251, 606,5173,2999,3289,1087,2085, # 1536 1323,2662,3000,5174,1631,1623,1750,4252,2691,5175,2878, 791,2723,2663,2339, 232, # 1552 2421,5176,3001,1498,5177,2664,2630, 755,1366,3707,3290,3151,2026,1609, 119,1918, # 1568 3474, 862,1026,4253,5178,4007,3839,4576,4008,4577,2265,1952,2477,5179,1125, 817, # 1584 4254,4255,4009,1513,1766,2041,1487,4256,3050,3291,2837,3840,3152,5180,5181,1507, # 1600 5182,2692, 733, 40,1632,1106,2879, 345,4257, 841,2531, 230,4578,3002,1847,3292, # 1616 3475,5183,1263, 986,3476,5184, 735, 879, 254,1137, 857, 622,1300,1180,1388,1562, # 1632 4010,4011,2954, 967,2761,2665,1349, 592,2134,1692,3361,3003,1995,4258,1679,4012, # 1648 1902,2188,5185, 739,3708,2724,1296,1290,5186,4259,2201,2202,1922,1563,2605,2559, # 1664 1871,2762,3004,5187, 435,5188, 343,1108, 596, 17,1751,4579,2239,3477,3709,5189, # 1680 4580, 294,3582,2955,1693, 477, 979, 281,2042,3583, 643,2043,3710,2631,2795,2266, # 1696 1031,2340,2135,2303,3584,4581, 367,1249,2560,5190,3585,5191,4582,1283,3362,2005, # 1712 240,1762,3363,4583,4584, 836,1069,3153, 474,5192,2149,2532, 268,3586,5193,3219, # 1728 1521,1284,5194,1658,1546,4260,5195,3587,3588,5196,4261,3364,2693,1685,4262, 961, # 1744 1673,2632, 190,2006,2203,3841,4585,4586,5197, 570,2504,3711,1490,5198,4587,2633, # 1760 3293,1957,4588, 584,1514, 396,1045,1945,5199,4589,1968,2449,5200,5201,4590,4013, # 1776 619,5202,3154,3294, 215,2007,2796,2561,3220,4591,3221,4592, 763,4263,3842,4593, # 1792 5203,5204,1958,1767,2956,3365,3712,1174, 452,1477,4594,3366,3155,5205,2838,1253, # 1808 2387,2189,1091,2290,4264, 492,5206, 638,1169,1825,2136,1752,4014, 648, 926,1021, # 1824 1324,4595, 520,4596, 997, 847,1007, 892,4597,3843,2267,1872,3713,2405,1785,4598, # 1840 1953,2957,3103,3222,1728,4265,2044,3714,4599,2008,1701,3156,1551, 30,2268,4266, # 1856 5207,2027,4600,3589,5208, 501,5209,4267, 594,3478,2166,1822,3590,3479,3591,3223, # 1872 829,2839,4268,5210,1680,3157,1225,4269,5211,3295,4601,4270,3158,2341,5212,4602, # 1888 4271,5213,4015,4016,5214,1848,2388,2606,3367,5215,4603, 374,4017, 652,4272,4273, # 1904 375,1140, 798,5216,5217,5218,2366,4604,2269, 546,1659, 138,3051,2450,4605,5219, # 1920 2254, 612,1849, 910, 796,3844,1740,1371, 825,3845,3846,5220,2920,2562,5221, 692, # 1936 444,3052,2634, 801,4606,4274,5222,1491, 244,1053,3053,4275,4276, 340,5223,4018, # 1952 1041,3005, 293,1168, 87,1357,5224,1539, 959,5225,2240, 721, 694,4277,3847, 219, # 1968 1478, 644,1417,3368,2666,1413,1401,1335,1389,4019,5226,5227,3006,2367,3159,1826, # 1984 730,1515, 184,2840, 66,4607,5228,1660,2958, 246,3369, 378,1457, 226,3480, 975, # 2000 4020,2959,1264,3592, 674, 696,5229, 163,5230,1141,2422,2167, 713,3593,3370,4608, # 2016 4021,5231,5232,1186, 15,5233,1079,1070,5234,1522,3224,3594, 276,1050,2725, 758, # 2032 1126, 653,2960,3296,5235,2342, 889,3595,4022,3104,3007, 903,1250,4609,4023,3481, # 2048 3596,1342,1681,1718, 766,3297, 286, 89,2961,3715,5236,1713,5237,2607,3371,3008, # 2064 5238,2962,2219,3225,2880,5239,4610,2505,2533, 181, 387,1075,4024, 731,2190,3372, # 2080 5240,3298, 310, 313,3482,2304, 770,4278, 54,3054, 189,4611,3105,3848,4025,5241, # 2096 1230,1617,1850, 355,3597,4279,4612,3373, 111,4280,3716,1350,3160,3483,3055,4281, # 2112 2150,3299,3598,5242,2797,4026,4027,3009, 722,2009,5243,1071, 247,1207,2343,2478, # 2128 1378,4613,2010, 864,1437,1214,4614, 373,3849,1142,2220, 667,4615, 442,2763,2563, # 2144 3850,4028,1969,4282,3300,1840, 837, 170,1107, 934,1336,1883,5244,5245,2119,4283, # 2160 2841, 743,1569,5246,4616,4284, 582,2389,1418,3484,5247,1803,5248, 357,1395,1729, # 2176 3717,3301,2423,1564,2241,5249,3106,3851,1633,4617,1114,2086,4285,1532,5250, 482, # 2192 2451,4618,5251,5252,1492, 833,1466,5253,2726,3599,1641,2842,5254,1526,1272,3718, # 2208 4286,1686,1795, 416,2564,1903,1954,1804,5255,3852,2798,3853,1159,2321,5256,2881, # 2224 4619,1610,1584,3056,2424,2764, 443,3302,1163,3161,5257,5258,4029,5259,4287,2506, # 2240 3057,4620,4030,3162,2104,1647,3600,2011,1873,4288,5260,4289, 431,3485,5261, 250, # 2256 97, 81,4290,5262,1648,1851,1558, 160, 848,5263, 866, 740,1694,5264,2204,2843, # 2272 3226,4291,4621,3719,1687, 950,2479, 426, 469,3227,3720,3721,4031,5265,5266,1188, # 2288 424,1996, 861,3601,4292,3854,2205,2694, 168,1235,3602,4293,5267,2087,1674,4622, # 2304 3374,3303, 220,2565,1009,5268,3855, 670,3010, 332,1208, 717,5269,5270,3603,2452, # 2320 4032,3375,5271, 513,5272,1209,2882,3376,3163,4623,1080,5273,5274,5275,5276,2534, # 2336 3722,3604, 815,1587,4033,4034,5277,3605,3486,3856,1254,4624,1328,3058,1390,4035, # 2352 1741,4036,3857,4037,5278, 236,3858,2453,3304,5279,5280,3723,3859,1273,3860,4625, # 2368 5281, 308,5282,4626, 245,4627,1852,2480,1307,2583, 430, 715,2137,2454,5283, 270, # 2384 199,2883,4038,5284,3606,2727,1753, 761,1754, 725,1661,1841,4628,3487,3724,5285, # 2400 5286, 587, 14,3305, 227,2608, 326, 480,2270, 943,2765,3607, 291, 650,1884,5287, # 2416 1702,1226, 102,1547, 62,3488, 904,4629,3489,1164,4294,5288,5289,1224,1548,2766, # 2432 391, 498,1493,5290,1386,1419,5291,2056,1177,4630, 813, 880,1081,2368, 566,1145, # 2448 4631,2291,1001,1035,2566,2609,2242, 394,1286,5292,5293,2069,5294, 86,1494,1730, # 2464 4039, 491,1588, 745, 897,2963, 843,3377,4040,2767,2884,3306,1768, 998,2221,2070, # 2480 397,1827,1195,1970,3725,3011,3378, 284,5295,3861,2507,2138,2120,1904,5296,4041, # 2496 2151,4042,4295,1036,3490,1905, 114,2567,4296, 209,1527,5297,5298,2964,2844,2635, # 2512 2390,2728,3164, 812,2568,5299,3307,5300,1559, 737,1885,3726,1210, 885, 28,2695, # 2528 3608,3862,5301,4297,1004,1780,4632,5302, 346,1982,2222,2696,4633,3863,1742, 797, # 2544 1642,4043,1934,1072,1384,2152, 896,4044,3308,3727,3228,2885,3609,5303,2569,1959, # 2560 4634,2455,1786,5304,5305,5306,4045,4298,1005,1308,3728,4299,2729,4635,4636,1528, # 2576 2610, 161,1178,4300,1983, 987,4637,1101,4301, 631,4046,1157,3229,2425,1343,1241, # 2592 1016,2243,2570, 372, 877,2344,2508,1160, 555,1935, 911,4047,5307, 466,1170, 169, # 2608 1051,2921,2697,3729,2481,3012,1182,2012,2571,1251,2636,5308, 992,2345,3491,1540, # 2624 2730,1201,2071,2406,1997,2482,5309,4638, 528,1923,2191,1503,1874,1570,2369,3379, # 2640 3309,5310, 557,1073,5311,1828,3492,2088,2271,3165,3059,3107, 767,3108,2799,4639, # 2656 1006,4302,4640,2346,1267,2179,3730,3230, 778,4048,3231,2731,1597,2667,5312,4641, # 2672 5313,3493,5314,5315,5316,3310,2698,1433,3311, 131, 95,1504,4049, 723,4303,3166, # 2688 1842,3610,2768,2192,4050,2028,2105,3731,5317,3013,4051,1218,5318,3380,3232,4052, # 2704 4304,2584, 248,1634,3864, 912,5319,2845,3732,3060,3865, 654, 53,5320,3014,5321, # 2720 1688,4642, 777,3494,1032,4053,1425,5322, 191, 820,2121,2846, 971,4643, 931,3233, # 2736 135, 664, 783,3866,1998, 772,2922,1936,4054,3867,4644,2923,3234, 282,2732, 640, # 2752 1372,3495,1127, 922, 325,3381,5323,5324, 711,2045,5325,5326,4055,2223,2800,1937, # 2768 4056,3382,2224,2255,3868,2305,5327,4645,3869,1258,3312,4057,3235,2139,2965,4058, # 2784 4059,5328,2225, 258,3236,4646, 101,1227,5329,3313,1755,5330,1391,3314,5331,2924, # 2800 2057, 893,5332,5333,5334,1402,4305,2347,5335,5336,3237,3611,5337,5338, 878,1325, # 2816 1781,2801,4647, 259,1385,2585, 744,1183,2272,4648,5339,4060,2509,5340, 684,1024, # 2832 4306,5341, 472,3612,3496,1165,3315,4061,4062, 322,2153, 881, 455,1695,1152,1340, # 2848 660, 554,2154,4649,1058,4650,4307, 830,1065,3383,4063,4651,1924,5342,1703,1919, # 2864 5343, 932,2273, 122,5344,4652, 947, 677,5345,3870,2637, 297,1906,1925,2274,4653, # 2880 2322,3316,5346,5347,4308,5348,4309, 84,4310, 112, 989,5349, 547,1059,4064, 701, # 2896 3613,1019,5350,4311,5351,3497, 942, 639, 457,2306,2456, 993,2966, 407, 851, 494, # 2912 4654,3384, 927,5352,1237,5353,2426,3385, 573,4312, 680, 921,2925,1279,1875, 285, # 2928 790,1448,1984, 719,2168,5354,5355,4655,4065,4066,1649,5356,1541, 563,5357,1077, # 2944 5358,3386,3061,3498, 511,3015,4067,4068,3733,4069,1268,2572,3387,3238,4656,4657, # 2960 5359, 535,1048,1276,1189,2926,2029,3167,1438,1373,2847,2967,1134,2013,5360,4313, # 2976 1238,2586,3109,1259,5361, 700,5362,2968,3168,3734,4314,5363,4315,1146,1876,1907, # 2992 4658,2611,4070, 781,2427, 132,1589, 203, 147, 273,2802,2407, 898,1787,2155,4071, # 3008 4072,5364,3871,2803,5365,5366,4659,4660,5367,3239,5368,1635,3872, 965,5369,1805, # 3024 2699,1516,3614,1121,1082,1329,3317,4073,1449,3873, 65,1128,2848,2927,2769,1590, # 3040 3874,5370,5371, 12,2668, 45, 976,2587,3169,4661, 517,2535,1013,1037,3240,5372, # 3056 3875,2849,5373,3876,5374,3499,5375,2612, 614,1999,2323,3877,3110,2733,2638,5376, # 3072 2588,4316, 599,1269,5377,1811,3735,5378,2700,3111, 759,1060, 489,1806,3388,3318, # 3088 1358,5379,5380,2391,1387,1215,2639,2256, 490,5381,5382,4317,1759,2392,2348,5383, # 3104 4662,3878,1908,4074,2640,1807,3241,4663,3500,3319,2770,2349, 874,5384,5385,3501, # 3120 3736,1859, 91,2928,3737,3062,3879,4664,5386,3170,4075,2669,5387,3502,1202,1403, # 3136 3880,2969,2536,1517,2510,4665,3503,2511,5388,4666,5389,2701,1886,1495,1731,4076, # 3152 2370,4667,5390,2030,5391,5392,4077,2702,1216, 237,2589,4318,2324,4078,3881,4668, # 3168 4669,2703,3615,3504, 445,4670,5393,5394,5395,5396,2771, 61,4079,3738,1823,4080, # 3184 5397, 687,2046, 935, 925, 405,2670, 703,1096,1860,2734,4671,4081,1877,1367,2704, # 3200 3389, 918,2106,1782,2483, 334,3320,1611,1093,4672, 564,3171,3505,3739,3390, 945, # 3216 2641,2058,4673,5398,1926, 872,4319,5399,3506,2705,3112, 349,4320,3740,4082,4674, # 3232 3882,4321,3741,2156,4083,4675,4676,4322,4677,2408,2047, 782,4084, 400, 251,4323, # 3248 1624,5400,5401, 277,3742, 299,1265, 476,1191,3883,2122,4324,4325,1109, 205,5402, # 3264 2590,1000,2157,3616,1861,5403,5404,5405,4678,5406,4679,2573, 107,2484,2158,4085, # 3280 3507,3172,5407,1533, 541,1301, 158, 753,4326,2886,3617,5408,1696, 370,1088,4327, # 3296 4680,3618, 579, 327, 440, 162,2244, 269,1938,1374,3508, 968,3063, 56,1396,3113, # 3312 2107,3321,3391,5409,1927,2159,4681,3016,5410,3619,5411,5412,3743,4682,2485,5413, # 3328 2804,5414,1650,4683,5415,2613,5416,5417,4086,2671,3392,1149,3393,4087,3884,4088, # 3344 5418,1076, 49,5419, 951,3242,3322,3323, 450,2850, 920,5420,1812,2805,2371,4328, # 3360 1909,1138,2372,3885,3509,5421,3243,4684,1910,1147,1518,2428,4685,3886,5422,4686, # 3376 2393,2614, 260,1796,3244,5423,5424,3887,3324, 708,5425,3620,1704,5426,3621,1351, # 3392 1618,3394,3017,1887, 944,4329,3395,4330,3064,3396,4331,5427,3744, 422, 413,1714, # 3408 3325, 500,2059,2350,4332,2486,5428,1344,1911, 954,5429,1668,5430,5431,4089,2409, # 3424 4333,3622,3888,4334,5432,2307,1318,2512,3114, 133,3115,2887,4687, 629, 31,2851, # 3440 2706,3889,4688, 850, 949,4689,4090,2970,1732,2089,4335,1496,1853,5433,4091, 620, # 3456 3245, 981,1242,3745,3397,1619,3746,1643,3326,2140,2457,1971,1719,3510,2169,5434, # 3472 3246,5435,5436,3398,1829,5437,1277,4690,1565,2048,5438,1636,3623,3116,5439, 869, # 3488 2852, 655,3890,3891,3117,4092,3018,3892,1310,3624,4691,5440,5441,5442,1733, 558, # 3504 4692,3747, 335,1549,3065,1756,4336,3748,1946,3511,1830,1291,1192, 470,2735,2108, # 3520 2806, 913,1054,4093,5443,1027,5444,3066,4094,4693, 982,2672,3399,3173,3512,3247, # 3536 3248,1947,2807,5445, 571,4694,5446,1831,5447,3625,2591,1523,2429,5448,2090, 984, # 3552 4695,3749,1960,5449,3750, 852, 923,2808,3513,3751, 969,1519, 999,2049,2325,1705, # 3568 5450,3118, 615,1662, 151, 597,4095,2410,2326,1049, 275,4696,3752,4337, 568,3753, # 3584 3626,2487,4338,3754,5451,2430,2275, 409,3249,5452,1566,2888,3514,1002, 769,2853, # 3600 194,2091,3174,3755,2226,3327,4339, 628,1505,5453,5454,1763,2180,3019,4096, 521, # 3616 1161,2592,1788,2206,2411,4697,4097,1625,4340,4341, 412, 42,3119, 464,5455,2642, # 3632 4698,3400,1760,1571,2889,3515,2537,1219,2207,3893,2643,2141,2373,4699,4700,3328, # 3648 1651,3401,3627,5456,5457,3628,2488,3516,5458,3756,5459,5460,2276,2092, 460,5461, # 3664 4701,5462,3020, 962, 588,3629, 289,3250,2644,1116, 52,5463,3067,1797,5464,5465, # 3680 5466,1467,5467,1598,1143,3757,4342,1985,1734,1067,4702,1280,3402, 465,4703,1572, # 3696 510,5468,1928,2245,1813,1644,3630,5469,4704,3758,5470,5471,2673,1573,1534,5472, # 3712 5473, 536,1808,1761,3517,3894,3175,2645,5474,5475,5476,4705,3518,2929,1912,2809, # 3728 5477,3329,1122, 377,3251,5478, 360,5479,5480,4343,1529, 551,5481,2060,3759,1769, # 3744 2431,5482,2930,4344,3330,3120,2327,2109,2031,4706,1404, 136,1468,1479, 672,1171, # 3760 3252,2308, 271,3176,5483,2772,5484,2050, 678,2736, 865,1948,4707,5485,2014,4098, # 3776 2971,5486,2737,2227,1397,3068,3760,4708,4709,1735,2931,3403,3631,5487,3895, 509, # 3792 2854,2458,2890,3896,5488,5489,3177,3178,4710,4345,2538,4711,2309,1166,1010, 552, # 3808 681,1888,5490,5491,2972,2973,4099,1287,1596,1862,3179, 358, 453, 736, 175, 478, # 3824 1117, 905,1167,1097,5492,1854,1530,5493,1706,5494,2181,3519,2292,3761,3520,3632, # 3840 4346,2093,4347,5495,3404,1193,2489,4348,1458,2193,2208,1863,1889,1421,3331,2932, # 3856 3069,2182,3521, 595,2123,5496,4100,5497,5498,4349,1707,2646, 223,3762,1359, 751, # 3872 3121, 183,3522,5499,2810,3021, 419,2374, 633, 704,3897,2394, 241,5500,5501,5502, # 3888 838,3022,3763,2277,2773,2459,3898,1939,2051,4101,1309,3122,2246,1181,5503,1136, # 3904 2209,3899,2375,1446,4350,2310,4712,5504,5505,4351,1055,2615, 484,3764,5506,4102, # 3920 625,4352,2278,3405,1499,4353,4103,5507,4104,4354,3253,2279,2280,3523,5508,5509, # 3936 2774, 808,2616,3765,3406,4105,4355,3123,2539, 526,3407,3900,4356, 955,5510,1620, # 3952 4357,2647,2432,5511,1429,3766,1669,1832, 994, 928,5512,3633,1260,5513,5514,5515, # 3968 1949,2293, 741,2933,1626,4358,2738,2460, 867,1184, 362,3408,1392,5516,5517,4106, # 3984 4359,1770,1736,3254,2934,4713,4714,1929,2707,1459,1158,5518,3070,3409,2891,1292, # 4000 1930,2513,2855,3767,1986,1187,2072,2015,2617,4360,5519,2574,2514,2170,3768,2490, # 4016 3332,5520,3769,4715,5521,5522, 666,1003,3023,1022,3634,4361,5523,4716,1814,2257, # 4032 574,3901,1603, 295,1535, 705,3902,4362, 283, 858, 417,5524,5525,3255,4717,4718, # 4048 3071,1220,1890,1046,2281,2461,4107,1393,1599, 689,2575, 388,4363,5526,2491, 802, # 4064 5527,2811,3903,2061,1405,2258,5528,4719,3904,2110,1052,1345,3256,1585,5529, 809, # 4080 5530,5531,5532, 575,2739,3524, 956,1552,1469,1144,2328,5533,2329,1560,2462,3635, # 4096 3257,4108, 616,2210,4364,3180,2183,2294,5534,1833,5535,3525,4720,5536,1319,3770, # 4112 3771,1211,3636,1023,3258,1293,2812,5537,5538,5539,3905, 607,2311,3906, 762,2892, # 4128 1439,4365,1360,4721,1485,3072,5540,4722,1038,4366,1450,2062,2648,4367,1379,4723, # 4144 2593,5541,5542,4368,1352,1414,2330,2935,1172,5543,5544,3907,3908,4724,1798,1451, # 4160 5545,5546,5547,5548,2936,4109,4110,2492,2351, 411,4111,4112,3637,3333,3124,4725, # 4176 1561,2674,1452,4113,1375,5549,5550, 47,2974, 316,5551,1406,1591,2937,3181,5552, # 4192 1025,2142,3125,3182, 354,2740, 884,2228,4369,2412, 508,3772, 726,3638, 996,2433, # 4208 3639, 729,5553, 392,2194,1453,4114,4726,3773,5554,5555,2463,3640,2618,1675,2813, # 4224 919,2352,2975,2353,1270,4727,4115, 73,5556,5557, 647,5558,3259,2856,2259,1550, # 4240 1346,3024,5559,1332, 883,3526,5560,5561,5562,5563,3334,2775,5564,1212, 831,1347, # 4256 4370,4728,2331,3909,1864,3073, 720,3910,4729,4730,3911,5565,4371,5566,5567,4731, # 4272 5568,5569,1799,4732,3774,2619,4733,3641,1645,2376,4734,5570,2938, 669,2211,2675, # 4288 2434,5571,2893,5572,5573,1028,3260,5574,4372,2413,5575,2260,1353,5576,5577,4735, # 4304 3183, 518,5578,4116,5579,4373,1961,5580,2143,4374,5581,5582,3025,2354,2355,3912, # 4320 516,1834,1454,4117,2708,4375,4736,2229,2620,1972,1129,3642,5583,2776,5584,2976, # 4336 1422, 577,1470,3026,1524,3410,5585,5586, 432,4376,3074,3527,5587,2594,1455,2515, # 4352 2230,1973,1175,5588,1020,2741,4118,3528,4737,5589,2742,5590,1743,1361,3075,3529, # 4368 2649,4119,4377,4738,2295, 895, 924,4378,2171, 331,2247,3076, 166,1627,3077,1098, # 4384 5591,1232,2894,2231,3411,4739, 657, 403,1196,2377, 542,3775,3412,1600,4379,3530, # 4400 5592,4740,2777,3261, 576, 530,1362,4741,4742,2540,2676,3776,4120,5593, 842,3913, # 4416 5594,2814,2032,1014,4121, 213,2709,3413, 665, 621,4380,5595,3777,2939,2435,5596, # 4432 2436,3335,3643,3414,4743,4381,2541,4382,4744,3644,1682,4383,3531,1380,5597, 724, # 4448 2282, 600,1670,5598,1337,1233,4745,3126,2248,5599,1621,4746,5600, 651,4384,5601, # 4464 1612,4385,2621,5602,2857,5603,2743,2312,3078,5604, 716,2464,3079, 174,1255,2710, # 4480 4122,3645, 548,1320,1398, 728,4123,1574,5605,1891,1197,3080,4124,5606,3081,3082, # 4496 3778,3646,3779, 747,5607, 635,4386,4747,5608,5609,5610,4387,5611,5612,4748,5613, # 4512 3415,4749,2437, 451,5614,3780,2542,2073,4388,2744,4389,4125,5615,1764,4750,5616, # 4528 4390, 350,4751,2283,2395,2493,5617,4391,4126,2249,1434,4127, 488,4752, 458,4392, # 4544 4128,3781, 771,1330,2396,3914,2576,3184,2160,2414,1553,2677,3185,4393,5618,2494, # 4560 2895,2622,1720,2711,4394,3416,4753,5619,2543,4395,5620,3262,4396,2778,5621,2016, # 4576 2745,5622,1155,1017,3782,3915,5623,3336,2313, 201,1865,4397,1430,5624,4129,5625, # 4592 5626,5627,5628,5629,4398,1604,5630, 414,1866, 371,2595,4754,4755,3532,2017,3127, # 4608 4756,1708, 960,4399, 887, 389,2172,1536,1663,1721,5631,2232,4130,2356,2940,1580, # 4624 5632,5633,1744,4757,2544,4758,4759,5634,4760,5635,2074,5636,4761,3647,3417,2896, # 4640 4400,5637,4401,2650,3418,2815, 673,2712,2465, 709,3533,4131,3648,4402,5638,1148, # 4656 502, 634,5639,5640,1204,4762,3649,1575,4763,2623,3783,5641,3784,3128, 948,3263, # 4672 121,1745,3916,1110,5642,4403,3083,2516,3027,4132,3785,1151,1771,3917,1488,4133, # 4688 1987,5643,2438,3534,5644,5645,2094,5646,4404,3918,1213,1407,2816, 531,2746,2545, # 4704 3264,1011,1537,4764,2779,4405,3129,1061,5647,3786,3787,1867,2897,5648,2018, 120, # 4720 4406,4407,2063,3650,3265,2314,3919,2678,3419,1955,4765,4134,5649,3535,1047,2713, # 4736 1266,5650,1368,4766,2858, 649,3420,3920,2546,2747,1102,2859,2679,5651,5652,2000, # 4752 5653,1111,3651,2977,5654,2495,3921,3652,2817,1855,3421,3788,5655,5656,3422,2415, # 4768 2898,3337,3266,3653,5657,2577,5658,3654,2818,4135,1460, 856,5659,3655,5660,2899, # 4784 2978,5661,2900,3922,5662,4408, 632,2517, 875,3923,1697,3924,2296,5663,5664,4767, # 4800 3028,1239, 580,4768,4409,5665, 914, 936,2075,1190,4136,1039,2124,5666,5667,5668, # 4816 5669,3423,1473,5670,1354,4410,3925,4769,2173,3084,4137, 915,3338,4411,4412,3339, # 4832 1605,1835,5671,2748, 398,3656,4413,3926,4138, 328,1913,2860,4139,3927,1331,4414, # 4848 3029, 937,4415,5672,3657,4140,4141,3424,2161,4770,3425, 524, 742, 538,3085,1012, # 4864 5673,5674,3928,2466,5675, 658,1103, 225,3929,5676,5677,4771,5678,4772,5679,3267, # 4880 1243,5680,4142, 963,2250,4773,5681,2714,3658,3186,5682,5683,2596,2332,5684,4774, # 4896 5685,5686,5687,3536, 957,3426,2547,2033,1931,2941,2467, 870,2019,3659,1746,2780, # 4912 2781,2439,2468,5688,3930,5689,3789,3130,3790,3537,3427,3791,5690,1179,3086,5691, # 4928 3187,2378,4416,3792,2548,3188,3131,2749,4143,5692,3428,1556,2549,2297, 977,2901, # 4944 2034,4144,1205,3429,5693,1765,3430,3189,2125,1271, 714,1689,4775,3538,5694,2333, # 4960 3931, 533,4417,3660,2184, 617,5695,2469,3340,3539,2315,5696,5697,3190,5698,5699, # 4976 3932,1988, 618, 427,2651,3540,3431,5700,5701,1244,1690,5702,2819,4418,4776,5703, # 4992 3541,4777,5704,2284,1576, 473,3661,4419,3432, 972,5705,3662,5706,3087,5707,5708, # 5008 4778,4779,5709,3793,4145,4146,5710, 153,4780, 356,5711,1892,2902,4420,2144, 408, # 5024 803,2357,5712,3933,5713,4421,1646,2578,2518,4781,4782,3934,5714,3935,4422,5715, # 5040 2416,3433, 752,5716,5717,1962,3341,2979,5718, 746,3030,2470,4783,4423,3794, 698, # 5056 4784,1893,4424,3663,2550,4785,3664,3936,5719,3191,3434,5720,1824,1302,4147,2715, # 5072 3937,1974,4425,5721,4426,3192, 823,1303,1288,1236,2861,3542,4148,3435, 774,3938, # 5088 5722,1581,4786,1304,2862,3939,4787,5723,2440,2162,1083,3268,4427,4149,4428, 344, # 5104 1173, 288,2316, 454,1683,5724,5725,1461,4788,4150,2597,5726,5727,4789, 985, 894, # 5120 5728,3436,3193,5729,1914,2942,3795,1989,5730,2111,1975,5731,4151,5732,2579,1194, # 5136 425,5733,4790,3194,1245,3796,4429,5734,5735,2863,5736, 636,4791,1856,3940, 760, # 5152 1800,5737,4430,2212,1508,4792,4152,1894,1684,2298,5738,5739,4793,4431,4432,2213, # 5168 479,5740,5741, 832,5742,4153,2496,5743,2980,2497,3797, 990,3132, 627,1815,2652, # 5184 4433,1582,4434,2126,2112,3543,4794,5744, 799,4435,3195,5745,4795,2113,1737,3031, # 5200 1018, 543, 754,4436,3342,1676,4796,4797,4154,4798,1489,5746,3544,5747,2624,2903, # 5216 4155,5748,5749,2981,5750,5751,5752,5753,3196,4799,4800,2185,1722,5754,3269,3270, # 5232 1843,3665,1715, 481, 365,1976,1857,5755,5756,1963,2498,4801,5757,2127,3666,3271, # 5248 433,1895,2064,2076,5758, 602,2750,5759,5760,5761,5762,5763,3032,1628,3437,5764, # 5264 3197,4802,4156,2904,4803,2519,5765,2551,2782,5766,5767,5768,3343,4804,2905,5769, # 5280 4805,5770,2864,4806,4807,1221,2982,4157,2520,5771,5772,5773,1868,1990,5774,5775, # 5296 5776,1896,5777,5778,4808,1897,4158, 318,5779,2095,4159,4437,5780,5781, 485,5782, # 5312 938,3941, 553,2680, 116,5783,3942,3667,5784,3545,2681,2783,3438,3344,2820,5785, # 5328 3668,2943,4160,1747,2944,2983,5786,5787, 207,5788,4809,5789,4810,2521,5790,3033, # 5344 890,3669,3943,5791,1878,3798,3439,5792,2186,2358,3440,1652,5793,5794,5795, 941, # 5360 2299, 208,3546,4161,2020, 330,4438,3944,2906,2499,3799,4439,4811,5796,5797,5798, # 5376 #last 512 #Everything below is of no interest for detection purpose 2522,1613,4812,5799,3345,3945,2523,5800,4162,5801,1637,4163,2471,4813,3946,5802, # 5392 2500,3034,3800,5803,5804,2195,4814,5805,2163,5806,5807,5808,5809,5810,5811,5812, # 5408 5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828, # 5424 5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844, # 5440 5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,5860, # 5456 5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872,5873,5874,5875,5876, # 5472 5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888,5889,5890,5891,5892, # 5488 5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904,5905,5906,5907,5908, # 5504 5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920,5921,5922,5923,5924, # 5520 5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936,5937,5938,5939,5940, # 5536 5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952,5953,5954,5955,5956, # 5552 5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5969,5970,5971,5972, # 5568 5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984,5985,5986,5987,5988, # 5584 5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004, # 5600 6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020, # 5616 6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036, # 5632 6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052, # 5648 6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068, # 5664 6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084, # 5680 6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100, # 5696 6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116, # 5712 6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132, # 5728 6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148, # 5744 6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164, # 5760 6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180, # 5776 6181,6182,6183,6184,6185,6186,6187,6188,6189,6190,6191,6192,6193,6194,6195,6196, # 5792 6197,6198,6199,6200,6201,6202,6203,6204,6205,6206,6207,6208,6209,6210,6211,6212, # 5808 6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,3670,6224,6225,6226,6227, # 5824 6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241,6242,6243, # 5840 6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6259, # 5856 6260,6261,6262,6263,6264,6265,6266,6267,6268,6269,6270,6271,6272,6273,6274,6275, # 5872 6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,4815,6286,6287,6288,6289,6290, # 5888 6291,6292,4816,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305, # 5904 6306,6307,6308,6309,6310,6311,4817,4818,6312,6313,6314,6315,6316,6317,6318,4819, # 5920 6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6330,6331,6332,6333,6334, # 5936 6335,6336,6337,4820,6338,6339,6340,6341,6342,6343,6344,6345,6346,6347,6348,6349, # 5952 6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6361,6362,6363,6364,6365, # 5968 6366,6367,6368,6369,6370,6371,6372,6373,6374,6375,6376,6377,6378,6379,6380,6381, # 5984 6382,6383,6384,6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395,6396,6397, # 6000 6398,6399,6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,3441,6411,6412, # 6016 6413,6414,6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,4440,6426,6427, # 6032 6428,6429,6430,6431,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443, # 6048 6444,6445,6446,6447,6448,6449,6450,6451,6452,6453,6454,4821,6455,6456,6457,6458, # 6064 6459,6460,6461,6462,6463,6464,6465,6466,6467,6468,6469,6470,6471,6472,6473,6474, # 6080 6475,6476,6477,3947,3948,6478,6479,6480,6481,3272,4441,6482,6483,6484,6485,4442, # 6096 6486,6487,6488,6489,6490,6491,6492,6493,6494,6495,6496,4822,6497,6498,6499,6500, # 6112 6501,6502,6503,6504,6505,6506,6507,6508,6509,6510,6511,6512,6513,6514,6515,6516, # 6128 6517,6518,6519,6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532, # 6144 6533,6534,6535,6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548, # 6160 6549,6550,6551,6552,6553,6554,6555,6556,2784,6557,4823,6558,6559,6560,6561,6562, # 6176 6563,6564,6565,6566,6567,6568,6569,3949,6570,6571,6572,4824,6573,6574,6575,6576, # 6192 6577,6578,6579,6580,6581,6582,6583,4825,6584,6585,6586,3950,2785,6587,6588,6589, # 6208 6590,6591,6592,6593,6594,6595,6596,6597,6598,6599,6600,6601,6602,6603,6604,6605, # 6224 6606,6607,6608,6609,6610,6611,6612,4826,6613,6614,6615,4827,6616,6617,6618,6619, # 6240 6620,6621,6622,6623,6624,6625,4164,6626,6627,6628,6629,6630,6631,6632,6633,6634, # 6256 3547,6635,4828,6636,6637,6638,6639,6640,6641,6642,3951,2984,6643,6644,6645,6646, # 6272 6647,6648,6649,4165,6650,4829,6651,6652,4830,6653,6654,6655,6656,6657,6658,6659, # 6288 6660,6661,6662,4831,6663,6664,6665,6666,6667,6668,6669,6670,6671,4166,6672,4832, # 6304 3952,6673,6674,6675,6676,4833,6677,6678,6679,4167,6680,6681,6682,3198,6683,6684, # 6320 6685,6686,6687,6688,6689,6690,6691,6692,6693,6694,6695,6696,6697,4834,6698,6699, # 6336 6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,6715, # 6352 6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6731, # 6368 6732,6733,6734,4443,6735,6736,6737,6738,6739,6740,6741,6742,6743,6744,6745,4444, # 6384 6746,6747,6748,6749,6750,6751,6752,6753,6754,6755,6756,6757,6758,6759,6760,6761, # 6400 6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777, # 6416 6778,6779,6780,6781,4168,6782,6783,3442,6784,6785,6786,6787,6788,6789,6790,6791, # 6432 4169,6792,6793,6794,6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,6805,6806, # 6448 6807,6808,6809,6810,6811,4835,6812,6813,6814,4445,6815,6816,4446,6817,6818,6819, # 6464 6820,6821,6822,6823,6824,6825,6826,6827,6828,6829,6830,6831,6832,6833,6834,6835, # 6480 3548,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,4836,6847,6848,6849, # 6496 6850,6851,6852,6853,6854,3953,6855,6856,6857,6858,6859,6860,6861,6862,6863,6864, # 6512 6865,6866,6867,6868,6869,6870,6871,6872,6873,6874,6875,6876,6877,3199,6878,6879, # 6528 6880,6881,6882,4447,6883,6884,6885,6886,6887,6888,6889,6890,6891,6892,6893,6894, # 6544 6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,4170,6905,6906,6907,6908,6909, # 6560 6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,6925, # 6576 6926,6927,4837,6928,6929,6930,6931,6932,6933,6934,6935,6936,3346,6937,6938,4838, # 6592 6939,6940,6941,4448,6942,6943,6944,6945,6946,4449,6947,6948,6949,6950,6951,6952, # 6608 6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968, # 6624 6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984, # 6640 6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,3671,6995,6996,6997,6998,4839, # 6656 6999,7000,7001,7002,3549,7003,7004,7005,7006,7007,7008,7009,7010,7011,7012,7013, # 6672 7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028,7029, # 6688 7030,4840,7031,7032,7033,7034,7035,7036,7037,7038,4841,7039,7040,7041,7042,7043, # 6704 7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058,7059, # 6720 7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,2985,7071,7072,7073,7074, # 6736 7075,7076,7077,7078,7079,7080,4842,7081,7082,7083,7084,7085,7086,7087,7088,7089, # 6752 7090,7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,7105, # 6768 7106,7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,4450,7119,7120, # 6784 7121,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136, # 6800 7137,7138,7139,7140,7141,7142,7143,4843,7144,7145,7146,7147,7148,7149,7150,7151, # 6816 7152,7153,7154,7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,7165,7166,7167, # 6832 7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183, # 6848 7184,7185,7186,7187,7188,4171,4172,7189,7190,7191,7192,7193,7194,7195,7196,7197, # 6864 7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213, # 6880 7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7229, # 6896 7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245, # 6912 7246,7247,7248,7249,7250,7251,7252,7253,7254,7255,7256,7257,7258,7259,7260,7261, # 6928 7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277, # 6944 7278,7279,7280,7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293, # 6960 7294,7295,7296,4844,7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308, # 6976 7309,7310,7311,7312,7313,7314,7315,7316,4451,7317,7318,7319,7320,7321,7322,7323, # 6992 7324,7325,7326,7327,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339, # 7008 7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,4173,7354, # 7024 7355,4845,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7367,7368,7369, # 7040 7370,7371,7372,7373,7374,7375,7376,7377,7378,7379,7380,7381,7382,7383,7384,7385, # 7056 7386,7387,7388,4846,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400, # 7072 7401,7402,7403,7404,7405,3672,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415, # 7088 7416,7417,7418,7419,7420,7421,7422,7423,7424,7425,7426,7427,7428,7429,7430,7431, # 7104 7432,7433,7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447, # 7120 7448,7449,7450,7451,7452,7453,4452,7454,3200,7455,7456,7457,7458,7459,7460,7461, # 7136 7462,7463,7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,4847,7475,7476, # 7152 7477,3133,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491, # 7168 7492,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,3347,7503,7504,7505,7506, # 7184 7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,4848, # 7200 7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537, # 7216 7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,3801,4849,7550,7551, # 7232 7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567, # 7248 7568,7569,3035,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582, # 7264 7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598, # 7280 7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614, # 7296 7615,7616,4850,7617,7618,3802,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628, # 7312 7629,7630,7631,7632,4851,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643, # 7328 7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659, # 7344 7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,4453,7671,7672,7673,7674, # 7360 7675,7676,7677,7678,7679,7680,7681,7682,7683,7684,7685,7686,7687,7688,7689,7690, # 7376 7691,7692,7693,7694,7695,7696,7697,3443,7698,7699,7700,7701,7702,4454,7703,7704, # 7392 7705,7706,7707,7708,7709,7710,7711,7712,7713,2472,7714,7715,7716,7717,7718,7719, # 7408 7720,7721,7722,7723,7724,7725,7726,7727,7728,7729,7730,7731,3954,7732,7733,7734, # 7424 7735,7736,7737,7738,7739,7740,7741,7742,7743,7744,7745,7746,7747,7748,7749,7750, # 7440 3134,7751,7752,4852,7753,7754,7755,4853,7756,7757,7758,7759,7760,4174,7761,7762, # 7456 7763,7764,7765,7766,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,7777,7778, # 7472 7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791,7792,7793,7794, # 7488 7795,7796,7797,7798,7799,7800,7801,7802,7803,7804,7805,4854,7806,7807,7808,7809, # 7504 7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824,7825, # 7520 4855,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840, # 7536 7841,7842,7843,7844,7845,7846,7847,3955,7848,7849,7850,7851,7852,7853,7854,7855, # 7552 7856,7857,7858,7859,7860,3444,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870, # 7568 7871,7872,7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886, # 7584 7887,7888,7889,7890,7891,4175,7892,7893,7894,7895,7896,4856,4857,7897,7898,7899, # 7600 7900,2598,7901,7902,7903,7904,7905,7906,7907,7908,4455,7909,7910,7911,7912,7913, # 7616 7914,3201,7915,7916,7917,7918,7919,7920,7921,4858,7922,7923,7924,7925,7926,7927, # 7632 7928,7929,7930,7931,7932,7933,7934,7935,7936,7937,7938,7939,7940,7941,7942,7943, # 7648 7944,7945,7946,7947,7948,7949,7950,7951,7952,7953,7954,7955,7956,7957,7958,7959, # 7664 7960,7961,7962,7963,7964,7965,7966,7967,7968,7969,7970,7971,7972,7973,7974,7975, # 7680 7976,7977,7978,7979,7980,7981,4859,7982,7983,7984,7985,7986,7987,7988,7989,7990, # 7696 7991,7992,7993,7994,7995,7996,4860,7997,7998,7999,8000,8001,8002,8003,8004,8005, # 7712 8006,8007,8008,8009,8010,8011,8012,8013,8014,8015,8016,4176,8017,8018,8019,8020, # 7728 8021,8022,8023,4861,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035, # 7744 8036,4862,4456,8037,8038,8039,8040,4863,8041,8042,8043,8044,8045,8046,8047,8048, # 7760 8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063,8064, # 7776 8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080, # 7792 8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096, # 7808 8097,8098,8099,4864,4177,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110, # 7824 8111,8112,8113,8114,8115,8116,8117,8118,8119,8120,4178,8121,8122,8123,8124,8125, # 7840 8126,8127,8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141, # 7856 8142,8143,8144,8145,4865,4866,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155, # 7872 8156,8157,8158,8159,8160,8161,8162,8163,8164,8165,4179,8166,8167,8168,8169,8170, # 7888 8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181,4457,8182,8183,8184,8185, # 7904 8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201, # 7920 8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,8213,8214,8215,8216,8217, # 7936 8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,8228,8229,8230,8231,8232,8233, # 7952 8234,8235,8236,8237,8238,8239,8240,8241,8242,8243,8244,8245,8246,8247,8248,8249, # 7968 8250,8251,8252,8253,8254,8255,8256,3445,8257,8258,8259,8260,8261,8262,4458,8263, # 7984 8264,8265,8266,8267,8268,8269,8270,8271,8272,4459,8273,8274,8275,8276,3550,8277, # 8000 8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,8288,8289,4460,8290,8291,8292, # 8016 8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,8304,8305,8306,8307,4867, # 8032 8308,8309,8310,8311,8312,3551,8313,8314,8315,8316,8317,8318,8319,8320,8321,8322, # 8048 8323,8324,8325,8326,4868,8327,8328,8329,8330,8331,8332,8333,8334,8335,8336,8337, # 8064 8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,8348,8349,8350,8351,8352,8353, # 8080 8354,8355,8356,8357,8358,8359,8360,8361,8362,8363,4869,4461,8364,8365,8366,8367, # 8096 8368,8369,8370,4870,8371,8372,8373,8374,8375,8376,8377,8378,8379,8380,8381,8382, # 8112 8383,8384,8385,8386,8387,8388,8389,8390,8391,8392,8393,8394,8395,8396,8397,8398, # 8128 8399,8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,4871,8411,8412,8413, # 8144 8414,8415,8416,8417,8418,8419,8420,8421,8422,4462,8423,8424,8425,8426,8427,8428, # 8160 8429,8430,8431,8432,8433,2986,8434,8435,8436,8437,8438,8439,8440,8441,8442,8443, # 8176 8444,8445,8446,8447,8448,8449,8450,8451,8452,8453,8454,8455,8456,8457,8458,8459, # 8192 8460,8461,8462,8463,8464,8465,8466,8467,8468,8469,8470,8471,8472,8473,8474,8475, # 8208 8476,8477,8478,4180,8479,8480,8481,8482,8483,8484,8485,8486,8487,8488,8489,8490, # 8224 8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501,8502,8503,8504,8505,8506, # 8240 8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517,8518,8519,8520,8521,8522, # 8256 8523,8524,8525,8526,8527,8528,8529,8530,8531,8532,8533,8534,8535,8536,8537,8538, # 8272 8539,8540,8541,8542,8543,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554, # 8288 8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,4872,8565,8566,8567,8568,8569, # 8304 8570,8571,8572,8573,4873,8574,8575,8576,8577,8578,8579,8580,8581,8582,8583,8584, # 8320 8585,8586,8587,8588,8589,8590,8591,8592,8593,8594,8595,8596,8597,8598,8599,8600, # 8336 8601,8602,8603,8604,8605,3803,8606,8607,8608,8609,8610,8611,8612,8613,4874,3804, # 8352 8614,8615,8616,8617,8618,8619,8620,8621,3956,8622,8623,8624,8625,8626,8627,8628, # 8368 8629,8630,8631,8632,8633,8634,8635,8636,8637,8638,2865,8639,8640,8641,8642,8643, # 8384 8644,8645,8646,8647,8648,8649,8650,8651,8652,8653,8654,8655,8656,4463,8657,8658, # 8400 8659,4875,4876,8660,8661,8662,8663,8664,8665,8666,8667,8668,8669,8670,8671,8672, # 8416 8673,8674,8675,8676,8677,8678,8679,8680,8681,4464,8682,8683,8684,8685,8686,8687, # 8432 8688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703, # 8448 8704,8705,8706,8707,8708,8709,2261,8710,8711,8712,8713,8714,8715,8716,8717,8718, # 8464 8719,8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,4181, # 8480 8734,8735,8736,8737,8738,8739,8740,8741,8742,8743,8744,8745,8746,8747,8748,8749, # 8496 8750,8751,8752,8753,8754,8755,8756,8757,8758,8759,8760,8761,8762,8763,4877,8764, # 8512 8765,8766,8767,8768,8769,8770,8771,8772,8773,8774,8775,8776,8777,8778,8779,8780, # 8528 8781,8782,8783,8784,8785,8786,8787,8788,4878,8789,4879,8790,8791,8792,4880,8793, # 8544 8794,8795,8796,8797,8798,8799,8800,8801,4881,8802,8803,8804,8805,8806,8807,8808, # 8560 8809,8810,8811,8812,8813,8814,8815,3957,8816,8817,8818,8819,8820,8821,8822,8823, # 8576 8824,8825,8826,8827,8828,8829,8830,8831,8832,8833,8834,8835,8836,8837,8838,8839, # 8592 8840,8841,8842,8843,8844,8845,8846,8847,4882,8848,8849,8850,8851,8852,8853,8854, # 8608 8855,8856,8857,8858,8859,8860,8861,8862,8863,8864,8865,8866,8867,8868,8869,8870, # 8624 8871,8872,8873,8874,8875,8876,8877,8878,8879,8880,8881,8882,8883,8884,3202,8885, # 8640 8886,8887,8888,8889,8890,8891,8892,8893,8894,8895,8896,8897,8898,8899,8900,8901, # 8656 8902,8903,8904,8905,8906,8907,8908,8909,8910,8911,8912,8913,8914,8915,8916,8917, # 8672 8918,8919,8920,8921,8922,8923,8924,4465,8925,8926,8927,8928,8929,8930,8931,8932, # 8688 4883,8933,8934,8935,8936,8937,8938,8939,8940,8941,8942,8943,2214,8944,8945,8946, # 8704 8947,8948,8949,8950,8951,8952,8953,8954,8955,8956,8957,8958,8959,8960,8961,8962, # 8720 8963,8964,8965,4884,8966,8967,8968,8969,8970,8971,8972,8973,8974,8975,8976,8977, # 8736 8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,4885, # 8752 8993,8994,8995,8996,8997,8998,8999,9000,9001,9002,9003,9004,9005,9006,9007,9008, # 8768 9009,9010,9011,9012,9013,9014,9015,9016,9017,9018,9019,9020,9021,4182,9022,9023, # 8784 9024,9025,9026,9027,9028,9029,9030,9031,9032,9033,9034,9035,9036,9037,9038,9039, # 8800 9040,9041,9042,9043,9044,9045,9046,9047,9048,9049,9050,9051,9052,9053,9054,9055, # 8816 9056,9057,9058,9059,9060,9061,9062,9063,4886,9064,9065,9066,9067,9068,9069,4887, # 8832 9070,9071,9072,9073,9074,9075,9076,9077,9078,9079,9080,9081,9082,9083,9084,9085, # 8848 9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9101, # 8864 9102,9103,9104,9105,9106,9107,9108,9109,9110,9111,9112,9113,9114,9115,9116,9117, # 8880 9118,9119,9120,9121,9122,9123,9124,9125,9126,9127,9128,9129,9130,9131,9132,9133, # 8896 9134,9135,9136,9137,9138,9139,9140,9141,3958,9142,9143,9144,9145,9146,9147,9148, # 8912 9149,9150,9151,4888,9152,9153,9154,9155,9156,9157,9158,9159,9160,9161,9162,9163, # 8928 9164,9165,9166,9167,9168,9169,9170,9171,9172,9173,9174,9175,4889,9176,9177,9178, # 8944 9179,9180,9181,9182,9183,9184,9185,9186,9187,9188,9189,9190,9191,9192,9193,9194, # 8960 9195,9196,9197,9198,9199,9200,9201,9202,9203,4890,9204,9205,9206,9207,9208,9209, # 8976 9210,9211,9212,9213,9214,9215,9216,9217,9218,9219,9220,9221,9222,4466,9223,9224, # 8992 9225,9226,9227,9228,9229,9230,9231,9232,9233,9234,9235,9236,9237,9238,9239,9240, # 9008 9241,9242,9243,9244,9245,4891,9246,9247,9248,9249,9250,9251,9252,9253,9254,9255, # 9024 9256,9257,4892,9258,9259,9260,9261,4893,4894,9262,9263,9264,9265,9266,9267,9268, # 9040 9269,9270,9271,9272,9273,4467,9274,9275,9276,9277,9278,9279,9280,9281,9282,9283, # 9056 9284,9285,3673,9286,9287,9288,9289,9290,9291,9292,9293,9294,9295,9296,9297,9298, # 9072 9299,9300,9301,9302,9303,9304,9305,9306,9307,9308,9309,9310,9311,9312,9313,9314, # 9088 9315,9316,9317,9318,9319,9320,9321,9322,4895,9323,9324,9325,9326,9327,9328,9329, # 9104 9330,9331,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345, # 9120 9346,9347,4468,9348,9349,9350,9351,9352,9353,9354,9355,9356,9357,9358,9359,9360, # 9136 9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9372,9373,4896,9374,4469, # 9152 9375,9376,9377,9378,9379,4897,9380,9381,9382,9383,9384,9385,9386,9387,9388,9389, # 9168 9390,9391,9392,9393,9394,9395,9396,9397,9398,9399,9400,9401,9402,9403,9404,9405, # 9184 9406,4470,9407,2751,9408,9409,3674,3552,9410,9411,9412,9413,9414,9415,9416,9417, # 9200 9418,9419,9420,9421,4898,9422,9423,9424,9425,9426,9427,9428,9429,3959,9430,9431, # 9216 9432,9433,9434,9435,9436,4471,9437,9438,9439,9440,9441,9442,9443,9444,9445,9446, # 9232 9447,9448,9449,9450,3348,9451,9452,9453,9454,9455,9456,9457,9458,9459,9460,9461, # 9248 9462,9463,9464,9465,9466,9467,9468,9469,9470,9471,9472,4899,9473,9474,9475,9476, # 9264 9477,4900,9478,9479,9480,9481,9482,9483,9484,9485,9486,9487,9488,3349,9489,9490, # 9280 9491,9492,9493,9494,9495,9496,9497,9498,9499,9500,9501,9502,9503,9504,9505,9506, # 9296 9507,9508,9509,9510,9511,9512,9513,9514,9515,9516,9517,9518,9519,9520,4901,9521, # 9312 9522,9523,9524,9525,9526,4902,9527,9528,9529,9530,9531,9532,9533,9534,9535,9536, # 9328 9537,9538,9539,9540,9541,9542,9543,9544,9545,9546,9547,9548,9549,9550,9551,9552, # 9344 9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568, # 9360 9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,9581,9582,9583,9584, # 9376 3805,9585,9586,9587,9588,9589,9590,9591,9592,9593,9594,9595,9596,9597,9598,9599, # 9392 9600,9601,9602,4903,9603,9604,9605,9606,9607,4904,9608,9609,9610,9611,9612,9613, # 9408 9614,4905,9615,9616,9617,9618,9619,9620,9621,9622,9623,9624,9625,9626,9627,9628, # 9424 9629,9630,9631,9632,4906,9633,9634,9635,9636,9637,9638,9639,9640,9641,9642,9643, # 9440 4907,9644,9645,9646,9647,9648,9649,9650,9651,9652,9653,9654,9655,9656,9657,9658, # 9456 9659,9660,9661,9662,9663,9664,9665,9666,9667,9668,9669,9670,9671,9672,4183,9673, # 9472 9674,9675,9676,9677,4908,9678,9679,9680,9681,4909,9682,9683,9684,9685,9686,9687, # 9488 9688,9689,9690,4910,9691,9692,9693,3675,9694,9695,9696,2945,9697,9698,9699,9700, # 9504 9701,9702,9703,9704,9705,4911,9706,9707,9708,9709,9710,9711,9712,9713,9714,9715, # 9520 9716,9717,9718,9719,9720,9721,9722,9723,9724,9725,9726,9727,9728,9729,9730,9731, # 9536 9732,9733,9734,9735,4912,9736,9737,9738,9739,9740,4913,9741,9742,9743,9744,9745, # 9552 9746,9747,9748,9749,9750,9751,9752,9753,9754,9755,9756,9757,9758,4914,9759,9760, # 9568 9761,9762,9763,9764,9765,9766,9767,9768,9769,9770,9771,9772,9773,9774,9775,9776, # 9584 9777,9778,9779,9780,9781,9782,4915,9783,9784,9785,9786,9787,9788,9789,9790,9791, # 9600 9792,9793,4916,9794,9795,9796,9797,9798,9799,9800,9801,9802,9803,9804,9805,9806, # 9616 9807,9808,9809,9810,9811,9812,9813,9814,9815,9816,9817,9818,9819,9820,9821,9822, # 9632 9823,9824,9825,9826,9827,9828,9829,9830,9831,9832,9833,9834,9835,9836,9837,9838, # 9648 9839,9840,9841,9842,9843,9844,9845,9846,9847,9848,9849,9850,9851,9852,9853,9854, # 9664 9855,9856,9857,9858,9859,9860,9861,9862,9863,9864,9865,9866,9867,9868,4917,9869, # 9680 9870,9871,9872,9873,9874,9875,9876,9877,9878,9879,9880,9881,9882,9883,9884,9885, # 9696 9886,9887,9888,9889,9890,9891,9892,4472,9893,9894,9895,9896,9897,3806,9898,9899, # 9712 9900,9901,9902,9903,9904,9905,9906,9907,9908,9909,9910,9911,9912,9913,9914,4918, # 9728 9915,9916,9917,4919,9918,9919,9920,9921,4184,9922,9923,9924,9925,9926,9927,9928, # 9744 9929,9930,9931,9932,9933,9934,9935,9936,9937,9938,9939,9940,9941,9942,9943,9944, # 9760 9945,9946,4920,9947,9948,9949,9950,9951,9952,9953,9954,9955,4185,9956,9957,9958, # 9776 9959,9960,9961,9962,9963,9964,9965,4921,9966,9967,9968,4473,9969,9970,9971,9972, # 9792 9973,9974,9975,9976,9977,4474,9978,9979,9980,9981,9982,9983,9984,9985,9986,9987, # 9808 9988,9989,9990,9991,9992,9993,9994,9995,9996,9997,9998,9999,10000,10001,10002,10003, # 9824 10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,10016,10017,10018,10019, # 9840 10020,10021,4922,10022,4923,10023,10024,10025,10026,10027,10028,10029,10030,10031,10032,10033, # 9856 10034,10035,10036,10037,10038,10039,10040,10041,10042,10043,10044,10045,10046,10047,10048,4924, # 9872 10049,10050,10051,10052,10053,10054,10055,10056,10057,10058,10059,10060,10061,10062,10063,10064, # 9888 10065,10066,10067,10068,10069,10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080, # 9904 10081,10082,10083,10084,10085,10086,10087,4475,10088,10089,10090,10091,10092,10093,10094,10095, # 9920 10096,10097,4476,10098,10099,10100,10101,10102,10103,10104,10105,10106,10107,10108,10109,10110, # 9936 10111,2174,10112,10113,10114,10115,10116,10117,10118,10119,10120,10121,10122,10123,10124,10125, # 9952 10126,10127,10128,10129,10130,10131,10132,10133,10134,10135,10136,10137,10138,10139,10140,3807, # 9968 4186,4925,10141,10142,10143,10144,10145,10146,10147,4477,4187,10148,10149,10150,10151,10152, # 9984 10153,4188,10154,10155,10156,10157,10158,10159,10160,10161,4926,10162,10163,10164,10165,10166, #10000 10167,10168,10169,10170,10171,10172,10173,10174,10175,10176,10177,10178,10179,10180,10181,10182, #10016 10183,10184,10185,10186,10187,10188,10189,10190,10191,10192,3203,10193,10194,10195,10196,10197, #10032 10198,10199,10200,4478,10201,10202,10203,10204,4479,10205,10206,10207,10208,10209,10210,10211, #10048 10212,10213,10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10224,10225,10226,10227, #10064 10228,10229,10230,10231,10232,10233,10234,4927,10235,10236,10237,10238,10239,10240,10241,10242, #10080 10243,10244,10245,10246,10247,10248,10249,10250,10251,10252,10253,10254,10255,10256,10257,10258, #10096 10259,10260,10261,10262,10263,10264,10265,10266,10267,10268,10269,10270,10271,10272,10273,4480, #10112 4928,4929,10274,10275,10276,10277,10278,10279,10280,10281,10282,10283,10284,10285,10286,10287, #10128 10288,10289,10290,10291,10292,10293,10294,10295,10296,10297,10298,10299,10300,10301,10302,10303, #10144 10304,10305,10306,10307,10308,10309,10310,10311,10312,10313,10314,10315,10316,10317,10318,10319, #10160 10320,10321,10322,10323,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334,4930, #10176 10335,10336,10337,10338,10339,10340,10341,10342,4931,10343,10344,10345,10346,10347,10348,10349, #10192 10350,10351,10352,10353,10354,10355,3088,10356,2786,10357,10358,10359,10360,4189,10361,10362, #10208 10363,10364,10365,10366,10367,10368,10369,10370,10371,10372,10373,10374,10375,4932,10376,10377, #10224 10378,10379,10380,10381,10382,10383,10384,10385,10386,10387,10388,10389,10390,10391,10392,4933, #10240 10393,10394,10395,4934,10396,10397,10398,10399,10400,10401,10402,10403,10404,10405,10406,10407, #10256 10408,10409,10410,10411,10412,3446,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422, #10272 10423,4935,10424,10425,10426,10427,10428,10429,10430,4936,10431,10432,10433,10434,10435,10436, #10288 10437,10438,10439,10440,10441,10442,10443,4937,10444,10445,10446,10447,4481,10448,10449,10450, #10304 10451,10452,10453,10454,10455,10456,10457,10458,10459,10460,10461,10462,10463,10464,10465,10466, #10320 10467,10468,10469,10470,10471,10472,10473,10474,10475,10476,10477,10478,10479,10480,10481,10482, #10336 10483,10484,10485,10486,10487,10488,10489,10490,10491,10492,10493,10494,10495,10496,10497,10498, #10352 10499,10500,10501,10502,10503,10504,10505,4938,10506,10507,10508,10509,10510,2552,10511,10512, #10368 10513,10514,10515,10516,3447,10517,10518,10519,10520,10521,10522,10523,10524,10525,10526,10527, #10384 10528,10529,10530,10531,10532,10533,10534,10535,10536,10537,10538,10539,10540,10541,10542,10543, #10400 4482,10544,4939,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557, #10416 10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,3676,4483,10568,10569,10570,10571, #10432 10572,3448,10573,10574,10575,10576,10577,10578,10579,10580,10581,10582,10583,10584,10585,10586, #10448 10587,10588,10589,10590,10591,10592,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602, #10464 10603,10604,10605,10606,10607,10608,10609,10610,10611,10612,10613,10614,10615,10616,10617,10618, #10480 10619,10620,10621,10622,10623,10624,10625,10626,10627,4484,10628,10629,10630,10631,10632,4940, #10496 10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646,10647,10648, #10512 10649,10650,10651,10652,10653,10654,10655,10656,4941,10657,10658,10659,2599,10660,10661,10662, #10528 10663,10664,10665,10666,3089,10667,10668,10669,10670,10671,10672,10673,10674,10675,10676,10677, #10544 10678,10679,10680,4942,10681,10682,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692, #10560 10693,10694,10695,10696,10697,4485,10698,10699,10700,10701,10702,10703,10704,4943,10705,3677, #10576 10706,10707,10708,10709,10710,10711,10712,4944,10713,10714,10715,10716,10717,10718,10719,10720, #10592 10721,10722,10723,10724,10725,10726,10727,10728,4945,10729,10730,10731,10732,10733,10734,10735, #10608 10736,10737,10738,10739,10740,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751, #10624 10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,4946,10762,10763,10764,10765,10766, #10640 10767,4947,4948,10768,10769,10770,10771,10772,10773,10774,10775,10776,10777,10778,10779,10780, #10656 10781,10782,10783,10784,10785,10786,10787,10788,10789,10790,10791,10792,10793,10794,10795,10796, #10672 10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812, #10688 10813,10814,10815,10816,10817,10818,10819,10820,10821,10822,10823,10824,10825,10826,10827,10828, #10704 10829,10830,10831,10832,10833,10834,10835,10836,10837,10838,10839,10840,10841,10842,10843,10844, #10720 10845,10846,10847,10848,10849,10850,10851,10852,10853,10854,10855,10856,10857,10858,10859,10860, #10736 10861,10862,10863,10864,10865,10866,10867,10868,10869,10870,10871,10872,10873,10874,10875,10876, #10752 10877,10878,4486,10879,10880,10881,10882,10883,10884,10885,4949,10886,10887,10888,10889,10890, #10768 10891,10892,10893,10894,10895,10896,10897,10898,10899,10900,10901,10902,10903,10904,10905,10906, #10784 10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,4487,10920,10921, #10800 10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,4950,10933,10934,10935,10936, #10816 10937,10938,10939,10940,10941,10942,10943,10944,10945,10946,10947,10948,10949,4488,10950,10951, #10832 10952,10953,10954,10955,10956,10957,10958,10959,4190,10960,10961,10962,10963,10964,10965,10966, #10848 10967,10968,10969,10970,10971,10972,10973,10974,10975,10976,10977,10978,10979,10980,10981,10982, #10864 10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993,10994,10995,10996,10997,10998, #10880 10999,11000,11001,11002,11003,11004,11005,11006,3960,11007,11008,11009,11010,11011,11012,11013, #10896 11014,11015,11016,11017,11018,11019,11020,11021,11022,11023,11024,11025,11026,11027,11028,11029, #10912 11030,11031,11032,4951,11033,11034,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044, #10928 11045,11046,11047,4489,11048,11049,11050,11051,4952,11052,11053,11054,11055,11056,11057,11058, #10944 4953,11059,11060,11061,11062,11063,11064,11065,11066,11067,11068,11069,11070,11071,4954,11072, #10960 11073,11074,11075,11076,11077,11078,11079,11080,11081,11082,11083,11084,11085,11086,11087,11088, #10976 11089,11090,11091,11092,11093,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104, #10992 11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,3808,11116,11117,11118,11119, #11008 11120,11121,11122,11123,11124,11125,11126,11127,11128,11129,11130,11131,11132,11133,11134,4955, #11024 11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150, #11040 11151,11152,11153,11154,11155,11156,11157,11158,11159,11160,11161,4956,11162,11163,11164,11165, #11056 11166,11167,11168,11169,11170,11171,11172,11173,11174,11175,11176,11177,11178,11179,11180,4957, #11072 11181,11182,11183,11184,11185,11186,4958,11187,11188,11189,11190,11191,11192,11193,11194,11195, #11088 11196,11197,11198,11199,11200,3678,11201,11202,11203,11204,11205,11206,4191,11207,11208,11209, #11104 11210,11211,11212,11213,11214,11215,11216,11217,11218,11219,11220,11221,11222,11223,11224,11225, #11120 11226,11227,11228,11229,11230,11231,11232,11233,11234,11235,11236,11237,11238,11239,11240,11241, #11136 11242,11243,11244,11245,11246,11247,11248,11249,11250,11251,4959,11252,11253,11254,11255,11256, #11152 11257,11258,11259,11260,11261,11262,11263,11264,11265,11266,11267,11268,11269,11270,11271,11272, #11168 11273,11274,11275,11276,11277,11278,11279,11280,11281,11282,11283,11284,11285,11286,11287,11288, #11184 11289,11290,11291,11292,11293,11294,11295,11296,11297,11298,11299,11300,11301,11302,11303,11304, #11200 11305,11306,11307,11308,11309,11310,11311,11312,11313,11314,3679,11315,11316,11317,11318,4490, #11216 11319,11320,11321,11322,11323,11324,11325,11326,11327,11328,11329,11330,11331,11332,11333,11334, #11232 11335,11336,11337,11338,11339,11340,11341,11342,11343,11344,11345,11346,11347,4960,11348,11349, #11248 11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365, #11264 11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,3961,4961,11378,11379, #11280 11380,11381,11382,11383,11384,11385,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395, #11296 11396,11397,4192,11398,11399,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410, #11312 11411,4962,11412,11413,11414,11415,11416,11417,11418,11419,11420,11421,11422,11423,11424,11425, #11328 11426,11427,11428,11429,11430,11431,11432,11433,11434,11435,11436,11437,11438,11439,11440,11441, #11344 11442,11443,11444,11445,11446,11447,11448,11449,11450,11451,11452,11453,11454,11455,11456,11457, #11360 11458,11459,11460,11461,11462,11463,11464,11465,11466,11467,11468,11469,4963,11470,11471,4491, #11376 11472,11473,11474,11475,4964,11476,11477,11478,11479,11480,11481,11482,11483,11484,11485,11486, #11392 11487,11488,11489,11490,11491,11492,4965,11493,11494,11495,11496,11497,11498,11499,11500,11501, #11408 11502,11503,11504,11505,11506,11507,11508,11509,11510,11511,11512,11513,11514,11515,11516,11517, #11424 11518,11519,11520,11521,11522,11523,11524,11525,11526,11527,11528,11529,3962,11530,11531,11532, #11440 11533,11534,11535,11536,11537,11538,11539,11540,11541,11542,11543,11544,11545,11546,11547,11548, #11456 11549,11550,11551,11552,11553,11554,11555,11556,11557,11558,11559,11560,11561,11562,11563,11564, #11472 4193,4194,11565,11566,11567,11568,11569,11570,11571,11572,11573,11574,11575,11576,11577,11578, #11488 11579,11580,11581,11582,11583,11584,11585,11586,11587,11588,11589,11590,11591,4966,4195,11592, #11504 11593,11594,11595,11596,11597,11598,11599,11600,11601,11602,11603,11604,3090,11605,11606,11607, #11520 11608,11609,11610,4967,11611,11612,11613,11614,11615,11616,11617,11618,11619,11620,11621,11622, #11536 11623,11624,11625,11626,11627,11628,11629,11630,11631,11632,11633,11634,11635,11636,11637,11638, #11552 11639,11640,11641,11642,11643,11644,11645,11646,11647,11648,11649,11650,11651,11652,11653,11654, #11568 11655,11656,11657,11658,11659,11660,11661,11662,11663,11664,11665,11666,11667,11668,11669,11670, #11584 11671,11672,11673,11674,4968,11675,11676,11677,11678,11679,11680,11681,11682,11683,11684,11685, #11600 11686,11687,11688,11689,11690,11691,11692,11693,3809,11694,11695,11696,11697,11698,11699,11700, #11616 11701,11702,11703,11704,11705,11706,11707,11708,11709,11710,11711,11712,11713,11714,11715,11716, #11632 11717,11718,3553,11719,11720,11721,11722,11723,11724,11725,11726,11727,11728,11729,11730,4969, #11648 11731,11732,11733,11734,11735,11736,11737,11738,11739,11740,4492,11741,11742,11743,11744,11745, #11664 11746,11747,11748,11749,11750,11751,11752,4970,11753,11754,11755,11756,11757,11758,11759,11760, #11680 11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,11776, #11696 11777,11778,11779,11780,11781,11782,11783,11784,11785,11786,11787,11788,11789,11790,4971,11791, #11712 11792,11793,11794,11795,11796,11797,4972,11798,11799,11800,11801,11802,11803,11804,11805,11806, #11728 11807,11808,11809,11810,4973,11811,11812,11813,11814,11815,11816,11817,11818,11819,11820,11821, #11744 11822,11823,11824,11825,11826,11827,11828,11829,11830,11831,11832,11833,11834,3680,3810,11835, #11760 11836,4974,11837,11838,11839,11840,11841,11842,11843,11844,11845,11846,11847,11848,11849,11850, #11776 11851,11852,11853,11854,11855,11856,11857,11858,11859,11860,11861,11862,11863,11864,11865,11866, #11792 11867,11868,11869,11870,11871,11872,11873,11874,11875,11876,11877,11878,11879,11880,11881,11882, #11808 11883,11884,4493,11885,11886,11887,11888,11889,11890,11891,11892,11893,11894,11895,11896,11897, #11824 11898,11899,11900,11901,11902,11903,11904,11905,11906,11907,11908,11909,11910,11911,11912,11913, #11840 11914,11915,4975,11916,11917,11918,11919,11920,11921,11922,11923,11924,11925,11926,11927,11928, #11856 11929,11930,11931,11932,11933,11934,11935,11936,11937,11938,11939,11940,11941,11942,11943,11944, #11872 11945,11946,11947,11948,11949,4976,11950,11951,11952,11953,11954,11955,11956,11957,11958,11959, #11888 11960,11961,11962,11963,11964,11965,11966,11967,11968,11969,11970,11971,11972,11973,11974,11975, #11904 11976,11977,11978,11979,11980,11981,11982,11983,11984,11985,11986,11987,4196,11988,11989,11990, #11920 11991,11992,4977,11993,11994,11995,11996,11997,11998,11999,12000,12001,12002,12003,12004,12005, #11936 12006,12007,12008,12009,12010,12011,12012,12013,12014,12015,12016,12017,12018,12019,12020,12021, #11952 12022,12023,12024,12025,12026,12027,12028,12029,12030,12031,12032,12033,12034,12035,12036,12037, #11968 12038,12039,12040,12041,12042,12043,12044,12045,12046,12047,12048,12049,12050,12051,12052,12053, #11984 12054,12055,12056,12057,12058,12059,12060,12061,4978,12062,12063,12064,12065,12066,12067,12068, #12000 12069,12070,12071,12072,12073,12074,12075,12076,12077,12078,12079,12080,12081,12082,12083,12084, #12016 12085,12086,12087,12088,12089,12090,12091,12092,12093,12094,12095,12096,12097,12098,12099,12100, #12032 12101,12102,12103,12104,12105,12106,12107,12108,12109,12110,12111,12112,12113,12114,12115,12116, #12048 12117,12118,12119,12120,12121,12122,12123,4979,12124,12125,12126,12127,12128,4197,12129,12130, #12064 12131,12132,12133,12134,12135,12136,12137,12138,12139,12140,12141,12142,12143,12144,12145,12146, #12080 12147,12148,12149,12150,12151,12152,12153,12154,4980,12155,12156,12157,12158,12159,12160,4494, #12096 12161,12162,12163,12164,3811,12165,12166,12167,12168,12169,4495,12170,12171,4496,12172,12173, #12112 12174,12175,12176,3812,12177,12178,12179,12180,12181,12182,12183,12184,12185,12186,12187,12188, #12128 12189,12190,12191,12192,12193,12194,12195,12196,12197,12198,12199,12200,12201,12202,12203,12204, #12144 12205,12206,12207,12208,12209,12210,12211,12212,12213,12214,12215,12216,12217,12218,12219,12220, #12160 12221,4981,12222,12223,12224,12225,12226,12227,12228,12229,12230,12231,12232,12233,12234,12235, #12176 4982,12236,12237,12238,12239,12240,12241,12242,12243,12244,12245,4983,12246,12247,12248,12249, #12192 4984,12250,12251,12252,12253,12254,12255,12256,12257,12258,12259,12260,12261,12262,12263,12264, #12208 4985,12265,4497,12266,12267,12268,12269,12270,12271,12272,12273,12274,12275,12276,12277,12278, #12224 12279,12280,12281,12282,12283,12284,12285,12286,12287,4986,12288,12289,12290,12291,12292,12293, #12240 12294,12295,12296,2473,12297,12298,12299,12300,12301,12302,12303,12304,12305,12306,12307,12308, #12256 12309,12310,12311,12312,12313,12314,12315,12316,12317,12318,12319,3963,12320,12321,12322,12323, #12272 12324,12325,12326,12327,12328,12329,12330,12331,12332,4987,12333,12334,12335,12336,12337,12338, #12288 12339,12340,12341,12342,12343,12344,12345,12346,12347,12348,12349,12350,12351,12352,12353,12354, #12304 12355,12356,12357,12358,12359,3964,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369, #12320 12370,3965,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384, #12336 12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400, #12352 12401,12402,12403,12404,12405,12406,12407,12408,4988,12409,12410,12411,12412,12413,12414,12415, #12368 12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431, #12384 12432,12433,12434,12435,12436,12437,12438,3554,12439,12440,12441,12442,12443,12444,12445,12446, #12400 12447,12448,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462, #12416 12463,12464,4989,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477, #12432 12478,12479,12480,4990,12481,12482,12483,12484,12485,12486,12487,12488,12489,4498,12490,12491, #12448 12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507, #12464 12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523, #12480 12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,12535,12536,12537,12538,12539, #12496 12540,12541,12542,12543,12544,12545,12546,12547,12548,12549,12550,12551,4991,12552,12553,12554, #12512 12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,12570, #12528 12571,12572,12573,12574,12575,12576,12577,12578,3036,12579,12580,12581,12582,12583,3966,12584, #12544 12585,12586,12587,12588,12589,12590,12591,12592,12593,12594,12595,12596,12597,12598,12599,12600, #12560 12601,12602,12603,12604,12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616, #12576 12617,12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,12631,12632, #12592 12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,4499,12647, #12608 12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,12659,12660,12661,12662,12663, #12624 12664,12665,12666,12667,12668,12669,12670,12671,12672,12673,12674,12675,12676,12677,12678,12679, #12640 12680,12681,12682,12683,12684,12685,12686,12687,12688,12689,12690,12691,12692,12693,12694,12695, #12656 12696,12697,12698,4992,12699,12700,12701,12702,12703,12704,12705,12706,12707,12708,12709,12710, #12672 12711,12712,12713,12714,12715,12716,12717,12718,12719,12720,12721,12722,12723,12724,12725,12726, #12688 12727,12728,12729,12730,12731,12732,12733,12734,12735,12736,12737,12738,12739,12740,12741,12742, #12704 12743,12744,12745,12746,12747,12748,12749,12750,12751,12752,12753,12754,12755,12756,12757,12758, #12720 12759,12760,12761,12762,12763,12764,12765,12766,12767,12768,12769,12770,12771,12772,12773,12774, #12736 12775,12776,12777,12778,4993,2175,12779,12780,12781,12782,12783,12784,12785,12786,4500,12787, #12752 12788,12789,12790,12791,12792,12793,12794,12795,12796,12797,12798,12799,12800,12801,12802,12803, #12768 12804,12805,12806,12807,12808,12809,12810,12811,12812,12813,12814,12815,12816,12817,12818,12819, #12784 12820,12821,12822,12823,12824,12825,12826,4198,3967,12827,12828,12829,12830,12831,12832,12833, #12800 12834,12835,12836,12837,12838,12839,12840,12841,12842,12843,12844,12845,12846,12847,12848,12849, #12816 12850,12851,12852,12853,12854,12855,12856,12857,12858,12859,12860,12861,4199,12862,12863,12864, #12832 12865,12866,12867,12868,12869,12870,12871,12872,12873,12874,12875,12876,12877,12878,12879,12880, #12848 12881,12882,12883,12884,12885,12886,12887,4501,12888,12889,12890,12891,12892,12893,12894,12895, #12864 12896,12897,12898,12899,12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,12911, #12880 12912,4994,12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,12923,12924,12925,12926, #12896 12927,12928,12929,12930,12931,12932,12933,12934,12935,12936,12937,12938,12939,12940,12941,12942, #12912 12943,12944,12945,12946,12947,12948,12949,12950,12951,12952,12953,12954,12955,12956,1772,12957, #12928 12958,12959,12960,12961,12962,12963,12964,12965,12966,12967,12968,12969,12970,12971,12972,12973, #12944 12974,12975,12976,12977,12978,12979,12980,12981,12982,12983,12984,12985,12986,12987,12988,12989, #12960 12990,12991,12992,12993,12994,12995,12996,12997,4502,12998,4503,12999,13000,13001,13002,13003, #12976 4504,13004,13005,13006,13007,13008,13009,13010,13011,13012,13013,13014,13015,13016,13017,13018, #12992 13019,13020,13021,13022,13023,13024,13025,13026,13027,13028,13029,3449,13030,13031,13032,13033, #13008 13034,13035,13036,13037,13038,13039,13040,13041,13042,13043,13044,13045,13046,13047,13048,13049, #13024 13050,13051,13052,13053,13054,13055,13056,13057,13058,13059,13060,13061,13062,13063,13064,13065, #13040 13066,13067,13068,13069,13070,13071,13072,13073,13074,13075,13076,13077,13078,13079,13080,13081, #13056 13082,13083,13084,13085,13086,13087,13088,13089,13090,13091,13092,13093,13094,13095,13096,13097, #13072 13098,13099,13100,13101,13102,13103,13104,13105,13106,13107,13108,13109,13110,13111,13112,13113, #13088 13114,13115,13116,13117,13118,3968,13119,4995,13120,13121,13122,13123,13124,13125,13126,13127, #13104 4505,13128,13129,13130,13131,13132,13133,13134,4996,4506,13135,13136,13137,13138,13139,4997, #13120 13140,13141,13142,13143,13144,13145,13146,13147,13148,13149,13150,13151,13152,13153,13154,13155, #13136 13156,13157,13158,13159,4998,13160,13161,13162,13163,13164,13165,13166,13167,13168,13169,13170, #13152 13171,13172,13173,13174,13175,13176,4999,13177,13178,13179,13180,13181,13182,13183,13184,13185, #13168 13186,13187,13188,13189,13190,13191,13192,13193,13194,13195,13196,13197,13198,13199,13200,13201, #13184 13202,13203,13204,13205,13206,5000,13207,13208,13209,13210,13211,13212,13213,13214,13215,13216, #13200 13217,13218,13219,13220,13221,13222,13223,13224,13225,13226,13227,4200,5001,13228,13229,13230, #13216 13231,13232,13233,13234,13235,13236,13237,13238,13239,13240,3969,13241,13242,13243,13244,3970, #13232 13245,13246,13247,13248,13249,13250,13251,13252,13253,13254,13255,13256,13257,13258,13259,13260, #13248 13261,13262,13263,13264,13265,13266,13267,13268,3450,13269,13270,13271,13272,13273,13274,13275, #13264 13276,5002,13277,13278,13279,13280,13281,13282,13283,13284,13285,13286,13287,13288,13289,13290, #13280 13291,13292,13293,13294,13295,13296,13297,13298,13299,13300,13301,13302,3813,13303,13304,13305, #13296 13306,13307,13308,13309,13310,13311,13312,13313,13314,13315,13316,13317,13318,13319,13320,13321, #13312 13322,13323,13324,13325,13326,13327,13328,4507,13329,13330,13331,13332,13333,13334,13335,13336, #13328 13337,13338,13339,13340,13341,5003,13342,13343,13344,13345,13346,13347,13348,13349,13350,13351, #13344 13352,13353,13354,13355,13356,13357,13358,13359,13360,13361,13362,13363,13364,13365,13366,13367, #13360 5004,13368,13369,13370,13371,13372,13373,13374,13375,13376,13377,13378,13379,13380,13381,13382, #13376 13383,13384,13385,13386,13387,13388,13389,13390,13391,13392,13393,13394,13395,13396,13397,13398, #13392 13399,13400,13401,13402,13403,13404,13405,13406,13407,13408,13409,13410,13411,13412,13413,13414, #13408 13415,13416,13417,13418,13419,13420,13421,13422,13423,13424,13425,13426,13427,13428,13429,13430, #13424 13431,13432,4508,13433,13434,13435,4201,13436,13437,13438,13439,13440,13441,13442,13443,13444, #13440 13445,13446,13447,13448,13449,13450,13451,13452,13453,13454,13455,13456,13457,5005,13458,13459, #13456 13460,13461,13462,13463,13464,13465,13466,13467,13468,13469,13470,4509,13471,13472,13473,13474, #13472 13475,13476,13477,13478,13479,13480,13481,13482,13483,13484,13485,13486,13487,13488,13489,13490, #13488 13491,13492,13493,13494,13495,13496,13497,13498,13499,13500,13501,13502,13503,13504,13505,13506, #13504 13507,13508,13509,13510,13511,13512,13513,13514,13515,13516,13517,13518,13519,13520,13521,13522, #13520 13523,13524,13525,13526,13527,13528,13529,13530,13531,13532,13533,13534,13535,13536,13537,13538, #13536 13539,13540,13541,13542,13543,13544,13545,13546,13547,13548,13549,13550,13551,13552,13553,13554, #13552 13555,13556,13557,13558,13559,13560,13561,13562,13563,13564,13565,13566,13567,13568,13569,13570, #13568 13571,13572,13573,13574,13575,13576,13577,13578,13579,13580,13581,13582,13583,13584,13585,13586, #13584 13587,13588,13589,13590,13591,13592,13593,13594,13595,13596,13597,13598,13599,13600,13601,13602, #13600 13603,13604,13605,13606,13607,13608,13609,13610,13611,13612,13613,13614,13615,13616,13617,13618, #13616 13619,13620,13621,13622,13623,13624,13625,13626,13627,13628,13629,13630,13631,13632,13633,13634, #13632 13635,13636,13637,13638,13639,13640,13641,13642,5006,13643,13644,13645,13646,13647,13648,13649, #13648 13650,13651,5007,13652,13653,13654,13655,13656,13657,13658,13659,13660,13661,13662,13663,13664, #13664 13665,13666,13667,13668,13669,13670,13671,13672,13673,13674,13675,13676,13677,13678,13679,13680, #13680 13681,13682,13683,13684,13685,13686,13687,13688,13689,13690,13691,13692,13693,13694,13695,13696, #13696 13697,13698,13699,13700,13701,13702,13703,13704,13705,13706,13707,13708,13709,13710,13711,13712, #13712 13713,13714,13715,13716,13717,13718,13719,13720,13721,13722,13723,13724,13725,13726,13727,13728, #13728 13729,13730,13731,13732,13733,13734,13735,13736,13737,13738,13739,13740,13741,13742,13743,13744, #13744 13745,13746,13747,13748,13749,13750,13751,13752,13753,13754,13755,13756,13757,13758,13759,13760, #13760 13761,13762,13763,13764,13765,13766,13767,13768,13769,13770,13771,13772,13773,13774,3273,13775, #13776 13776,13777,13778,13779,13780,13781,13782,13783,13784,13785,13786,13787,13788,13789,13790,13791, #13792 13792,13793,13794,13795,13796,13797,13798,13799,13800,13801,13802,13803,13804,13805,13806,13807, #13808 13808,13809,13810,13811,13812,13813,13814,13815,13816,13817,13818,13819,13820,13821,13822,13823, #13824 13824,13825,13826,13827,13828,13829,13830,13831,13832,13833,13834,13835,13836,13837,13838,13839, #13840 13840,13841,13842,13843,13844,13845,13846,13847,13848,13849,13850,13851,13852,13853,13854,13855, #13856 13856,13857,13858,13859,13860,13861,13862,13863,13864,13865,13866,13867,13868,13869,13870,13871, #13872 13872,13873,13874,13875,13876,13877,13878,13879,13880,13881,13882,13883,13884,13885,13886,13887, #13888 13888,13889,13890,13891,13892,13893,13894,13895,13896,13897,13898,13899,13900,13901,13902,13903, #13904 13904,13905,13906,13907,13908,13909,13910,13911,13912,13913,13914,13915,13916,13917,13918,13919, #13920 13920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,13931,13932,13933,13934,13935, #13936 13936,13937,13938,13939,13940,13941,13942,13943,13944,13945,13946,13947,13948,13949,13950,13951, #13952 13952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,13967, #13968 13968,13969,13970,13971,13972) #13973 # flake8: noqa
agpl-3.0
[ 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, 13123, 21, 9857, 1817, 199, 3, 701, 377, 5789, 20444, 1159, 603, 460, 285, 262, 27724, 23193, 1849, 1097, 382, 199, 3, 665, 1014, 921, 1544, 14, 8654, 14, 8122, 26, 2835, 15, 10333, 82, 3133, 199, 3, 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, 21245, 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, 18643, 21, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 378, 14, 2194, 199, 199, 3, 1610, 370, 481, 2103, 4738, 1817, 199, 18643, 21, 63, 8723, 63, 4305, 275, 959, 11452, 199, 199, 7279, 21, 18139, 13875, 4738, 275, 334, 2043, 413, 12, 1085, 614, 12, 1046, 1690, 12, 5450, 12, 1079, 2192, 12, 413, 2905, 12, 257, 1749, 12, 221, 18051, 12, 257, 1227, 12, 5783, 24, 12, 413, 1138, 12, 19328, 12, 1344, 2835, 12, 713, 1367, 12, 1651, 2025, 12, 16814, 12, 327, 257, 3193, 199, 1703, 1079, 12, 221, 9404, 12, 708, 1342, 12, 499, 2976, 12, 221, 14646, 12, 221, 10868, 12, 18, 7636, 12, 221, 3193, 12, 1398, 2466, 12, 9252, 23, 12, 31989, 12, 1227, 1427, 12, 1355, 3172, 12, 221, 7875, 12, 1082, 2869, 12, 1479, 2481, 12, 327, 257, 4337, 199, 845, 2905, 12, 1355, 2819, 12, 1153, 1400, 12, 2260, 996, 12, 32321, 12, 1081, 1046, 12, 11485, 12, 959, 2710, 12, 650, 2976, 12, 1167, 772, 12, 257, 1695, 12, 14785, 12, 221, 13713, 12, 2322, 709, 12, 5783, 25, 12, 1167, 708, 12, 327, 257, 9615, 523, 13668, 12, 8216, 16, 12, 8216, 17, 12, 650, 1196, 12, 975, 1079, 12, 221, 13098, 12, 26485, 12, 413, 1427, 12, 20, 11341, 12, 1194, 1196, 12, 1079, 1257, 12, 8216, 18, 12, 10156, 21, 12, 1216, 3328, 12, 18565, 12, 29736, 12, 327, 257, 5049, 199, 1344, 2564, 12, 257, 650, 12, 221, 1616, 12, 1355, 2898, 12, 1079, 3172, 12, 221, 7349, 12, 1465, 1555, 12, 845, 1276, 12, 11125, 22, 12, 30614, 12, 10513, 19, 12, 21334, 12, 708, 2194, 12, 17, 4288, 12, 650, 713, 12, 8216, 19, 12, 327, 257, 5939, 199, 2322, 845, 12, 1165, 2528, 12, 959, 1780, 12, 27210, 12, 1227, 2564, 12, 8216, 20, 12, 31308, 12, 1167, 1046, 12, 25442, 12, 26761, 12, 1398, 2417, 12, 221, 8177, 12, 10156, 22, 12, 708, 966, 12, 221, 5049, 12, 1227, 966, 12, 327, 257, 15580, 199, 8216, 21, 12, 821, 614, 12, 1167, 1138, 12, 1167, 2277, 12, 29710, 12, 7155, 17, 12, 5049, 21, 12, 5049, 17, 12, 975, 1690, 12, 8216, 22, 12, 1082, 2528, 12, 650, 1401, 12, 221, 15323, 12, 841, 1690, 12, 8216, 23, 12, 221, 5939, 12, 327, 221, 20240, 199, 1227, 1216, 12, 27077, 12, 708, 1717, 12, 1046, 1643, 12, 499, 2766, 12, 1749, 1355, 12, 709, 2942, 12, 1479, 1477, 12, 1520, 1367, 12, 1079, 2167, 12, 709, 2635, 12, 1082, 2481, 12, 841, 1887, 12, 221, 14610, 12, 1398, 1555, 12, 959, 3328, 12, 327, 221, 7960, 199, 31420, 12, 1165, 2534, 12, 841, 3172, 12, 22560, 12, 1165, 1276, 12, 1085, 1602, 12, 221, 5212, 12, 221, 5238, 12, 1398, 1299, 12, 25956, 12, 5939, 22, 12, 1085, 1876, 12, 1520, 1082, 12, 1165, 1344, 12, 1082, 1477, 12, 13576, 12, 327, 221, 21771, 199, 8806, 21, 12, 975, 1780, 12, 32609, 12, 959, 1401, 12, 1398, 1780, 12, 1227, 1299, 12, 8216, 24, 12, 650, 1167, 12, 969, 1717, 12, 8375, 25, 12, 6886, 21, 12, 959, 1079, 12, 10638, 25, 12, 499, 2905, 12, 2322, 713, 12, 650, 1427, 12, 327, 221, 21235, 199, 27874, 12, 221, 9137, 12, 1465, 975, 12, 969, 1703, 12, 1227, 2766, 12, 221, 4119, 12, 1749, 1690, 12, 709, 1020, 12, 2299, 19, 12, 221, 3388, 12, 1194, 2953, 12, 413, 2564, 12, 959, 708, 12, 1196, 975, 12, 8216, 25, 12, 1520, 708, 12, 327, 221, 27827, 199, 969, 2114, 12, 2260, 966, 12, 969, 845, 12, 1079, 1165, 12, 708, 1690, 12, 221, 5661, 12, 1789, 1196, 12, 709, 1367, 12, 24073, 12, 650, 1020, 12, 650, 2564 ]
[ 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, 13123, 21, 9857, 1817, 199, 3, 701, 377, 5789, 20444, 1159, 603, 460, 285, 262, 27724, 23193, 1849, 1097, 382, 199, 3, 665, 1014, 921, 1544, 14, 8654, 14, 8122, 26, 2835, 15, 10333, 82, 3133, 199, 3, 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, 21245, 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, 18643, 21, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 378, 14, 2194, 199, 199, 3, 1610, 370, 481, 2103, 4738, 1817, 199, 18643, 21, 63, 8723, 63, 4305, 275, 959, 11452, 199, 199, 7279, 21, 18139, 13875, 4738, 275, 334, 2043, 413, 12, 1085, 614, 12, 1046, 1690, 12, 5450, 12, 1079, 2192, 12, 413, 2905, 12, 257, 1749, 12, 221, 18051, 12, 257, 1227, 12, 5783, 24, 12, 413, 1138, 12, 19328, 12, 1344, 2835, 12, 713, 1367, 12, 1651, 2025, 12, 16814, 12, 327, 257, 3193, 199, 1703, 1079, 12, 221, 9404, 12, 708, 1342, 12, 499, 2976, 12, 221, 14646, 12, 221, 10868, 12, 18, 7636, 12, 221, 3193, 12, 1398, 2466, 12, 9252, 23, 12, 31989, 12, 1227, 1427, 12, 1355, 3172, 12, 221, 7875, 12, 1082, 2869, 12, 1479, 2481, 12, 327, 257, 4337, 199, 845, 2905, 12, 1355, 2819, 12, 1153, 1400, 12, 2260, 996, 12, 32321, 12, 1081, 1046, 12, 11485, 12, 959, 2710, 12, 650, 2976, 12, 1167, 772, 12, 257, 1695, 12, 14785, 12, 221, 13713, 12, 2322, 709, 12, 5783, 25, 12, 1167, 708, 12, 327, 257, 9615, 523, 13668, 12, 8216, 16, 12, 8216, 17, 12, 650, 1196, 12, 975, 1079, 12, 221, 13098, 12, 26485, 12, 413, 1427, 12, 20, 11341, 12, 1194, 1196, 12, 1079, 1257, 12, 8216, 18, 12, 10156, 21, 12, 1216, 3328, 12, 18565, 12, 29736, 12, 327, 257, 5049, 199, 1344, 2564, 12, 257, 650, 12, 221, 1616, 12, 1355, 2898, 12, 1079, 3172, 12, 221, 7349, 12, 1465, 1555, 12, 845, 1276, 12, 11125, 22, 12, 30614, 12, 10513, 19, 12, 21334, 12, 708, 2194, 12, 17, 4288, 12, 650, 713, 12, 8216, 19, 12, 327, 257, 5939, 199, 2322, 845, 12, 1165, 2528, 12, 959, 1780, 12, 27210, 12, 1227, 2564, 12, 8216, 20, 12, 31308, 12, 1167, 1046, 12, 25442, 12, 26761, 12, 1398, 2417, 12, 221, 8177, 12, 10156, 22, 12, 708, 966, 12, 221, 5049, 12, 1227, 966, 12, 327, 257, 15580, 199, 8216, 21, 12, 821, 614, 12, 1167, 1138, 12, 1167, 2277, 12, 29710, 12, 7155, 17, 12, 5049, 21, 12, 5049, 17, 12, 975, 1690, 12, 8216, 22, 12, 1082, 2528, 12, 650, 1401, 12, 221, 15323, 12, 841, 1690, 12, 8216, 23, 12, 221, 5939, 12, 327, 221, 20240, 199, 1227, 1216, 12, 27077, 12, 708, 1717, 12, 1046, 1643, 12, 499, 2766, 12, 1749, 1355, 12, 709, 2942, 12, 1479, 1477, 12, 1520, 1367, 12, 1079, 2167, 12, 709, 2635, 12, 1082, 2481, 12, 841, 1887, 12, 221, 14610, 12, 1398, 1555, 12, 959, 3328, 12, 327, 221, 7960, 199, 31420, 12, 1165, 2534, 12, 841, 3172, 12, 22560, 12, 1165, 1276, 12, 1085, 1602, 12, 221, 5212, 12, 221, 5238, 12, 1398, 1299, 12, 25956, 12, 5939, 22, 12, 1085, 1876, 12, 1520, 1082, 12, 1165, 1344, 12, 1082, 1477, 12, 13576, 12, 327, 221, 21771, 199, 8806, 21, 12, 975, 1780, 12, 32609, 12, 959, 1401, 12, 1398, 1780, 12, 1227, 1299, 12, 8216, 24, 12, 650, 1167, 12, 969, 1717, 12, 8375, 25, 12, 6886, 21, 12, 959, 1079, 12, 10638, 25, 12, 499, 2905, 12, 2322, 713, 12, 650, 1427, 12, 327, 221, 21235, 199, 27874, 12, 221, 9137, 12, 1465, 975, 12, 969, 1703, 12, 1227, 2766, 12, 221, 4119, 12, 1749, 1690, 12, 709, 1020, 12, 2299, 19, 12, 221, 3388, 12, 1194, 2953, 12, 413, 2564, 12, 959, 708, 12, 1196, 975, 12, 8216, 25, 12, 1520, 708, 12, 327, 221, 27827, 199, 969, 2114, 12, 2260, 966, 12, 969, 845, 12, 1079, 1165, 12, 708, 1690, 12, 221, 5661, 12, 1789, 1196, 12, 709, 1367, 12, 24073, 12, 650, 1020, 12, 650, 2564, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
Achuth17/scikit-learn
sklearn/neighbors/tests/test_dist_metrics.py
230
5234
import itertools import pickle import numpy as np from numpy.testing import assert_array_almost_equal import scipy from scipy.spatial.distance import cdist from sklearn.neighbors.dist_metrics import DistanceMetric from nose import SkipTest def dist_func(x1, x2, p): return np.sum((x1 - x2) ** p) ** (1. / p) def cmp_version(version1, version2): version1 = tuple(map(int, version1.split('.')[:2])) version2 = tuple(map(int, version2.split('.')[:2])) if version1 < version2: return -1 elif version1 > version2: return 1 else: return 0 class TestMetrics: def __init__(self, n1=20, n2=25, d=4, zero_frac=0.5, rseed=0, dtype=np.float64): np.random.seed(rseed) self.X1 = np.random.random((n1, d)).astype(dtype) self.X2 = np.random.random((n2, d)).astype(dtype) # make boolean arrays: ones and zeros self.X1_bool = self.X1.round(0) self.X2_bool = self.X2.round(0) V = np.random.random((d, d)) VI = np.dot(V, V.T) self.metrics = {'euclidean': {}, 'cityblock': {}, 'minkowski': dict(p=(1, 1.5, 2, 3)), 'chebyshev': {}, 'seuclidean': dict(V=(np.random.random(d),)), 'wminkowski': dict(p=(1, 1.5, 3), w=(np.random.random(d),)), 'mahalanobis': dict(VI=(VI,)), 'hamming': {}, 'canberra': {}, 'braycurtis': {}} self.bool_metrics = ['matching', 'jaccard', 'dice', 'kulsinski', 'rogerstanimoto', 'russellrao', 'sokalmichener', 'sokalsneath'] def test_cdist(self): for metric, argdict in self.metrics.items(): keys = argdict.keys() for vals in itertools.product(*argdict.values()): kwargs = dict(zip(keys, vals)) D_true = cdist(self.X1, self.X2, metric, **kwargs) yield self.check_cdist, metric, kwargs, D_true for metric in self.bool_metrics: D_true = cdist(self.X1_bool, self.X2_bool, metric) yield self.check_cdist_bool, metric, D_true def check_cdist(self, metric, kwargs, D_true): if metric == 'canberra' and cmp_version(scipy.__version__, '0.9') <= 0: raise SkipTest("Canberra distance incorrect in scipy < 0.9") dm = DistanceMetric.get_metric(metric, **kwargs) D12 = dm.pairwise(self.X1, self.X2) assert_array_almost_equal(D12, D_true) def check_cdist_bool(self, metric, D_true): dm = DistanceMetric.get_metric(metric) D12 = dm.pairwise(self.X1_bool, self.X2_bool) assert_array_almost_equal(D12, D_true) def test_pdist(self): for metric, argdict in self.metrics.items(): keys = argdict.keys() for vals in itertools.product(*argdict.values()): kwargs = dict(zip(keys, vals)) D_true = cdist(self.X1, self.X1, metric, **kwargs) yield self.check_pdist, metric, kwargs, D_true for metric in self.bool_metrics: D_true = cdist(self.X1_bool, self.X1_bool, metric) yield self.check_pdist_bool, metric, D_true def check_pdist(self, metric, kwargs, D_true): if metric == 'canberra' and cmp_version(scipy.__version__, '0.9') <= 0: raise SkipTest("Canberra distance incorrect in scipy < 0.9") dm = DistanceMetric.get_metric(metric, **kwargs) D12 = dm.pairwise(self.X1) assert_array_almost_equal(D12, D_true) def check_pdist_bool(self, metric, D_true): dm = DistanceMetric.get_metric(metric) D12 = dm.pairwise(self.X1_bool) assert_array_almost_equal(D12, D_true) def test_haversine_metric(): def haversine_slow(x1, x2): return 2 * np.arcsin(np.sqrt(np.sin(0.5 * (x1[0] - x2[0])) ** 2 + np.cos(x1[0]) * np.cos(x2[0]) * np.sin(0.5 * (x1[1] - x2[1])) ** 2)) X = np.random.random((10, 2)) haversine = DistanceMetric.get_metric("haversine") D1 = haversine.pairwise(X) D2 = np.zeros_like(D1) for i, x1 in enumerate(X): for j, x2 in enumerate(X): D2[i, j] = haversine_slow(x1, x2) assert_array_almost_equal(D1, D2) assert_array_almost_equal(haversine.dist_to_rdist(D1), np.sin(0.5 * D2) ** 2) def test_pyfunc_metric(): X = np.random.random((10, 3)) euclidean = DistanceMetric.get_metric("euclidean") pyfunc = DistanceMetric.get_metric("pyfunc", func=dist_func, p=2) # Check if both callable metric and predefined metric initialized # DistanceMetric object is picklable euclidean_pkl = pickle.loads(pickle.dumps(euclidean)) pyfunc_pkl = pickle.loads(pickle.dumps(pyfunc)) D1 = euclidean.pairwise(X) D2 = pyfunc.pairwise(X) D1_pkl = euclidean_pkl.pairwise(X) D2_pkl = pyfunc_pkl.pairwise(X) assert_array_almost_equal(D1, D2) assert_array_almost_equal(D1_pkl, D2_pkl)
bsd-3-clause
[ 646, 7975, 199, 646, 5927, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 199, 646, 7026, 199, 504, 7026, 14, 11679, 14, 5590, 492, 286, 2686, 199, 504, 6357, 14, 11113, 14, 2686, 63, 6759, 492, 21892, 11119, 199, 504, 11354, 492, 18795, 421, 199, 318, 2917, 63, 1532, 8, 88, 17, 12, 671, 18, 12, 299, 304, 272, 372, 980, 14, 1838, 1332, 88, 17, 446, 671, 18, 9, 1011, 299, 9, 1011, 334, 17, 14, 1182, 299, 9, 421, 199, 318, 10467, 63, 1023, 8, 1023, 17, 12, 1015, 18, 304, 272, 1015, 17, 275, 2008, 8, 1130, 8, 442, 12, 1015, 17, 14, 1294, 7563, 1491, 18, 2459, 272, 1015, 18, 275, 2008, 8, 1130, 8, 442, 12, 1015, 18, 14, 1294, 7563, 1491, 18, 2459, 339, 340, 1015, 17, 665, 1015, 18, 26, 267, 372, 446, 17, 272, 916, 1015, 17, 690, 1015, 18, 26, 267, 372, 413, 272, 587, 26, 267, 372, 378, 421, 199, 533, 1379, 17213, 26, 272, 347, 636, 826, 721, 277, 12, 302, 17, 29, 1165, 12, 302, 18, 29, 821, 12, 366, 29, 20, 12, 4697, 63, 10865, 29, 16, 14, 21, 12, 326, 519, 5176, 29, 16, 12, 2152, 29, 1590, 14, 1609, 772, 304, 267, 980, 14, 2355, 14, 5176, 8, 82, 5176, 9, 267, 291, 14, 56, 17, 275, 980, 14, 2355, 14, 2355, 1332, 78, 17, 12, 366, 4992, 6041, 8, 2271, 9, 267, 291, 14, 56, 18, 275, 980, 14, 2355, 14, 2355, 1332, 78, 18, 12, 366, 4992, 6041, 8, 2271, 9, 398, 327, 1852, 5046, 6572, 26, 7869, 436, 10136, 267, 291, 14, 56, 17, 63, 2245, 275, 291, 14, 56, 17, 14, 2363, 8, 16, 9, 267, 291, 14, 56, 18, 63, 2245, 275, 291, 14, 56, 18, 14, 2363, 8, 16, 9, 398, 812, 275, 980, 14, 2355, 14, 2355, 1332, 68, 12, 366, 430, 267, 812, 41, 275, 980, 14, 3287, 8, 54, 12, 812, 14, 52, 9, 398, 291, 14, 6759, 275, 791, 26479, 356, 5479, 717, 283, 3690, 1457, 356, 5479, 717, 283, 827, 75, 19844, 356, 1211, 8, 80, 2687, 17, 12, 413, 14, 21, 12, 499, 12, 650, 1826, 717, 283, 25820, 27185, 356, 5479, 717, 283, 261, 24941, 356, 1211, 8, 54, 2687, 1590, 14, 2355, 14, 2355, 8, 68, 395, 1826, 717, 283, 87, 827, 75, 19844, 356, 1211, 8, 80, 2687, 17, 12, 413, 14, 21, 12, 650, 395, 5644, 336, 2687, 1590, 14, 2355, 14, 2355, 8, 68, 395, 1826, 717, 283, 391, 19785, 290, 2873, 374, 356, 1211, 8, 17655, 2687, 17655, 16965, 717, 283, 10670, 14566, 356, 5479, 717, 283, 2425, 605, 345, 356, 5479, 717, 283, 66, 803, 895, 16753, 356, 24312, 398, 291, 14, 2245, 63, 6759, 275, 788, 9467, 297, 283, 74, 5470, 1005, 297, 283, 328, 301, 297, 2490, 283, 75, 348, 5911, 10728, 297, 283, 293, 836, 9746, 1017, 3459, 297, 283, 20791, 23235, 345, 79, 297, 2490, 283, 83, 745, 279, 77, 1158, 727, 297, 283, 83, 745, 2551, 685, 1619, 418, 339, 347, 511, 63, 67, 2686, 8, 277, 304, 267, 367, 6370, 12, 1680, 807, 315, 291, 14, 6759, 14, 1744, 837, 288, 2883, 275, 1680, 807, 14, 1612, 342, 288, 367, 5322, 315, 7975, 14, 2558, 2031, 1273, 807, 14, 1459, 5109, 355, 2074, 275, 1211, 8, 3065, 8, 1612, 12, 5322, 430, 355, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 12, 291, 14, 56, 18, 12, 6370, 12, 1011, 958, 9, 355, 1995, 291, 14, 1074, 63, 67, 2686, 12, 6370, 12, 2074, 12, 577, 63, 2052, 398, 367, 6370, 315, 291, 14, 2245, 63, 6759, 26, 288, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 63, 2245, 12, 291, 14, 56, 18, 63, 2245, 12, 6370, 9, 288, 1995, 291, 14, 1074, 63, 67, 2686, 63, 2245, 12, 6370, 12, 577, 63, 2052, 339, 347, 1104, 63, 67, 2686, 8, 277, 12, 6370, 12, 2074, 12, 577, 63, 2052, 304, 267, 340, 6370, 508, 283, 2425, 605, 345, 7, 436, 10467, 63, 1023, 8, 14248, 855, 1023, 3108, 283, 16, 14, 25, 358, 2695, 378, 26, 288, 746, 18795, 480, 6049, 605, 345, 6033, 8927, 315, 7026, 665, 378, 14, 25, 531, 267, 17547, 275, 21892, 11119, 14, 362, 63, 5165, 8, 5165, 12, 1011, 958, 9, 267, 577, 713, 275, 17547, 14, 25069, 8, 277, 14, 56, 17, 12, 291, 14, 56, 18, 9, 267, 702, 63, 1144, 63, 4398, 63, 1452, 8, 36, 713, 12, 577, 63, 2052, 9, 339, 347, 1104, 63, 67, 2686, 63, 2245, 8, 277, 12, 6370, 12, 577, 63, 2052, 304, 267, 17547, 275, 21892, 11119, 14, 362, 63, 5165, 8, 5165, 9, 267, 577, 713, 275, 17547, 14, 25069, 8, 277, 14, 56, 17, 63, 2245, 12, 291, 14, 56, 18, 63, 2245, 9, 267, 702, 63, 1144, 63, 4398, 63, 1452, 8, 36, 713, 12, 577, 63, 2052, 9, 339, 347, 511, 63, 29528, 8, 277, 304, 267, 367, 6370, 12, 1680, 807, 315, 291, 14, 6759, 14, 1744, 837, 288, 2883, 275, 1680, 807, 14, 1612, 342, 288, 367, 5322, 315, 7975, 14, 2558, 2031, 1273, 807, 14, 1459, 5109, 355, 2074, 275, 1211, 8, 3065, 8, 1612, 12, 5322, 430, 355, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 12, 291, 14, 56, 17, 12, 6370, 12, 1011, 958, 9, 355, 1995, 291, 14, 1074, 63, 29528, 12, 6370, 12, 2074, 12, 577, 63, 2052, 398, 367, 6370, 315, 291, 14, 2245, 63, 6759, 26, 288, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 63, 2245, 12, 291, 14, 56, 17, 63, 2245, 12, 6370, 9, 288, 1995, 291, 14, 1074, 63, 29528, 63, 2245, 12, 6370, 12, 577, 63, 2052, 339, 347, 1104, 63, 29528, 8, 277, 12, 6370, 12, 2074, 12, 577, 63, 2052, 304, 267, 340, 6370, 508, 283, 2425, 605, 345, 7, 436, 10467, 63, 1023, 8, 14248, 855, 1023, 3108, 283, 16, 14, 25, 358, 2695, 378, 26, 288, 746, 18795, 480 ]
[ 7975, 199, 646, 5927, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 199, 646, 7026, 199, 504, 7026, 14, 11679, 14, 5590, 492, 286, 2686, 199, 504, 6357, 14, 11113, 14, 2686, 63, 6759, 492, 21892, 11119, 199, 504, 11354, 492, 18795, 421, 199, 318, 2917, 63, 1532, 8, 88, 17, 12, 671, 18, 12, 299, 304, 272, 372, 980, 14, 1838, 1332, 88, 17, 446, 671, 18, 9, 1011, 299, 9, 1011, 334, 17, 14, 1182, 299, 9, 421, 199, 318, 10467, 63, 1023, 8, 1023, 17, 12, 1015, 18, 304, 272, 1015, 17, 275, 2008, 8, 1130, 8, 442, 12, 1015, 17, 14, 1294, 7563, 1491, 18, 2459, 272, 1015, 18, 275, 2008, 8, 1130, 8, 442, 12, 1015, 18, 14, 1294, 7563, 1491, 18, 2459, 339, 340, 1015, 17, 665, 1015, 18, 26, 267, 372, 446, 17, 272, 916, 1015, 17, 690, 1015, 18, 26, 267, 372, 413, 272, 587, 26, 267, 372, 378, 421, 199, 533, 1379, 17213, 26, 272, 347, 636, 826, 721, 277, 12, 302, 17, 29, 1165, 12, 302, 18, 29, 821, 12, 366, 29, 20, 12, 4697, 63, 10865, 29, 16, 14, 21, 12, 326, 519, 5176, 29, 16, 12, 2152, 29, 1590, 14, 1609, 772, 304, 267, 980, 14, 2355, 14, 5176, 8, 82, 5176, 9, 267, 291, 14, 56, 17, 275, 980, 14, 2355, 14, 2355, 1332, 78, 17, 12, 366, 4992, 6041, 8, 2271, 9, 267, 291, 14, 56, 18, 275, 980, 14, 2355, 14, 2355, 1332, 78, 18, 12, 366, 4992, 6041, 8, 2271, 9, 398, 327, 1852, 5046, 6572, 26, 7869, 436, 10136, 267, 291, 14, 56, 17, 63, 2245, 275, 291, 14, 56, 17, 14, 2363, 8, 16, 9, 267, 291, 14, 56, 18, 63, 2245, 275, 291, 14, 56, 18, 14, 2363, 8, 16, 9, 398, 812, 275, 980, 14, 2355, 14, 2355, 1332, 68, 12, 366, 430, 267, 812, 41, 275, 980, 14, 3287, 8, 54, 12, 812, 14, 52, 9, 398, 291, 14, 6759, 275, 791, 26479, 356, 5479, 717, 283, 3690, 1457, 356, 5479, 717, 283, 827, 75, 19844, 356, 1211, 8, 80, 2687, 17, 12, 413, 14, 21, 12, 499, 12, 650, 1826, 717, 283, 25820, 27185, 356, 5479, 717, 283, 261, 24941, 356, 1211, 8, 54, 2687, 1590, 14, 2355, 14, 2355, 8, 68, 395, 1826, 717, 283, 87, 827, 75, 19844, 356, 1211, 8, 80, 2687, 17, 12, 413, 14, 21, 12, 650, 395, 5644, 336, 2687, 1590, 14, 2355, 14, 2355, 8, 68, 395, 1826, 717, 283, 391, 19785, 290, 2873, 374, 356, 1211, 8, 17655, 2687, 17655, 16965, 717, 283, 10670, 14566, 356, 5479, 717, 283, 2425, 605, 345, 356, 5479, 717, 283, 66, 803, 895, 16753, 356, 24312, 398, 291, 14, 2245, 63, 6759, 275, 788, 9467, 297, 283, 74, 5470, 1005, 297, 283, 328, 301, 297, 2490, 283, 75, 348, 5911, 10728, 297, 283, 293, 836, 9746, 1017, 3459, 297, 283, 20791, 23235, 345, 79, 297, 2490, 283, 83, 745, 279, 77, 1158, 727, 297, 283, 83, 745, 2551, 685, 1619, 418, 339, 347, 511, 63, 67, 2686, 8, 277, 304, 267, 367, 6370, 12, 1680, 807, 315, 291, 14, 6759, 14, 1744, 837, 288, 2883, 275, 1680, 807, 14, 1612, 342, 288, 367, 5322, 315, 7975, 14, 2558, 2031, 1273, 807, 14, 1459, 5109, 355, 2074, 275, 1211, 8, 3065, 8, 1612, 12, 5322, 430, 355, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 12, 291, 14, 56, 18, 12, 6370, 12, 1011, 958, 9, 355, 1995, 291, 14, 1074, 63, 67, 2686, 12, 6370, 12, 2074, 12, 577, 63, 2052, 398, 367, 6370, 315, 291, 14, 2245, 63, 6759, 26, 288, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 63, 2245, 12, 291, 14, 56, 18, 63, 2245, 12, 6370, 9, 288, 1995, 291, 14, 1074, 63, 67, 2686, 63, 2245, 12, 6370, 12, 577, 63, 2052, 339, 347, 1104, 63, 67, 2686, 8, 277, 12, 6370, 12, 2074, 12, 577, 63, 2052, 304, 267, 340, 6370, 508, 283, 2425, 605, 345, 7, 436, 10467, 63, 1023, 8, 14248, 855, 1023, 3108, 283, 16, 14, 25, 358, 2695, 378, 26, 288, 746, 18795, 480, 6049, 605, 345, 6033, 8927, 315, 7026, 665, 378, 14, 25, 531, 267, 17547, 275, 21892, 11119, 14, 362, 63, 5165, 8, 5165, 12, 1011, 958, 9, 267, 577, 713, 275, 17547, 14, 25069, 8, 277, 14, 56, 17, 12, 291, 14, 56, 18, 9, 267, 702, 63, 1144, 63, 4398, 63, 1452, 8, 36, 713, 12, 577, 63, 2052, 9, 339, 347, 1104, 63, 67, 2686, 63, 2245, 8, 277, 12, 6370, 12, 577, 63, 2052, 304, 267, 17547, 275, 21892, 11119, 14, 362, 63, 5165, 8, 5165, 9, 267, 577, 713, 275, 17547, 14, 25069, 8, 277, 14, 56, 17, 63, 2245, 12, 291, 14, 56, 18, 63, 2245, 9, 267, 702, 63, 1144, 63, 4398, 63, 1452, 8, 36, 713, 12, 577, 63, 2052, 9, 339, 347, 511, 63, 29528, 8, 277, 304, 267, 367, 6370, 12, 1680, 807, 315, 291, 14, 6759, 14, 1744, 837, 288, 2883, 275, 1680, 807, 14, 1612, 342, 288, 367, 5322, 315, 7975, 14, 2558, 2031, 1273, 807, 14, 1459, 5109, 355, 2074, 275, 1211, 8, 3065, 8, 1612, 12, 5322, 430, 355, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 12, 291, 14, 56, 17, 12, 6370, 12, 1011, 958, 9, 355, 1995, 291, 14, 1074, 63, 29528, 12, 6370, 12, 2074, 12, 577, 63, 2052, 398, 367, 6370, 315, 291, 14, 2245, 63, 6759, 26, 288, 577, 63, 2052, 275, 286, 2686, 8, 277, 14, 56, 17, 63, 2245, 12, 291, 14, 56, 17, 63, 2245, 12, 6370, 9, 288, 1995, 291, 14, 1074, 63, 29528, 63, 2245, 12, 6370, 12, 577, 63, 2052, 339, 347, 1104, 63, 29528, 8, 277, 12, 6370, 12, 2074, 12, 577, 63, 2052, 304, 267, 340, 6370, 508, 283, 2425, 605, 345, 7, 436, 10467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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 ]
ImageEngine/gaffer
python/GafferUI/GraphBookmarksUI.py
4
11249
########################################################################## # # Copyright (c) 2015, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the following # disclaimer. # # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided with # the distribution. # # * Neither the name of John Haddon nor the names of # any other contributors to this software may be used to endorse or # promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ########################################################################## import functools import weakref import IECore import Gaffer import GafferUI ########################################################################## # Public methods ########################################################################## def appendNodeContextMenuDefinitions( graphEditor, node, menuDefinition ) : if len( menuDefinition.items() ) : menuDefinition.append( "/GraphBookmarksDivider", { "divider" : True } ) menuDefinition.append( "/Bookmarked", { "checkBox" : Gaffer.MetadataAlgo.getBookmarked( node ), "command" : functools.partial( __setBookmarked, node ), "active" : not Gaffer.MetadataAlgo.readOnly( node ), } ) for i in range( 1, 10 ) : menuDefinition.append( "/Numeric Bookmark/%s" % i, { "command" : functools.partial( __assignNumericBookmark, node, i ), "shortCut" : "Ctrl+%i" % i, "active" : not Gaffer.MetadataAlgo.readOnly( node ), } ) menuDefinition.append( "/Numeric Bookmark/Remove", { "command" : functools.partial( __assignNumericBookmark, node, 0 ), "shortCut" : "Ctrl+0", "active" : Gaffer.MetadataAlgo.numericBookmark( node ) } ) def appendPlugContextMenuDefinitions( graphEditor, plug, menuDefinition ) : parent = graphEditor.graphGadget().getRoot() dividerAdded = False for bookmark in Gaffer.MetadataAlgo.bookmarks( parent ) : nodeGadget = graphEditor.graphGadget().nodeGadget( bookmark ) if nodeGadget is None : continue compatibleConnections = [] for nodule in __nodules( nodeGadget ) : inPlug, outPlug = __connection( plug, nodule.plug() ) if inPlug is not None : compatibleConnections.append( ( inPlug, outPlug ) ) if not compatibleConnections : continue if not dividerAdded : if len( menuDefinition.items() ) : menuDefinition.append( "/BookmarksDivider", { "divider" : True } ) dividerAdded = True for inPlug, outPlug in compatibleConnections : label = bookmark.getName() if len( compatibleConnections ) > 1 : bookmarkPlug = outPlug if inPlug.isSame( plug ) else inPlug label += "/" + bookmarkPlug.relativeName( bookmark ) menuDefinition.append( "/Connect Bookmark/" + label, { "command" : functools.partial( __connect, inPlug, outPlug ), "active" : not outPlug.isSame( inPlug.getInput() ) and not Gaffer.MetadataAlgo.readOnly( inPlug ) } ) def appendNodeSetMenuDefinitions( editor, menuDefinition ) : weakEditor = weakref.ref( editor ) # Follow bookmarks def followBookmark( number, weakEditor, _ ) : editor = weakEditor() if editor is not None : b = Gaffer.NumericBookmarkSet( editor.scriptNode(), number ) editor.setNodeSet( b ) n = editor.getNodeSet() for i in range( 1, 10 ) : isCurrent = isinstance( n, Gaffer.NumericBookmarkSet ) and n.getBookmark() == i menuDefinition.insertBefore( "/Numeric Bookmark/%d" % i, { "command" : functools.partial( followBookmark, i, weakEditor ), "checkBox" : isCurrent }, "/Pin Divider" ) # Pin bookmarks for i in range( 1, 10 ) : menuDefinition.append( "/Bookmark/%s" % i, { "command" : functools.partial( __findNumericBookmark, editor, i ), "active" : Gaffer.MetadataAlgo.getNumericBookmark( editor.scriptNode(), i ) is not None, } ) menuDefinition.append( "/Bookmark/Divider", { "divider" : True } ) bookmarks = __findableBookmarks( editor ) menuDefinition.append( "/Bookmark/Other...", { "command" : functools.partial( __findBookmark, editor, bookmarks ), "active" : len( bookmarks ), "shortCut" : "B", } ) def connectToEditor( editor ) : editor.keyPressSignal().connect( __editorKeyPress, scoped = False ) ########################################################################## # Internal implementation ########################################################################## def __setBookmarked( node, bookmarked ) : with Gaffer.UndoScope( node.scriptNode() ) : Gaffer.MetadataAlgo.setBookmarked( node, bookmarked ) ## \todo Perhaps this functionality should be provided by the # GraphGadget or NodeGadget class? def __nodules( nodeGadget ) : result = [] def walk( graphComponent ) : if isinstance( graphComponent, Gaffer.Plug ) : nodule = nodeGadget.nodule( graphComponent ) if nodule is not None : result.append( nodule ) for c in graphComponent.children( Gaffer.Plug ) : walk( c ) walk( nodeGadget.node() ) return result ## \todo This is similar to the private # StandardNodule::connection() method. Perhaps we # should find a single sensible place to put it? # Maybe on the GraphGadget class? Or in a new # PlugAlgo.h file? def __connection( plug1, plug2 ) : if plug1.node().isSame( plug2.node() ) : return None, None if plug1.direction() == plug2.direction() : return None, None if plug1.direction() == plug1.Direction.In : inPlug, outPlug = plug1, plug2 else : inPlug, outPlug = plug2, plug1 if inPlug.acceptsInput( outPlug ) : return inPlug, outPlug return None, None def __connect( inPlug, outPlug ) : with Gaffer.UndoScope( inPlug.ancestor( Gaffer.ScriptNode ) ) : inPlug.setInput( outPlug ) def __editBookmark( editorWeakRef, bookmark ) : editor = editorWeakRef() if isinstance( editor, GafferUI.GraphEditor ) : editor.graphGadget().setRoot( bookmark.parent() ) editor.frame( [ bookmark ] ) else : editor.setNodeSet( Gaffer.StandardSet( [ bookmark ] ) ) def __findableBookmarks( editor ) : # Prefer this over manual recursion through the graph because it is _much_ # faster. bookmarks = Gaffer.Metadata.nodesWithMetadata( editor.scriptNode(), "bookmarked", instanceOnly = True ) return [ b for b in bookmarks if b.ancestor( Gaffer.Reference ) is None ] def __findBookmark( editor, bookmarks = None ) : if not isinstance( editor, ( GafferUI.NodeSetEditor, GafferUI.GraphEditor ) ) : return # Don't modify the contents of floating windows, because these are # expected to be locked to one node. if editor.ancestor( GafferUI.CompoundEditor ) is None : return if bookmarks is None : bookmarks = __findableBookmarks( editor ) scriptNode = editor.scriptNode() pathsAndNodes = [ ( "/" + b.relativeName( scriptNode ).replace( ".", "/" ), b ) for b in bookmarks ] pathsAndNodes.sort( key = lambda x : x[0] ) menuDefinition = IECore.MenuDefinition() for i, ( path, node ) in enumerate( pathsAndNodes ) : haveDescendantBookmarks = False if i < len( pathsAndNodes ) - 1 : nextPath = pathsAndNodes[i+1][0] if nextPath[len(path):len(path)+1] == "/" : haveDescendantBookmarks = True command = functools.partial( __editBookmark, weakref.ref( editor ), node ) if haveDescendantBookmarks : menuDefinition.append( path + "/This Node", { "command" : command, "searchText" : node.getName() } ) menuDefinition.append( path + "/__BookmarksParentDivider__", { "divider" : True } ) else : menuDefinition.append( path, { "command" : command } ) if not len( bookmarks ) : menuDefinition.append( "/No bookmarks available", { "active" : False, "searchText" : "" } ) editor.__findBookmarksMenu = GafferUI.Menu( menuDefinition, title = "Find Bookmark", searchable = True ) editor.__findBookmarksMenu.popup() def __assignNumericBookmark( node, numericBookmark ) : with Gaffer.UndoScope( node.scriptNode() ) : if numericBookmark == 0 : # Remove the current numeric bookmark from selection current = Gaffer.MetadataAlgo.numericBookmark( node ) if current : Gaffer.MetadataAlgo.setNumericBookmark( node.scriptNode(), current, None ) else : Gaffer.MetadataAlgo.setNumericBookmark( node.scriptNode(), numericBookmark, node ) def __findNumericBookmark( editor, numericBookmark ) : if not isinstance( editor, ( GafferUI.NodeSetEditor, GafferUI.GraphEditor ) ) : return False # Don't modify the contents of floating windows, because these are # expected to be locked to one node. if editor.ancestor( GafferUI.CompoundEditor ) is None : return False node = Gaffer.MetadataAlgo.getNumericBookmark( editor.scriptNode(), numericBookmark ) if not node : return False if isinstance( editor, GafferUI.GraphEditor ) : editor.graphGadget().setRoot( node.parent() ) editor.frame( [ node ] ) else : s = Gaffer.StandardSet( [ node ] ) editor.setNodeSet( s ) return True def __editorKeyPress( editor, event ) : if event.key == "B" : __findBookmark( editor ) return True if event.key in [ str( x ) for x in range( 0, 10 ) ] : numericBookmark = int( event.key ) if event.modifiers == event.modifiers.Control : # Assign node = None if isinstance( editor, GafferUI.GraphEditor ) : selection = editor.scriptNode().selection() if len( selection ) == 1 : node = selection[0] else : backdrops = [ n for n in selection if isinstance( n, Gaffer.Backdrop ) ] if len( backdrops ) == 1 : node = backdrops[0] elif isinstance( editor, GafferUI.NodeSetEditor ) : nodeSet = editor.getNodeSet() node = nodeSet[-1] if len( nodeSet ) else None if node is not None : __assignNumericBookmark( node, numericBookmark ) elif not event.modifiers : # Find # For linked editors, its more intuitive for the user if we update # the driving editor, rather than breaking the link. if numericBookmark != 0 : __findNumericBookmark( editor, numericBookmark ) elif isinstance( editor, GafferUI.NodeSetEditor ) : editor.setNodeSet( editor.scriptNode().selection() ) return True
bsd-3-clause
[ 26863, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6900, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 420, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 14, 199, 3, 199, 3, 420, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 199, 3, 263, 314, 4084, 14, 199, 3, 199, 3, 420, 627, 11443, 314, 536, 402, 17815, 869, 9291, 6590, 314, 1561, 402, 199, 3, 263, 1263, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 263, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 263, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 9143, 199, 646, 13852, 199, 199, 646, 14707, 199, 199, 646, 16600, 199, 646, 16600, 6379, 199, 199, 26863, 199, 3, 1684, 3102, 199, 26863, 199, 199, 318, 5666, 1716, 2998, 5977, 16738, 8, 3343, 10423, 12, 1031, 12, 6269, 10701, 776, 520, 421, 198, 692, 822, 8, 6269, 10701, 14, 1744, 342, 776, 520, 507, 198, 4470, 10701, 14, 740, 8, 3286, 4578, 8696, 10375, 1341, 2922, 401, 469, 298, 328, 2922, 2, 520, 715, 789, 776, 421, 198, 4470, 10701, 14, 740, 8, 507, 198, 15313, 8696, 17938, 401, 507, 198, 91, 686, 198, 2, 1074, 3532, 2, 520, 16600, 14, 5142, 2439, 1939, 14, 362, 8696, 17938, 8, 1031, 2318, 686, 198, 2, 1531, 2, 520, 9143, 14, 6672, 8, 636, 409, 8696, 17938, 12, 1031, 2318, 686, 198, 2, 2682, 2, 520, 440, 16600, 14, 5142, 2439, 1939, 14, 739, 5903, 8, 1031, 2318, 507, 198, 93, 199, 198, 9, 421, 198, 509, 284, 315, 1425, 8, 413, 12, 1616, 776, 520, 17957, 6269, 10701, 14, 740, 8, 29294, 3286, 14687, 8944, 1657, 3149, 83, 2, 450, 284, 12, 29294, 469, 1585, 221, 298, 1531, 2, 520, 9143, 14, 6672, 8, 636, 5038, 14687, 8696, 1657, 12, 1031, 12, 284, 2318, 1585, 221, 298, 3612, 23498, 2, 520, 298, 9778, 25389, 73, 2, 450, 284, 12, 1585, 221, 298, 2682, 2, 520, 440, 16600, 14, 5142, 2439, 1939, 14, 739, 5903, 8, 1031, 2318, 29294, 789, 17957, 776, 421, 198, 4470, 10701, 14, 740, 8, 507, 198, 15313, 14687, 8944, 1657, 15, 5587, 401, 507, 198, 91, 686, 198, 2, 1531, 2, 520, 9143, 14, 6672, 8, 636, 5038, 14687, 8696, 1657, 12, 1031, 12, 378, 2318, 686, 198, 2, 3612, 23498, 2, 520, 298, 9778, 11, 16, 401, 686, 198, 2, 2682, 2, 520, 16600, 14, 5142, 2439, 1939, 14, 6677, 8696, 1657, 8, 1031, 776, 507, 198, 93, 199, 198, 9, 199, 199, 318, 5666, 19173, 2998, 5977, 16738, 8, 3343, 10423, 12, 14202, 12, 6269, 10701, 776, 520, 421, 198, 1708, 275, 3343, 10423, 14, 2180, 39, 31287, 1252, 362, 6405, 342, 199, 198, 328, 2922, 20201, 275, 756, 199, 198, 509, 23799, 315, 16600, 14, 5142, 2439, 1939, 14, 25799, 8, 1676, 776, 520, 2742, 198, 932, 39, 31287, 275, 3343, 10423, 14, 2180, 39, 31287, 1252, 932, 39, 31287, 8, 23799, 776, 507, 198, 692, 1031, 39, 31287, 365, 488, 520, 686, 198, 6958, 2742, 198, 6490, 22122, 275, 942, 507, 198, 509, 302, 483, 315, 636, 78, 483, 83, 8, 1031, 39, 31287, 776, 520, 686, 198, 262, 19173, 12, 734, 19173, 275, 636, 2105, 8, 14202, 12, 302, 483, 14, 13963, 342, 776, 686, 198, 692, 315, 19173, 365, 440, 488, 520, 1585, 198, 6490, 22122, 14, 740, 8, 334, 315, 19173, 12, 734, 19173, 776, 776, 2742, 198, 692, 440, 9025, 22122, 520, 686, 198, 6958, 2742, 198, 692, 440, 487, 2922, 20201, 520, 686, 198, 692, 822, 8, 6269, 10701, 14, 1744, 342, 776, 520, 1585, 198, 4470, 10701, 14, 740, 8, 3286, 8696, 10375, 1341, 2922, 401, 469, 298, 328, 2922, 2, 520, 715, 789, 776, 686, 198, 328, 2922, 20201, 275, 715, 2742, 198, 509, 315, 19173, 12, 734, 19173, 315, 9025, 22122, 520, 686, 198, 1302, 275, 23799, 14, 16405, 342, 686, 198, 692, 822, 8, 9025, 22122, 776, 690, 413, 520, 1585, 198, 17341, 19173, 275, 734, 19173, 340, 315, 19173, 14, 374, 8479, 8, 14202, 776, 587, 315, 19173, 1585, 198, 1302, 847, 10609, 221, 435, 23799, 19173, 14, 6188, 985, 8, 23799, 776, 686, 198, 4470, 10701, 14, 740, 8, 1585, 198, 15313, 8631, 8944, 1657, 6687, 435, 1768, 12, 1585, 198, 91, 1871, 198, 2, 1531, 2, 520, 9143, 14, 6672, 8, 636, 2242, 12, 315, 19173, 12, 734, 19173, 2318, 1871, 198, 2, 2682, 2, 520, 440, 734, 19173, 14, 374, 8479, 8, 315, 19173, 14, 362, 3205, 342, 776, 436, 440, 16600, 14 ]
[ 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6900, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 420, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 14, 199, 3, 199, 3, 420, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 199, 3, 263, 314, 4084, 14, 199, 3, 199, 3, 420, 627, 11443, 314, 536, 402, 17815, 869, 9291, 6590, 314, 1561, 402, 199, 3, 263, 1263, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 263, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 263, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 9143, 199, 646, 13852, 199, 199, 646, 14707, 199, 199, 646, 16600, 199, 646, 16600, 6379, 199, 199, 26863, 199, 3, 1684, 3102, 199, 26863, 199, 199, 318, 5666, 1716, 2998, 5977, 16738, 8, 3343, 10423, 12, 1031, 12, 6269, 10701, 776, 520, 421, 198, 692, 822, 8, 6269, 10701, 14, 1744, 342, 776, 520, 507, 198, 4470, 10701, 14, 740, 8, 3286, 4578, 8696, 10375, 1341, 2922, 401, 469, 298, 328, 2922, 2, 520, 715, 789, 776, 421, 198, 4470, 10701, 14, 740, 8, 507, 198, 15313, 8696, 17938, 401, 507, 198, 91, 686, 198, 2, 1074, 3532, 2, 520, 16600, 14, 5142, 2439, 1939, 14, 362, 8696, 17938, 8, 1031, 2318, 686, 198, 2, 1531, 2, 520, 9143, 14, 6672, 8, 636, 409, 8696, 17938, 12, 1031, 2318, 686, 198, 2, 2682, 2, 520, 440, 16600, 14, 5142, 2439, 1939, 14, 739, 5903, 8, 1031, 2318, 507, 198, 93, 199, 198, 9, 421, 198, 509, 284, 315, 1425, 8, 413, 12, 1616, 776, 520, 17957, 6269, 10701, 14, 740, 8, 29294, 3286, 14687, 8944, 1657, 3149, 83, 2, 450, 284, 12, 29294, 469, 1585, 221, 298, 1531, 2, 520, 9143, 14, 6672, 8, 636, 5038, 14687, 8696, 1657, 12, 1031, 12, 284, 2318, 1585, 221, 298, 3612, 23498, 2, 520, 298, 9778, 25389, 73, 2, 450, 284, 12, 1585, 221, 298, 2682, 2, 520, 440, 16600, 14, 5142, 2439, 1939, 14, 739, 5903, 8, 1031, 2318, 29294, 789, 17957, 776, 421, 198, 4470, 10701, 14, 740, 8, 507, 198, 15313, 14687, 8944, 1657, 15, 5587, 401, 507, 198, 91, 686, 198, 2, 1531, 2, 520, 9143, 14, 6672, 8, 636, 5038, 14687, 8696, 1657, 12, 1031, 12, 378, 2318, 686, 198, 2, 3612, 23498, 2, 520, 298, 9778, 11, 16, 401, 686, 198, 2, 2682, 2, 520, 16600, 14, 5142, 2439, 1939, 14, 6677, 8696, 1657, 8, 1031, 776, 507, 198, 93, 199, 198, 9, 199, 199, 318, 5666, 19173, 2998, 5977, 16738, 8, 3343, 10423, 12, 14202, 12, 6269, 10701, 776, 520, 421, 198, 1708, 275, 3343, 10423, 14, 2180, 39, 31287, 1252, 362, 6405, 342, 199, 198, 328, 2922, 20201, 275, 756, 199, 198, 509, 23799, 315, 16600, 14, 5142, 2439, 1939, 14, 25799, 8, 1676, 776, 520, 2742, 198, 932, 39, 31287, 275, 3343, 10423, 14, 2180, 39, 31287, 1252, 932, 39, 31287, 8, 23799, 776, 507, 198, 692, 1031, 39, 31287, 365, 488, 520, 686, 198, 6958, 2742, 198, 6490, 22122, 275, 942, 507, 198, 509, 302, 483, 315, 636, 78, 483, 83, 8, 1031, 39, 31287, 776, 520, 686, 198, 262, 19173, 12, 734, 19173, 275, 636, 2105, 8, 14202, 12, 302, 483, 14, 13963, 342, 776, 686, 198, 692, 315, 19173, 365, 440, 488, 520, 1585, 198, 6490, 22122, 14, 740, 8, 334, 315, 19173, 12, 734, 19173, 776, 776, 2742, 198, 692, 440, 9025, 22122, 520, 686, 198, 6958, 2742, 198, 692, 440, 487, 2922, 20201, 520, 686, 198, 692, 822, 8, 6269, 10701, 14, 1744, 342, 776, 520, 1585, 198, 4470, 10701, 14, 740, 8, 3286, 8696, 10375, 1341, 2922, 401, 469, 298, 328, 2922, 2, 520, 715, 789, 776, 686, 198, 328, 2922, 20201, 275, 715, 2742, 198, 509, 315, 19173, 12, 734, 19173, 315, 9025, 22122, 520, 686, 198, 1302, 275, 23799, 14, 16405, 342, 686, 198, 692, 822, 8, 9025, 22122, 776, 690, 413, 520, 1585, 198, 17341, 19173, 275, 734, 19173, 340, 315, 19173, 14, 374, 8479, 8, 14202, 776, 587, 315, 19173, 1585, 198, 1302, 847, 10609, 221, 435, 23799, 19173, 14, 6188, 985, 8, 23799, 776, 686, 198, 4470, 10701, 14, 740, 8, 1585, 198, 15313, 8631, 8944, 1657, 6687, 435, 1768, 12, 1585, 198, 91, 1871, 198, 2, 1531, 2, 520, 9143, 14, 6672, 8, 636, 2242, 12, 315, 19173, 12, 734, 19173, 2318, 1871, 198, 2, 2682, 2, 520, 440, 734, 19173, 14, 374, 8479, 8, 315, 19173, 14, 362, 3205, 342, 776, 436, 440, 16600, 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, 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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 ]
joyent/sdc-headnode
tools/node_modules/cmdln/node_modules/dashdash/tools/cutarelease.py
171
22043
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2009-2012 Trent Mick """cutarelease -- Cut a release of your project. A script that will help cut a release for a git-based project that follows a few conventions. It'll update your changelog (CHANGES.md), add a git tag, push those changes, update your version to the next patch level release and create a new changelog section for that new version. Conventions: - XXX """ __version_info__ = (1, 0, 7) __version__ = '.'.join(map(str, __version_info__)) import sys import os from os.path import join, dirname, normpath, abspath, exists, basename, splitext from glob import glob from pprint import pprint import re import codecs import logging import optparse import json #---- globals and config log = logging.getLogger("cutarelease") class Error(Exception): pass #---- main functionality def cutarelease(project_name, version_files, dry_run=False): """Cut a release. @param project_name {str} @param version_files {list} List of paths to files holding the version info for this project. If none are given it attempts to guess the version file: package.json or VERSION.txt or VERSION or $project_name.py or lib/$project_name.py or $project_name.js or lib/$project_name.js. The version file can be in one of the following forms: - A .py file, in which case the file is expect to have a top-level global called "__version_info__" as follows. [1] __version_info__ = (0, 7, 6) Note that I typically follow that with the following to get a string version attribute on my modules: __version__ = '.'.join(map(str, __version_info__)) - A .js file, in which case the file is expected to have a top-level global called "VERSION" as follows: ver VERSION = "1.2.3"; - A "package.json" file, typical of a node.js npm-using project. The package.json file must have a "version" field. - TODO: A simple version file whose only content is a "1.2.3"-style version string. [1]: This is a convention I tend to follow in my projects. Granted it might not be your cup of tea. I should add support for just `__version__ = "1.2.3"`. I'm open to other suggestions too. """ dry_run_str = dry_run and " (dry-run)" or "" if not version_files: log.info("guessing version file") candidates = [ "package.json", "VERSION.txt", "VERSION", "%s.py" % project_name, "lib/%s.py" % project_name, "%s.js" % project_name, "lib/%s.js" % project_name, ] for candidate in candidates: if exists(candidate): version_files = [candidate] break else: raise Error("could not find a version file: specify its path or " "add one of the following to your project: '%s'" % "', '".join(candidates)) log.info("using '%s' as version file", version_files[0]) parsed_version_files = [_parse_version_file(f) for f in version_files] version_file_type, version_info = parsed_version_files[0] version = _version_from_version_info(version_info) # Confirm if not dry_run: answer = query_yes_no("* * *\n" "Are you sure you want cut a %s release?\n" "This will involved commits and a push." % version, default="no") print "* * *" if answer != "yes": log.info("user abort") return log.info("cutting a %s release%s", version, dry_run_str) # Checks: Ensure there is a section in changes for this version. changes_path = "CHANGES.md" changes_txt, changes, nyr = parse_changelog(changes_path) #pprint(changes) top_ver = changes[0]["version"] if top_ver != version: raise Error("changelog '%s' top section says " "version %r, expected version %r: aborting" % (changes_path, top_ver, version)) top_verline = changes[0]["verline"] if not top_verline.endswith(nyr): answer = query_yes_no("\n* * *\n" "The changelog '%s' top section doesn't have the expected\n" "'%s' marker. Has this been released already?" % (changes_path, nyr), default="yes") print "* * *" if answer != "no": log.info("abort") return top_body = changes[0]["body"] if top_body.strip() == "(nothing yet)": raise Error("top section body is `(nothing yet)': it looks like " "nothing has been added to this release") # Commits to prepare release. changes_txt_before = changes_txt changes_txt = changes_txt.replace(" (not yet released)", "", 1) if not dry_run and changes_txt != changes_txt_before: log.info("prepare `%s' for release", changes_path) f = codecs.open(changes_path, 'w', 'utf-8') f.write(changes_txt) f.close() run('git commit %s -m "prepare for %s release"' % (changes_path, version)) # Tag version and push. curr_tags = set(t for t in _capture_stdout(["git", "tag", "-l"]).split('\n') if t) if not dry_run and version not in curr_tags: log.info("tag the release") run('git tag -a "%s" -m "version %s"' % (version, version)) run('git push --tags') # Optionally release. if exists("package.json"): answer = query_yes_no("\n* * *\nPublish to npm?", default="yes") print "* * *" if answer == "yes": if dry_run: log.info("skipping npm publish (dry-run)") else: run('npm publish') elif exists("setup.py"): answer = query_yes_no("\n* * *\nPublish to pypi?", default="yes") print "* * *" if answer == "yes": if dry_run: log.info("skipping pypi publish (dry-run)") else: run("%spython setup.py sdist --formats zip upload" % _setup_command_prefix()) # Commits to prepare for future dev and push. # - update changelog file next_version_info = _get_next_version_info(version_info) next_version = _version_from_version_info(next_version_info) log.info("prepare for future dev (version %s)", next_version) marker = "## " + changes[0]["verline"] if marker.endswith(nyr): marker = marker[0:-len(nyr)] if marker not in changes_txt: raise Error("couldn't find `%s' marker in `%s' " "content: can't prep for subsequent dev" % (marker, changes_path)) next_verline = "%s %s%s" % (marker.rsplit(None, 1)[0], next_version, nyr) changes_txt = changes_txt.replace(marker + '\n', "%s\n\n(nothing yet)\n\n\n%s\n" % (next_verline, marker)) if not dry_run: f = codecs.open(changes_path, 'w', 'utf-8') f.write(changes_txt) f.close() # - update version file next_version_tuple = _tuple_from_version(next_version) for i, ver_file in enumerate(version_files): ver_content = codecs.open(ver_file, 'r', 'utf-8').read() ver_file_type, ver_info = parsed_version_files[i] if ver_file_type == "json": marker = '"version": "%s"' % version if marker not in ver_content: raise Error("couldn't find `%s' version marker in `%s' " "content: can't prep for subsequent dev" % (marker, ver_file)) ver_content = ver_content.replace(marker, '"version": "%s"' % next_version) elif ver_file_type == "javascript": candidates = [ ("single", "var VERSION = '%s';" % version), ("double", 'var VERSION = "%s";' % version), ] for quote_type, marker in candidates: if marker in ver_content: break else: raise Error("couldn't find any candidate version marker in " "`%s' content: can't prep for subsequent dev: %r" % (ver_file, candidates)) if quote_type == "single": ver_content = ver_content.replace(marker, "var VERSION = '%s';" % next_version) else: ver_content = ver_content.replace(marker, 'var VERSION = "%s";' % next_version) elif ver_file_type == "python": marker = "__version_info__ = %r" % (version_info,) if marker not in ver_content: raise Error("couldn't find `%s' version marker in `%s' " "content: can't prep for subsequent dev" % (marker, ver_file)) ver_content = ver_content.replace(marker, "__version_info__ = %r" % (next_version_tuple,)) elif ver_file_type == "version": ver_content = next_version else: raise Error("unknown ver_file_type: %r" % ver_file_type) if not dry_run: log.info("update version to '%s' in '%s'", next_version, ver_file) f = codecs.open(ver_file, 'w', 'utf-8') f.write(ver_content) f.close() if not dry_run: run('git commit %s %s -m "prep for future dev"' % ( changes_path, ' '.join(version_files))) run('git push') #---- internal support routines def _indent(s, indent=' '): return indent + indent.join(s.splitlines(True)) def _tuple_from_version(version): def _intify(s): try: return int(s) except ValueError: return s return tuple(_intify(b) for b in version.split('.')) def _get_next_version_info(version_info): next = list(version_info[:]) next[-1] += 1 return tuple(next) def _version_from_version_info(version_info): v = str(version_info[0]) state_dot_join = True for i in version_info[1:]: if state_dot_join: try: int(i) except ValueError: state_dot_join = False else: pass if state_dot_join: v += "." + str(i) else: v += str(i) return v _version_re = re.compile(r"^(\d+)\.(\d+)(?:\.(\d+)([abc](\d+)?)?)?$") def _version_info_from_version(version): m = _version_re.match(version) if not m: raise Error("could not convert '%s' version to version info" % version) version_info = [] for g in m.groups(): if g is None: break try: version_info.append(int(g)) except ValueError: version_info.append(g) return tuple(version_info) def _parse_version_file(version_file): """Get version info from the given file. It can be any of: Supported version file types (i.e. types of files from which we know how to parse the version string/number -- often by some convention): - json: use the "version" key - javascript: look for a `var VERSION = "1.2.3";` or `var VERSION = '1.2.3';` - python: Python script/module with `__version_info__ = (1, 2, 3)` - version: a VERSION.txt or VERSION file where the whole contents are the version string @param version_file {str} Can be a path or "type:path", where "type" is one of the supported types. """ # Get version file *type*. version_file_type = None match = re.compile("^([a-z]+):(.*)$").search(version_file) if match: version_file = match.group(2) version_file_type = match.group(1) aliases = { "js": "javascript" } if version_file_type in aliases: version_file_type = aliases[version_file_type] f = codecs.open(version_file, 'r', 'utf-8') content = f.read() f.close() if not version_file_type: # Guess the type. base = basename(version_file) ext = splitext(base)[1] if ext == ".json": version_file_type = "json" elif ext == ".py": version_file_type = "python" elif ext == ".js": version_file_type = "javascript" elif content.startswith("#!"): shebang = content.splitlines(False)[0] shebang_bits = re.split(r'[/ \t]', shebang) for name, typ in {"python": "python", "node": "javascript"}.items(): if name in shebang_bits: version_file_type = typ break elif base in ("VERSION", "VERSION.txt"): version_file_type = "version" if not version_file_type: raise RuntimeError("can't extract version from '%s': no idea " "what type of file it it" % version_file) if version_file_type == "json": obj = json.loads(content) version_info = _version_info_from_version(obj["version"]) elif version_file_type == "python": m = re.search(r'^__version_info__ = (.*?)$', content, re.M) version_info = eval(m.group(1)) elif version_file_type == "javascript": m = re.search(r'^var VERSION = (\'|")(.*?)\1;$', content, re.M) version_info = _version_info_from_version(m.group(2)) elif version_file_type == "version": version_info = _version_info_from_version(content.strip()) else: raise RuntimeError("unexpected version_file_type: %r" % version_file_type) return version_file_type, version_info def parse_changelog(changes_path): """Parse the given changelog path and return `(content, parsed, nyr)` where `nyr` is the ' (not yet released)' marker and `parsed` looks like: [{'body': u'\n(nothing yet)\n\n', 'verline': u'restify 1.0.1 (not yet released)', 'version': u'1.0.1'}, # version is parsed out for top section only {'body': u'...', 'verline': u'1.0.0'}, {'body': u'...', 'verline': u'1.0.0-rc2'}, {'body': u'...', 'verline': u'1.0.0-rc1'}] A changelog (CHANGES.md) is expected to look like this: # $project Changelog ## $next_version (not yet released) ... ## $version1 ... ## $version2 ... and so on The version lines are enforced as follows: - The top entry should have a " (not yet released)" suffix. "Should" because recovery from half-cutarelease failures is supported. - A version string must be extractable from there, but it tries to be loose (though strict "X.Y.Z" versioning is preferred). Allowed ## 1.0.0 ## my project 1.0.1 ## foo 1.2.3-rc2 Basically, (a) the " (not yet released)" is stripped, (b) the last token is the version, and (c) that version must start with a digit (sanity check). """ if not exists(changes_path): raise Error("changelog file '%s' not found" % changes_path) content = codecs.open(changes_path, 'r', 'utf-8').read() parser = re.compile( r'^##\s*(?P<verline>[^\n]*?)\s*$(?P<body>.*?)(?=^##|\Z)', re.M | re.S) sections = parser.findall(content) # Sanity checks on changelog format. if not sections: template = "## 1.0.0 (not yet released)\n\n(nothing yet)\n" raise Error("changelog '%s' must have at least one section, " "suggestion:\n\n%s" % (changes_path, _indent(template))) first_section_verline = sections[0][0] nyr = ' (not yet released)' #if not first_section_verline.endswith(nyr): # eg = "## %s%s" % (first_section_verline, nyr) # raise Error("changelog '%s' top section must end with %r, " # "naive e.g.: '%s'" % (changes_path, nyr, eg)) items = [] for i, section in enumerate(sections): item = { "verline": section[0], "body": section[1] } if i == 0: # We only bother to pull out 'version' for the top section. verline = section[0] if verline.endswith(nyr): verline = verline[0:-len(nyr)] version = verline.split()[-1] try: int(version[0]) except ValueError: msg = '' if version.endswith(')'): msg = " (cutarelease is picky about the trailing %r " \ "on the top version line. Perhaps you misspelled " \ "that?)" % nyr raise Error("changelog '%s' top section version '%s' is " "invalid: first char isn't a number%s" % (changes_path, version, msg)) item["version"] = version items.append(item) return content, items, nyr ## {{{ http://code.activestate.com/recipes/577058/ (r2) def query_yes_no(question, default="yes"): """Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits <Enter>. It must be "yes" (the default), "no" or None (meaning an answer is required of the user). The "answer" return value is one of "yes" or "no". """ valid = {"yes":"yes", "y":"yes", "ye":"yes", "no":"no", "n":"no"} if default == None: prompt = " [y/n] " elif default == "yes": prompt = " [Y/n] " elif default == "no": prompt = " [y/N] " else: raise ValueError("invalid default answer: '%s'" % default) while 1: sys.stdout.write(question + prompt) choice = raw_input().lower() if default is not None and choice == '': return default elif choice in valid.keys(): return valid[choice] else: sys.stdout.write("Please respond with 'yes' or 'no' "\ "(or 'y' or 'n').\n") ## end of http://code.activestate.com/recipes/577058/ }}} def _capture_stdout(argv): import subprocess p = subprocess.Popen(argv, stdout=subprocess.PIPE) return p.communicate()[0] class _NoReflowFormatter(optparse.IndentedHelpFormatter): """An optparse formatter that does NOT reflow the description.""" def format_description(self, description): return description or "" def run(cmd): """Run the given command. Raises OSError is the command returns a non-zero exit status. """ log.debug("running '%s'", cmd) fixed_cmd = cmd if sys.platform == "win32" and cmd.count('"') > 2: fixed_cmd = '"' + cmd + '"' retval = os.system(fixed_cmd) if hasattr(os, "WEXITSTATUS"): status = os.WEXITSTATUS(retval) else: status = retval if status: raise OSError(status, "error running '%s'" % cmd) def _setup_command_prefix(): prefix = "" if sys.platform == "darwin": # http://forums.macosxhints.com/archive/index.php/t-43243.html # This is an Apple customization to `tar` to avoid creating # '._foo' files for extended-attributes for archived files. prefix = "COPY_EXTENDED_ATTRIBUTES_DISABLE=1 " return prefix #---- mainline def main(argv): logging.basicConfig(format="%(name)s: %(levelname)s: %(message)s") log.setLevel(logging.INFO) # Parse options. parser = optparse.OptionParser(prog="cutarelease", usage='', version="%prog " + __version__, description=__doc__, formatter=_NoReflowFormatter()) parser.add_option("-v", "--verbose", dest="log_level", action="store_const", const=logging.DEBUG, help="more verbose output") parser.add_option("-q", "--quiet", dest="log_level", action="store_const", const=logging.WARNING, help="quieter output (just warnings and errors)") parser.set_default("log_level", logging.INFO) parser.add_option("--test", action="store_true", help="run self-test and exit (use 'eol.py -v --test' for verbose test output)") parser.add_option("-p", "--project-name", metavar="NAME", help='the name of this project (default is the base dir name)', default=basename(os.getcwd())) parser.add_option("-f", "--version-file", metavar="[TYPE:]PATH", action='append', dest="version_files", help='The path to the project file holding the version info. Can be ' 'specified multiple times if more than one file should be updated ' 'with new version info. If excluded, it will be guessed.') parser.add_option("-n", "--dry-run", action="store_true", help='Do a dry-run', default=False) opts, args = parser.parse_args() log.setLevel(opts.log_level) cutarelease(opts.project_name, opts.version_files, dry_run=opts.dry_run) ## {{{ http://code.activestate.com/recipes/577258/ (r5+) if __name__ == "__main__": try: retval = main(sys.argv) except KeyboardInterrupt: sys.exit(1) except SystemExit: raise except: import traceback, logging if not log.handlers and not logging.root.handlers: logging.basicConfig() skip_it = False exc_info = sys.exc_info() if hasattr(exc_info[0], "__name__"): exc_class, exc, tb = exc_info if isinstance(exc, IOError) and exc.args[0] == 32: # Skip 'IOError: [Errno 32] Broken pipe': often a cancelling of `less`. skip_it = True if not skip_it: tb_path, tb_lineno, tb_func = traceback.extract_tb(tb)[-1][:3] log.error("%s (%s:%s in %s)", exc_info[1], tb_path, tb_lineno, tb_func) else: # string exception log.error(exc_info[0]) if not skip_it: if log.isEnabledFor(logging.DEBUG): traceback.print_exception(*exc_info) sys.exit(1) else: sys.exit(retval) ## end of http://code.activestate.com/recipes/577258/ }}}
mpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 8937, 13, 7409, 377, 640, 603, 2000, 199, 199, 624, 5919, 1530, 1756, 1553, 445, 337, 282, 4683, 402, 2195, 2199, 14, 199, 199, 33, 2884, 626, 911, 1720, 10415, 282, 4683, 367, 282, 6135, 13, 6788, 2199, 626, 11924, 199, 65, 9284, 8758, 852, 14, 2779, 7171, 1678, 2195, 1570, 793, 334, 17858, 654, 14, 1064, 395, 1050, 282, 6135, 199, 1450, 12, 6675, 5204, 4493, 12, 1678, 2195, 1015, 370, 314, 2163, 3371, 2166, 4683, 199, 460, 1218, 282, 892, 1570, 793, 3420, 367, 626, 892, 1015, 14, 199, 199, 714, 1856, 852, 26, 199, 13, 5787, 199, 624, 199, 199, 363, 1023, 63, 815, 363, 275, 334, 17, 12, 378, 12, 1520, 9, 199, 363, 1023, 363, 275, 15671, 904, 8, 1130, 8, 495, 12, 636, 1023, 63, 815, 8964, 199, 199, 646, 984, 199, 646, 747, 199, 504, 747, 14, 515, 492, 4263, 12, 9017, 12, 25962, 12, 19529, 12, 3495, 12, 9593, 12, 2249, 7699, 199, 504, 5739, 492, 5739, 199, 504, 10933, 492, 10933, 199, 646, 295, 199, 646, 6010, 199, 646, 2050, 199, 646, 8691, 199, 646, 2022, 4388, 199, 3, 375, 7992, 436, 1101, 199, 199, 793, 275, 2050, 14, 5572, 480, 5919, 1530, 1756, 531, 199, 199, 533, 4520, 8, 1726, 304, 272, 986, 4388, 199, 3, 375, 2446, 9330, 199, 199, 318, 10415, 1530, 1756, 8, 1715, 63, 354, 12, 1015, 63, 1725, 12, 9951, 63, 1065, 29, 797, 304, 272, 408, 23498, 282, 4683, 14, 339, 768, 635, 2199, 63, 354, 469, 495, 93, 272, 768, 635, 1015, 63, 1725, 469, 513, 93, 3820, 402, 3792, 370, 1584, 17573, 314, 1015, 267, 2256, 367, 642, 2199, 14, 398, 982, 7179, 787, 1627, 652, 12454, 370, 9519, 314, 1015, 570, 26, 267, 2559, 14, 1001, 503, 15945, 14, 2424, 503, 15945, 503, 2672, 1715, 63, 354, 14, 647, 267, 503, 1973, 21792, 1715, 63, 354, 14, 647, 503, 2672, 1715, 63, 354, 14, 3596, 503, 1973, 21792, 1715, 63, 354, 14, 3596, 14, 398, 710, 1015, 570, 883, 506, 315, 1373, 402, 314, 2569, 4513, 26, 398, 446, 437, 1275, 647, 570, 12, 315, 1314, 1930, 314, 570, 365, 4282, 370, 1172, 282, 2746, 13, 1896, 881, 2288, 2797, 4396, 1023, 63, 815, 16526, 465, 11924, 14, 359, 17, 61, 953, 636, 1023, 63, 815, 363, 275, 334, 16, 12, 1520, 12, 1227, 9, 8592, 3390, 626, 473, 13609, 2035, 626, 543, 314, 2569, 370, 664, 282, 881, 1059, 1015, 2225, 641, 3002, 4621, 26, 953, 636, 1023, 363, 275, 15671, 904, 8, 1130, 8, 495, 12, 636, 1023, 63, 815, 8964, 398, 446, 437, 1275, 3596, 570, 12, 315, 1314, 1930, 314, 570, 365, 1420, 370, 1172, 282, 2746, 13, 1896, 881, 2288, 2797, 298, 4612, 2, 465, 11924, 26, 953, 809, 15945, 275, 298, 17, 14, 18, 14, 19, 11436, 398, 446, 437, 298, 2491, 14, 1001, 2, 570, 12, 25780, 402, 282, 1031, 14, 3596, 980, 77, 13, 4941, 2199, 14, 881, 710, 2559, 14, 1001, 570, 1471, 1172, 282, 298, 1023, 2, 901, 14, 398, 446, 3254, 26, 437, 3486, 1015, 570, 7447, 1454, 1564, 365, 282, 298, 17, 14, 18, 14, 19, 32095, 2487, 1015, 881, 1059, 14, 339, 359, 17, 2189, 961, 365, 282, 16129, 473, 221, 7169, 370, 2035, 315, 3002, 11336, 14, 267, 598, 1312, 471, 652, 5594, 440, 506, 2195, 286, 384, 402, 1565, 65, 14, 473, 1077, 1050, 2291, 367, 267, 2951, 26856, 1023, 363, 275, 298, 17, 14, 18, 14, 19, 2, 2313, 473, 6704, 1551, 370, 1163, 18453, 15293, 4634, 14, 272, 408, 272, 9951, 63, 1065, 63, 495, 275, 9951, 63, 1065, 436, 298, 334, 10481, 13, 1065, 2924, 503, 3087, 339, 340, 440, 1015, 63, 1725, 26, 267, 943, 14, 815, 480, 11636, 316, 1015, 570, 531, 267, 15101, 275, 359, 288, 298, 2491, 14, 1001, 401, 288, 298, 4612, 14, 2424, 401, 288, 298, 4612, 401, 288, 2071, 83, 14, 647, 2, 450, 2199, 63, 354, 12, 288, 298, 773, 3149, 83, 14, 647, 2, 450, 2199, 63, 354, 12, 288, 2071, 83, 14, 3596, 2, 450, 2199, 63, 354, 12, 288, 298, 773, 3149, 83, 14, 3596, 2, 450, 2199, 63, 354, 12, 267, 1622, 267, 367, 7627, 315, 15101, 26, 288, 340, 3495, 8, 9007, 304, 355, 1015, 63, 1725, 275, 359, 9007, 61, 355, 2059, 267, 587, 26, 288, 746, 4520, 480, 15153, 440, 2342, 282, 1015, 570, 26, 4165, 2399, 931, 503, 298, 355, 298, 525, 1373, 402, 314, 2569, 370, 2195, 2199, 26, 1543, 83, 4065, 355, 450, 298, 297, 283, 1674, 904, 8, 16389, 430, 267, 943, 14, 815, 480, 4941, 1543, 83, 7, 465, 1015, 570, 401, 1015, 63, 1725, 59, 16, 566, 339, 4565, 63, 1023, 63, 1725, 275, 15500, 1122, 63, 1023, 63, 493, 8, 70, 9, 367, 289, 315, 1015, 63, 1725, 61, 272, 1015, 63, 493, 63, 466, 12, 1015, 63, 815, 275, 4565, 63, 1023, 63, 1725, 59, 16, 61, 272, 1015, 275, 485, 1023, 63, 504, 63, 1023, 63, 815, 8, 1023, 63, 815, 9, 339, 327, 32112, 272, 340, 440, 9951, 63, 1065, 26, 267, 6385, 275, 1827, 63, 5066, 63, 889, 23124, 627, 30940, 78, 2, 288, 298, 17683, 1265, 3238, 1265, 2934, 10415, 282, 450, 83, 4683, 8995, 78, 2, 288, 298, 2765, 911, 28244, 20835, 436, 282, 6675, 2122, 450, 1015, 12, 288, 849, 628, 889, 531, 267, 870, 8969, 627, 14390, 267, 340, 6385, 1137, 298, 5066, 582, 288, 943, 14, 815, 480, 751, 12004, 531, 288, 372, 272, 943, 14, 815, 480, 5919, 1337, 282, 450, 83, 4683, 5, 83, 401, 1015, 12, 9951, 63, 1065, 63, 495, 9, 339, 327, 13813, 26, 7523, 2337, 365, 282, 3420, 315, 4493, 367, 642, 1015, 14, 16478, 4493, 63, 515, 275, 298, 17858, 654, 14, 1064, 2, 272, 4493, 63, 2424, 12, 4493, 12, 302, 21897, 275, 2198, 63, 23436, 8, 6627, 63, 515, 9, 272, 327, 15380, 8, 6627, 9, 272, 2746, 63, 422, 275, 4493, 59, 16, 7541 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 8937, 13, 7409, 377, 640, 603, 2000, 199, 199, 624, 5919, 1530, 1756, 1553, 445, 337, 282, 4683, 402, 2195, 2199, 14, 199, 199, 33, 2884, 626, 911, 1720, 10415, 282, 4683, 367, 282, 6135, 13, 6788, 2199, 626, 11924, 199, 65, 9284, 8758, 852, 14, 2779, 7171, 1678, 2195, 1570, 793, 334, 17858, 654, 14, 1064, 395, 1050, 282, 6135, 199, 1450, 12, 6675, 5204, 4493, 12, 1678, 2195, 1015, 370, 314, 2163, 3371, 2166, 4683, 199, 460, 1218, 282, 892, 1570, 793, 3420, 367, 626, 892, 1015, 14, 199, 199, 714, 1856, 852, 26, 199, 13, 5787, 199, 624, 199, 199, 363, 1023, 63, 815, 363, 275, 334, 17, 12, 378, 12, 1520, 9, 199, 363, 1023, 363, 275, 15671, 904, 8, 1130, 8, 495, 12, 636, 1023, 63, 815, 8964, 199, 199, 646, 984, 199, 646, 747, 199, 504, 747, 14, 515, 492, 4263, 12, 9017, 12, 25962, 12, 19529, 12, 3495, 12, 9593, 12, 2249, 7699, 199, 504, 5739, 492, 5739, 199, 504, 10933, 492, 10933, 199, 646, 295, 199, 646, 6010, 199, 646, 2050, 199, 646, 8691, 199, 646, 2022, 4388, 199, 3, 375, 7992, 436, 1101, 199, 199, 793, 275, 2050, 14, 5572, 480, 5919, 1530, 1756, 531, 199, 199, 533, 4520, 8, 1726, 304, 272, 986, 4388, 199, 3, 375, 2446, 9330, 199, 199, 318, 10415, 1530, 1756, 8, 1715, 63, 354, 12, 1015, 63, 1725, 12, 9951, 63, 1065, 29, 797, 304, 272, 408, 23498, 282, 4683, 14, 339, 768, 635, 2199, 63, 354, 469, 495, 93, 272, 768, 635, 1015, 63, 1725, 469, 513, 93, 3820, 402, 3792, 370, 1584, 17573, 314, 1015, 267, 2256, 367, 642, 2199, 14, 398, 982, 7179, 787, 1627, 652, 12454, 370, 9519, 314, 1015, 570, 26, 267, 2559, 14, 1001, 503, 15945, 14, 2424, 503, 15945, 503, 2672, 1715, 63, 354, 14, 647, 267, 503, 1973, 21792, 1715, 63, 354, 14, 647, 503, 2672, 1715, 63, 354, 14, 3596, 503, 1973, 21792, 1715, 63, 354, 14, 3596, 14, 398, 710, 1015, 570, 883, 506, 315, 1373, 402, 314, 2569, 4513, 26, 398, 446, 437, 1275, 647, 570, 12, 315, 1314, 1930, 314, 570, 365, 4282, 370, 1172, 282, 2746, 13, 1896, 881, 2288, 2797, 4396, 1023, 63, 815, 16526, 465, 11924, 14, 359, 17, 61, 953, 636, 1023, 63, 815, 363, 275, 334, 16, 12, 1520, 12, 1227, 9, 8592, 3390, 626, 473, 13609, 2035, 626, 543, 314, 2569, 370, 664, 282, 881, 1059, 1015, 2225, 641, 3002, 4621, 26, 953, 636, 1023, 363, 275, 15671, 904, 8, 1130, 8, 495, 12, 636, 1023, 63, 815, 8964, 398, 446, 437, 1275, 3596, 570, 12, 315, 1314, 1930, 314, 570, 365, 1420, 370, 1172, 282, 2746, 13, 1896, 881, 2288, 2797, 298, 4612, 2, 465, 11924, 26, 953, 809, 15945, 275, 298, 17, 14, 18, 14, 19, 11436, 398, 446, 437, 298, 2491, 14, 1001, 2, 570, 12, 25780, 402, 282, 1031, 14, 3596, 980, 77, 13, 4941, 2199, 14, 881, 710, 2559, 14, 1001, 570, 1471, 1172, 282, 298, 1023, 2, 901, 14, 398, 446, 3254, 26, 437, 3486, 1015, 570, 7447, 1454, 1564, 365, 282, 298, 17, 14, 18, 14, 19, 32095, 2487, 1015, 881, 1059, 14, 339, 359, 17, 2189, 961, 365, 282, 16129, 473, 221, 7169, 370, 2035, 315, 3002, 11336, 14, 267, 598, 1312, 471, 652, 5594, 440, 506, 2195, 286, 384, 402, 1565, 65, 14, 473, 1077, 1050, 2291, 367, 267, 2951, 26856, 1023, 363, 275, 298, 17, 14, 18, 14, 19, 2, 2313, 473, 6704, 1551, 370, 1163, 18453, 15293, 4634, 14, 272, 408, 272, 9951, 63, 1065, 63, 495, 275, 9951, 63, 1065, 436, 298, 334, 10481, 13, 1065, 2924, 503, 3087, 339, 340, 440, 1015, 63, 1725, 26, 267, 943, 14, 815, 480, 11636, 316, 1015, 570, 531, 267, 15101, 275, 359, 288, 298, 2491, 14, 1001, 401, 288, 298, 4612, 14, 2424, 401, 288, 298, 4612, 401, 288, 2071, 83, 14, 647, 2, 450, 2199, 63, 354, 12, 288, 298, 773, 3149, 83, 14, 647, 2, 450, 2199, 63, 354, 12, 288, 2071, 83, 14, 3596, 2, 450, 2199, 63, 354, 12, 288, 298, 773, 3149, 83, 14, 3596, 2, 450, 2199, 63, 354, 12, 267, 1622, 267, 367, 7627, 315, 15101, 26, 288, 340, 3495, 8, 9007, 304, 355, 1015, 63, 1725, 275, 359, 9007, 61, 355, 2059, 267, 587, 26, 288, 746, 4520, 480, 15153, 440, 2342, 282, 1015, 570, 26, 4165, 2399, 931, 503, 298, 355, 298, 525, 1373, 402, 314, 2569, 370, 2195, 2199, 26, 1543, 83, 4065, 355, 450, 298, 297, 283, 1674, 904, 8, 16389, 430, 267, 943, 14, 815, 480, 4941, 1543, 83, 7, 465, 1015, 570, 401, 1015, 63, 1725, 59, 16, 566, 339, 4565, 63, 1023, 63, 1725, 275, 15500, 1122, 63, 1023, 63, 493, 8, 70, 9, 367, 289, 315, 1015, 63, 1725, 61, 272, 1015, 63, 493, 63, 466, 12, 1015, 63, 815, 275, 4565, 63, 1023, 63, 1725, 59, 16, 61, 272, 1015, 275, 485, 1023, 63, 504, 63, 1023, 63, 815, 8, 1023, 63, 815, 9, 339, 327, 32112, 272, 340, 440, 9951, 63, 1065, 26, 267, 6385, 275, 1827, 63, 5066, 63, 889, 23124, 627, 30940, 78, 2, 288, 298, 17683, 1265, 3238, 1265, 2934, 10415, 282, 450, 83, 4683, 8995, 78, 2, 288, 298, 2765, 911, 28244, 20835, 436, 282, 6675, 2122, 450, 1015, 12, 288, 849, 628, 889, 531, 267, 870, 8969, 627, 14390, 267, 340, 6385, 1137, 298, 5066, 582, 288, 943, 14, 815, 480, 751, 12004, 531, 288, 372, 272, 943, 14, 815, 480, 5919, 1337, 282, 450, 83, 4683, 5, 83, 401, 1015, 12, 9951, 63, 1065, 63, 495, 9, 339, 327, 13813, 26, 7523, 2337, 365, 282, 3420, 315, 4493, 367, 642, 1015, 14, 16478, 4493, 63, 515, 275, 298, 17858, 654, 14, 1064, 2, 272, 4493, 63, 2424, 12, 4493, 12, 302, 21897, 275, 2198, 63, 23436, 8, 6627, 63, 515, 9, 272, 327, 15380, 8, 6627, 9, 272, 2746, 63, 422, 275, 4493, 59, 16, 7541, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
neoareslinux/neutron
neutron/tests/unit/ipam/test_requests.py
23
15679
# 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 mock import netaddr from oslo_config import cfg from oslo_utils import uuidutils from neutron.common import constants from neutron.common import ipv6_utils from neutron import context from neutron.ipam import driver from neutron.ipam import exceptions as ipam_exc from neutron.ipam import requests as ipam_req from neutron import manager from neutron.tests import base from neutron.tests.unit.ipam import fake_driver FAKE_IPAM_CLASS = 'neutron.tests.unit.ipam.fake_driver.FakeDriver' class IpamSubnetRequestTestCase(base.BaseTestCase): def setUp(self): super(IpamSubnetRequestTestCase, self).setUp() self.tenant_id = uuidutils.generate_uuid() self.subnet_id = uuidutils.generate_uuid() class TestIpamSubnetRequests(IpamSubnetRequestTestCase): def test_subnet_request(self): pool = ipam_req.SubnetRequest(self.tenant_id, self.subnet_id) self.assertEqual(self.tenant_id, pool.tenant_id) self.assertEqual(self.subnet_id, pool.subnet_id) self.assertEqual(None, pool.gateway_ip) self.assertEqual(None, pool.allocation_pools) def test_subnet_request_gateway(self): request = ipam_req.SubnetRequest(self.tenant_id, self.subnet_id, gateway_ip='1.2.3.1') self.assertEqual('1.2.3.1', str(request.gateway_ip)) def test_subnet_request_bad_gateway(self): self.assertRaises(netaddr.core.AddrFormatError, ipam_req.SubnetRequest, self.tenant_id, self.subnet_id, gateway_ip='1.2.3.') def test_subnet_request_with_range(self): allocation_pools = [netaddr.IPRange('1.2.3.4', '1.2.3.5'), netaddr.IPRange('1.2.3.7', '1.2.3.9')] request = ipam_req.SubnetRequest(self.tenant_id, self.subnet_id, allocation_pools=allocation_pools) self.assertEqual(allocation_pools, request.allocation_pools) def test_subnet_request_range_not_list(self): self.assertRaises(TypeError, ipam_req.SubnetRequest, self.tenant_id, self.subnet_id, allocation_pools=1) def test_subnet_request_bad_range(self): self.assertRaises(TypeError, ipam_req.SubnetRequest, self.tenant_id, self.subnet_id, allocation_pools=['1.2.3.4']) def test_subnet_request_different_versions(self): pools = [netaddr.IPRange('0.0.0.1', '0.0.0.2'), netaddr.IPRange('::1', '::2')] self.assertRaises(ValueError, ipam_req.SubnetRequest, self.tenant_id, self.subnet_id, allocation_pools=pools) def test_subnet_request_overlap(self): pools = [netaddr.IPRange('0.0.0.10', '0.0.0.20'), netaddr.IPRange('0.0.0.8', '0.0.0.10')] self.assertRaises(ValueError, ipam_req.SubnetRequest, self.tenant_id, self.subnet_id, allocation_pools=pools) class TestIpamAnySubnetRequest(IpamSubnetRequestTestCase): def test_subnet_request(self): request = ipam_req.AnySubnetRequest(self.tenant_id, self.subnet_id, constants.IPv4, 24, gateway_ip='0.0.0.1') self.assertEqual(24, request.prefixlen) def test_subnet_request_bad_prefix_type(self): self.assertRaises(netaddr.core.AddrFormatError, ipam_req.AnySubnetRequest, self.tenant_id, self.subnet_id, constants.IPv4, 'A') def test_subnet_request_bad_prefix(self): self.assertRaises(netaddr.core.AddrFormatError, ipam_req.AnySubnetRequest, self.tenant_id, self.subnet_id, constants.IPv4, 33) self.assertRaises(netaddr.core.AddrFormatError, ipam_req.AnySubnetRequest, self.tenant_id, self.subnet_id, constants.IPv6, 129) def test_subnet_request_bad_gateway(self): self.assertRaises(ValueError, ipam_req.AnySubnetRequest, self.tenant_id, self.subnet_id, constants.IPv6, 64, gateway_ip='2000::1') def test_subnet_request_allocation_pool_wrong_version(self): pools = [netaddr.IPRange('0.0.0.4', '0.0.0.5')] self.assertRaises(ValueError, ipam_req.AnySubnetRequest, self.tenant_id, self.subnet_id, constants.IPv6, 64, allocation_pools=pools) def test_subnet_request_allocation_pool_not_in_net(self): pools = [netaddr.IPRange('0.0.0.64', '0.0.0.128')] self.assertRaises(ValueError, ipam_req.AnySubnetRequest, self.tenant_id, self.subnet_id, constants.IPv4, 25, allocation_pools=pools) class TestIpamSpecificSubnetRequest(IpamSubnetRequestTestCase): def test_subnet_request(self): request = ipam_req.SpecificSubnetRequest(self.tenant_id, self.subnet_id, '1.2.3.0/24', gateway_ip='1.2.3.1') self.assertEqual(24, request.prefixlen) self.assertEqual(netaddr.IPAddress('1.2.3.1'), request.gateway_ip) self.assertEqual(netaddr.IPNetwork('1.2.3.0/24'), request.subnet_cidr) def test_subnet_request_bad_gateway(self): self.assertRaises(ValueError, ipam_req.SpecificSubnetRequest, self.tenant_id, self.subnet_id, '2001::1', gateway_ip='2000::1') class TestAddressRequest(base.BaseTestCase): # This class doesn't test much. At least running through all of the # constructors may shake out some trivial bugs. EUI64 = ipam_req.AutomaticAddressRequest.EUI64 def setUp(self): super(TestAddressRequest, self).setUp() def test_specific_address_ipv6(self): request = ipam_req.SpecificAddressRequest('2000::45') self.assertEqual(netaddr.IPAddress('2000::45'), request.address) def test_specific_address_ipv4(self): request = ipam_req.SpecificAddressRequest('1.2.3.32') self.assertEqual(netaddr.IPAddress('1.2.3.32'), request.address) def test_any_address(self): ipam_req.AnyAddressRequest() def test_automatic_address_request_eui64(self): subnet_cidr = '2607:f0d0:1002:51::/64' port_mac = 'aa:bb:cc:dd:ee:ff' eui_addr = str(ipv6_utils.get_ipv6_addr_by_EUI64(subnet_cidr, port_mac)) request = ipam_req.AutomaticAddressRequest( address_type=self.EUI64, prefix=subnet_cidr, mac=port_mac) self.assertEqual(request.address, netaddr.IPAddress(eui_addr)) def test_automatic_address_request_invalid_address_type_raises(self): self.assertRaises(ipam_exc.InvalidAddressType, ipam_req.AutomaticAddressRequest, address_type='kaboom') def test_automatic_address_request_eui64_no_mac_raises(self): self.assertRaises(ipam_exc.AddressCalculationFailure, ipam_req.AutomaticAddressRequest, address_type=self.EUI64, prefix='meh') def test_automatic_address_request_eui64_alien_param_raises(self): self.assertRaises(ipam_exc.AddressCalculationFailure, ipam_req.AutomaticAddressRequest, address_type=self.EUI64, mac='meh', alien='et', prefix='meh') class TestIpamDriverLoader(base.BaseTestCase): def setUp(self): super(TestIpamDriverLoader, self).setUp() self.ctx = context.get_admin_context() def _verify_fake_ipam_driver_is_loaded(self, driver_name): mgr = manager.NeutronManager ipam_driver = mgr.load_class_for_provider('neutron.ipam_drivers', driver_name) self.assertEqual( fake_driver.FakeDriver, ipam_driver, "loaded ipam driver should be FakeDriver") def _verify_import_error_is_generated(self, driver_name): mgr = manager.NeutronManager self.assertRaises(ImportError, mgr.load_class_for_provider, 'neutron.ipam_drivers', driver_name) def test_ipam_driver_is_loaded_by_class(self): self._verify_fake_ipam_driver_is_loaded(FAKE_IPAM_CLASS) def test_ipam_driver_is_loaded_by_name(self): self._verify_fake_ipam_driver_is_loaded('fake') def test_ipam_driver_raises_import_error(self): self._verify_import_error_is_generated( 'neutron.tests.unit.ipam_req.SomeNonExistentClass') def test_ipam_driver_raises_import_error_for_none(self): self._verify_import_error_is_generated(None) def _load_ipam_driver(self, driver_name, subnet_pool_id): cfg.CONF.set_override("ipam_driver", driver_name) return driver.Pool.get_instance(subnet_pool_id, self.ctx) def test_ipam_driver_is_loaded_from_ipam_driver_config_value(self): ipam_driver = self._load_ipam_driver('fake', None) self.assertIsInstance( ipam_driver, fake_driver.FakeDriver, "loaded ipam driver should be of type FakeDriver") @mock.patch(FAKE_IPAM_CLASS) def test_ipam_driver_is_loaded_with_subnet_pool_id(self, ipam_mock): subnet_pool_id = 'SomePoolID' self._load_ipam_driver('fake', subnet_pool_id) ipam_mock.assert_called_once_with(subnet_pool_id, self.ctx) class TestAddressRequestFactory(base.BaseTestCase): def test_specific_address_request_is_loaded(self): for address in ('10.12.0.15', 'fffe::1'): ip = {'ip_address': address} self.assertIsInstance( ipam_req.AddressRequestFactory.get_request(None, None, ip), ipam_req.SpecificAddressRequest) def test_any_address_request_is_loaded(self): for addr in [None, '']: ip = {'ip_address': addr} self.assertIsInstance( ipam_req.AddressRequestFactory.get_request(None, None, ip), ipam_req.AnyAddressRequest) def test_automatic_address_request_is_loaded(self): ip = {'mac': '6c:62:6d:de:cf:49', 'subnet_cidr': '2001:470:abcd::/64', 'eui64_address': True} self.assertIsInstance( ipam_req.AddressRequestFactory.get_request(None, None, ip), ipam_req.AutomaticAddressRequest) class TestSubnetRequestFactory(IpamSubnetRequestTestCase): def _build_subnet_dict(self, id=None, cidr='192.168.1.0/24', prefixlen=8, ip_version=4): subnet = {'cidr': cidr, 'prefixlen': prefixlen, 'ip_version': ip_version, 'tenant_id': self.tenant_id, 'gateway_ip': None, 'allocation_pools': None, 'id': id or self.subnet_id} subnetpool = {'ip_version': ip_version, 'default_prefixlen': prefixlen} return subnet, subnetpool def test_specific_subnet_request_is_loaded(self): addresses = [ '10.12.0.15/24', '10.12.0.0/24', 'fffe::1/64', 'fffe::/64'] for address in addresses: subnet, subnetpool = self._build_subnet_dict(cidr=address) self.assertIsInstance( ipam_req.SubnetRequestFactory.get_request(None, subnet, subnetpool), ipam_req.SpecificSubnetRequest) def test_any_address_request_is_loaded_for_ipv4(self): subnet, subnetpool = self._build_subnet_dict(cidr=None, ip_version=4) self.assertIsInstance( ipam_req.SubnetRequestFactory.get_request(None, subnet, subnetpool), ipam_req.AnySubnetRequest) def test_any_address_request_is_loaded_for_ipv6(self): subnet, subnetpool = self._build_subnet_dict(cidr=None, ip_version=6) self.assertIsInstance( ipam_req.SubnetRequestFactory.get_request(None, subnet, subnetpool), ipam_req.AnySubnetRequest) def test_args_are_passed_to_specific_request(self): subnet, subnetpool = self._build_subnet_dict() request = ipam_req.SubnetRequestFactory.get_request(None, subnet, subnetpool) self.assertIsInstance(request, ipam_req.SpecificSubnetRequest) self.assertEqual(self.tenant_id, request.tenant_id) self.assertEqual(self.subnet_id, request.subnet_id) self.assertEqual(None, request.gateway_ip) self.assertEqual(None, request.allocation_pools) class TestGetRequestFactory(base.BaseTestCase): def setUp(self): super(TestGetRequestFactory, self).setUp() cfg.CONF.set_override('ipam_driver', 'fake') self.driver = driver.Pool.get_instance(None, None) def test_get_subnet_request_factory(self): self.assertEqual( self.driver.get_subnet_request_factory(), ipam_req.SubnetRequestFactory) def test_get_address_request_factory(self): self.assertEqual( self.driver.get_address_request_factory(), ipam_req.AddressRequestFactory)
apache-2.0
[ 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 646, 25798, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 5377, 1208, 199, 199, 504, 8224, 14, 2330, 492, 5262, 199, 504, 8224, 14, 2330, 492, 3278, 22, 63, 1208, 199, 504, 8224, 492, 1067, 199, 504, 8224, 14, 20014, 77, 492, 5253, 199, 504, 8224, 14, 20014, 77, 492, 4967, 465, 18210, 77, 63, 2804, 199, 504, 8224, 14, 20014, 77, 492, 4145, 465, 18210, 77, 63, 2103, 199, 504, 8224, 492, 5256, 199, 504, 8224, 14, 2219, 492, 1300, 199, 504, 8224, 14, 2219, 14, 3248, 14, 20014, 77, 492, 4026, 63, 3090, 199, 199, 14623, 63, 1772, 1156, 63, 6885, 275, 283, 10271, 14, 2219, 14, 3248, 14, 20014, 77, 14, 3183, 63, 3090, 14, 8249, 6158, 7, 421, 199, 533, 473, 28024, 15238, 2017, 1746, 8, 1095, 14, 20760, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 41, 28024, 15238, 2017, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 4647, 63, 344, 275, 5377, 1208, 14, 4208, 63, 2580, 342, 267, 291, 14, 5327, 63, 344, 275, 5377, 1208, 14, 4208, 63, 2580, 342, 421, 199, 533, 1379, 41, 28024, 15238, 16272, 8, 41, 28024, 15238, 2017, 1746, 304, 339, 347, 511, 63, 5327, 63, 1069, 8, 277, 304, 267, 4203, 275, 18210, 77, 63, 2103, 14, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 3303, 291, 14, 5327, 63, 344, 9, 267, 291, 14, 629, 8, 277, 14, 4647, 63, 344, 12, 4203, 14, 4647, 63, 344, 9, 267, 291, 14, 629, 8, 277, 14, 5327, 63, 344, 12, 4203, 14, 5327, 63, 344, 9, 267, 291, 14, 629, 8, 403, 12, 4203, 14, 7019, 63, 711, 9, 267, 291, 14, 629, 8, 403, 12, 4203, 14, 14940, 63, 12406, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 7019, 8, 277, 304, 267, 1056, 275, 18210, 77, 63, 2103, 14, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 3660, 291, 14, 5327, 63, 344, 12, 3660, 10391, 63, 711, 534, 17, 14, 18, 14, 19, 14, 17, 358, 267, 291, 14, 629, 360, 17, 14, 18, 14, 19, 14, 17, 297, 620, 8, 1069, 14, 7019, 63, 711, 430, 339, 347, 511, 63, 5327, 63, 1069, 63, 4087, 63, 7019, 8, 277, 304, 267, 291, 14, 1855, 8, 846, 2697, 14, 1018, 14, 11404, 3484, 547, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 10391, 63, 711, 534, 17, 14, 18, 14, 19, 2659, 339, 347, 511, 63, 5327, 63, 1069, 63, 1045, 63, 1842, 8, 277, 304, 267, 18723, 63, 12406, 275, 359, 846, 2697, 14, 1772, 4709, 360, 17, 14, 18, 14, 19, 14, 20, 297, 283, 17, 14, 18, 14, 19, 14, 21, 659, 1169, 25798, 14, 1772, 4709, 360, 17, 14, 18, 14, 19, 14, 23, 297, 283, 17, 14, 18, 14, 19, 14, 25, 5440, 267, 1056, 275, 18210, 77, 63, 2103, 14, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 3660, 291, 14, 5327, 63, 344, 12, 3660, 18723, 63, 12406, 29, 14940, 63, 12406, 9, 267, 291, 14, 629, 8, 14940, 63, 12406, 12, 1056, 14, 14940, 63, 12406, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 1842, 63, 1397, 63, 513, 8, 277, 304, 267, 291, 14, 1855, 8, 4333, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 29, 17, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 4087, 63, 1842, 8, 277, 304, 267, 291, 14, 1855, 8, 4333, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 2968, 17, 14, 18, 14, 19, 14, 20, 1105, 339, 347, 511, 63, 5327, 63, 1069, 63, 14020, 63, 6234, 8, 277, 304, 267, 20092, 275, 359, 846, 2697, 14, 1772, 4709, 360, 16, 14, 16, 14, 16, 14, 17, 297, 283, 16, 14, 16, 14, 16, 14, 18, 659, 326, 25798, 14, 1772, 4709, 29539, 17, 297, 19069, 18, 5440, 267, 291, 14, 1855, 8, 3393, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 29, 12406, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 16736, 8, 277, 304, 267, 20092, 275, 359, 846, 2697, 14, 1772, 4709, 360, 16, 14, 16, 14, 16, 14, 709, 297, 283, 16, 14, 16, 14, 16, 14, 1165, 659, 326, 25798, 14, 1772, 4709, 360, 16, 14, 16, 14, 16, 14, 24, 297, 283, 16, 14, 16, 14, 16, 14, 709, 5440, 267, 291, 14, 1855, 8, 3393, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 29, 12406, 9, 421, 199, 533, 1379, 41, 28024, 9874, 15238, 2017, 8, 41, 28024, 15238, 2017, 1746, 304, 339, 347, 511, 63, 5327, 63, 1069, 8, 277, 304, 267, 1056, 275, 18210, 77, 63, 2103, 14, 9874, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12 ]
[ 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 646, 25798, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 5377, 1208, 199, 199, 504, 8224, 14, 2330, 492, 5262, 199, 504, 8224, 14, 2330, 492, 3278, 22, 63, 1208, 199, 504, 8224, 492, 1067, 199, 504, 8224, 14, 20014, 77, 492, 5253, 199, 504, 8224, 14, 20014, 77, 492, 4967, 465, 18210, 77, 63, 2804, 199, 504, 8224, 14, 20014, 77, 492, 4145, 465, 18210, 77, 63, 2103, 199, 504, 8224, 492, 5256, 199, 504, 8224, 14, 2219, 492, 1300, 199, 504, 8224, 14, 2219, 14, 3248, 14, 20014, 77, 492, 4026, 63, 3090, 199, 199, 14623, 63, 1772, 1156, 63, 6885, 275, 283, 10271, 14, 2219, 14, 3248, 14, 20014, 77, 14, 3183, 63, 3090, 14, 8249, 6158, 7, 421, 199, 533, 473, 28024, 15238, 2017, 1746, 8, 1095, 14, 20760, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 41, 28024, 15238, 2017, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 4647, 63, 344, 275, 5377, 1208, 14, 4208, 63, 2580, 342, 267, 291, 14, 5327, 63, 344, 275, 5377, 1208, 14, 4208, 63, 2580, 342, 421, 199, 533, 1379, 41, 28024, 15238, 16272, 8, 41, 28024, 15238, 2017, 1746, 304, 339, 347, 511, 63, 5327, 63, 1069, 8, 277, 304, 267, 4203, 275, 18210, 77, 63, 2103, 14, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 3303, 291, 14, 5327, 63, 344, 9, 267, 291, 14, 629, 8, 277, 14, 4647, 63, 344, 12, 4203, 14, 4647, 63, 344, 9, 267, 291, 14, 629, 8, 277, 14, 5327, 63, 344, 12, 4203, 14, 5327, 63, 344, 9, 267, 291, 14, 629, 8, 403, 12, 4203, 14, 7019, 63, 711, 9, 267, 291, 14, 629, 8, 403, 12, 4203, 14, 14940, 63, 12406, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 7019, 8, 277, 304, 267, 1056, 275, 18210, 77, 63, 2103, 14, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 3660, 291, 14, 5327, 63, 344, 12, 3660, 10391, 63, 711, 534, 17, 14, 18, 14, 19, 14, 17, 358, 267, 291, 14, 629, 360, 17, 14, 18, 14, 19, 14, 17, 297, 620, 8, 1069, 14, 7019, 63, 711, 430, 339, 347, 511, 63, 5327, 63, 1069, 63, 4087, 63, 7019, 8, 277, 304, 267, 291, 14, 1855, 8, 846, 2697, 14, 1018, 14, 11404, 3484, 547, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 10391, 63, 711, 534, 17, 14, 18, 14, 19, 2659, 339, 347, 511, 63, 5327, 63, 1069, 63, 1045, 63, 1842, 8, 277, 304, 267, 18723, 63, 12406, 275, 359, 846, 2697, 14, 1772, 4709, 360, 17, 14, 18, 14, 19, 14, 20, 297, 283, 17, 14, 18, 14, 19, 14, 21, 659, 1169, 25798, 14, 1772, 4709, 360, 17, 14, 18, 14, 19, 14, 23, 297, 283, 17, 14, 18, 14, 19, 14, 25, 5440, 267, 1056, 275, 18210, 77, 63, 2103, 14, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 3660, 291, 14, 5327, 63, 344, 12, 3660, 18723, 63, 12406, 29, 14940, 63, 12406, 9, 267, 291, 14, 629, 8, 14940, 63, 12406, 12, 1056, 14, 14940, 63, 12406, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 1842, 63, 1397, 63, 513, 8, 277, 304, 267, 291, 14, 1855, 8, 4333, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 29, 17, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 4087, 63, 1842, 8, 277, 304, 267, 291, 14, 1855, 8, 4333, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 2968, 17, 14, 18, 14, 19, 14, 20, 1105, 339, 347, 511, 63, 5327, 63, 1069, 63, 14020, 63, 6234, 8, 277, 304, 267, 20092, 275, 359, 846, 2697, 14, 1772, 4709, 360, 16, 14, 16, 14, 16, 14, 17, 297, 283, 16, 14, 16, 14, 16, 14, 18, 659, 326, 25798, 14, 1772, 4709, 29539, 17, 297, 19069, 18, 5440, 267, 291, 14, 1855, 8, 3393, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 29, 12406, 9, 339, 347, 511, 63, 5327, 63, 1069, 63, 16736, 8, 277, 304, 267, 20092, 275, 359, 846, 2697, 14, 1772, 4709, 360, 16, 14, 16, 14, 16, 14, 709, 297, 283, 16, 14, 16, 14, 16, 14, 1165, 659, 326, 25798, 14, 1772, 4709, 360, 16, 14, 16, 14, 16, 14, 24, 297, 283, 16, 14, 16, 14, 16, 14, 709, 5440, 267, 291, 14, 1855, 8, 3393, 12, 2079, 18210, 77, 63, 2103, 14, 15238, 2017, 12, 2079, 291, 14, 4647, 63, 344, 12, 2079, 291, 14, 5327, 63, 344, 12, 2079, 18723, 63, 12406, 29, 12406, 9, 421, 199, 533, 1379, 41, 28024, 9874, 15238, 2017, 8, 41, 28024, 15238, 2017, 1746, 304, 339, 347, 511, 63, 5327, 63, 1069, 8, 277, 304, 267, 1056, 275, 18210, 77, 63, 2103, 14, 9874, 15238, 2017, 8, 277, 14, 4647, 63, 344, 12, 0 ]
[ 1, 1,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eni/ansible
lib/ansible/modules/cloud/amazon/aws_ssm_parameter_store.py
1
7817
#!/usr/bin/python # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'metadata_version': '1.1'} DOCUMENTATION = ''' --- module: aws_ssm_parameter_store short_description: Manage key-value pairs in aws parameter store. description: - Manage key-value pairs in aws parameter store. version_added: "2.5" options: name: description: - Parameter key name. required: true type: str description: description: - Parameter key description. required: false type: str value: description: - Parameter value. required: false type: str state: description: - Creates or modifies an existing parameter. - Deletes a parameter. required: false choices: ['present', 'absent'] default: present type: str string_type: description: - Parameter String type. required: false choices: ['String', 'StringList', 'SecureString'] default: String type: str decryption: description: - Work with SecureString type to get plain text secrets type: bool required: false default: true key_id: description: - AWS KMS key to decrypt the secrets. - The default key (C(alias/aws/ssm)) is automatically generated the first time it's requested. required: false default: alias/aws/ssm type: str overwrite_value: description: - Option to overwrite an existing value if it already exists. required: false version_added: "2.6" choices: ['never', 'changed', 'always'] default: changed type: str author: - Nathan Webster (@nathanwebsterdotme) - Bill Wang (@ozbillwang) <ozbillwang@gmail.com> - Michael De La Rue (@mikedlr) extends_documentation_fragment: - aws - ec2 requirements: [ botocore, boto3 ] ''' EXAMPLES = ''' - name: Create or update key/value pair in aws parameter store aws_ssm_parameter_store: name: "Hello" description: "This is your first key" value: "World" - name: Delete the key aws_ssm_parameter_store: name: "Hello" state: absent - name: Create or update secure key/value pair with default kms key (aws/ssm) aws_ssm_parameter_store: name: "Hello" description: "This is your first key" string_type: "SecureString" value: "World" - name: Create or update secure key/value pair with nominated kms key aws_ssm_parameter_store: name: "Hello" description: "This is your first key" string_type: "SecureString" key_id: "alias/demo" value: "World" - name: Always update a parameter store value and create a new version aws_ssm_parameter_store: name: "overwrite_example" description: "This example will always overwrite the value" string_type: "String" value: "Test1234" overwrite_value: "always" - name: recommend to use with aws_ssm lookup plugin debug: msg="{{ lookup('aws_ssm', 'hello') }}" ''' RETURN = ''' put_parameter: description: Add one or more parameters to the system. returned: success type: dict delete_parameter: description: Delete a parameter from the system. returned: success type: dict ''' from ansible.module_utils.aws.core import AnsibleAWSModule from ansible.module_utils.ec2 import boto3_conn, get_aws_connection_info try: from botocore.exceptions import ClientError except ImportError: pass # will be captured by imported HAS_BOTO3 def update_parameter(client, module, args): changed = False response = {} try: response = client.put_parameter(**args) changed = True except ClientError as e: module.fail_json_aws(e, msg="setting parameter") return changed, response def create_update_parameter(client, module): changed = False existing_parameter = None response = {} args = dict( Name=module.params.get('name'), Value=module.params.get('value'), Type=module.params.get('string_type') ) if (module.params.get('overwrite_value') in ("always", "changed")): args.update(Overwrite=True) else: args.update(Overwrite=False) if module.params.get('description'): args.update(Description=module.params.get('description')) if module.params.get('string_type') == 'SecureString': args.update(KeyId=module.params.get('key_id')) try: existing_parameter = client.get_parameter(Name=args['Name'], WithDecryption=True) except Exception: pass if existing_parameter: if (module.params.get('overwrite_value') == 'always'): (changed, response) = update_parameter(client, module, args) elif (module.params.get('overwrite_value') == 'changed'): if existing_parameter['Parameter']['Type'] != args['Type']: (changed, response) = update_parameter(client, module, args) if existing_parameter['Parameter']['Value'] != args['Value']: (changed, response) = update_parameter(client, module, args) if args.get('Description'): # Description field not available from get_parameter function so get it from describe_parameters describe_existing_parameter = None try: describe_existing_parameter_paginator = client.get_paginator('describe_parameters') describe_existing_parameter = describe_existing_parameter_paginator.paginate( Filters=[{"Key": "Name", "Values": [args['Name']]}]).build_full_result() except ClientError as e: module.fail_json_aws(e, msg="getting description value") if describe_existing_parameter['Parameters'][0]['Description'] != args['Description']: (changed, response) = update_parameter(client, module, args) else: (changed, response) = update_parameter(client, module, args) return changed, response def delete_parameter(client, module): response = {} try: response = client.delete_parameter( Name=module.params.get('name') ) except ClientError as e: if e.response['Error']['Code'] == 'ParameterNotFound': return False, {} module.fail_json_aws(e, msg="deleting parameter") return True, response def setup_client(module): region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True) connection = boto3_conn(module, conn_type='client', resource='ssm', region=region, endpoint=ec2_url, **aws_connect_params) return connection def setup_module_object(): argument_spec = dict( name=dict(required=True), description=dict(), value=dict(required=False, no_log=True), state=dict(default='present', choices=['present', 'absent']), string_type=dict(default='String', choices=['String', 'StringList', 'SecureString']), decryption=dict(default=True, type='bool'), key_id=dict(default="alias/aws/ssm"), overwrite_value=dict(default='changed', choices=['never', 'changed', 'always']), ) return AnsibleAWSModule( argument_spec=argument_spec, ) def main(): module = setup_module_object() state = module.params.get('state') client = setup_client(module) invocations = { "present": create_update_parameter, "absent": delete_parameter, } (changed, response) = invocations[state](client, module) module.exit_json(changed=changed, response=response) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 11488, 63, 385, 77, 63, 5329, 63, 1617, 199, 3612, 63, 1802, 26, 14944, 790, 13, 585, 6342, 315, 11488, 2725, 3877, 14, 199, 1802, 26, 523, 446, 14944, 790, 13, 585, 6342, 315, 11488, 2725, 3877, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 12009, 790, 536, 14, 272, 1415, 26, 2549, 272, 730, 26, 620, 523, 1369, 26, 272, 1369, 26, 489, 446, 12009, 790, 1369, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 574, 26, 272, 1369, 26, 489, 446, 12009, 574, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 489, 446, 10560, 503, 26473, 376, 3411, 2725, 14, 489, 446, 28382, 282, 2725, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 272, 849, 26, 3451, 272, 730, 26, 620, 523, 1059, 63, 466, 26, 272, 1369, 26, 489, 446, 12009, 2624, 730, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 1558, 297, 283, 32216, 297, 283, 24117, 1558, 418, 272, 849, 26, 2624, 272, 730, 26, 620, 523, 477, 7950, 26, 272, 1369, 26, 489, 446, 9361, 543, 30894, 1558, 730, 370, 664, 8971, 1318, 25563, 272, 730, 26, 2155, 272, 1415, 26, 3055, 272, 849, 26, 2549, 523, 790, 63, 344, 26, 272, 1369, 26, 489, 446, 10168, 1804, 3053, 790, 370, 20090, 314, 25563, 14, 489, 446, 710, 849, 790, 334, 35, 8, 3620, 15, 7231, 15, 385, 77, 430, 365, 5847, 4046, 314, 1642, 267, 900, 652, 1159, 5839, 14, 272, 1415, 26, 3055, 272, 849, 26, 5162, 15, 7231, 15, 385, 77, 272, 730, 26, 620, 523, 8970, 63, 585, 26, 272, 1369, 26, 489, 446, 3207, 370, 8970, 376, 3411, 574, 340, 652, 2575, 3495, 14, 272, 1415, 26, 3055, 272, 1015, 63, 3270, 26, 298, 18, 14, 22, 2, 272, 3415, 26, 788, 18178, 297, 283, 2489, 297, 283, 9223, 418, 272, 849, 26, 2896, 272, 730, 26, 620, 199, 2502, 26, 523, 446, 653, 1619, 290, 2136, 1533, 351, 8593, 78, 1619, 290, 1129, 1533, 351, 3287, 278, 9, 523, 446, 699, 778, 644, 621, 8593, 26051, 19815, 87, 621, 9, 665, 26051, 19815, 87, 621, 32, 6799, 14, 957, 30, 523, 446, 16922, 1487, 7964, 820, 310, 8593, 2664, 25503, 7493, 9, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 7538, 26, 359, 21199, 12, 6055, 19, 1622, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 503, 1678, 790, 15, 585, 4092, 315, 11488, 2725, 3877, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1369, 26, 298, 2765, 365, 2195, 1642, 790, 2, 272, 574, 26, 298, 15943, 2, 199, 199, 13, 536, 26, 8496, 314, 790, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 2790, 503, 1678, 11153, 790, 15, 585, 4092, 543, 849, 1022, 706, 790, 334, 7231, 15, 385, 77, 9, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1369, 26, 298, 2765, 365, 2195, 1642, 790, 2, 272, 1059, 63, 466, 26, 298, 24117, 1558, 2, 272, 574, 26, 298, 15943, 2, 199, 199, 13, 536, 26, 2790, 503, 1678, 11153, 790, 15, 585, 4092, 543, 17468, 23831, 1022, 706, 790, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1369, 26, 298, 2765, 365, 2195, 1642, 790, 2, 272, 1059, 63, 466, 26, 298, 24117, 1558, 2, 272, 790, 63, 344, 26, 298, 3620, 15, 8768, 2, 272, 574, 26, 298, 15943, 2, 199, 199, 13, 536, 26, 16763, 1678, 282, 2725, 3877, 574, 436, 1218, 282, 892, 1015, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 14658, 63, 2694, 2, 272, 1369, 26, 298, 2765, 2893, 911, 3544, 8970, 314, 574, 2, 272, 1059, 63, 466, 26, 298, 1558, 2, 272, 574, 26, 298, 774, 4321, 2, 272, 8970, 63, 585, 26, 298, 9223, 2, 199, 199, 13, 536, 26, 27747, 370, 675, 543, 11488, 63, 385, 77, 4237, 3589, 523, 3105, 26, 1499, 628, 3638, 4237, 360, 7231, 63, 385, 77, 297, 283, 5006, 358, 7820, 199, 2344, 199, 199, 9677, 275, 1449, 199, 524, 63, 5329, 26, 272, 1369, 26, 2654, 1373, 503, 1655, 2633, 370, 314, 2656, 14, 272, 2138, 26, 3182, 272, 730, 26, 1211, 199, 1807, 63, 5329, 26, 272, 1369, 26, 8496, 282, 2725, 687, 314, 2656, 14, 272, 2138, 26, 3182, 272, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 7231, 14, 1018, 492, 2622, 13226, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 6055, 19, 63, 1631, 12, 664, 63, 7231, 63, 2105, 63, 815, 199, 199, 893, 26, 272, 687, 21199, 14, 3924, 492, 28972, 199, 2590, 3545, 26, 272, 986, 221, 327, 911, 506, 17487, 701, 8439, 7509, 63, 21373, 19, 421, 199, 318, 1678, 63, 5329, 8, 1258, 12, 859, 12, 1249, 304, 272, 2896, 275, 756, 272, 1177, 275, 1052, 339, 862, 26, 267, 1177, 275, 1890, 14, 524, 63, 5329, 3682, 589, 9, 267, 2896, 275, 715, 272, 871, 28972, 465, 325, 26, 267, 859, 14, 1633 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 11488, 63, 385, 77, 63, 5329, 63, 1617, 199, 3612, 63, 1802, 26, 14944, 790, 13, 585, 6342, 315, 11488, 2725, 3877, 14, 199, 1802, 26, 523, 446, 14944, 790, 13, 585, 6342, 315, 11488, 2725, 3877, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 12009, 790, 536, 14, 272, 1415, 26, 2549, 272, 730, 26, 620, 523, 1369, 26, 272, 1369, 26, 489, 446, 12009, 790, 1369, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 574, 26, 272, 1369, 26, 489, 446, 12009, 574, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 489, 446, 10560, 503, 26473, 376, 3411, 2725, 14, 489, 446, 28382, 282, 2725, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 272, 849, 26, 3451, 272, 730, 26, 620, 523, 1059, 63, 466, 26, 272, 1369, 26, 489, 446, 12009, 2624, 730, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 1558, 297, 283, 32216, 297, 283, 24117, 1558, 418, 272, 849, 26, 2624, 272, 730, 26, 620, 523, 477, 7950, 26, 272, 1369, 26, 489, 446, 9361, 543, 30894, 1558, 730, 370, 664, 8971, 1318, 25563, 272, 730, 26, 2155, 272, 1415, 26, 3055, 272, 849, 26, 2549, 523, 790, 63, 344, 26, 272, 1369, 26, 489, 446, 10168, 1804, 3053, 790, 370, 20090, 314, 25563, 14, 489, 446, 710, 849, 790, 334, 35, 8, 3620, 15, 7231, 15, 385, 77, 430, 365, 5847, 4046, 314, 1642, 267, 900, 652, 1159, 5839, 14, 272, 1415, 26, 3055, 272, 849, 26, 5162, 15, 7231, 15, 385, 77, 272, 730, 26, 620, 523, 8970, 63, 585, 26, 272, 1369, 26, 489, 446, 3207, 370, 8970, 376, 3411, 574, 340, 652, 2575, 3495, 14, 272, 1415, 26, 3055, 272, 1015, 63, 3270, 26, 298, 18, 14, 22, 2, 272, 3415, 26, 788, 18178, 297, 283, 2489, 297, 283, 9223, 418, 272, 849, 26, 2896, 272, 730, 26, 620, 199, 2502, 26, 523, 446, 653, 1619, 290, 2136, 1533, 351, 8593, 78, 1619, 290, 1129, 1533, 351, 3287, 278, 9, 523, 446, 699, 778, 644, 621, 8593, 26051, 19815, 87, 621, 9, 665, 26051, 19815, 87, 621, 32, 6799, 14, 957, 30, 523, 446, 16922, 1487, 7964, 820, 310, 8593, 2664, 25503, 7493, 9, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 7538, 26, 359, 21199, 12, 6055, 19, 1622, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 503, 1678, 790, 15, 585, 4092, 315, 11488, 2725, 3877, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1369, 26, 298, 2765, 365, 2195, 1642, 790, 2, 272, 574, 26, 298, 15943, 2, 199, 199, 13, 536, 26, 8496, 314, 790, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 2790, 503, 1678, 11153, 790, 15, 585, 4092, 543, 849, 1022, 706, 790, 334, 7231, 15, 385, 77, 9, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1369, 26, 298, 2765, 365, 2195, 1642, 790, 2, 272, 1059, 63, 466, 26, 298, 24117, 1558, 2, 272, 574, 26, 298, 15943, 2, 199, 199, 13, 536, 26, 2790, 503, 1678, 11153, 790, 15, 585, 4092, 543, 17468, 23831, 1022, 706, 790, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 6257, 2, 272, 1369, 26, 298, 2765, 365, 2195, 1642, 790, 2, 272, 1059, 63, 466, 26, 298, 24117, 1558, 2, 272, 790, 63, 344, 26, 298, 3620, 15, 8768, 2, 272, 574, 26, 298, 15943, 2, 199, 199, 13, 536, 26, 16763, 1678, 282, 2725, 3877, 574, 436, 1218, 282, 892, 1015, 523, 11488, 63, 385, 77, 63, 5329, 63, 1617, 26, 272, 536, 26, 298, 14658, 63, 2694, 2, 272, 1369, 26, 298, 2765, 2893, 911, 3544, 8970, 314, 574, 2, 272, 1059, 63, 466, 26, 298, 1558, 2, 272, 574, 26, 298, 774, 4321, 2, 272, 8970, 63, 585, 26, 298, 9223, 2, 199, 199, 13, 536, 26, 27747, 370, 675, 543, 11488, 63, 385, 77, 4237, 3589, 523, 3105, 26, 1499, 628, 3638, 4237, 360, 7231, 63, 385, 77, 297, 283, 5006, 358, 7820, 199, 2344, 199, 199, 9677, 275, 1449, 199, 524, 63, 5329, 26, 272, 1369, 26, 2654, 1373, 503, 1655, 2633, 370, 314, 2656, 14, 272, 2138, 26, 3182, 272, 730, 26, 1211, 199, 1807, 63, 5329, 26, 272, 1369, 26, 8496, 282, 2725, 687, 314, 2656, 14, 272, 2138, 26, 3182, 272, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 7231, 14, 1018, 492, 2622, 13226, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 6055, 19, 63, 1631, 12, 664, 63, 7231, 63, 2105, 63, 815, 199, 199, 893, 26, 272, 687, 21199, 14, 3924, 492, 28972, 199, 2590, 3545, 26, 272, 986, 221, 327, 911, 506, 17487, 701, 8439, 7509, 63, 21373, 19, 421, 199, 318, 1678, 63, 5329, 8, 1258, 12, 859, 12, 1249, 304, 272, 2896, 275, 756, 272, 1177, 275, 1052, 339, 862, 26, 267, 1177, 275, 1890, 14, 524, 63, 5329, 3682, 589, 9, 267, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Konubinix/weboob
modules/boursorama/pages/investment.py
4
3587
# -*- coding: utf-8 -*- # Copyright(C) 2014 Simon Murail # # This file is part of weboob. # # weboob 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. # # weboob 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 weboob. If not, see <http://www.gnu.org/licenses/>. import re from lxml.etree import XPath from weboob.deprecated.browser import Page from weboob.capabilities.bank import Investment from weboob.browser.filters.standard import CleanDecimal _el_to_string = XPath('string()') def el_to_string(el): return unicode(_el_to_string(el)) class IsinMixin(object): def get_isin(self, s): mobj = self._re_isin.search(s) if mobj: return mobj.group(1) class AccountInvestment(IsinMixin, Page): _re_isin = re.compile(r'isin=(\w+)') _tr_list = XPath('//div[@id="content-gauche"]//table[@class="list"]/tbody/tr') _td_list = XPath('./td') _link = XPath('./td[1]/a/@href') def get_investment(self): Decimal = CleanDecimal(replace_dots=True).filter for tr in self._tr_list(self.document): cells = list(el_to_string(td) for td in self._td_list(tr)) link = unicode(self._link(tr)[0]) ''' Boursorama table cells ---------------------- 0. Fonds 1. Date de valeur 2. Valeur de part 3. Nombre de parts 4. Contre valeur 5. Prix revient 6. +/- value en €* 7. +/- value en %* Investment model ---------------- label = StringField('Label of stocks') code = StringField('Identifier of the stock (ISIN code)') description = StringField('Short description of the stock') quantity = IntField('Quantity of stocks') unitprice = DecimalField('Buy price of one stock') unitvalue = DecimalField('Current value of one stock') valuation = DecimalField('Total current valuation of the Investment') diff = DecimalField('Difference between the buy cost and the current valuation') ''' inv = Investment() isin = self.get_isin(link) if isin: inv.id = inv.code = isin inv.label = cells[0] inv.quantity = Decimal(cells[3]) inv.valuation = Decimal(cells[4]) inv.unitprice = Decimal(cells[5]) inv.unitvalue = Decimal(cells[2]) inv.diff = Decimal(cells[6]) inv._detail_url = link if '/cours.phtml' in link else None yield inv class InvestmentDetail(IsinMixin, Page): _re_isin = re.compile('(\w+)') _isin = XPath('//h2[@class and contains(concat(" ", normalize-space(@class), " "), " fv-isin ")]') _description = XPath('//p[@class="taj"]') def get_investment_detail(self, inv): subtitle = el_to_string(self._isin(self.document)[0]) inv.id = inv.code = self.get_isin(subtitle) inv.description = el_to_string(self._description(self.document)[0]).strip()
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6927, 755, 10751, 265, 603, 300, 1054, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 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, 29896, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 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, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 295, 199, 504, 14490, 14, 9464, 492, 1323, 2042, 199, 199, 504, 29896, 14, 6667, 14, 5750, 492, 10331, 199, 504, 29896, 14, 10732, 14, 9860, 492, 1010, 13981, 434, 199, 504, 29896, 14, 5750, 14, 4273, 14, 6807, 492, 12762, 6745, 421, 199, 63, 352, 63, 475, 63, 875, 275, 1323, 2042, 360, 875, 19004, 199, 199, 318, 579, 63, 475, 63, 875, 8, 352, 304, 272, 372, 2649, 1547, 352, 63, 475, 63, 875, 8, 352, 430, 421, 199, 533, 473, 5911, 4256, 8, 785, 304, 272, 347, 664, 63, 25184, 8, 277, 12, 308, 304, 267, 14208, 275, 291, 423, 264, 63, 25184, 14, 1733, 8, 83, 9, 267, 340, 14208, 26, 288, 372, 14208, 14, 923, 8, 17, 9, 421, 199, 533, 9973, 607, 13981, 434, 8, 1831, 262, 4256, 12, 10331, 304, 272, 485, 264, 63, 25184, 275, 295, 14, 2014, 8, 82, 7, 25184, 2687, 60, 87, 11, 5942, 272, 485, 454, 63, 513, 275, 1323, 2042, 15079, 3015, 14251, 344, 628, 1317, 13, 16750, 595, 937, 501, 1224, 14251, 533, 628, 513, 937, 15, 17847, 15, 454, 358, 272, 485, 2076, 63, 513, 275, 1323, 2042, 17371, 2076, 358, 272, 485, 1073, 275, 1323, 2042, 17371, 2076, 59, 17, 12978, 65, 15, 32, 6399, 358, 339, 347, 664, 63, 262, 13981, 434, 8, 277, 304, 267, 6345, 275, 12762, 6745, 8, 1814, 63, 25310, 29, 549, 680, 1541, 398, 367, 5651, 315, 291, 423, 454, 63, 513, 8, 277, 14, 3554, 304, 288, 10106, 275, 769, 8, 352, 63, 475, 63, 875, 8, 2076, 9, 367, 12749, 315, 291, 423, 2076, 63, 513, 8, 454, 430, 288, 2142, 275, 2649, 8, 277, 423, 1073, 8, 454, 2788, 16, 566, 953, 1449, 953, 699, 567, 1509, 14541, 1817, 10106, 288, 10652, 8648, 953, 378, 14, 481, 265, 795, 288, 413, 14, 6148, 477, 373, 1895, 300, 288, 499, 14, 812, 1895, 300, 477, 1777, 288, 650, 14, 653, 676, 10205, 477, 4184, 288, 841, 14, 1448, 18468, 373, 1895, 300, 288, 959, 14, 510, 1904, 295, 433, 484, 288, 1227, 14, 435, 22551, 574, 655, 22410, 225, 106, 10, 288, 1520, 14, 435, 22551, 574, 655, 450, 10, 953, 1010, 13981, 434, 1402, 288, 10652, 953, 1768, 275, 755, 21409, 360, 4314, 402, 10952, 83, 358, 288, 1233, 275, 263, 21409, 360, 7544, 402, 314, 10952, 334, 1311, 568, 1233, 5942, 288, 1369, 275, 21409, 360, 10039, 1369, 402, 314, 10952, 358, 288, 12524, 275, 259, 9805, 792, 360, 19703, 402, 10952, 83, 358, 288, 4137, 4777, 275, 257, 6345, 792, 360, 1713, 89, 8033, 402, 1373, 10952, 358, 288, 4137, 585, 275, 257, 6345, 792, 360, 5639, 574, 402, 1373, 10952, 358, 288, 1139, 4086, 275, 257, 6345, 792, 360, 7316, 1453, 1139, 4086, 402, 314, 1010, 13981, 434, 358, 288, 3915, 275, 263, 6345, 792, 360, 32279, 3382, 314, 1032, 89, 7918, 436, 314, 1453, 1139, 4086, 358, 953, 1449, 953, 4572, 275, 1010, 13981, 434, 342, 288, 365, 262, 275, 291, 14, 362, 63, 25184, 8, 1073, 9, 953, 340, 365, 262, 26, 355, 4572, 14, 344, 275, 4572, 14, 600, 275, 365, 262, 288, 4572, 14, 1302, 275, 10106, 59, 16, 61, 288, 4572, 14, 10577, 275, 6345, 8, 9041, 59, 19, 566, 288, 4572, 14, 27456, 275, 6345, 8, 9041, 59, 20, 566, 288, 4572, 14, 3248, 4777, 275, 6345, 8, 9041, 59, 21, 566, 288, 4572, 14, 3248, 585, 275, 6345, 8, 9041, 59, 18, 566, 288, 4572, 14, 3028, 275, 6345, 8, 9041, 59, 22, 566, 953, 4572, 423, 5506, 63, 633, 275, 2142, 340, 1994, 331, 21050, 14, 80, 1360, 7, 315, 2142, 587, 488, 953, 1995, 4572, 421, 199, 533, 1010, 13981, 434, 8064, 8, 1831, 262, 4256, 12, 10331, 304, 272, 485, 264, 63, 25184, 275, 295, 14, 2014, 360, 2961, 87, 11, 5942, 272, 485, 25184, 275, 1323, 2042, 15079, 72, 18, 14251, 533, 436, 3509, 8, 9419, 480, 3872, 7666, 13, 2638, 8, 32, 533, 395, 298, 26261, 298, 289, 86, 13, 25184, 298, 1874, 358, 272, 485, 1802, 275, 1323, 2042, 15079, 80, 14251, 533, 628, 502, 74, 937, 358, 339, 347, 664, 63, 262, 13981, 434, 63, 5506, 8, 277, 12, 4572, 304, 267, 18197, 275, 579, 63, 475, 63, 875, 8, 277, 423, 25184, 8, 277, 14, 3554, 2788, 16, 566, 398, 4572, 14, 344, 275, 4572, 14, 600, 275, 291, 14, 362, 63, 25184, 8, 14348, 9, 267, 4572, 14, 1802, 275, 579, 63, 475, 63, 875, 8, 277, 423, 1802, 8, 277, 14, 3554, 2788, 16, 6575, 1913, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6927, 755, 10751, 265, 603, 300, 1054, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 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, 29896, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 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, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 295, 199, 504, 14490, 14, 9464, 492, 1323, 2042, 199, 199, 504, 29896, 14, 6667, 14, 5750, 492, 10331, 199, 504, 29896, 14, 10732, 14, 9860, 492, 1010, 13981, 434, 199, 504, 29896, 14, 5750, 14, 4273, 14, 6807, 492, 12762, 6745, 421, 199, 63, 352, 63, 475, 63, 875, 275, 1323, 2042, 360, 875, 19004, 199, 199, 318, 579, 63, 475, 63, 875, 8, 352, 304, 272, 372, 2649, 1547, 352, 63, 475, 63, 875, 8, 352, 430, 421, 199, 533, 473, 5911, 4256, 8, 785, 304, 272, 347, 664, 63, 25184, 8, 277, 12, 308, 304, 267, 14208, 275, 291, 423, 264, 63, 25184, 14, 1733, 8, 83, 9, 267, 340, 14208, 26, 288, 372, 14208, 14, 923, 8, 17, 9, 421, 199, 533, 9973, 607, 13981, 434, 8, 1831, 262, 4256, 12, 10331, 304, 272, 485, 264, 63, 25184, 275, 295, 14, 2014, 8, 82, 7, 25184, 2687, 60, 87, 11, 5942, 272, 485, 454, 63, 513, 275, 1323, 2042, 15079, 3015, 14251, 344, 628, 1317, 13, 16750, 595, 937, 501, 1224, 14251, 533, 628, 513, 937, 15, 17847, 15, 454, 358, 272, 485, 2076, 63, 513, 275, 1323, 2042, 17371, 2076, 358, 272, 485, 1073, 275, 1323, 2042, 17371, 2076, 59, 17, 12978, 65, 15, 32, 6399, 358, 339, 347, 664, 63, 262, 13981, 434, 8, 277, 304, 267, 6345, 275, 12762, 6745, 8, 1814, 63, 25310, 29, 549, 680, 1541, 398, 367, 5651, 315, 291, 423, 454, 63, 513, 8, 277, 14, 3554, 304, 288, 10106, 275, 769, 8, 352, 63, 475, 63, 875, 8, 2076, 9, 367, 12749, 315, 291, 423, 2076, 63, 513, 8, 454, 430, 288, 2142, 275, 2649, 8, 277, 423, 1073, 8, 454, 2788, 16, 566, 953, 1449, 953, 699, 567, 1509, 14541, 1817, 10106, 288, 10652, 8648, 953, 378, 14, 481, 265, 795, 288, 413, 14, 6148, 477, 373, 1895, 300, 288, 499, 14, 812, 1895, 300, 477, 1777, 288, 650, 14, 653, 676, 10205, 477, 4184, 288, 841, 14, 1448, 18468, 373, 1895, 300, 288, 959, 14, 510, 1904, 295, 433, 484, 288, 1227, 14, 435, 22551, 574, 655, 22410, 225, 106, 10, 288, 1520, 14, 435, 22551, 574, 655, 450, 10, 953, 1010, 13981, 434, 1402, 288, 10652, 953, 1768, 275, 755, 21409, 360, 4314, 402, 10952, 83, 358, 288, 1233, 275, 263, 21409, 360, 7544, 402, 314, 10952, 334, 1311, 568, 1233, 5942, 288, 1369, 275, 21409, 360, 10039, 1369, 402, 314, 10952, 358, 288, 12524, 275, 259, 9805, 792, 360, 19703, 402, 10952, 83, 358, 288, 4137, 4777, 275, 257, 6345, 792, 360, 1713, 89, 8033, 402, 1373, 10952, 358, 288, 4137, 585, 275, 257, 6345, 792, 360, 5639, 574, 402, 1373, 10952, 358, 288, 1139, 4086, 275, 257, 6345, 792, 360, 7316, 1453, 1139, 4086, 402, 314, 1010, 13981, 434, 358, 288, 3915, 275, 263, 6345, 792, 360, 32279, 3382, 314, 1032, 89, 7918, 436, 314, 1453, 1139, 4086, 358, 953, 1449, 953, 4572, 275, 1010, 13981, 434, 342, 288, 365, 262, 275, 291, 14, 362, 63, 25184, 8, 1073, 9, 953, 340, 365, 262, 26, 355, 4572, 14, 344, 275, 4572, 14, 600, 275, 365, 262, 288, 4572, 14, 1302, 275, 10106, 59, 16, 61, 288, 4572, 14, 10577, 275, 6345, 8, 9041, 59, 19, 566, 288, 4572, 14, 27456, 275, 6345, 8, 9041, 59, 20, 566, 288, 4572, 14, 3248, 4777, 275, 6345, 8, 9041, 59, 21, 566, 288, 4572, 14, 3248, 585, 275, 6345, 8, 9041, 59, 18, 566, 288, 4572, 14, 3028, 275, 6345, 8, 9041, 59, 22, 566, 953, 4572, 423, 5506, 63, 633, 275, 2142, 340, 1994, 331, 21050, 14, 80, 1360, 7, 315, 2142, 587, 488, 953, 1995, 4572, 421, 199, 533, 1010, 13981, 434, 8064, 8, 1831, 262, 4256, 12, 10331, 304, 272, 485, 264, 63, 25184, 275, 295, 14, 2014, 360, 2961, 87, 11, 5942, 272, 485, 25184, 275, 1323, 2042, 15079, 72, 18, 14251, 533, 436, 3509, 8, 9419, 480, 3872, 7666, 13, 2638, 8, 32, 533, 395, 298, 26261, 298, 289, 86, 13, 25184, 298, 1874, 358, 272, 485, 1802, 275, 1323, 2042, 15079, 80, 14251, 533, 628, 502, 74, 937, 358, 339, 347, 664, 63, 262, 13981, 434, 63, 5506, 8, 277, 12, 4572, 304, 267, 18197, 275, 579, 63, 475, 63, 875, 8, 277, 423, 25184, 8, 277, 14, 3554, 2788, 16, 566, 398, 4572, 14, 344, 275, 4572, 14, 600, 275, 291, 14, 362, 63, 25184, 8, 14348, 9, 267, 4572, 14, 1802, 275, 579, 63, 475, 63, 875, 8, 277, 423, 1802, 8, 277, 14, 3554, 2788, 16, 6575, 1913, 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, 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 ]
SanPen/GridCal
src/GridCal/Engine/Simulations/LinearFactors/linear_analysis_ts_driver.py
1
10126
# This file is part of GridCal. # # GridCal 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. # # GridCal 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 GridCal. If not, see <http://www.gnu.org/licenses/>. import json import pandas as pd import numpy as np import scipy.sparse as sp from scipy.sparse.linalg import spsolve, factorized import time from GridCal.Engine.Simulations.result_types import ResultTypes from GridCal.Engine.Core.multi_circuit import MultiCircuit from GridCal.Engine.Simulations.PowerFlow.power_flow_options import PowerFlowOptions from GridCal.Engine.Simulations.LinearFactors.linear_analysis import LinearAnalysis from GridCal.Engine.Simulations.LinearFactors.linear_analysis_driver import LinearAnalysisOptions from GridCal.Engine.Simulations.results_model import ResultsModel from GridCal.Engine.Core.time_series_pf_data import compile_time_circuit from GridCal.Engine.Simulations.driver_types import SimulationTypes from GridCal.Engine.Simulations.results_template import ResultsTemplate from GridCal.Engine.Simulations.driver_template import TSDriverTemplate class LinearAnalysisTimeSeriesResults(ResultsTemplate): def __init__(self, n, m, time_array, bus_names, bus_types, branch_names): """ TimeSeriesResults constructor @param n: number of buses @param m: number of branches @param nt: number of time steps """ ResultsTemplate.__init__(self, name='Linear Analysis time series', available_results=[ResultTypes.BusActivePower, ResultTypes.BranchActivePowerFrom, ResultTypes.BranchLoading ], data_variables=['bus_names', 'bus_types', 'time', 'branch_names', 'voltage', 'S', 'Sf', 'loading', 'losses']) self.nt = len(time_array) self.m = m self.n = n self.time = time_array self.bus_names = bus_names self.bus_types = bus_types self.branch_names = branch_names self.voltage = np.ones((self.nt, n), dtype=float) self.S = np.zeros((self.nt, n), dtype=float) self.Sf = np.zeros((self.nt, m), dtype=float) self.loading = np.zeros((self.nt, m), dtype=float) self.losses = np.zeros((self.nt, m), dtype=float) def apply_new_time_series_rates(self, nc: "TimeCircuit"): rates = nc.Rates.T self.loading = self.Sf / (rates + 1e-9) def get_results_dict(self): """ Returns a dictionary with the results sorted in a dictionary :return: dictionary of 2D numpy arrays (probably of complex numbers) """ data = {'V': self.voltage.tolist(), 'P': self.S.real.tolist(), 'Q': self.S.imag.tolist(), 'Sbr_real': self.Sf.real.tolist(), 'Sbr_imag': self.Sf.imag.tolist(), 'loading': np.abs(self.loading).tolist()} return data def mdl(self, result_type: ResultTypes) -> "ResultsModel": """ Get ResultsModel instance :param result_type: :return: ResultsModel instance """ if result_type == ResultTypes.BusActivePower: labels = self.bus_names data = self.S y_label = '(MW)' title = 'Bus active power ' elif result_type == ResultTypes.BranchActivePowerFrom: labels = self.branch_names data = self.Sf.real y_label = '(MW)' title = 'Branch power ' elif result_type == ResultTypes.BranchLoading: labels = self.branch_names data = self.loading * 100 y_label = '(%)' title = 'Branch loading ' elif result_type == ResultTypes.BranchLosses: labels = self.branch_names data = self.losses y_label = '(MVA)' title = 'Branch losses' elif result_type == ResultTypes.BusVoltageModule: labels = self.bus_names data = self.voltage y_label = '(p.u.)' title = 'Bus voltage' else: raise Exception('Result type not understood:' + str(result_type)) if self.time is not None: index = self.time else: index = list(range(data.shape[0])) # assemble model return ResultsModel(data=data, index=index, columns=labels, title=title, ylabel=y_label, units=y_label) class LinearAnalysisTimeSeries(TSDriverTemplate): name = 'Linear analysis time series' tpe = SimulationTypes.LinearAnalysis_TS_run def __init__(self, grid: MultiCircuit, options: LinearAnalysisOptions, start_=0, end_=None): """ TimeSeries constructor @param grid: MultiCircuit instance @param options: LinearAnalysisOptions instance """ TSDriverTemplate.__init__(self, grid=grid, start_=start_, end_=end_) self.options = options self.results = LinearAnalysisTimeSeriesResults(n=0, m=0, time_array=[], bus_names=[], bus_types=[], branch_names=[]) self.ptdf_driver = LinearAnalysis(grid=self.grid, distributed_slack=self.options.distribute_slack) def get_steps(self): """ Get time steps list of strings """ return [l.strftime('%d-%m-%Y %H:%M') for l in self.indices] def run(self): """ Run the time series simulation @return: """ self.__cancel__ = False a = time.time() if self.end_ is None: self.end_ = len(self.grid.time_profile) time_indices = np.arange(self.start_, self.end_ + 1) ts_numeric_circuit = compile_time_circuit(self.grid) self.results = LinearAnalysisTimeSeriesResults(n=ts_numeric_circuit.nbus, m=ts_numeric_circuit.nbr, time_array=ts_numeric_circuit.time_array[time_indices], bus_names=ts_numeric_circuit.bus_names, bus_types=ts_numeric_circuit.bus_types, branch_names=ts_numeric_circuit.branch_names) self.indices = pd.to_datetime(ts_numeric_circuit.time_array[time_indices]) self.progress_text.emit('Computing PTDF...') linear_analysis = LinearAnalysis(grid=self.grid, distributed_slack=self.options.distribute_slack, correct_values=self.options.correct_values ) linear_analysis.run() self.progress_text.emit('Computing branch flows...') Pbus_0 = ts_numeric_circuit.Sbus.real[:, time_indices] self.results.Sf = linear_analysis.get_flows_time_series(Pbus_0) # compute post process self.results.loading = self.results.Sf / (ts_numeric_circuit.Rates[:, time_indices].T + 1e-9) self.results.S = Pbus_0.T self.elapsed = time.time() - a # send the finnish signal self.progress_signal.emit(0.0) self.progress_text.emit('Done!') self.done_signal.emit() if __name__ == '__main__': from matplotlib import pyplot as plt from GridCal.Engine import * fname = '/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/IEEE39_1W.gridcal' # fname = '/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/grid_2_islands.xlsx' # fname = '/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/1354 Pegase.xlsx' main_circuit = FileOpen(fname).open() options_ = LinearAnalysisOptions() ptdf_driver = LinearAnalysisTimeSeries(grid=main_circuit, options=options_) ptdf_driver.run() pf_options_ = PowerFlowOptions(solver_type=SolverType.NR) ts_driver = TimeSeries(grid=main_circuit, options=pf_options_) ts_driver.run() fig = plt.figure() ax1 = fig.add_subplot(221) ax1.set_title('Newton-Raphson based flow') ax1.plot(ts_driver.results.Sf.real) ax2 = fig.add_subplot(222) ax2.set_title('PTDF based flow') ax2.plot(ptdf_driver.results.Sf.real) ax3 = fig.add_subplot(223) ax3.set_title('Difference') diff = ts_driver.results.Sf.real - ptdf_driver.results.Sf.real ax3.plot(diff) fig2 = plt.figure() ax1 = fig2.add_subplot(221) ax1.set_title('Newton-Raphson based voltage') ax1.plot(np.abs(ts_driver.results.voltage)) ax2 = fig2.add_subplot(222) ax2.set_title('PTDF based voltage') ax2.plot(ptdf_driver.results.voltage) ax3 = fig2.add_subplot(223) ax3.set_title('Difference') diff = np.abs(ts_driver.results.voltage) - ptdf_driver.results.voltage ax3.plot(diff) plt.show()
gpl-3.0
[ 3, 961, 570, 365, 1777, 402, 16386, 6584, 14, 199, 3, 199, 3, 16386, 6584, 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, 16386, 6584, 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, 16386, 6584, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 2022, 199, 646, 10634, 465, 6454, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 504, 7026, 14, 4421, 14, 10096, 492, 308, 1190, 3344, 12, 6535, 1759, 199, 646, 900, 199, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 1099, 63, 1313, 492, 10695, 4100, 199, 504, 16386, 6584, 14, 8524, 14, 5402, 14, 3029, 63, 18516, 492, 6879, 35, 14221, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 6921, 5060, 14, 5652, 63, 1659, 63, 1419, 492, 18879, 5060, 4558, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 10608, 12666, 83, 14, 6676, 63, 10466, 492, 12489, 13182, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 10608, 12666, 83, 14, 6676, 63, 10466, 63, 3090, 492, 12489, 13182, 4558, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 2604, 63, 1238, 492, 24288, 1685, 199, 504, 16386, 6584, 14, 8524, 14, 5402, 14, 521, 63, 5602, 63, 9928, 63, 576, 492, 6555, 63, 521, 63, 18516, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 3090, 63, 1313, 492, 10751, 5332, 4100, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 2604, 63, 1160, 492, 24288, 4231, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 3090, 63, 1160, 492, 377, 3693, 2046, 4231, 421, 199, 533, 12489, 13182, 30887, 6579, 8, 6579, 4231, 304, 339, 347, 636, 826, 721, 277, 12, 302, 12, 333, 12, 900, 63, 1144, 12, 10414, 63, 1247, 12, 10414, 63, 1313, 12, 5246, 63, 1247, 304, 267, 408, 267, 4703, 9641, 6579, 3787, 267, 768, 635, 302, 26, 1329, 402, 1032, 874, 267, 768, 635, 333, 26, 1329, 402, 17347, 267, 768, 635, 13377, 26, 1329, 402, 900, 7124, 267, 408, 267, 24288, 4231, 855, 826, 721, 277, 12, 639, 536, 534, 10608, 21916, 900, 6779, 297, 639, 2808, 63, 2604, 1524, 2889, 4100, 14, 12106, 7472, 6921, 12, 8105, 10695, 4100, 14, 12526, 7472, 6921, 2532, 12, 8105, 10695, 4100, 14, 12526, 19236, 8105, 2156, 639, 666, 63, 3669, 2968, 5610, 63, 1247, 297, 1740, 283, 5610, 63, 1313, 297, 1740, 283, 521, 297, 1740, 283, 4694, 63, 1247, 297, 1740, 283, 27543, 297, 1740, 283, 51, 297, 1740, 283, 51, 70, 297, 1740, 283, 8786, 297, 1740, 283, 17865, 1105, 398, 291, 14, 343, 275, 822, 8, 521, 63, 1144, 9, 267, 291, 14, 77, 275, 333, 267, 291, 14, 78, 275, 302, 267, 291, 14, 521, 275, 900, 63, 1144, 398, 291, 14, 5610, 63, 1247, 275, 10414, 63, 1247, 398, 291, 14, 5610, 63, 1313, 275, 10414, 63, 1313, 398, 291, 14, 4694, 63, 1247, 275, 5246, 63, 1247, 398, 291, 14, 27543, 275, 980, 14, 4548, 1332, 277, 14, 343, 12, 302, 395, 2152, 29, 1609, 9, 398, 291, 14, 51, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 302, 395, 2152, 29, 1609, 9, 398, 291, 14, 51, 70, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 333, 395, 2152, 29, 1609, 9, 398, 291, 14, 8786, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 333, 395, 2152, 29, 1609, 9, 398, 291, 14, 17865, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 333, 395, 2152, 29, 1609, 9, 339, 347, 4838, 63, 1222, 63, 521, 63, 5602, 63, 17153, 8, 277, 12, 12698, 26, 298, 1366, 35, 14221, 2349, 267, 24434, 275, 12698, 14, 23308, 14, 52, 267, 291, 14, 8786, 275, 291, 14, 51, 70, 1182, 334, 17153, 435, 413, 69, 13, 25, 9, 339, 347, 664, 63, 2604, 63, 807, 8, 277, 304, 267, 408, 267, 1803, 282, 2600, 543, 314, 2058, 3355, 315, 282, 2600, 267, 520, 1107, 26, 2600, 402, 499, 36, 2680, 6572, 334, 6101, 6665, 402, 6114, 5579, 9, 267, 408, 267, 666, 275, 791, 54, 356, 291, 14, 27543, 14, 13633, 1062, 355, 283, 48, 356, 291, 14, 51, 14, 3093, 14, 13633, 1062, 355, 283, 49, 356, 291, 14, 51, 14, 14688, 14, 13633, 1062, 355, 283, 51, 3289, 63, 3093, 356, 291, 14, 51, 70, 14, 3093, 14, 13633, 1062, 355, 283, 51, 3289, 63, 14688, 356, 291, 14, 51, 70, 14, 14688, 14, 13633, 1062, 355, 283, 8786, 356, 980, 14, 2101, 8, 277, 14, 8786, 680, 13633, 12737, 267, 372, 666, 339, 347, 333, 5030, 8, 277, 12, 754, 63, 466, 26, 10695, 4100, 9, 1035, 298, 6579, 1685, 582, 267, 408, 267, 2372, 24288, 1685, 1256, 267, 520, 635, 754, 63, 466, 26, 267, 520, 1107, 26, 24288, 1685, 1256, 267, 408, 398, 340, 754, 63, 466, 508, 10695, 4100, 14, 12106, 7472, 6921, 26, 288, 3628, 275, 291, 14, 5610, 63, 1247, 288, 666, 275, 291, 14, 51, 288, 612, 63, 1302, 275, 8189, 32726, 3171, 288, 2538, 275, 283, 12106, 4702, 7074, 283, 398, 916, 754, 63, 466, 508, 10695, 4100, 14, 12526, 7472, 6921, 2532, 26, 288, 3628, 275, 291, 14, 4694, 63, 1247, 288, 666, 275, 291, 14, 51, 70, 14, 3093, 288, 612, 63, 1302, 275, 8189, 32726, 3171, 288, 2538, 275, 283, 12526, 7074, 283, 398, 916, 754, 63, 466, 508, 10695, 4100, 14, 12526, 19236, 26, 288 ]
[ 961, 570, 365, 1777, 402, 16386, 6584, 14, 199, 3, 199, 3, 16386, 6584, 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, 16386, 6584, 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, 16386, 6584, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 2022, 199, 646, 10634, 465, 6454, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 504, 7026, 14, 4421, 14, 10096, 492, 308, 1190, 3344, 12, 6535, 1759, 199, 646, 900, 199, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 1099, 63, 1313, 492, 10695, 4100, 199, 504, 16386, 6584, 14, 8524, 14, 5402, 14, 3029, 63, 18516, 492, 6879, 35, 14221, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 6921, 5060, 14, 5652, 63, 1659, 63, 1419, 492, 18879, 5060, 4558, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 10608, 12666, 83, 14, 6676, 63, 10466, 492, 12489, 13182, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 10608, 12666, 83, 14, 6676, 63, 10466, 63, 3090, 492, 12489, 13182, 4558, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 2604, 63, 1238, 492, 24288, 1685, 199, 504, 16386, 6584, 14, 8524, 14, 5402, 14, 521, 63, 5602, 63, 9928, 63, 576, 492, 6555, 63, 521, 63, 18516, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 3090, 63, 1313, 492, 10751, 5332, 4100, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 2604, 63, 1160, 492, 24288, 4231, 199, 504, 16386, 6584, 14, 8524, 14, 7467, 21429, 14, 3090, 63, 1160, 492, 377, 3693, 2046, 4231, 421, 199, 533, 12489, 13182, 30887, 6579, 8, 6579, 4231, 304, 339, 347, 636, 826, 721, 277, 12, 302, 12, 333, 12, 900, 63, 1144, 12, 10414, 63, 1247, 12, 10414, 63, 1313, 12, 5246, 63, 1247, 304, 267, 408, 267, 4703, 9641, 6579, 3787, 267, 768, 635, 302, 26, 1329, 402, 1032, 874, 267, 768, 635, 333, 26, 1329, 402, 17347, 267, 768, 635, 13377, 26, 1329, 402, 900, 7124, 267, 408, 267, 24288, 4231, 855, 826, 721, 277, 12, 639, 536, 534, 10608, 21916, 900, 6779, 297, 639, 2808, 63, 2604, 1524, 2889, 4100, 14, 12106, 7472, 6921, 12, 8105, 10695, 4100, 14, 12526, 7472, 6921, 2532, 12, 8105, 10695, 4100, 14, 12526, 19236, 8105, 2156, 639, 666, 63, 3669, 2968, 5610, 63, 1247, 297, 1740, 283, 5610, 63, 1313, 297, 1740, 283, 521, 297, 1740, 283, 4694, 63, 1247, 297, 1740, 283, 27543, 297, 1740, 283, 51, 297, 1740, 283, 51, 70, 297, 1740, 283, 8786, 297, 1740, 283, 17865, 1105, 398, 291, 14, 343, 275, 822, 8, 521, 63, 1144, 9, 267, 291, 14, 77, 275, 333, 267, 291, 14, 78, 275, 302, 267, 291, 14, 521, 275, 900, 63, 1144, 398, 291, 14, 5610, 63, 1247, 275, 10414, 63, 1247, 398, 291, 14, 5610, 63, 1313, 275, 10414, 63, 1313, 398, 291, 14, 4694, 63, 1247, 275, 5246, 63, 1247, 398, 291, 14, 27543, 275, 980, 14, 4548, 1332, 277, 14, 343, 12, 302, 395, 2152, 29, 1609, 9, 398, 291, 14, 51, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 302, 395, 2152, 29, 1609, 9, 398, 291, 14, 51, 70, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 333, 395, 2152, 29, 1609, 9, 398, 291, 14, 8786, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 333, 395, 2152, 29, 1609, 9, 398, 291, 14, 17865, 275, 980, 14, 4250, 1332, 277, 14, 343, 12, 333, 395, 2152, 29, 1609, 9, 339, 347, 4838, 63, 1222, 63, 521, 63, 5602, 63, 17153, 8, 277, 12, 12698, 26, 298, 1366, 35, 14221, 2349, 267, 24434, 275, 12698, 14, 23308, 14, 52, 267, 291, 14, 8786, 275, 291, 14, 51, 70, 1182, 334, 17153, 435, 413, 69, 13, 25, 9, 339, 347, 664, 63, 2604, 63, 807, 8, 277, 304, 267, 408, 267, 1803, 282, 2600, 543, 314, 2058, 3355, 315, 282, 2600, 267, 520, 1107, 26, 2600, 402, 499, 36, 2680, 6572, 334, 6101, 6665, 402, 6114, 5579, 9, 267, 408, 267, 666, 275, 791, 54, 356, 291, 14, 27543, 14, 13633, 1062, 355, 283, 48, 356, 291, 14, 51, 14, 3093, 14, 13633, 1062, 355, 283, 49, 356, 291, 14, 51, 14, 14688, 14, 13633, 1062, 355, 283, 51, 3289, 63, 3093, 356, 291, 14, 51, 70, 14, 3093, 14, 13633, 1062, 355, 283, 51, 3289, 63, 14688, 356, 291, 14, 51, 70, 14, 14688, 14, 13633, 1062, 355, 283, 8786, 356, 980, 14, 2101, 8, 277, 14, 8786, 680, 13633, 12737, 267, 372, 666, 339, 347, 333, 5030, 8, 277, 12, 754, 63, 466, 26, 10695, 4100, 9, 1035, 298, 6579, 1685, 582, 267, 408, 267, 2372, 24288, 1685, 1256, 267, 520, 635, 754, 63, 466, 26, 267, 520, 1107, 26, 24288, 1685, 1256, 267, 408, 398, 340, 754, 63, 466, 508, 10695, 4100, 14, 12106, 7472, 6921, 26, 288, 3628, 275, 291, 14, 5610, 63, 1247, 288, 666, 275, 291, 14, 51, 288, 612, 63, 1302, 275, 8189, 32726, 3171, 288, 2538, 275, 283, 12106, 4702, 7074, 283, 398, 916, 754, 63, 466, 508, 10695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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 ]
PanDAWMS/autopyfactory
attic/pluginsmanagement.py
2
21864
#! /usr/bin/env python ''' module with code for plugins management ''' import logging import logging.handlers import traceback from pprint import pprint #from autopyfactory.configloader import Config, ConfigManager class PluginHandler(object): def __init__(self): self.plugin_name = None self.plugin_class_name = None self.plugin_module_name = None self.config_section = [] self.plugin_class = None def __repr__(self): s = "" s += "plugin_name = %s " % self.plugin_name s += "plugin_class_name = %s " % self.plugin_class_name s += "plugin_module_name = %s " % self.plugin_module_name s += "plugin_section = %s " % self.config_section s += "plugin_class = %s " % self.plugin_class return s class QueuePluginDispatcher(object): ''' class to create and deliver, on request, the different plug-ins needed for the APFQueues. Does not really implement any generic API, each plugin has different characteristics. It is just to take all the code for all APFQueue plugins in a separate class. ''' def __init__(self, apfqueue): self.log = logging.getLogger('main.queueplugindispatcher') self.apfqueue = apfqueue self.qcl = apfqueue.qcl self.fcl = apfqueue.fcl self.mcl = apfqueue.mcl self.apfqname = apfqueue.apfqname self.log.debug("Getting sched plugins") self.schedplugins = self.getschedplugins() self.log.debug("Got %d sched plugins" % len(self.schedplugins)) self.log.debug("Getting batchstatus plugin") self.batchstatusplugin = self.getbatchstatusplugin() self.log.debug("Getting batchstatus plugin") self.wmsstatusplugin = self.getwmsstatusplugin() self.log.debug("Getting submit plugin") self.submitplugin = self.getsubmitplugin() self.log.debug("Getting monitor plugins") self.monitorplugins = self.getmonitorplugins() self.log.debug("Got %d monitor plugins" % len(self.monitorplugins)) self.log.info('QueuePluginDispatcher: Object initialized.') def getschedplugins(self): scheduler_plugin_handlers = self._getplugin('queue', 'sched') # list of PluginHandler objects # Note that for the Sched category, # we allow more than one plugin # (split by comma in the config file) scheduler_plugins = [] for scheduler_ph in scheduler_plugin_handlers: scheduler_cls = scheduler_ph.plugin_class scheduler_plugin = scheduler_cls(self.apfqueue) # calls __init__() to instantiate the class scheduler_plugins.append(scheduler_plugin) return scheduler_plugins def getbatchstatusplugin(self): condor_q_id = 'local' if self.qcl.generic_get(self.apfqname, 'batchstatusplugin') == 'Condor': queryargs = self.qcl.generic_get(self.apfqname, 'batchstatus.condor.queryargs') if queryargs: condor_q_id = self.__queryargs2condorqid(queryargs) batchstatus_plugin_handler = self._getplugin('queue', 'batchstatus')[0] batchstatus_cls = batchstatus_plugin_handler.plugin_class # calls __init__() to instantiate the class # In this case the call accepts a second arguments: # an ID used to allow the creation of more than one Singleton # of this category. Remember the BatchStatusPlugin class is a Singleton. # Therefore, we can have more than one # Batch Status Plugin objects, each one shared by a different # bunch of APF Queues. batchstatus_plugin = batchstatus_cls(self.apfqueue, condor_q_id=condor_q_id) # starts the thread batchstatus_plugin.start() return batchstatus_plugin ###def getwmsstatusplugin(self): ### ### wmsstatus_plugin_handler = self._getplugin('wmsstatus')[0] ### wmsstatus_cls = wmsstatus_plugin_handler.plugin_class ### ### # calls __init__() to instantiate the class ### wmsstatus_plugin = wmsstatus_cls(self.apfqueue) ### ### # starts the thread ### wmsstatus_plugin.start() ### ### return wmsstatus_plugin def getwmsstatusplugin(self): condor_q_id = 'local' if self.qcl.generic_get(self.apfqname, 'wmsstatusplugin') == 'Condor': queryargs = self.qcl.generic_get(self.apfqname, 'wmsstatus.condor.queryargs') if queryargs: condor_q_id = self.__queryargs2condorqid(queryargs) wmsstatus_plugin_handler = self._getplugin('queue', 'wmsstatus')[0] wmsstatus_cls = wmsstatus_plugin_handler.plugin_class # calls __init__() to instantiate the class if self.qcl.generic_get(self.apfqname, 'wmsstatusplugin') == 'Condor': # In this case the call accepts a second arguments: # an ID used to allow the creation of more than one Singleton # of this category. Remember the WMSStatusPlugin class is a Singleton. # Therefore, we can have more than one # WMS Status Plugin objects, each one shared by a different # bunch of APF Queues. wmsstatus_plugin = wmsstatus_cls(self.apfqueue, condor_q_id=condor_q_id) else: wmsstatus_plugin = wmsstatus_cls(self.apfqueue) # starts the thread wmsstatus_plugin.start() return wmsstatus_plugin def getsubmitplugin(self): batchsubmit_plugin_handler = self._getplugin('queue', 'batchsubmit')[0] batchsubmit_cls = batchsubmit_plugin_handler.plugin_class # calls __init__() to instantiate the class batchsubmit_plugin = batchsubmit_cls(self.apfqueue) return batchsubmit_plugin def getmonitorplugins(self): monitor_plugin_handlers = self._getplugin('queue', 'monitor', self.mcl) # list of classes self.log.debug("monitor_plugin_handlers = %s" % monitor_plugin_handlers) monitor_plugins = [] for monitor_ph in monitor_plugin_handlers: try: monitor_cls = monitor_ph.plugin_class monitor_id = monitor_ph.config_section[1] # the name of the section in the monitor.conf monitor_plugin = monitor_cls(self.apfqueue, monitor_id=monitor_id) monitor_plugins.append(monitor_plugin) except Exception, e: self.log.error("Problem getting monitor plugin %s" % monitor_ph.plugin_name) self.log.debug("Exception: %s" % traceback.format_exc()) return monitor_plugins def __queryargs2condorqid(self, queryargs): """ method to get the name for the condor_q singleton, based on the combination of the values from -name and -pool input options. The entire list of input options come from the queues conf file, and it is recorded in queryargs. """ l = queryargs.split() # convert the string into a list # e.g. ['-name', 'foo', '-pool', 'bar'....] name = '' pool = '' if '-name' in l: name = l[l.index('-name') + 1] if '-pool' in l: pool = l[l.index('-pool') + 1] if name == '' and pool == '': return 'local' else: return '%s:%s' %(name, pool) def _getplugin(self, level, action, config=None): ''' Generic private method to find out the specific plugin to be used depending on the level and action. Level can be: - queue - factory Action can be: - sched - batchstatus - wmsstatus - batchsubmit - monitor If passed, config is an Config object, as defined in autopyfactory.configloader Steps taken are: [a] config is None: This means the content of the variable <action>plugin in self.qcl is directly the actual plugin 1. The name of the item in the config file is calculated. It is supposed to have format <action>plugin. For example: schedplugin, batchstatusplugin, ... 2. The name of the plugin module is calculated. It is supposed to have format <config item><prefix>Plugin. The prefix is taken from a map. For example: SimpleSchedPlugin, CondorBatchStatusPlugin 3. The plugin module is imported, using __import__ 4. The plugin class is retrieved. The name of the class is the same as the name of the module [b] config is not None. This means the content of variable <action>section points to a section in config where the actual plugin can be found. Therefore, there is an extra step to read the value of <action>plugin from the config object. It has been added the option of getting more than one plugins of the same category. The value is comma-split, and one class is retrieve for each field. Then, it will be up to the invoking entity to determine if only one item is expected, and therefore a [0] is needed, or a list of item is possible. Output is a list of 2-items tuples. First item is the name of the plugin. ''' self.log.debug("Starting for action %s" %action) plugin_config_item = '%splugin' %action # i.e. schedplugin plugin_action = action # list of objects PluginHandler plugin_handlers = [] # Get the list of plugin names if config: config_section_item = '%ssection' % action # i.e. monitorsection if self.qcl.has_option(self.apfqname, config_section_item): plugin_names = [] sections = self.qcl.get(self.apfqname, config_section_item) for section in sections.split(','): section = section.strip() plugin_name = config.get(section, plugin_config_item) # i.e. APF (from monitor.conf) plugin_names.append(plugin_name) ph = PluginHandler() ph.plugin_name = plugin_name ph.config_section = [self.apfqname, section] plugin_handlers.append(ph) #else: # return [PluginHandler()] # temporary solution else: if self.qcl.has_option(self.apfqname, plugin_config_item): plugin_names = self.qcl.get(self.apfqname, plugin_config_item) # i.e. Activated plugin_names = plugin_names.split(',') # we convert a string split by comma into a list for plugin_name in plugin_names: if plugin_name != "None": plugin_name = plugin_name.strip() ph = PluginHandler() ph.plugin_name = plugin_name ph.config_section = [self.apfqname] plugin_handlers.append(ph) #else: # return [PluginHandler()] # temporary solution for ph in plugin_handlers: name = ph.plugin_name plugin_module_name = name plugin_path = "autopyfactory.plugins.%s.%s.%s" % ( level, plugin_action, plugin_module_name) self.log.debug("Attempting to import derived classnames: %s" % plugin_path) plugin_module = __import__(plugin_path, globals(), locals(), ["%s" % plugin_module_name]) plugin_class_name = plugin_module_name # the name of the class is always the name of the module self.log.debug("Attempting to return plugin with classname %s" %plugin_class_name) plugin_class = getattr(plugin_module, plugin_class_name) # with getattr() we extract the actual class from the module object ph.plugin_class_name = plugin_class_name ph.plugin_module_name = plugin_module_name ph.plugin_class = plugin_class return plugin_handlers #################################################### # FIXME # -- Too much code duplicated between # FactoryPluginDispatcher and # QueuePluginDispatcher # -- things in the code that only # make sense to queues plugins # -- the concept of "default" here # may be also valid for queues plugins #################################################### class FactoryPluginDispatcher(object): ''' class to create and deliver, on request, the different plug-ins needed for the Factory object. Does not really implement any generic API, each plugin has different characteristics. It is just to take all the code for all Factory plugins in a separate class. ''' def __init__(self, factory): self.log = logging.getLogger('main.factoryplugindispatcher') self.factory = factory self.fcl = factory.fcl self.log.info('QueuePluginDispatcher: Object initialized.') def getconfigplugin(self): """ return a Config plugin to read the APFQueues configuration. Typically from queues.conf or from an URL """ config_plugin_handlers = self._getplugin('factory', 'config', default_plugins='File') # list of PluginHander objects, # as we allow more than one config plugin config_plugins = [] for config_ph in config_plugin_handlers: config_cls = config_ph.plugin_class config_plugin = config_cls(self.factory) # calls __init__() to instantiate the class config_plugins.append(config_plugin) return config_plugins def _getplugin(self, level, action, config=None, default_plugins=None): ''' ''' self.log.debug("Starting for action %s" %action) plugin_config_item = '%splugin' %action # i.e. schedplugin plugin_action = action # list of objects PluginHandler plugin_handlers = [] # Get the list of plugin names if config: config_section_item = '%ssection' % action # i.e. monitorsection if self.qcl.has_option(self.apfqname, config_section_item): plugin_names = [] sections = self.qcl.get(self.apfqname, config_section_item) for section in sections.split(','): section = section.strip() plugin_name = config.get(section, plugin_config_item) # i.e. APF (from monitor.conf) plugin_names.append(plugin_name) ph = PluginHandler() ph.plugin_name = plugin_name ph.config_section = [self.apfqname, section] plugin_handlers.append(ph) #else: # return [PluginHandler()] # temporary solution else: if self.fcl.has_option('Factory', plugin_config_item): plugin_names = self.fcl.get('Factory', plugin_config_item) plugin_names = plugin_names.split(',') # we convert a string split by comma into a list for plugin_name in plugin_names: if plugin_name != "None": plugin_name = plugin_name.strip() ph = PluginHandler() ph.plugin_name = plugin_name ph.config_section = ['Factory'] plugin_handlers.append(ph) # FIXME # too much duplicated code here else: if default_plugins: plugin_names = default_plugins plugin_names = plugin_names.split(',') # we convert a string split by comma into a list for plugin_name in plugin_names: if plugin_name != "None": plugin_name = plugin_name.strip() ph = PluginHandler() ph.plugin_name = plugin_name ph.config_section = ['Factory'] plugin_handlers.append(ph) #else: # return [PluginHandler()] # temporary solution for ph in plugin_handlers: name = ph.plugin_name plugin_module_name = name plugin_path = "autopyfactory.plugins.%s.%s.%s" % ( level, plugin_action, plugin_module_name) self.log.debug("Attempting to import derived classnames: %s" % plugin_path) plugin_module = __import__(plugin_path, globals(), locals(), ["%s" % plugin_module_name]) plugin_class_name = plugin_module_name # the name of the class is always the name of the module self.log.debug("Attempting to return plugin with classname %s" %plugin_class_name) plugin_class = getattr(plugin_module, plugin_class_name) # with getattr() we extract the actual class from the module object ph.plugin_class_name = plugin_class_name ph.plugin_module_name = plugin_module_name ph.plugin_class = plugin_class return plugin_handlers ############################################################################################## # NEW CODE ############################################################################################## # FIXME log = logging.getLogger('main.pluginsdispatcher') def getpluginclass(level, type, name): """ returns the plugin class (not an object) """ log.debug('starting, with values: level=%s, type=%s, name=%s' %(level, type, name)) plugin_path = "autopyfactory.plugins.%s.%s.%s" % (level, type, name) plugin_module = __import__(plugin_path, globals(), locals(), [name]) # NOTE: # an alternative to __import__ would be like this # # plugin_path = "autopyfactory/plugins/%s/%s/%s.py" % (level, type, name) # import imp # plugin_module = imp.load_source(name, plugin_path) # # with getattr() we extract the actual class from the module object # the name of the class is always the name of the module plugin_class = getattr(plugin_module, name) log.info('returning plugin class %s' %plugin_class) return plugin_class def initializeplugin(plugin_class, *args, **kwargs): """ initializes an object for a given plugin class and returns the object, or raises an exception in case of failure """ log.debug('starting, with values plugin_class=%s, *args=%s, **kwargs=%s' %(plugin_class, args, kwargs)) try: plugin_object = plugin_class(*args, **kwargs) log.info('returning object for plugin class %s' %plugin_class) return plugin_object except: log.error('there was an error initializing an object for plugin class %s. Raising an exception.' %plugin_class) raise Exception def getpluginnames(conf, section, type, auxconf=None): """ gets the name of the plugins to be retrieved from a ConfigParser object Sometimes the name of the plugin is not in the ConfigParser object. Instead of that, the ConfigParser objects contains the name of a section in a secondary config file (auxconf) """ log.debug('starting, with values conf=%s, section=%s, type=%s, auxconf=%s' %(conf, section, type, auxconf)) names = [] if auxconf: auxconf_section_item = '%ssection' % type # i.e. monitorsection log.info('the auxiliar section name is %s' %auxconf_section_item) if conf.has_option(section, auxconf_section_item): sections = conf.get(section, auxconf_section_item) sections = [section.strip() for section in sections.split(',') if section.strip() != "None"] for section in sections: log.info('getting plugin names for section %s' %section) # recursive call to the same getpluginname() function # but passing the auxconf ConfigParser as primary conf newnames = getpluginnames(auxconf, section, type) log.info('new plugin names for section %s are: %s' %(section, newnames)) names += newnames else: plugin_config_item = '%splugin' %type # i.e. schedplugin log.info('the section item is %s' %plugin_config_item) if conf.has_option(section, plugin_config_item): names = conf.get(section, plugin_config_item) # i.e. Activated # and we convert a string split by comma into a list names = [name.strip() for name in names.split(',') if name.strip() != "None"] log.info('new plugin names are: %s' %names) log.info('returning list of plugin names: %s' %names) return names
apache-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 421, 199, 2344, 199, 578, 543, 1233, 367, 8963, 10041, 199, 2344, 199, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 646, 5190, 199, 199, 504, 10933, 492, 10933, 199, 199, 3, 504, 6384, 927, 3702, 14, 888, 3422, 492, 4094, 12, 4094, 2988, 421, 199, 533, 11349, 2461, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 2718, 63, 354, 275, 488, 267, 291, 14, 2718, 63, 533, 63, 354, 275, 488, 267, 291, 14, 2718, 63, 578, 63, 354, 275, 488, 267, 291, 14, 888, 63, 2792, 275, 942, 267, 291, 14, 2718, 63, 533, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 308, 275, 3087, 267, 308, 847, 298, 2718, 63, 354, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 354, 267, 308, 847, 298, 2718, 63, 533, 63, 354, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 533, 63, 354, 267, 308, 847, 298, 2718, 63, 578, 63, 354, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 578, 63, 354, 267, 308, 847, 298, 2718, 63, 2792, 275, 450, 83, 298, 450, 291, 14, 888, 63, 2792, 267, 308, 847, 298, 2718, 63, 533, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 533, 267, 372, 308, 421, 199, 533, 10703, 5061, 15461, 8, 785, 304, 272, 1449, 272, 1021, 370, 1218, 436, 28503, 12, 641, 1056, 12, 314, 3365, 14202, 13, 3617, 4346, 367, 314, 10319, 38, 3737, 83, 14, 272, 12078, 440, 7710, 5669, 1263, 7809, 3261, 12, 1924, 3589, 965, 3365, 2735, 6236, 8323, 14, 272, 2779, 365, 2951, 370, 5452, 1006, 314, 1233, 367, 1006, 10319, 38, 3737, 8963, 315, 282, 7396, 1021, 14, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 2771, 70, 1825, 304, 398, 291, 14, 793, 275, 2050, 14, 5572, 360, 973, 14, 1825, 2718, 14913, 358, 398, 291, 14, 439, 70, 1825, 275, 2771, 70, 1825, 267, 291, 14, 81, 429, 275, 2771, 70, 1825, 14, 81, 429, 267, 291, 14, 70, 429, 275, 2771, 70, 1825, 14, 70, 429, 267, 291, 14, 77, 429, 275, 2771, 70, 1825, 14, 77, 429, 2728, 291, 14, 439, 11878, 354, 275, 2771, 70, 1825, 14, 439, 11878, 354, 398, 291, 14, 793, 14, 1757, 480, 28277, 10286, 8963, 531, 267, 291, 14, 10487, 5265, 275, 291, 14, 362, 10487, 5265, 342, 267, 291, 14, 793, 14, 1757, 480, 13662, 450, 68, 10286, 8963, 2, 450, 822, 8, 277, 14, 10487, 5265, 430, 267, 291, 14, 793, 14, 1757, 480, 28277, 3522, 1205, 3589, 531, 267, 291, 14, 2912, 1205, 2718, 275, 221, 291, 14, 362, 2912, 1205, 2718, 342, 267, 291, 14, 793, 14, 1757, 480, 28277, 3522, 1205, 3589, 531, 18418, 291, 14, 30297, 1205, 2718, 275, 221, 291, 14, 362, 30297, 1205, 2718, 342, 267, 291, 14, 793, 14, 1757, 480, 28277, 11482, 3589, 531, 267, 291, 14, 7275, 2718, 275, 221, 291, 14, 362, 7275, 2718, 342, 267, 291, 14, 793, 14, 1757, 480, 28277, 8372, 8963, 531, 267, 291, 14, 7157, 5265, 275, 291, 14, 362, 7157, 5265, 342, 267, 291, 14, 793, 14, 1757, 480, 13662, 450, 68, 8372, 8963, 2, 450, 822, 8, 277, 14, 7157, 5265, 430, 398, 291, 14, 793, 14, 815, 360, 3737, 5061, 15461, 26, 6935, 10038, 2659, 339, 347, 7545, 1809, 5265, 8, 277, 304, 398, 11899, 63, 2718, 63, 5586, 275, 291, 423, 362, 2718, 360, 1825, 297, 283, 10487, 358, 221, 327, 769, 402, 11349, 2461, 2251, 10028, 327, 3390, 626, 367, 314, 428, 1809, 4637, 12, 10028, 327, 781, 2040, 1655, 2419, 1373, 3589, 221, 10028, 327, 334, 1294, 701, 10029, 315, 314, 1101, 570, 9, 267, 11899, 63, 5265, 275, 942, 267, 367, 11899, 63, 838, 315, 11899, 63, 2718, 63, 5586, 26, 288, 11899, 63, 1886, 275, 11899, 63, 838, 14, 2718, 63, 533, 288, 11899, 63, 2718, 275, 11899, 63, 1886, 8, 277, 14, 439, 70, 1825, 9, 221, 327, 4882, 636, 826, 4533, 370, 17321, 314, 1021, 288, 11899, 63, 5265, 14, 740, 8, 8874, 63, 2718, 9, 267, 372, 11899, 63, 5265, 339, 347, 664, 2912, 1205, 2718, 8, 277, 304, 398, 9288, 269, 63, 81, 63, 344, 275, 283, 1832, 7, 267, 340, 291, 14, 81, 429, 14, 6767, 63, 362, 8, 277, 14, 439, 11878, 354, 12, 283, 2912, 1205, 2718, 358, 508, 283, 23735, 269, 356, 7205, 1827, 589, 275, 291, 14, 81, 429, 14, 6767, 63, 362, 8, 277, 14, 439, 11878, 354, 12, 283, 2912, 1205, 14, 2067, 269, 14, 1131, 589, 358, 288, 340, 1827, 589, 26, 490, 9288, 269, 63, 81, 63, 344, 275, 291, 855, 1131, 589, 18, 2067, 269, 81, 344, 8, 1131, 589, 9, 27144, 3522, 1205, 63, 2718, 63, 2232, 275, 291, 423, 362, 2718, 360, 1825, 297, 283, 2912, 1205, 5832, 16, 61, 267, 3522, 1205, 63, 1886, 275, 3522, 1205, 63, 2718, 63, 2232, 14, 2718, 63, 533, 398, 327, 4882, 636, 826, 4533, 370, 17321, 314, 1021, 267, 327, 1010, 642, 1930, 314, 1240, 11479, 282, 3499, 2368, 26, 267, 327, 259, 376, 2870, 1202, 370, 2040, 314, 7143, 402, 1655, 2419, 1373, 13050, 1860, 267, 327, 259, 402, 642, 4637, 14, 31859, 314, 17206, 3694, 5061, 1021, 365, 282, 13050, 1860, 14, 4960, 327, 259, 21039, 12, 781, 883, 1172, 1655, 2419, 1373, 267, 327, 259, 17206, 9795, 11349, 2251, 12, 1924, 1373, 5709, 701, 282, 3365, 267, 327, 259, 22219, 402, 10319, 38, 10703, 83, 14, 267, 3522, 1205, 63, 2718, 275, 3522, 1205, 63, 1886, 8, 277, 14, 439, 70, 1825, 12, 9288, 269, 63, 81, 63, 344, 29, 2067, 269, 63, 81, 63, 344, 9, 257, 398, 327, 9174, 314, 2462, 267, 3522, 1205, 63, 2718, 14, 928, 342, 221, 2728, 372, 3522, 1205, 63, 2718, 16478, 6754, 318, 664, 30297, 1205, 2718, 8, 277, 304, 272, 6754, 272, 6754, 259, 336, 706, 1205, 63, 2718, 63, 2232, 275, 291, 423, 362, 2718, 360, 30297, 1205, 5832, 16, 61, 272, 6754, 259, 336, 706, 1205, 63, 1886, 275, 336, 706, 1205, 63, 2718, 63, 2232, 14, 2718 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 421, 199, 2344, 199, 578, 543, 1233, 367, 8963, 10041, 199, 2344, 199, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 646, 5190, 199, 199, 504, 10933, 492, 10933, 199, 199, 3, 504, 6384, 927, 3702, 14, 888, 3422, 492, 4094, 12, 4094, 2988, 421, 199, 533, 11349, 2461, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 2718, 63, 354, 275, 488, 267, 291, 14, 2718, 63, 533, 63, 354, 275, 488, 267, 291, 14, 2718, 63, 578, 63, 354, 275, 488, 267, 291, 14, 888, 63, 2792, 275, 942, 267, 291, 14, 2718, 63, 533, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 308, 275, 3087, 267, 308, 847, 298, 2718, 63, 354, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 354, 267, 308, 847, 298, 2718, 63, 533, 63, 354, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 533, 63, 354, 267, 308, 847, 298, 2718, 63, 578, 63, 354, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 578, 63, 354, 267, 308, 847, 298, 2718, 63, 2792, 275, 450, 83, 298, 450, 291, 14, 888, 63, 2792, 267, 308, 847, 298, 2718, 63, 533, 275, 450, 83, 298, 450, 291, 14, 2718, 63, 533, 267, 372, 308, 421, 199, 533, 10703, 5061, 15461, 8, 785, 304, 272, 1449, 272, 1021, 370, 1218, 436, 28503, 12, 641, 1056, 12, 314, 3365, 14202, 13, 3617, 4346, 367, 314, 10319, 38, 3737, 83, 14, 272, 12078, 440, 7710, 5669, 1263, 7809, 3261, 12, 1924, 3589, 965, 3365, 2735, 6236, 8323, 14, 272, 2779, 365, 2951, 370, 5452, 1006, 314, 1233, 367, 1006, 10319, 38, 3737, 8963, 315, 282, 7396, 1021, 14, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 2771, 70, 1825, 304, 398, 291, 14, 793, 275, 2050, 14, 5572, 360, 973, 14, 1825, 2718, 14913, 358, 398, 291, 14, 439, 70, 1825, 275, 2771, 70, 1825, 267, 291, 14, 81, 429, 275, 2771, 70, 1825, 14, 81, 429, 267, 291, 14, 70, 429, 275, 2771, 70, 1825, 14, 70, 429, 267, 291, 14, 77, 429, 275, 2771, 70, 1825, 14, 77, 429, 2728, 291, 14, 439, 11878, 354, 275, 2771, 70, 1825, 14, 439, 11878, 354, 398, 291, 14, 793, 14, 1757, 480, 28277, 10286, 8963, 531, 267, 291, 14, 10487, 5265, 275, 291, 14, 362, 10487, 5265, 342, 267, 291, 14, 793, 14, 1757, 480, 13662, 450, 68, 10286, 8963, 2, 450, 822, 8, 277, 14, 10487, 5265, 430, 267, 291, 14, 793, 14, 1757, 480, 28277, 3522, 1205, 3589, 531, 267, 291, 14, 2912, 1205, 2718, 275, 221, 291, 14, 362, 2912, 1205, 2718, 342, 267, 291, 14, 793, 14, 1757, 480, 28277, 3522, 1205, 3589, 531, 18418, 291, 14, 30297, 1205, 2718, 275, 221, 291, 14, 362, 30297, 1205, 2718, 342, 267, 291, 14, 793, 14, 1757, 480, 28277, 11482, 3589, 531, 267, 291, 14, 7275, 2718, 275, 221, 291, 14, 362, 7275, 2718, 342, 267, 291, 14, 793, 14, 1757, 480, 28277, 8372, 8963, 531, 267, 291, 14, 7157, 5265, 275, 291, 14, 362, 7157, 5265, 342, 267, 291, 14, 793, 14, 1757, 480, 13662, 450, 68, 8372, 8963, 2, 450, 822, 8, 277, 14, 7157, 5265, 430, 398, 291, 14, 793, 14, 815, 360, 3737, 5061, 15461, 26, 6935, 10038, 2659, 339, 347, 7545, 1809, 5265, 8, 277, 304, 398, 11899, 63, 2718, 63, 5586, 275, 291, 423, 362, 2718, 360, 1825, 297, 283, 10487, 358, 221, 327, 769, 402, 11349, 2461, 2251, 10028, 327, 3390, 626, 367, 314, 428, 1809, 4637, 12, 10028, 327, 781, 2040, 1655, 2419, 1373, 3589, 221, 10028, 327, 334, 1294, 701, 10029, 315, 314, 1101, 570, 9, 267, 11899, 63, 5265, 275, 942, 267, 367, 11899, 63, 838, 315, 11899, 63, 2718, 63, 5586, 26, 288, 11899, 63, 1886, 275, 11899, 63, 838, 14, 2718, 63, 533, 288, 11899, 63, 2718, 275, 11899, 63, 1886, 8, 277, 14, 439, 70, 1825, 9, 221, 327, 4882, 636, 826, 4533, 370, 17321, 314, 1021, 288, 11899, 63, 5265, 14, 740, 8, 8874, 63, 2718, 9, 267, 372, 11899, 63, 5265, 339, 347, 664, 2912, 1205, 2718, 8, 277, 304, 398, 9288, 269, 63, 81, 63, 344, 275, 283, 1832, 7, 267, 340, 291, 14, 81, 429, 14, 6767, 63, 362, 8, 277, 14, 439, 11878, 354, 12, 283, 2912, 1205, 2718, 358, 508, 283, 23735, 269, 356, 7205, 1827, 589, 275, 291, 14, 81, 429, 14, 6767, 63, 362, 8, 277, 14, 439, 11878, 354, 12, 283, 2912, 1205, 14, 2067, 269, 14, 1131, 589, 358, 288, 340, 1827, 589, 26, 490, 9288, 269, 63, 81, 63, 344, 275, 291, 855, 1131, 589, 18, 2067, 269, 81, 344, 8, 1131, 589, 9, 27144, 3522, 1205, 63, 2718, 63, 2232, 275, 291, 423, 362, 2718, 360, 1825, 297, 283, 2912, 1205, 5832, 16, 61, 267, 3522, 1205, 63, 1886, 275, 3522, 1205, 63, 2718, 63, 2232, 14, 2718, 63, 533, 398, 327, 4882, 636, 826, 4533, 370, 17321, 314, 1021, 267, 327, 1010, 642, 1930, 314, 1240, 11479, 282, 3499, 2368, 26, 267, 327, 259, 376, 2870, 1202, 370, 2040, 314, 7143, 402, 1655, 2419, 1373, 13050, 1860, 267, 327, 259, 402, 642, 4637, 14, 31859, 314, 17206, 3694, 5061, 1021, 365, 282, 13050, 1860, 14, 4960, 327, 259, 21039, 12, 781, 883, 1172, 1655, 2419, 1373, 267, 327, 259, 17206, 9795, 11349, 2251, 12, 1924, 1373, 5709, 701, 282, 3365, 267, 327, 259, 22219, 402, 10319, 38, 10703, 83, 14, 267, 3522, 1205, 63, 2718, 275, 3522, 1205, 63, 1886, 8, 277, 14, 439, 70, 1825, 12, 9288, 269, 63, 81, 63, 344, 29, 2067, 269, 63, 81, 63, 344, 9, 257, 398, 327, 9174, 314, 2462, 267, 3522, 1205, 63, 2718, 14, 928, 342, 221, 2728, 372, 3522, 1205, 63, 2718, 16478, 6754, 318, 664, 30297, 1205, 2718, 8, 277, 304, 272, 6754, 272, 6754, 259, 336, 706, 1205, 63, 2718, 63, 2232, 275, 291, 423, 362, 2718, 360, 30297, 1205, 5832, 16, 61, 272, 6754, 259, 336, 706, 1205, 63, 1886, 275, 336, 706, 1205, 63, 2718, 63, 2232, 14, 2718, 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, 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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 ]
bladehd/jieba
test/test_whoosh.py
64
1734
# -*- coding: UTF-8 -*- from __future__ import unicode_literals import sys,os sys.path.append("../") from whoosh.index import create_in,open_dir from whoosh.fields import * from whoosh.qparser import QueryParser from jieba.analyse import ChineseAnalyzer analyzer = ChineseAnalyzer() schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer)) if not os.path.exists("tmp"): os.mkdir("tmp") ix = create_in("tmp", schema) # for create new index #ix = open_dir("tmp") # for read only writer = ix.writer() writer.add_document( title="document1", path="/a", content="This is the first document we’ve added!" ) writer.add_document( title="document2", path="/b", content="The second one 你 中文测试中文 is even more interesting! 吃水果" ) writer.add_document( title="document3", path="/c", content="买水果然后来世博园。" ) writer.add_document( title="document4", path="/c", content="工信处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作" ) writer.add_document( title="document4", path="/c", content="咱俩交换一下吧。" ) writer.commit() searcher = ix.searcher() parser = QueryParser("content", schema=ix.schema) for keyword in ("水果世博园","你","first","中文","交换机","交换"): print("result of ",keyword) q = parser.parse(keyword) results = searcher.search(q) for hit in results: print(hit.highlights("content")) print("="*10) for t in analyzer("我的好朋友是李明;我爱北京天安门;IBM和Microsoft; I have a dream. this is intetesting and interested me a lot"): print(t.text)
mit
[ 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 984, 12, 736, 199, 1274, 14, 515, 14, 740, 480, 5093, 531, 199, 504, 3963, 22267, 14, 1080, 492, 1218, 63, 262, 12, 1490, 63, 694, 199, 504, 3963, 22267, 14, 955, 492, 627, 199, 504, 3963, 22267, 14, 81, 2087, 492, 8133, 2842, 199, 199, 504, 1335, 1873, 2470, 14, 26943, 492, 2799, 26883, 17606, 199, 199, 17965, 275, 2799, 26883, 17606, 342, 199, 199, 3629, 275, 13268, 8, 1213, 29, 3876, 8, 16431, 29, 549, 395, 931, 29, 998, 8, 16431, 29, 549, 395, 1564, 29, 3876, 8, 16431, 29, 549, 12, 24608, 29, 17965, 430, 199, 692, 440, 747, 14, 515, 14, 2444, 480, 2791, 2349, 272, 747, 14, 8215, 480, 2791, 531, 199, 199, 1148, 275, 1218, 63, 262, 480, 2791, 401, 4177, 9, 327, 367, 1218, 892, 1478, 199, 3, 1148, 275, 1551, 63, 694, 480, 2791, 531, 327, 367, 1586, 1454, 199, 5491, 275, 20593, 14, 5491, 342, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 17, 401, 272, 931, 9555, 65, 401, 272, 1564, 628, 2765, 365, 314, 1642, 2213, 781, 21045, 432, 3483, 9539, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 18, 401, 272, 931, 9555, 66, 401, 272, 1564, 628, 1918, 3499, 1373, 221, 11046, 255, 221, 17088, 20918, 19451, 234, 8400, 244, 17088, 20918, 365, 2755, 1655, 19604, 1, 7094, 239, 226, 32226, 19349, 251, 2, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 19, 401, 272, 931, 9555, 67, 401, 272, 1564, 628, 32677, 32226, 19349, 251, 164, 227, 115, 30368, 15771, 99, 4344, 245, 10450, 249, 14339, 256, 20061, 2, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 20, 401, 272, 931, 9555, 67, 401, 272, 1564, 628, 18189, 99, 23305, 11546, 227, 25440, 112, 16322, 111, 6923, 234, 28285, 238, 31452, 20134, 13201, 230, 24233, 27289, 253, 19012, 240, 10270, 98, 166, 25315, 22274, 6923, 111, 6075, 97, 11112, 10192, 1194, 6075, 97, 11112, 17109, 96, 25138, 24181, 232, 11825, 223, 6587, 108, 17182, 101, 162, 248, 102, 15054, 8106, 10270, 232, 29655, 228, 18189, 99, 21927, 2, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 20, 401, 272, 931, 9555, 67, 401, 272, 1564, 628, 28118, 110, 13764, 103, 11112, 17109, 96, 9372, 24233, 8197, 101, 20061, 2, 199, 9, 199, 199, 5491, 14, 3543, 342, 199, 24994, 275, 20593, 14, 24994, 342, 199, 2087, 275, 8133, 2842, 480, 1317, 401, 4177, 29, 1148, 14, 3629, 9, 199, 199, 509, 4252, 315, 1689, 32226, 19349, 251, 4344, 245, 10450, 249, 14339, 256, 2266, 11046, 255, 2266, 2246, 2266, 17088, 20918, 2266, 11112, 17109, 96, 25138, 2266, 11112, 17109, 96, 2349, 272, 870, 480, 1099, 402, 3872, 6691, 9, 272, 1894, 275, 1798, 14, 1122, 8, 6691, 9, 272, 2058, 275, 2754, 281, 14, 1733, 8, 81, 9, 272, 367, 9793, 315, 2058, 26, 267, 870, 8, 12948, 14, 14337, 83, 480, 1317, 2237, 272, 870, 480, 32103, 709, 9, 199, 199, 509, 307, 315, 24608, 480, 9077, 240, 8106, 25440, 122, 6587, 234, 6075, 234, 9729, 15771, 237, 6812, 237, 27, 9077, 240, 164, 231, 110, 21018, 246, 6923, 106, 11546, 103, 10270, 232, 19248, 102, 27, 2100, 45, 30557, 12940, 27, 473, 1172, 282, 366, 1091, 14, 642, 365, 4661, 4776, 436, 22201, 562, 282, 13918, 2349, 272, 870, 8, 84, 14, 505, 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 ]
[ 1882, 2803, 26, 9094, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 984, 12, 736, 199, 1274, 14, 515, 14, 740, 480, 5093, 531, 199, 504, 3963, 22267, 14, 1080, 492, 1218, 63, 262, 12, 1490, 63, 694, 199, 504, 3963, 22267, 14, 955, 492, 627, 199, 504, 3963, 22267, 14, 81, 2087, 492, 8133, 2842, 199, 199, 504, 1335, 1873, 2470, 14, 26943, 492, 2799, 26883, 17606, 199, 199, 17965, 275, 2799, 26883, 17606, 342, 199, 199, 3629, 275, 13268, 8, 1213, 29, 3876, 8, 16431, 29, 549, 395, 931, 29, 998, 8, 16431, 29, 549, 395, 1564, 29, 3876, 8, 16431, 29, 549, 12, 24608, 29, 17965, 430, 199, 692, 440, 747, 14, 515, 14, 2444, 480, 2791, 2349, 272, 747, 14, 8215, 480, 2791, 531, 199, 199, 1148, 275, 1218, 63, 262, 480, 2791, 401, 4177, 9, 327, 367, 1218, 892, 1478, 199, 3, 1148, 275, 1551, 63, 694, 480, 2791, 531, 327, 367, 1586, 1454, 199, 5491, 275, 20593, 14, 5491, 342, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 17, 401, 272, 931, 9555, 65, 401, 272, 1564, 628, 2765, 365, 314, 1642, 2213, 781, 21045, 432, 3483, 9539, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 18, 401, 272, 931, 9555, 66, 401, 272, 1564, 628, 1918, 3499, 1373, 221, 11046, 255, 221, 17088, 20918, 19451, 234, 8400, 244, 17088, 20918, 365, 2755, 1655, 19604, 1, 7094, 239, 226, 32226, 19349, 251, 2, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 19, 401, 272, 931, 9555, 67, 401, 272, 1564, 628, 32677, 32226, 19349, 251, 164, 227, 115, 30368, 15771, 99, 4344, 245, 10450, 249, 14339, 256, 20061, 2, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 20, 401, 272, 931, 9555, 67, 401, 272, 1564, 628, 18189, 99, 23305, 11546, 227, 25440, 112, 16322, 111, 6923, 234, 28285, 238, 31452, 20134, 13201, 230, 24233, 27289, 253, 19012, 240, 10270, 98, 166, 25315, 22274, 6923, 111, 6075, 97, 11112, 10192, 1194, 6075, 97, 11112, 17109, 96, 25138, 24181, 232, 11825, 223, 6587, 108, 17182, 101, 162, 248, 102, 15054, 8106, 10270, 232, 29655, 228, 18189, 99, 21927, 2, 199, 9, 199, 199, 5491, 14, 525, 63, 3554, 8, 272, 2538, 628, 3554, 20, 401, 272, 931, 9555, 67, 401, 272, 1564, 628, 28118, 110, 13764, 103, 11112, 17109, 96, 9372, 24233, 8197, 101, 20061, 2, 199, 9, 199, 199, 5491, 14, 3543, 342, 199, 24994, 275, 20593, 14, 24994, 342, 199, 2087, 275, 8133, 2842, 480, 1317, 401, 4177, 29, 1148, 14, 3629, 9, 199, 199, 509, 4252, 315, 1689, 32226, 19349, 251, 4344, 245, 10450, 249, 14339, 256, 2266, 11046, 255, 2266, 2246, 2266, 17088, 20918, 2266, 11112, 17109, 96, 25138, 2266, 11112, 17109, 96, 2349, 272, 870, 480, 1099, 402, 3872, 6691, 9, 272, 1894, 275, 1798, 14, 1122, 8, 6691, 9, 272, 2058, 275, 2754, 281, 14, 1733, 8, 81, 9, 272, 367, 9793, 315, 2058, 26, 267, 870, 8, 12948, 14, 14337, 83, 480, 1317, 2237, 272, 870, 480, 32103, 709, 9, 199, 199, 509, 307, 315, 24608, 480, 9077, 240, 8106, 25440, 122, 6587, 234, 6075, 234, 9729, 15771, 237, 6812, 237, 27, 9077, 240, 164, 231, 110, 21018, 246, 6923, 106, 11546, 103, 10270, 232, 19248, 102, 27, 2100, 45, 30557, 12940, 27, 473, 1172, 282, 366, 1091, 14, 642, 365, 4661, 4776, 436, 22201, 562, 282, 13918, 2349, 272, 870, 8, 84, 14, 505, 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, 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, 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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 ]
yongshengwang/hue
desktop/core/ext-py/markdown/markdown/extensions/extra.py
130
1761
#!/usr/bin/env python """ Python-Markdown Extra Extension =============================== A compilation of various Python-Markdown extensions that imitates [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/). Note that each of the individual extensions still need to be available on your PYTHONPATH. This extension simply wraps them all up as a convenience so that only one extension needs to be listed when initiating Markdown. See the documentation for each individual extension for specifics about that extension. In the event that one or more of the supported extensions are not available for import, Markdown will issue a warning and simply continue without that extension. There may be additional extensions that are distributed with Python-Markdown that are not included here in Extra. Those extensions are not part of PHP Markdown Extra, and therefore, not part of Python-Markdown Extra. If you really would like Extra to include additional extensions, we suggest creating your own clone of Extra under a differant name. You could also edit the `extensions` global variable defined below, but be aware that such changes may be lost when you upgrade to any future version of Python-Markdown. """ import markdown extensions = ['fenced_code', 'footnotes', 'headerid', 'def_list', 'tables', 'abbr', ] class ExtraExtension(markdown.Extension): """ Add various extensions to Markdown class.""" def extendMarkdown(self, md, md_globals): """ Register extension instances. """ md.registerExtensions(extensions, self.config) def makeExtension(configs={}): return ExtraExtension(configs=dict(configs))
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 199, 4718, 13, 30916, 11177, 13282, 199, 1280, 16964, 199, 199, 33, 18653, 402, 7750, 2018, 13, 30916, 5478, 626, 284, 1147, 2335, 199, 59, 31300, 24537, 11177, 8738, 1014, 921, 2664, 595, 276, 14, 957, 15, 6776, 15, 8624, 13, 15653, 15, 2911, 15, 680, 199, 199, 7443, 626, 1924, 402, 314, 8212, 5478, 5139, 1929, 370, 506, 2808, 199, 265, 2195, 31176, 14, 961, 3329, 9329, 14018, 3062, 1006, 1536, 465, 282, 221, 199, 388, 23329, 880, 626, 1454, 1373, 3329, 4839, 370, 506, 10532, 1380, 199, 14188, 1958, 24537, 14, 1666, 314, 3794, 367, 1924, 8212, 199, 3435, 367, 1106, 329, 1259, 3595, 626, 3329, 14, 199, 199, 607, 314, 1566, 626, 1373, 503, 1655, 402, 314, 3748, 5478, 787, 440, 221, 199, 4561, 367, 492, 12, 24537, 911, 4976, 282, 5721, 436, 9329, 1980, 221, 199, 7395, 626, 3329, 14, 9948, 199, 10924, 1443, 506, 4722, 5478, 626, 787, 1854, 543, 221, 199, 4718, 13, 30916, 626, 787, 440, 5120, 2348, 315, 11177, 14, 18049, 261, 5478, 199, 1530, 440, 1777, 402, 510, 18635, 24537, 11177, 12, 436, 16119, 12, 440, 1777, 402, 199, 4718, 13, 30916, 11177, 14, 982, 1265, 7710, 3955, 2839, 11177, 370, 2387, 199, 8460, 5478, 12, 781, 18453, 6425, 2195, 5705, 7289, 402, 11177, 199, 7138, 282, 14460, 867, 536, 14, 2047, 4293, 2597, 5283, 314, 658, 5359, 64, 2288, 221, 199, 1975, 3247, 5084, 12, 1325, 506, 20381, 626, 4066, 4493, 1443, 506, 14669, 221, 199, 6526, 1265, 10754, 370, 1263, 6466, 1015, 402, 2018, 13, 30916, 14, 199, 199, 624, 199, 199, 646, 18502, 199, 199, 5359, 275, 788, 28306, 68, 63, 600, 297, 1598, 283, 11407, 5983, 297, 1598, 283, 426, 9587, 1677, 297, 1598, 283, 318, 63, 513, 297, 1598, 283, 5987, 297, 1598, 283, 20787, 297, 1598, 1622, 2049, 199, 199, 533, 11177, 6382, 8, 15653, 14, 6382, 304, 272, 408, 2654, 7750, 5478, 370, 24537, 1021, 1041, 339, 347, 12247, 30916, 8, 277, 12, 6128, 12, 6128, 63, 8473, 304, 267, 408, 11828, 3329, 4454, 14, 408, 267, 6128, 14, 2683, 10597, 8, 5359, 12, 291, 14, 888, 9, 199, 199, 318, 1852, 6382, 8, 7532, 16420, 272, 372, 11177, 6382, 8, 7532, 29, 807, 8, 7532, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 199, 4718, 13, 30916, 11177, 13282, 199, 1280, 16964, 199, 199, 33, 18653, 402, 7750, 2018, 13, 30916, 5478, 626, 284, 1147, 2335, 199, 59, 31300, 24537, 11177, 8738, 1014, 921, 2664, 595, 276, 14, 957, 15, 6776, 15, 8624, 13, 15653, 15, 2911, 15, 680, 199, 199, 7443, 626, 1924, 402, 314, 8212, 5478, 5139, 1929, 370, 506, 2808, 199, 265, 2195, 31176, 14, 961, 3329, 9329, 14018, 3062, 1006, 1536, 465, 282, 221, 199, 388, 23329, 880, 626, 1454, 1373, 3329, 4839, 370, 506, 10532, 1380, 199, 14188, 1958, 24537, 14, 1666, 314, 3794, 367, 1924, 8212, 199, 3435, 367, 1106, 329, 1259, 3595, 626, 3329, 14, 199, 199, 607, 314, 1566, 626, 1373, 503, 1655, 402, 314, 3748, 5478, 787, 440, 221, 199, 4561, 367, 492, 12, 24537, 911, 4976, 282, 5721, 436, 9329, 1980, 221, 199, 7395, 626, 3329, 14, 9948, 199, 10924, 1443, 506, 4722, 5478, 626, 787, 1854, 543, 221, 199, 4718, 13, 30916, 626, 787, 440, 5120, 2348, 315, 11177, 14, 18049, 261, 5478, 199, 1530, 440, 1777, 402, 510, 18635, 24537, 11177, 12, 436, 16119, 12, 440, 1777, 402, 199, 4718, 13, 30916, 11177, 14, 982, 1265, 7710, 3955, 2839, 11177, 370, 2387, 199, 8460, 5478, 12, 781, 18453, 6425, 2195, 5705, 7289, 402, 11177, 199, 7138, 282, 14460, 867, 536, 14, 2047, 4293, 2597, 5283, 314, 658, 5359, 64, 2288, 221, 199, 1975, 3247, 5084, 12, 1325, 506, 20381, 626, 4066, 4493, 1443, 506, 14669, 221, 199, 6526, 1265, 10754, 370, 1263, 6466, 1015, 402, 2018, 13, 30916, 14, 199, 199, 624, 199, 199, 646, 18502, 199, 199, 5359, 275, 788, 28306, 68, 63, 600, 297, 1598, 283, 11407, 5983, 297, 1598, 283, 426, 9587, 1677, 297, 1598, 283, 318, 63, 513, 297, 1598, 283, 5987, 297, 1598, 283, 20787, 297, 1598, 1622, 2049, 199, 199, 533, 11177, 6382, 8, 15653, 14, 6382, 304, 272, 408, 2654, 7750, 5478, 370, 24537, 1021, 1041, 339, 347, 12247, 30916, 8, 277, 12, 6128, 12, 6128, 63, 8473, 304, 267, 408, 11828, 3329, 4454, 14, 408, 267, 6128, 14, 2683, 10597, 8, 5359, 12, 291, 14, 888, 9, 199, 199, 318, 1852, 6382, 8, 7532, 16420, 272, 372, 11177, 6382, 8, 7532, 29, 807, 8, 7532, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
vjraitila/alfred-issues
src/requests/packages/urllib3/util/url.py
713
5879
from __future__ import absolute_import from collections import namedtuple from ..exceptions import LocationParseError url_attrs = ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment'] class Url(namedtuple('Url', url_attrs)): """ Datastructure for representing an HTTP URL. Used as a return value for :func:`parse_url`. """ slots = () def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None, query=None, fragment=None): if path and not path.startswith('/'): path = '/' + path return super(Url, cls).__new__(cls, scheme, auth, host, port, path, query, fragment) @property def hostname(self): """For backwards-compatibility with urlparse. We're nice like that.""" return self.host @property def request_uri(self): """Absolute path including the query string.""" uri = self.path or '/' if self.query is not None: uri += '?' + self.query return uri @property def netloc(self): """Network location including host and port""" if self.port: return '%s:%d' % (self.host, self.port) return self.host @property def url(self): """ Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). Example: :: >>> U = parse_url('http://google.com/mail/') >>> U.url 'http://google.com/mail/' >>> Url('http', 'username:password', 'host.com', 80, ... '/path', 'query', 'fragment').url 'http://username:password@host.com:80/path?query#fragment' """ scheme, auth, host, port, path, query, fragment = self url = '' # We use "is not None" we want things to happen with empty strings (or 0 port) if scheme is not None: url += scheme + '://' if auth is not None: url += auth + '@' if host is not None: url += host if port is not None: url += ':' + str(port) if path is not None: url += path if query is not None: url += '?' + query if fragment is not None: url += '#' + fragment return url def __str__(self): return self.url def split_first(s, delims): """ Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz', '/') >>> split_first('foo/bar?baz', '123') ('foo/bar?baz', '', None) Scales linearly with number of delims. Not ideal for large number of delims. """ min_idx = None min_delim = None for d in delims: idx = s.find(d) if idx < 0: continue if min_idx is None or idx < min_idx: min_idx = idx min_delim = d if min_idx is None or min_idx < 0: return s, '', None return s[:min_idx], s[min_idx + 1:], min_delim def parse_url(url): """ Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. Partly backwards-compatible with :mod:`urlparse`. Example:: >>> parse_url('http://google.com/mail/') Url(scheme='http', host='google.com', port=None, path='/mail/', ...) >>> parse_url('google.com:80') Url(scheme=None, host='google.com', port=80, path=None, ...) >>> parse_url('/foo?bar') Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...) """ # While this code has overlap with stdlib's urlparse, it is much # simplified for our needs and less annoying. # Additionally, this implementations does silly things to be optimal # on CPython. if not url: # Empty return Url() scheme = None auth = None host = None port = None path = None fragment = None query = None # Scheme if '://' in url: scheme, url = url.split('://', 1) # Find the earliest Authority Terminator # (http://tools.ietf.org/html/rfc3986#section-3.2) url, path_, delim = split_first(url, ['/', '?', '#']) if delim: # Reassemble the path path = delim + path_ # Auth if '@' in url: # Last '@' denotes end of auth part auth, url = url.rsplit('@', 1) # IPv6 if url and url[0] == '[': host, url = url.split(']', 1) host += ']' # Port if ':' in url: _host, port = url.split(':', 1) if not host: host = _host if port: # If given, ports must be integers. if not port.isdigit(): raise LocationParseError(url) port = int(port) else: # Blank ports are cool, too. (rfc3986#section-3.2.3) port = None elif not host and url: host = url if not path: return Url(scheme, auth, host, port, path, query, fragment) # Fragment if '#' in path: path, fragment = path.split('#', 1) # Query if '?' in path: path, query = path.split('?', 1) return Url(scheme, auth, host, port, path, query, fragment) def get_host(url): """ Deprecated. Use :func:`.parse_url` instead. """ p = parse_url(url) return p.scheme or 'http', p.hostname, p.port
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 5055, 492, 12863, 199, 199, 504, 2508, 3924, 492, 12625, 9123, 421, 199, 633, 63, 3288, 275, 788, 5512, 297, 283, 1178, 297, 283, 1102, 297, 283, 719, 297, 283, 515, 297, 283, 1131, 297, 283, 7677, 418, 421, 199, 533, 20503, 8, 18921, 360, 6417, 297, 1166, 63, 3288, 2298, 272, 408, 272, 3918, 6976, 367, 6144, 376, 3101, 2851, 14, 8051, 465, 282, 372, 574, 367, 272, 520, 1532, 1705, 1122, 63, 633, 2313, 272, 408, 272, 14319, 275, 6248, 339, 347, 636, 1222, 721, 1886, 12, 5687, 29, 403, 12, 1790, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 29, 403, 12, 355, 1827, 29, 403, 12, 7956, 29, 403, 304, 267, 340, 931, 436, 440, 931, 14, 2460, 18265, 288, 931, 275, 7324, 435, 931, 267, 372, 1613, 8, 6417, 12, 843, 2843, 1222, 721, 1886, 12, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 4318, 1827, 12, 7956, 9, 339, 768, 1829, 272, 347, 6246, 8, 277, 304, 267, 408, 1858, 8552, 13, 15390, 543, 7097, 14, 2136, 3984, 14213, 2839, 626, 1041, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1056, 63, 2302, 8, 277, 304, 267, 408, 24677, 931, 5893, 314, 1827, 1059, 1041, 267, 5108, 275, 291, 14, 515, 503, 7324, 398, 340, 291, 14, 1131, 365, 440, 488, 26, 288, 5108, 847, 15539, 435, 291, 14, 1131, 398, 372, 5108, 339, 768, 1829, 272, 347, 10154, 8, 277, 304, 267, 408, 4491, 2909, 5893, 1591, 436, 1844, 624, 267, 340, 291, 14, 719, 26, 288, 372, 1543, 83, 2689, 68, 7, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 408, 267, 7905, 291, 1901, 282, 1166, 398, 961, 805, 1077, 1655, 503, 6656, 6168, 13, 7254, 543, 520, 1532, 5026, 1122, 63, 633, 2313, 710, 267, 2138, 1166, 1443, 440, 506, 8840, 314, 2011, 465, 314, 1166, 1324, 471, 370, 267, 520, 1532, 5026, 1122, 63, 633, 3559, 1325, 652, 1077, 506, 7353, 701, 314, 7329, 334, 69, 14, 71, 2020, 8187, 267, 543, 282, 4596, 1844, 911, 1172, 520, 4829, 680, 398, 5679, 26, 3800, 953, 1306, 738, 275, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 288, 1306, 738, 14, 633, 288, 283, 1014, 921, 3098, 14, 957, 15, 1198, 4805, 288, 1306, 20503, 360, 1014, 297, 283, 2473, 26, 2060, 297, 283, 1102, 14, 957, 297, 5939, 12, 288, 2263, 1994, 515, 297, 283, 1131, 297, 283, 7677, 1959, 633, 288, 283, 1014, 921, 2473, 26, 2060, 32, 1102, 14, 957, 26, 1257, 15, 515, 31, 1131, 3, 7677, 7, 267, 408, 267, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 1827, 12, 7956, 275, 291, 267, 1166, 275, 2125, 398, 327, 2136, 675, 298, 374, 440, 488, 2, 781, 2934, 7645, 370, 5992, 543, 2701, 3326, 334, 269, 378, 1844, 9, 267, 340, 5687, 365, 440, 488, 26, 288, 1166, 847, 5687, 435, 283, 22399, 267, 340, 1790, 365, 440, 488, 26, 288, 1166, 847, 1790, 435, 22143, 267, 340, 1591, 365, 440, 488, 26, 288, 1166, 847, 1591, 267, 340, 1844, 365, 440, 488, 26, 288, 1166, 847, 10871, 435, 620, 8, 719, 9, 267, 340, 931, 365, 440, 488, 26, 288, 1166, 847, 931, 267, 340, 1827, 365, 440, 488, 26, 288, 1166, 847, 15539, 435, 1827, 267, 340, 7956, 365, 440, 488, 26, 288, 1166, 847, 19619, 435, 7956, 398, 372, 1166, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 633, 421, 199, 318, 3715, 63, 2246, 8, 83, 12, 9122, 706, 304, 272, 408, 272, 9138, 282, 1059, 436, 376, 6076, 402, 26968, 12, 3715, 641, 314, 1642, 1911, 272, 11172, 14, 1432, 2877, 3715, 4184, 436, 314, 7838, 11172, 14, 339, 982, 440, 1911, 12, 2066, 314, 1642, 1777, 365, 314, 2615, 1324, 1059, 14, 339, 5679, 447, 398, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 8720, 15, 14619, 267, 661, 1421, 297, 283, 1700, 31, 6185, 297, 15107, 267, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 283, 4288, 358, 267, 661, 1421, 15, 1700, 31, 6185, 297, 3260, 488, 9, 339, 22869, 83, 7798, 590, 543, 1329, 402, 9122, 706, 14, 2832, 28264, 367, 7031, 1329, 402, 9122, 706, 14, 272, 408, 272, 1748, 63, 2996, 275, 488, 272, 1748, 63, 15966, 275, 488, 272, 367, 366, 315, 9122, 706, 26, 267, 4280, 275, 308, 14, 1623, 8, 68, 9, 267, 340, 4280, 665, 378, 26, 288, 1980, 398, 340, 1748, 63, 2996, 365, 488, 503, 4280, 665, 1748, 63, 2996, 26, 288, 1748, 63, 2996, 275, 4280, 288, 1748, 63, 15966, 275, 366, 339, 340, 1748, 63, 2996, 365, 488, 503, 1748, 63, 2996, 665, 378, 26, 267, 372, 308, 12, 3260, 488, 339, 372, 308, 1491, 827, 63, 2996, 467, 308, 59, 827, 63, 2996, 435, 413, 8429, 1748, 63, 15966, 421, 199, 318, 2198, 63, 633, 8, 633, 304, 272, 408, 272, 9138, 282, 1166, 12, 372, 282, 4565, 520, 533, 5026, 6417, 64, 12863, 14, 699, 597, 13, 26088, 365, 272, 10585, 370, 2198, 17110, 8187, 14, 16424, 440, 2741, 911, 506, 488, 14, 339, 14320, 590, 8552, 13, 6490, 543, 520, 1494, 1705, 10290, 2313, 339, 5679, 447, 398, 1306, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 267, 20503, 8, 5512, 534, 1014, 297, 1591, 534, 3098, 14, 957, 297, 1844, 29, 403, 12, 931, 8805, 1198, 3678, 19172, 267, 1306, 2198, 63, 633, 360, 3098, 14, 957, 26, 1257, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 534, 3098, 14, 957, 297, 1844, 29, 1257, 12, 931, 29, 403, 12, 19172, 267, 1306, 2198, 63, 633, 2336, 1421, 31, 1700, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 8805, 1421, 297, 1827, 534, 1700, 297, 19172, 272, 408, 339, 327, 22117, 642, 1233, 965, 15145, 543, 26678, 1159, 7097, 12, 652, 365 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 5055, 492, 12863, 199, 199, 504, 2508, 3924, 492, 12625, 9123, 421, 199, 633, 63, 3288, 275, 788, 5512, 297, 283, 1178, 297, 283, 1102, 297, 283, 719, 297, 283, 515, 297, 283, 1131, 297, 283, 7677, 418, 421, 199, 533, 20503, 8, 18921, 360, 6417, 297, 1166, 63, 3288, 2298, 272, 408, 272, 3918, 6976, 367, 6144, 376, 3101, 2851, 14, 8051, 465, 282, 372, 574, 367, 272, 520, 1532, 1705, 1122, 63, 633, 2313, 272, 408, 272, 14319, 275, 6248, 339, 347, 636, 1222, 721, 1886, 12, 5687, 29, 403, 12, 1790, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 29, 403, 12, 355, 1827, 29, 403, 12, 7956, 29, 403, 304, 267, 340, 931, 436, 440, 931, 14, 2460, 18265, 288, 931, 275, 7324, 435, 931, 267, 372, 1613, 8, 6417, 12, 843, 2843, 1222, 721, 1886, 12, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 4318, 1827, 12, 7956, 9, 339, 768, 1829, 272, 347, 6246, 8, 277, 304, 267, 408, 1858, 8552, 13, 15390, 543, 7097, 14, 2136, 3984, 14213, 2839, 626, 1041, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1056, 63, 2302, 8, 277, 304, 267, 408, 24677, 931, 5893, 314, 1827, 1059, 1041, 267, 5108, 275, 291, 14, 515, 503, 7324, 398, 340, 291, 14, 1131, 365, 440, 488, 26, 288, 5108, 847, 15539, 435, 291, 14, 1131, 398, 372, 5108, 339, 768, 1829, 272, 347, 10154, 8, 277, 304, 267, 408, 4491, 2909, 5893, 1591, 436, 1844, 624, 267, 340, 291, 14, 719, 26, 288, 372, 1543, 83, 2689, 68, 7, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 408, 267, 7905, 291, 1901, 282, 1166, 398, 961, 805, 1077, 1655, 503, 6656, 6168, 13, 7254, 543, 520, 1532, 5026, 1122, 63, 633, 2313, 710, 267, 2138, 1166, 1443, 440, 506, 8840, 314, 2011, 465, 314, 1166, 1324, 471, 370, 267, 520, 1532, 5026, 1122, 63, 633, 3559, 1325, 652, 1077, 506, 7353, 701, 314, 7329, 334, 69, 14, 71, 2020, 8187, 267, 543, 282, 4596, 1844, 911, 1172, 520, 4829, 680, 398, 5679, 26, 3800, 953, 1306, 738, 275, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 288, 1306, 738, 14, 633, 288, 283, 1014, 921, 3098, 14, 957, 15, 1198, 4805, 288, 1306, 20503, 360, 1014, 297, 283, 2473, 26, 2060, 297, 283, 1102, 14, 957, 297, 5939, 12, 288, 2263, 1994, 515, 297, 283, 1131, 297, 283, 7677, 1959, 633, 288, 283, 1014, 921, 2473, 26, 2060, 32, 1102, 14, 957, 26, 1257, 15, 515, 31, 1131, 3, 7677, 7, 267, 408, 267, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 1827, 12, 7956, 275, 291, 267, 1166, 275, 2125, 398, 327, 2136, 675, 298, 374, 440, 488, 2, 781, 2934, 7645, 370, 5992, 543, 2701, 3326, 334, 269, 378, 1844, 9, 267, 340, 5687, 365, 440, 488, 26, 288, 1166, 847, 5687, 435, 283, 22399, 267, 340, 1790, 365, 440, 488, 26, 288, 1166, 847, 1790, 435, 22143, 267, 340, 1591, 365, 440, 488, 26, 288, 1166, 847, 1591, 267, 340, 1844, 365, 440, 488, 26, 288, 1166, 847, 10871, 435, 620, 8, 719, 9, 267, 340, 931, 365, 440, 488, 26, 288, 1166, 847, 931, 267, 340, 1827, 365, 440, 488, 26, 288, 1166, 847, 15539, 435, 1827, 267, 340, 7956, 365, 440, 488, 26, 288, 1166, 847, 19619, 435, 7956, 398, 372, 1166, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 633, 421, 199, 318, 3715, 63, 2246, 8, 83, 12, 9122, 706, 304, 272, 408, 272, 9138, 282, 1059, 436, 376, 6076, 402, 26968, 12, 3715, 641, 314, 1642, 1911, 272, 11172, 14, 1432, 2877, 3715, 4184, 436, 314, 7838, 11172, 14, 339, 982, 440, 1911, 12, 2066, 314, 1642, 1777, 365, 314, 2615, 1324, 1059, 14, 339, 5679, 447, 398, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 8720, 15, 14619, 267, 661, 1421, 297, 283, 1700, 31, 6185, 297, 15107, 267, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 283, 4288, 358, 267, 661, 1421, 15, 1700, 31, 6185, 297, 3260, 488, 9, 339, 22869, 83, 7798, 590, 543, 1329, 402, 9122, 706, 14, 2832, 28264, 367, 7031, 1329, 402, 9122, 706, 14, 272, 408, 272, 1748, 63, 2996, 275, 488, 272, 1748, 63, 15966, 275, 488, 272, 367, 366, 315, 9122, 706, 26, 267, 4280, 275, 308, 14, 1623, 8, 68, 9, 267, 340, 4280, 665, 378, 26, 288, 1980, 398, 340, 1748, 63, 2996, 365, 488, 503, 4280, 665, 1748, 63, 2996, 26, 288, 1748, 63, 2996, 275, 4280, 288, 1748, 63, 15966, 275, 366, 339, 340, 1748, 63, 2996, 365, 488, 503, 1748, 63, 2996, 665, 378, 26, 267, 372, 308, 12, 3260, 488, 339, 372, 308, 1491, 827, 63, 2996, 467, 308, 59, 827, 63, 2996, 435, 413, 8429, 1748, 63, 15966, 421, 199, 318, 2198, 63, 633, 8, 633, 304, 272, 408, 272, 9138, 282, 1166, 12, 372, 282, 4565, 520, 533, 5026, 6417, 64, 12863, 14, 699, 597, 13, 26088, 365, 272, 10585, 370, 2198, 17110, 8187, 14, 16424, 440, 2741, 911, 506, 488, 14, 339, 14320, 590, 8552, 13, 6490, 543, 520, 1494, 1705, 10290, 2313, 339, 5679, 447, 398, 1306, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 267, 20503, 8, 5512, 534, 1014, 297, 1591, 534, 3098, 14, 957, 297, 1844, 29, 403, 12, 931, 8805, 1198, 3678, 19172, 267, 1306, 2198, 63, 633, 360, 3098, 14, 957, 26, 1257, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 534, 3098, 14, 957, 297, 1844, 29, 1257, 12, 931, 29, 403, 12, 19172, 267, 1306, 2198, 63, 633, 2336, 1421, 31, 1700, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 8805, 1421, 297, 1827, 534, 1700, 297, 19172, 272, 408, 339, 327, 22117, 642, 1233, 965, 15145, 543, 26678, 1159, 7097, 12, 652, 365, 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 ]
moble/sympy
sympy/stats/frv.py
58
10115
""" Finite Discrete Random Variables Module See Also ======== sympy.stats.frv_types sympy.stats.rv sympy.stats.crv """ from __future__ import print_function, division from itertools import product from sympy import (Basic, Symbol, cacheit, sympify, Mul, And, Or, Tuple, Piecewise, Eq, Lambda) from sympy.sets.sets import FiniteSet from sympy.stats.rv import (RandomDomain, ProductDomain, ConditionalDomain, PSpace, ProductPSpace, SinglePSpace, random_symbols, sumsets, rv_subs, NamedArgsMixin) from sympy.core.containers import Dict import random class FiniteDensity(dict): def __call__(self, item): item = sympify(item) if item in self: return self[item] else: return 0 @property def dict(self): return dict(self) class FiniteDomain(RandomDomain): """ A domain with discrete finite support Represented using a FiniteSet. """ is_Finite = True @property def symbols(self): return FiniteSet(sym for sym, val in self.elements) @property def elements(self): return self.args[0] @property def dict(self): return FiniteSet(*[Dict(dict(el)) for el in self.elements]) def __contains__(self, other): return other in self.elements def __iter__(self): return self.elements.__iter__() def as_boolean(self): return Or(*[And(*[Eq(sym, val) for sym, val in item]) for item in self]) class SingleFiniteDomain(FiniteDomain): """ A FiniteDomain over a single symbol/set Example: The possibilities of a *single* die roll. """ def __new__(cls, symbol, set): if not isinstance(set, FiniteSet): set = FiniteSet(*set) return Basic.__new__(cls, symbol, set) @property def symbol(self): return self.args[0] return tuple(self.symbols)[0] @property def symbols(self): return FiniteSet(self.symbol) @property def set(self): return self.args[1] @property def elements(self): return FiniteSet(*[frozenset(((self.symbol, elem), )) for elem in self.set]) def __iter__(self): return (frozenset(((self.symbol, elem),)) for elem in self.set) def __contains__(self, other): sym, val = tuple(other)[0] return sym == self.symbol and val in self.set class ProductFiniteDomain(ProductDomain, FiniteDomain): """ A Finite domain consisting of several other FiniteDomains Example: The possibilities of the rolls of three independent dice """ def __iter__(self): proditer = product(*self.domains) return (sumsets(items) for items in proditer) @property def elements(self): return FiniteSet(*self) class ConditionalFiniteDomain(ConditionalDomain, ProductFiniteDomain): """ A FiniteDomain that has been restricted by a condition Example: The possibilities of a die roll under the condition that the roll is even. """ def __new__(cls, domain, condition): if condition is True: return domain cond = rv_subs(condition) # Check that we aren't passed a condition like die1 == z # where 'z' is a symbol that we don't know about # We will never be able to test this equality through iteration if not cond.free_symbols.issubset(domain.free_symbols): raise ValueError('Condition "%s" contains foreign symbols \n%s.\n' % ( condition, tuple(cond.free_symbols - domain.free_symbols)) + "Will be unable to iterate using this condition") return Basic.__new__(cls, domain, cond) def _test(self, elem): val = self.condition.xreplace(dict(elem)) if val in [True, False]: return val elif val.is_Equality: return val.lhs == val.rhs raise ValueError("Undeciable if %s" % str(val)) def __contains__(self, other): return other in self.fulldomain and self._test(other) def __iter__(self): return (elem for elem in self.fulldomain if self._test(elem)) @property def set(self): if self.fulldomain.__class__ is SingleFiniteDomain: return FiniteSet(*[elem for elem in self.fulldomain.set if frozenset(((self.fulldomain.symbol, elem),)) in self]) else: raise NotImplementedError( "Not implemented on multi-dimensional conditional domain") def as_boolean(self): return FiniteDomain.as_boolean(self) class SingleFiniteDistribution(Basic, NamedArgsMixin): def __new__(cls, *args): args = list(map(sympify, args)) return Basic.__new__(cls, *args) @property @cacheit def dict(self): return dict((k, self.pdf(k)) for k in self.set) @property def pdf(self): x = Symbol('x') return Lambda(x, Piecewise(*( [(v, Eq(k, x)) for k, v in self.dict.items()] + [(0, True)]))) @property def set(self): return list(self.dict.keys()) values = property(lambda self: self.dict.values) items = property(lambda self: self.dict.items) __iter__ = property(lambda self: self.dict.__iter__) __getitem__ = property(lambda self: self.dict.__getitem__) __call__ = pdf def __contains__(self, other): return other in self.set #============================================= #========= Probability Space =============== #============================================= class FinitePSpace(PSpace): """ A Finite Probability Space Represents the probabilities of a finite number of events. """ is_Finite = True @property def domain(self): return self.args[0] @property def density(self): return self.args[0] def __new__(cls, domain, density): density = dict((sympify(key), sympify(val)) for key, val in density.items()) public_density = Dict(density) obj = PSpace.__new__(cls, domain, public_density) obj._density = density return obj def prob_of(self, elem): return self._density.get(elem, 0) def where(self, condition): assert all(r.symbol in self.symbols for r in random_symbols(condition)) return ConditionalFiniteDomain(self.domain, condition) def compute_density(self, expr): expr = expr.xreplace(dict(((rs, rs.symbol) for rs in self.values))) d = FiniteDensity() for elem in self.domain: val = expr.xreplace(dict(elem)) prob = self.prob_of(elem) d[val] = d.get(val, 0) + prob return d @cacheit def compute_cdf(self, expr): d = self.compute_density(expr) cum_prob = 0 cdf = [] for key in sorted(d): prob = d[key] cum_prob += prob cdf.append((key, cum_prob)) return dict(cdf) @cacheit def sorted_cdf(self, expr, python_float=False): cdf = self.compute_cdf(expr) items = list(cdf.items()) sorted_items = sorted(items, key=lambda val_cumprob: val_cumprob[1]) if python_float: sorted_items = [(v, float(cum_prob)) for v, cum_prob in sorted_items] return sorted_items def integrate(self, expr, rvs=None): rvs = rvs or self.values expr = expr.xreplace(dict((rs, rs.symbol) for rs in rvs)) return sum([expr.xreplace(dict(elem)) * self.prob_of(elem) for elem in self.domain]) def probability(self, condition): cond_symbols = frozenset(rs.symbol for rs in random_symbols(condition)) assert cond_symbols.issubset(self.symbols) return sum(self.prob_of(elem) for elem in self.where(condition)) def conditional_space(self, condition): domain = self.where(condition) prob = self.probability(condition) density = dict((key, val / prob) for key, val in self._density.items() if key in domain) return FinitePSpace(domain, density) def sample(self): """ Internal sample method Returns dictionary mapping RandomSymbol to realization value. """ expr = Tuple(*self.values) cdf = self.sorted_cdf(expr, python_float=True) x = random.uniform(0, 1) # Find first occurence with cumulative probability less than x # This should be replaced with binary search for value, cum_prob in cdf: if x < cum_prob: # return dictionary mapping RandomSymbols to values return dict(list(zip(expr, value))) assert False, "We should never have gotten to this point" class SingleFinitePSpace(SinglePSpace, FinitePSpace): """ A single finite probability space Represents the probabilities of a set of random events that can be attributed to a single variable/symbol. This class is implemented by many of the standard FiniteRV types such as Die, Bernoulli, Coin, etc.... """ @property def domain(self): return SingleFiniteDomain(self.symbol, self.distribution.set) @property @cacheit def _density(self): return dict((frozenset(((self.symbol, val),)), prob) for val, prob in self.distribution.dict.items()) class ProductFinitePSpace(ProductPSpace, FinitePSpace): """ A collection of several independent finite probability spaces """ @property def domain(self): return ProductFiniteDomain(*[space.domain for space in self.spaces]) @property @cacheit def _density(self): proditer = product(*[iter(space._density.items()) for space in self.spaces]) d = {} for items in proditer: elems, probs = list(zip(*items)) elem = sumsets(elems) prob = Mul(*probs) d[elem] = d.get(elem, 0) + prob return Dict(d) @property @cacheit def density(self): return Dict(self._density)
bsd-3-clause
[ 624, 199, 8694, 1175, 5289, 7564, 9571, 17198, 5673, 199, 199, 9295, 6121, 199, 763, 199, 18132, 14, 3200, 14, 4391, 86, 63, 1313, 199, 18132, 14, 3200, 14, 6310, 199, 18132, 14, 3200, 14, 1556, 86, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 7975, 492, 3336, 199, 199, 504, 5840, 492, 334, 6845, 12, 10080, 12, 2581, 390, 12, 25991, 12, 22578, 12, 267, 6061, 12, 4236, 12, 11634, 12, 31362, 12, 21779, 12, 28650, 9, 199, 504, 5840, 14, 2193, 14, 2193, 492, 11711, 1175, 1084, 199, 504, 5840, 14, 3200, 14, 6310, 492, 334, 3883, 7705, 12, 12705, 7705, 12, 24191, 7705, 12, 267, 510, 7643, 12, 12705, 5067, 1142, 12, 13050, 5067, 1142, 12, 2196, 63, 7450, 12, 3089, 2193, 12, 4336, 63, 9841, 12, 267, 16198, 6213, 4256, 9, 199, 504, 5840, 14, 1018, 14, 13577, 492, 7448, 199, 646, 2196, 199, 199, 533, 11711, 1175, 26211, 8, 807, 304, 272, 347, 636, 1250, 721, 277, 12, 1242, 304, 267, 1242, 275, 25991, 8, 1053, 9, 267, 340, 1242, 315, 291, 26, 288, 372, 291, 59, 1053, 61, 267, 587, 26, 288, 372, 378, 339, 768, 1829, 272, 347, 1211, 8, 277, 304, 267, 372, 1211, 8, 277, 9, 199, 199, 533, 11711, 1175, 7705, 8, 3883, 7705, 304, 272, 408, 272, 437, 2881, 543, 24635, 21837, 2291, 339, 799, 10317, 1808, 282, 11711, 1175, 1084, 14, 272, 408, 272, 365, 63, 8694, 1175, 275, 715, 339, 768, 1829, 272, 347, 6698, 8, 277, 304, 267, 372, 11711, 1175, 1084, 8, 3840, 367, 4678, 12, 1139, 315, 291, 14, 5527, 9, 339, 768, 1829, 272, 347, 4008, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 339, 768, 1829, 272, 347, 1211, 8, 277, 304, 267, 372, 11711, 1175, 1084, 23151, 2141, 8, 807, 8, 352, 430, 367, 579, 315, 291, 14, 5527, 566, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 372, 1163, 315, 291, 14, 5527, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 14, 5527, 855, 1661, 4533, 339, 347, 465, 63, 4871, 8, 277, 304, 267, 372, 4236, 23151, 3325, 23151, 19706, 8, 3840, 12, 1139, 9, 367, 4678, 12, 1139, 315, 1242, 566, 367, 1242, 315, 291, 566, 421, 199, 533, 13050, 8694, 1175, 7705, 8, 8694, 1175, 7705, 304, 272, 408, 272, 437, 11711, 1175, 7705, 1806, 282, 2849, 5272, 15, 409, 339, 5679, 26, 710, 2086, 23422, 402, 282, 627, 4780, 10, 18833, 11848, 14, 272, 408, 339, 347, 636, 1222, 721, 1886, 12, 5272, 12, 663, 304, 267, 340, 440, 1228, 8, 409, 12, 11711, 1175, 1084, 304, 288, 663, 275, 11711, 1175, 1084, 2031, 409, 9, 267, 372, 10082, 855, 1222, 721, 1886, 12, 5272, 12, 663, 9, 339, 768, 1829, 272, 347, 5272, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 267, 372, 2008, 8, 277, 14, 7450, 2788, 16, 61, 339, 768, 1829, 272, 347, 6698, 8, 277, 304, 267, 372, 11711, 1175, 1084, 8, 277, 14, 5155, 9, 339, 768, 1829, 272, 347, 663, 8, 277, 304, 267, 372, 291, 14, 589, 59, 17, 61, 339, 768, 1829, 272, 347, 4008, 8, 277, 304, 267, 372, 11711, 1175, 1084, 23151, 21362, 12925, 277, 14, 5155, 12, 6193, 395, 5082, 367, 6193, 315, 291, 14, 409, 566, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 334, 21362, 12925, 277, 14, 5155, 12, 6193, 18399, 367, 6193, 315, 291, 14, 409, 9, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 4678, 12, 1139, 275, 2008, 8, 1848, 2788, 16, 61, 267, 372, 4678, 508, 291, 14, 5155, 436, 1139, 315, 291, 14, 409, 421, 199, 533, 12705, 8694, 1175, 7705, 8, 5884, 7705, 12, 11711, 1175, 7705, 304, 272, 408, 272, 437, 11711, 1175, 2881, 22581, 402, 9978, 1163, 11711, 1175, 7705, 83, 339, 5679, 26, 710, 2086, 23422, 402, 314, 20182, 478, 402, 7795, 12717, 487, 301, 272, 408, 339, 347, 636, 1661, 721, 277, 304, 267, 557, 13360, 275, 3336, 2031, 277, 14, 9756, 9, 267, 372, 334, 1838, 2193, 8, 1744, 9, 367, 2974, 315, 557, 13360, 9, 339, 768, 1829, 272, 347, 4008, 8, 277, 304, 267, 372, 11711, 1175, 1084, 2031, 277, 9, 421, 199, 533, 24191, 8694, 1175, 7705, 8, 21321, 7705, 12, 12705, 8694, 1175, 7705, 304, 272, 408, 272, 437, 11711, 1175, 7705, 626, 965, 2757, 15297, 701, 282, 5558, 339, 5679, 26, 710, 2086, 23422, 402, 282, 18833, 11848, 1334, 314, 5558, 626, 314, 272, 11848, 365, 2755, 14, 272, 408, 339, 347, 636, 1222, 721, 1886, 12, 2881, 12, 5558, 304, 267, 340, 5558, 365, 715, 26, 288, 372, 2881, 267, 9288, 275, 4336, 63, 9841, 8, 5394, 9, 267, 327, 2670, 626, 781, 10621, 1133, 3032, 282, 5558, 2839, 18833, 17, 508, 1315, 267, 327, 2382, 283, 90, 7, 365, 282, 5272, 626, 781, 2793, 1133, 5715, 3595, 267, 327, 2136, 911, 7078, 506, 7688, 370, 511, 642, 16612, 4012, 8494, 267, 340, 440, 9288, 14, 4624, 63, 7450, 14, 374, 9401, 8, 2261, 14, 4624, 63, 7450, 304, 288, 746, 1722, 360, 9558, 2071, 83, 2, 3509, 11608, 6698, 971, 78, 5, 83, 3134, 78, 7, 450, 334, 355, 5558, 12, 2008, 8, 2067, 14, 4624, 63, 7450, 446, 2881, 14, 4624, 63, 7450, 430, 435, 355, 298, 20326, 506, 17329, 370, 13974, 1808, 642, 5558, 531, 398, 372, 10082, 855, 1222, 721, 1886, 12, 2881, 12, 9288, 9, 16478, 347, 485, 396, 8, 277, 12, 6193, 304, 267, 1139, 275, 291, 14, 5394, 14, 88, 1814, 8, 807, 8, 6086, 430, 267, 340, 1139, 315, 359, 549, 12, 756, 2189, 288, 372, 1139, 267, 916, 1139, 14, 374, 63, 22977, 26, 288, 372, 1139, 14, 12697, 508, 1139, 14, 12071, 267, 746, 1722, 480, 1358, 22612, 461, 340, 450, 83, 2, 450, 620, 8, 637, 430, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 372, 1163, 315, 291, 14, 2861, 2261, 436, 291, 423, 396, 8, 1848, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 334, 6086, 367, 6193, 315, 291 ]
[ 199, 8694, 1175, 5289, 7564, 9571, 17198, 5673, 199, 199, 9295, 6121, 199, 763, 199, 18132, 14, 3200, 14, 4391, 86, 63, 1313, 199, 18132, 14, 3200, 14, 6310, 199, 18132, 14, 3200, 14, 1556, 86, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 7975, 492, 3336, 199, 199, 504, 5840, 492, 334, 6845, 12, 10080, 12, 2581, 390, 12, 25991, 12, 22578, 12, 267, 6061, 12, 4236, 12, 11634, 12, 31362, 12, 21779, 12, 28650, 9, 199, 504, 5840, 14, 2193, 14, 2193, 492, 11711, 1175, 1084, 199, 504, 5840, 14, 3200, 14, 6310, 492, 334, 3883, 7705, 12, 12705, 7705, 12, 24191, 7705, 12, 267, 510, 7643, 12, 12705, 5067, 1142, 12, 13050, 5067, 1142, 12, 2196, 63, 7450, 12, 3089, 2193, 12, 4336, 63, 9841, 12, 267, 16198, 6213, 4256, 9, 199, 504, 5840, 14, 1018, 14, 13577, 492, 7448, 199, 646, 2196, 199, 199, 533, 11711, 1175, 26211, 8, 807, 304, 272, 347, 636, 1250, 721, 277, 12, 1242, 304, 267, 1242, 275, 25991, 8, 1053, 9, 267, 340, 1242, 315, 291, 26, 288, 372, 291, 59, 1053, 61, 267, 587, 26, 288, 372, 378, 339, 768, 1829, 272, 347, 1211, 8, 277, 304, 267, 372, 1211, 8, 277, 9, 199, 199, 533, 11711, 1175, 7705, 8, 3883, 7705, 304, 272, 408, 272, 437, 2881, 543, 24635, 21837, 2291, 339, 799, 10317, 1808, 282, 11711, 1175, 1084, 14, 272, 408, 272, 365, 63, 8694, 1175, 275, 715, 339, 768, 1829, 272, 347, 6698, 8, 277, 304, 267, 372, 11711, 1175, 1084, 8, 3840, 367, 4678, 12, 1139, 315, 291, 14, 5527, 9, 339, 768, 1829, 272, 347, 4008, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 339, 768, 1829, 272, 347, 1211, 8, 277, 304, 267, 372, 11711, 1175, 1084, 23151, 2141, 8, 807, 8, 352, 430, 367, 579, 315, 291, 14, 5527, 566, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 372, 1163, 315, 291, 14, 5527, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 14, 5527, 855, 1661, 4533, 339, 347, 465, 63, 4871, 8, 277, 304, 267, 372, 4236, 23151, 3325, 23151, 19706, 8, 3840, 12, 1139, 9, 367, 4678, 12, 1139, 315, 1242, 566, 367, 1242, 315, 291, 566, 421, 199, 533, 13050, 8694, 1175, 7705, 8, 8694, 1175, 7705, 304, 272, 408, 272, 437, 11711, 1175, 7705, 1806, 282, 2849, 5272, 15, 409, 339, 5679, 26, 710, 2086, 23422, 402, 282, 627, 4780, 10, 18833, 11848, 14, 272, 408, 339, 347, 636, 1222, 721, 1886, 12, 5272, 12, 663, 304, 267, 340, 440, 1228, 8, 409, 12, 11711, 1175, 1084, 304, 288, 663, 275, 11711, 1175, 1084, 2031, 409, 9, 267, 372, 10082, 855, 1222, 721, 1886, 12, 5272, 12, 663, 9, 339, 768, 1829, 272, 347, 5272, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 267, 372, 2008, 8, 277, 14, 7450, 2788, 16, 61, 339, 768, 1829, 272, 347, 6698, 8, 277, 304, 267, 372, 11711, 1175, 1084, 8, 277, 14, 5155, 9, 339, 768, 1829, 272, 347, 663, 8, 277, 304, 267, 372, 291, 14, 589, 59, 17, 61, 339, 768, 1829, 272, 347, 4008, 8, 277, 304, 267, 372, 11711, 1175, 1084, 23151, 21362, 12925, 277, 14, 5155, 12, 6193, 395, 5082, 367, 6193, 315, 291, 14, 409, 566, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 334, 21362, 12925, 277, 14, 5155, 12, 6193, 18399, 367, 6193, 315, 291, 14, 409, 9, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 4678, 12, 1139, 275, 2008, 8, 1848, 2788, 16, 61, 267, 372, 4678, 508, 291, 14, 5155, 436, 1139, 315, 291, 14, 409, 421, 199, 533, 12705, 8694, 1175, 7705, 8, 5884, 7705, 12, 11711, 1175, 7705, 304, 272, 408, 272, 437, 11711, 1175, 2881, 22581, 402, 9978, 1163, 11711, 1175, 7705, 83, 339, 5679, 26, 710, 2086, 23422, 402, 314, 20182, 478, 402, 7795, 12717, 487, 301, 272, 408, 339, 347, 636, 1661, 721, 277, 304, 267, 557, 13360, 275, 3336, 2031, 277, 14, 9756, 9, 267, 372, 334, 1838, 2193, 8, 1744, 9, 367, 2974, 315, 557, 13360, 9, 339, 768, 1829, 272, 347, 4008, 8, 277, 304, 267, 372, 11711, 1175, 1084, 2031, 277, 9, 421, 199, 533, 24191, 8694, 1175, 7705, 8, 21321, 7705, 12, 12705, 8694, 1175, 7705, 304, 272, 408, 272, 437, 11711, 1175, 7705, 626, 965, 2757, 15297, 701, 282, 5558, 339, 5679, 26, 710, 2086, 23422, 402, 282, 18833, 11848, 1334, 314, 5558, 626, 314, 272, 11848, 365, 2755, 14, 272, 408, 339, 347, 636, 1222, 721, 1886, 12, 2881, 12, 5558, 304, 267, 340, 5558, 365, 715, 26, 288, 372, 2881, 267, 9288, 275, 4336, 63, 9841, 8, 5394, 9, 267, 327, 2670, 626, 781, 10621, 1133, 3032, 282, 5558, 2839, 18833, 17, 508, 1315, 267, 327, 2382, 283, 90, 7, 365, 282, 5272, 626, 781, 2793, 1133, 5715, 3595, 267, 327, 2136, 911, 7078, 506, 7688, 370, 511, 642, 16612, 4012, 8494, 267, 340, 440, 9288, 14, 4624, 63, 7450, 14, 374, 9401, 8, 2261, 14, 4624, 63, 7450, 304, 288, 746, 1722, 360, 9558, 2071, 83, 2, 3509, 11608, 6698, 971, 78, 5, 83, 3134, 78, 7, 450, 334, 355, 5558, 12, 2008, 8, 2067, 14, 4624, 63, 7450, 446, 2881, 14, 4624, 63, 7450, 430, 435, 355, 298, 20326, 506, 17329, 370, 13974, 1808, 642, 5558, 531, 398, 372, 10082, 855, 1222, 721, 1886, 12, 2881, 12, 9288, 9, 16478, 347, 485, 396, 8, 277, 12, 6193, 304, 267, 1139, 275, 291, 14, 5394, 14, 88, 1814, 8, 807, 8, 6086, 430, 267, 340, 1139, 315, 359, 549, 12, 756, 2189, 288, 372, 1139, 267, 916, 1139, 14, 374, 63, 22977, 26, 288, 372, 1139, 14, 12697, 508, 1139, 14, 12071, 267, 746, 1722, 480, 1358, 22612, 461, 340, 450, 83, 2, 450, 620, 8, 637, 430, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 372, 1163, 315, 291, 14, 2861, 2261, 436, 291, 423, 396, 8, 1848, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 334, 6086, 367, 6193, 315, 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,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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 ]
googleapis/googleapis-gen
google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise-v1beta1-py/google/cloud/recaptchaenterprise_v1beta1/services/recaptcha_enterprise_service_v1_beta1/transports/base.py
1
9862
# -*- coding: utf-8 -*- # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union import packaging.version import pkg_resources import google.auth # type: ignore import google.api_core # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.recaptchaenterprise_v1beta1.types import recaptchaenterprise from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=pkg_resources.get_distribution( 'google-cloud-recaptchaenterprise', ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() try: # google.auth.__version__ was added in 1.26.0 _GOOGLE_AUTH_VERSION = google.auth.__version__ except AttributeError: try: # try pkg_resources if it is available _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version except pkg_resources.DistributionNotFound: # pragma: NO COVER _GOOGLE_AUTH_VERSION = None class RecaptchaEnterpriseServiceV1Beta1Transport(abc.ABC): """Abstract transport class for RecaptchaEnterpriseServiceV1Beta1.""" AUTH_SCOPES = ( 'https://www.googleapis.com/auth/cloud-platform', ) DEFAULT_HOST: str = 'recaptchaenterprise.googleapis.com' def __init__( self, *, host: str = DEFAULT_HOST, credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, **kwargs, ) -> None: """Instantiate the transport. Args: host (Optional[str]): The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ':' not in host: host += ':443' self._host = host scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) # Save the scopes. self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) # If the credentials is service account credentials, then always try to use self signed JWT. if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. self._credentials = credentials # TODO(busunkim): This method is in the base transport # to avoid duplicating code across the transport classes. These functions # should be deleted once the minimum required versions of google-auth is increased. # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" scopes_kwargs = {} if _GOOGLE_AUTH_VERSION and ( packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0") ): scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} else: scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} return scopes_kwargs def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_assessment: gapic_v1.method.wrap_method( self.create_assessment, default_timeout=600.0, client_info=client_info, ), self.annotate_assessment: gapic_v1.method.wrap_method( self.annotate_assessment, default_timeout=600.0, client_info=client_info, ), self.create_key: gapic_v1.method.wrap_method( self.create_key, default_timeout=600.0, client_info=client_info, ), self.list_keys: gapic_v1.method.wrap_method( self.list_keys, default_timeout=600.0, client_info=client_info, ), self.get_key: gapic_v1.method.wrap_method( self.get_key, default_timeout=600.0, client_info=client_info, ), self.update_key: gapic_v1.method.wrap_method( self.update_key, default_timeout=600.0, client_info=client_info, ), self.delete_key: gapic_v1.method.wrap_method( self.delete_key, default_timeout=600.0, client_info=client_info, ), } @property def create_assessment(self) -> Callable[ [recaptchaenterprise.CreateAssessmentRequest], Union[ recaptchaenterprise.Assessment, Awaitable[recaptchaenterprise.Assessment] ]]: raise NotImplementedError() @property def annotate_assessment(self) -> Callable[ [recaptchaenterprise.AnnotateAssessmentRequest], Union[ recaptchaenterprise.AnnotateAssessmentResponse, Awaitable[recaptchaenterprise.AnnotateAssessmentResponse] ]]: raise NotImplementedError() @property def create_key(self) -> Callable[ [recaptchaenterprise.CreateKeyRequest], Union[ recaptchaenterprise.Key, Awaitable[recaptchaenterprise.Key] ]]: raise NotImplementedError() @property def list_keys(self) -> Callable[ [recaptchaenterprise.ListKeysRequest], Union[ recaptchaenterprise.ListKeysResponse, Awaitable[recaptchaenterprise.ListKeysResponse] ]]: raise NotImplementedError() @property def get_key(self) -> Callable[ [recaptchaenterprise.GetKeyRequest], Union[ recaptchaenterprise.Key, Awaitable[recaptchaenterprise.Key] ]]: raise NotImplementedError() @property def update_key(self) -> Callable[ [recaptchaenterprise.UpdateKeyRequest], Union[ recaptchaenterprise.Key, Awaitable[recaptchaenterprise.Key] ]]: raise NotImplementedError() @property def delete_key(self) -> Callable[ [recaptchaenterprise.DeleteKeyRequest], Union[ empty_pb2.Empty, Awaitable[empty_pb2.Empty] ]]: raise NotImplementedError() __all__ = ( 'RecaptchaEnterpriseServiceV1Beta1Transport', )
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 25455, 4475, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 199, 646, 13022, 199, 504, 14090, 492, 437, 2573, 461, 12, 16975, 12, 7448, 12, 4879, 12, 10975, 12, 15961, 199, 646, 27369, 14, 1023, 199, 646, 5496, 63, 4435, 199, 199, 646, 6233, 14, 1178, 221, 327, 730, 26, 3686, 199, 646, 6233, 14, 1246, 63, 1018, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 1246, 63, 1018, 492, 4967, 465, 6170, 63, 3924, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 1246, 63, 1018, 492, 16301, 530, 63, 86, 17, 259, 327, 730, 26, 3686, 199, 504, 6233, 14, 1246, 63, 1018, 492, 7269, 465, 10086, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 1178, 492, 6235, 465, 16072, 63, 6942, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 6126, 18, 492, 2435, 63, 2048, 327, 730, 26, 3686, 199, 199, 504, 6233, 14, 4091, 14, 2761, 6182, 9518, 24375, 63, 86, 17, 5683, 17, 14, 1313, 492, 295, 20559, 24375, 199, 504, 6233, 14, 7204, 492, 2701, 63, 3317, 18, 221, 327, 730, 26, 3686, 199, 199, 893, 26, 272, 6186, 63, 9901, 63, 4531, 275, 16301, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 8, 267, 16301, 530, 63, 1023, 29, 4600, 63, 4435, 14, 362, 63, 4972, 8, 288, 283, 3098, 13, 4091, 13, 2761, 6182, 9518, 24375, 297, 267, 7092, 1023, 12, 272, 776, 199, 2590, 5496, 63, 4435, 14, 8580, 4667, 26, 272, 6186, 63, 9901, 63, 4531, 275, 16301, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 342, 199, 199, 893, 26, 272, 327, 6233, 14, 1178, 855, 1023, 363, 1990, 3483, 315, 413, 14, 1479, 14, 16, 272, 485, 24243, 63, 5580, 63, 4612, 275, 6233, 14, 1178, 855, 1023, 363, 199, 2590, 4281, 26, 272, 862, 26, 221, 327, 862, 5496, 63, 4435, 340, 652, 365, 2808, 267, 485, 24243, 63, 5580, 63, 4612, 275, 5496, 63, 4435, 14, 362, 63, 4972, 480, 3098, 13, 1178, 3471, 1023, 272, 871, 5496, 63, 4435, 14, 8580, 4667, 26, 221, 327, 11942, 26, 4825, 5099, 2111, 267, 485, 24243, 63, 5580, 63, 4612, 275, 488, 421, 199, 533, 799, 20559, 8468, 13219, 3167, 54, 17, 21732, 17, 7836, 8, 3175, 14, 8390, 304, 272, 408, 8458, 7773, 1021, 367, 799, 20559, 8468, 13219, 3167, 54, 17, 21732, 17, 1041, 339, 7560, 63, 15901, 48, 654, 275, 334, 267, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4091, 13, 3246, 297, 272, 776, 339, 6186, 63, 5449, 26, 620, 275, 283, 2761, 6182, 9518, 24375, 14, 17533, 14, 957, 7, 272, 347, 636, 826, 721, 288, 291, 12, 9889, 288, 1591, 26, 620, 275, 6186, 63, 5449, 12, 288, 6235, 26, 16072, 63, 6942, 14, 13428, 275, 488, 12, 288, 6235, 63, 493, 26, 4879, 59, 495, 61, 275, 488, 12, 288, 14570, 26, 4879, 59, 5826, 59, 495, 2677, 275, 488, 12, 288, 12132, 63, 1715, 63, 344, 26, 4879, 59, 495, 61, 275, 488, 12, 288, 1890, 63, 815, 26, 16301, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 275, 6186, 63, 9901, 63, 4531, 12, 288, 3544, 63, 1180, 63, 30033, 63, 2732, 26, 4879, 59, 2245, 61, 275, 756, 12, 288, 1011, 958, 12, 288, 776, 1035, 488, 26, 267, 408, 10083, 18973, 314, 7773, 14, 398, 3033, 26, 288, 1591, 334, 7012, 59, 495, 4682, 326, 710, 6246, 370, 4907, 370, 14, 288, 6235, 334, 7012, 59, 3098, 14, 1178, 14, 6942, 14, 13428, 4682, 710, 355, 13448, 6235, 370, 6554, 370, 4145, 14, 5723, 355, 6235, 10405, 314, 4223, 370, 314, 2435, 27, 340, 7179, 355, 787, 2013, 12, 314, 1890, 911, 7427, 370, 465, 20226, 314, 355, 6235, 687, 314, 3734, 14, 288, 6235, 63, 493, 334, 7012, 59, 495, 4682, 437, 570, 543, 6235, 626, 883, 355, 506, 6511, 543, 520, 1532, 1705, 3098, 14, 1178, 14, 912, 63, 6942, 63, 504, 63, 493, 2313, 355, 961, 1423, 365, 16108, 13914, 543, 6235, 14, 288, 14570, 334, 7012, 59, 5826, 59, 495, 2677, 304, 437, 769, 402, 14570, 14, 288, 12132, 63, 1715, 63, 344, 334, 7012, 59, 495, 4682, 1626, 2716, 2199, 370, 675, 367, 32663, 355, 436, 12132, 14, 288, 1890, 63, 815, 334, 3098, 14, 1246, 63, 1018, 14, 15046, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 304, 355, 710, 1890, 2256, 1202, 370, 3222, 282, 922, 13, 4054, 1059, 3180, 543, 355, 3261, 4145, 14, 982, 1124, 403, 4542, 2066, 849, 2256, 911, 506, 1202, 14, 355, 1464, 1183, 12, 1265, 1454, 1929, 370, 663, 642, 340, 1265, 3984, 477, 3419, 4073, 355, 2195, 5705, 1890, 3555, 14, 288, 3544, 63, 1180, 63, 30033, 63, 2732, 334, 7012, 59, 2245, 4682, 7480, 291, 10514, 1603, 21283, 1077, 355, 506, 1202, 367, 2435, 2933, 6235, 14, 267, 408, 267, 327, 11063, 314, 6246, 14, 3758, 370, 1844, 23865, 334, 14921, 9, 340, 7179, 365, 2013, 14, 267, 340, 10871, 440, 315, 1591, 26, 288, 1591, 847, 7596, 16284, 7, 267, 291, 423, 1102, 275, 1591, 398, 14570, 63, 958, 275, 291, 423, 362, 63, 14129, 63, 958, 8, 277, 423, 1102, 12, 14570, 9, 398, 327, 11063, 314, 14570, 14, 267, 291, 423, 14129, 275, 14570, 398, 327, 982 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 25455, 4475, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 199, 646, 13022, 199, 504, 14090, 492, 437, 2573, 461, 12, 16975, 12, 7448, 12, 4879, 12, 10975, 12, 15961, 199, 646, 27369, 14, 1023, 199, 646, 5496, 63, 4435, 199, 199, 646, 6233, 14, 1178, 221, 327, 730, 26, 3686, 199, 646, 6233, 14, 1246, 63, 1018, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 1246, 63, 1018, 492, 4967, 465, 6170, 63, 3924, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 1246, 63, 1018, 492, 16301, 530, 63, 86, 17, 259, 327, 730, 26, 3686, 199, 504, 6233, 14, 1246, 63, 1018, 492, 7269, 465, 10086, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 1178, 492, 6235, 465, 16072, 63, 6942, 221, 327, 730, 26, 3686, 199, 504, 6233, 14, 6126, 18, 492, 2435, 63, 2048, 327, 730, 26, 3686, 199, 199, 504, 6233, 14, 4091, 14, 2761, 6182, 9518, 24375, 63, 86, 17, 5683, 17, 14, 1313, 492, 295, 20559, 24375, 199, 504, 6233, 14, 7204, 492, 2701, 63, 3317, 18, 221, 327, 730, 26, 3686, 199, 199, 893, 26, 272, 6186, 63, 9901, 63, 4531, 275, 16301, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 8, 267, 16301, 530, 63, 1023, 29, 4600, 63, 4435, 14, 362, 63, 4972, 8, 288, 283, 3098, 13, 4091, 13, 2761, 6182, 9518, 24375, 297, 267, 7092, 1023, 12, 272, 776, 199, 2590, 5496, 63, 4435, 14, 8580, 4667, 26, 272, 6186, 63, 9901, 63, 4531, 275, 16301, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 342, 199, 199, 893, 26, 272, 327, 6233, 14, 1178, 855, 1023, 363, 1990, 3483, 315, 413, 14, 1479, 14, 16, 272, 485, 24243, 63, 5580, 63, 4612, 275, 6233, 14, 1178, 855, 1023, 363, 199, 2590, 4281, 26, 272, 862, 26, 221, 327, 862, 5496, 63, 4435, 340, 652, 365, 2808, 267, 485, 24243, 63, 5580, 63, 4612, 275, 5496, 63, 4435, 14, 362, 63, 4972, 480, 3098, 13, 1178, 3471, 1023, 272, 871, 5496, 63, 4435, 14, 8580, 4667, 26, 221, 327, 11942, 26, 4825, 5099, 2111, 267, 485, 24243, 63, 5580, 63, 4612, 275, 488, 421, 199, 533, 799, 20559, 8468, 13219, 3167, 54, 17, 21732, 17, 7836, 8, 3175, 14, 8390, 304, 272, 408, 8458, 7773, 1021, 367, 799, 20559, 8468, 13219, 3167, 54, 17, 21732, 17, 1041, 339, 7560, 63, 15901, 48, 654, 275, 334, 267, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4091, 13, 3246, 297, 272, 776, 339, 6186, 63, 5449, 26, 620, 275, 283, 2761, 6182, 9518, 24375, 14, 17533, 14, 957, 7, 272, 347, 636, 826, 721, 288, 291, 12, 9889, 288, 1591, 26, 620, 275, 6186, 63, 5449, 12, 288, 6235, 26, 16072, 63, 6942, 14, 13428, 275, 488, 12, 288, 6235, 63, 493, 26, 4879, 59, 495, 61, 275, 488, 12, 288, 14570, 26, 4879, 59, 5826, 59, 495, 2677, 275, 488, 12, 288, 12132, 63, 1715, 63, 344, 26, 4879, 59, 495, 61, 275, 488, 12, 288, 1890, 63, 815, 26, 16301, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 275, 6186, 63, 9901, 63, 4531, 12, 288, 3544, 63, 1180, 63, 30033, 63, 2732, 26, 4879, 59, 2245, 61, 275, 756, 12, 288, 1011, 958, 12, 288, 776, 1035, 488, 26, 267, 408, 10083, 18973, 314, 7773, 14, 398, 3033, 26, 288, 1591, 334, 7012, 59, 495, 4682, 326, 710, 6246, 370, 4907, 370, 14, 288, 6235, 334, 7012, 59, 3098, 14, 1178, 14, 6942, 14, 13428, 4682, 710, 355, 13448, 6235, 370, 6554, 370, 4145, 14, 5723, 355, 6235, 10405, 314, 4223, 370, 314, 2435, 27, 340, 7179, 355, 787, 2013, 12, 314, 1890, 911, 7427, 370, 465, 20226, 314, 355, 6235, 687, 314, 3734, 14, 288, 6235, 63, 493, 334, 7012, 59, 495, 4682, 437, 570, 543, 6235, 626, 883, 355, 506, 6511, 543, 520, 1532, 1705, 3098, 14, 1178, 14, 912, 63, 6942, 63, 504, 63, 493, 2313, 355, 961, 1423, 365, 16108, 13914, 543, 6235, 14, 288, 14570, 334, 7012, 59, 5826, 59, 495, 2677, 304, 437, 769, 402, 14570, 14, 288, 12132, 63, 1715, 63, 344, 334, 7012, 59, 495, 4682, 1626, 2716, 2199, 370, 675, 367, 32663, 355, 436, 12132, 14, 288, 1890, 63, 815, 334, 3098, 14, 1246, 63, 1018, 14, 15046, 530, 63, 86, 17, 14, 1258, 63, 815, 14, 3041, 2354, 304, 355, 710, 1890, 2256, 1202, 370, 3222, 282, 922, 13, 4054, 1059, 3180, 543, 355, 3261, 4145, 14, 982, 1124, 403, 4542, 2066, 849, 2256, 911, 506, 1202, 14, 355, 1464, 1183, 12, 1265, 1454, 1929, 370, 663, 642, 340, 1265, 3984, 477, 3419, 4073, 355, 2195, 5705, 1890, 3555, 14, 288, 3544, 63, 1180, 63, 30033, 63, 2732, 334, 7012, 59, 2245, 4682, 7480, 291, 10514, 1603, 21283, 1077, 355, 506, 1202, 367, 2435, 2933, 6235, 14, 267, 408, 267, 327, 11063, 314, 6246, 14, 3758, 370, 1844, 23865, 334, 14921, 9, 340, 7179, 365, 2013, 14, 267, 340, 10871, 440, 315, 1591, 26, 288, 1591, 847, 7596, 16284, 7, 267, 291, 423, 1102, 275, 1591, 398, 14570, 63, 958, 275, 291, 423, 362, 63, 14129, 63, 958, 8, 277, 423, 1102, 12, 14570, 9, 398, 327, 11063, 314, 14570, 14, 267, 291, 423, 14129, 275, 14570, 398, 327, 982, 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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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 ]
kyvinh/home-assistant
homeassistant/components/verisure.py
17
7543
""" Support for Verisure components. For more details about this component, please refer to the documentation at https://home-assistant.io/components/verisure/ """ import logging import threading import time import os.path from datetime import timedelta import voluptuous as vol from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.helpers import discovery from homeassistant.util import Throttle import homeassistant.config as conf_util import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['vsure==0.11.1'] _LOGGER = logging.getLogger(__name__) ATTR_DEVICE_SERIAL = 'device_serial' CONF_ALARM = 'alarm' CONF_CODE_DIGITS = 'code_digits' CONF_HYDROMETERS = 'hygrometers' CONF_LOCKS = 'locks' CONF_MOUSE = 'mouse' CONF_SMARTPLUGS = 'smartplugs' CONF_THERMOMETERS = 'thermometers' CONF_SMARTCAM = 'smartcam' DOMAIN = 'verisure' SERVICE_CAPTURE_SMARTCAM = 'capture_smartcam' HUB = None CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_USERNAME): cv.string, vol.Optional(CONF_ALARM, default=True): cv.boolean, vol.Optional(CONF_CODE_DIGITS, default=4): cv.positive_int, vol.Optional(CONF_HYDROMETERS, default=True): cv.boolean, vol.Optional(CONF_LOCKS, default=True): cv.boolean, vol.Optional(CONF_MOUSE, default=True): cv.boolean, vol.Optional(CONF_SMARTPLUGS, default=True): cv.boolean, vol.Optional(CONF_THERMOMETERS, default=True): cv.boolean, vol.Optional(CONF_SMARTCAM, default=True): cv.boolean, }), }, extra=vol.ALLOW_EXTRA) CAPTURE_IMAGE_SCHEMA = vol.Schema({ vol.Required(ATTR_DEVICE_SERIAL): cv.string }) def setup(hass, config): """Setup the Verisure component.""" import verisure global HUB HUB = VerisureHub(config[DOMAIN], verisure) if not HUB.login(): return False for component in ('sensor', 'switch', 'alarm_control_panel', 'lock', 'camera'): discovery.load_platform(hass, component, DOMAIN, {}, config) descriptions = conf_util.load_yaml_config_file( os.path.join(os.path.dirname(__file__), 'services.yaml')) def capture_smartcam(service): """Capture a new picture from a smartcam.""" device_id = service.data.get(ATTR_DEVICE_SERIAL) HUB.smartcam_capture(device_id) _LOGGER.debug('Capturing new image from %s', ATTR_DEVICE_SERIAL) hass.services.register(DOMAIN, SERVICE_CAPTURE_SMARTCAM, capture_smartcam, descriptions[DOMAIN][SERVICE_CAPTURE_SMARTCAM], schema=CAPTURE_IMAGE_SCHEMA) return True class VerisureHub(object): """A Verisure hub wrapper class.""" def __init__(self, domain_config, verisure): """Initialize the Verisure hub.""" self.alarm_status = {} self.lock_status = {} self.climate_status = {} self.mouse_status = {} self.smartplug_status = {} self.smartcam_status = {} self.smartcam_dict = {} self.config = domain_config self._verisure = verisure self._lock = threading.Lock() # When MyPages is brought up from maintenance it sometimes give us a # "wrong password" message. We will continue to retry after maintenance # regardless of that error. self._disable_wrong_password_error = False self._password_retries = 1 self._reconnect_timeout = time.time() self.my_pages = verisure.MyPages( domain_config[CONF_USERNAME], domain_config[CONF_PASSWORD]) def login(self): """Login to Verisure MyPages.""" try: self.my_pages.login() except self._verisure.Error as ex: _LOGGER.error('Could not log in to verisure mypages, %s', ex) return False return True @Throttle(timedelta(seconds=1)) def update_alarms(self): """Update the status of the alarm.""" self.update_component( self.my_pages.alarm.get, self.alarm_status) @Throttle(timedelta(seconds=1)) def update_locks(self): """Update the status of the locks.""" self.update_component( self.my_pages.lock.get, self.lock_status) @Throttle(timedelta(seconds=60)) def update_climate(self): """Update the status of the climate units.""" self.update_component( self.my_pages.climate.get, self.climate_status) @Throttle(timedelta(seconds=60)) def update_mousedetection(self): """Update the status of the mouse detectors.""" self.update_component( self.my_pages.mousedetection.get, self.mouse_status) @Throttle(timedelta(seconds=1)) def update_smartplugs(self): """Update the status of the smartplugs.""" self.update_component( self.my_pages.smartplug.get, self.smartplug_status) @Throttle(timedelta(seconds=30)) def update_smartcam(self): """Update the status of the smartcam.""" self.update_component( self.my_pages.smartcam.get, self.smartcam_status) @Throttle(timedelta(seconds=30)) def update_smartcam_imagelist(self): """Update the imagelist for the camera.""" _LOGGER.debug('Running update imagelist') self.smartcam_dict = self.my_pages.smartcam.get_imagelist() _LOGGER.debug('New dict: %s', self.smartcam_dict) @Throttle(timedelta(seconds=30)) def smartcam_capture(self, device_id): """Capture a new image from a smartcam.""" self.my_pages.smartcam.capture(device_id) @property def available(self): """Return True if hub is available.""" return self._password_retries >= 0 def update_component(self, get_function, status): """Update the status of Verisure components.""" try: for overview in get_function(): try: status[overview.id] = overview except AttributeError: status[overview.deviceLabel] = overview except self._verisure.Error as ex: _LOGGER.info('Caught connection error %s, tries to reconnect', ex) self.reconnect() def reconnect(self): """Reconnect to Verisure MyPages.""" if (self._reconnect_timeout > time.time() or not self._lock.acquire(blocking=False) or self._password_retries < 0): return try: self.my_pages.login() self._disable_wrong_password_error = False self._password_retries = 1 except self._verisure.LoginError as ex: _LOGGER.error("Wrong user name or password for Verisure MyPages") if self._disable_wrong_password_error: self._reconnect_timeout = time.time() + 60*60 else: self._password_retries = self._password_retries - 1 except self._verisure.MaintenanceError: self._disable_wrong_password_error = True self._reconnect_timeout = time.time() + 60*60 _LOGGER.error("Verisure MyPages down for maintenance") except self._verisure.Error as ex: _LOGGER.error("Could not login to Verisure MyPages, %s", ex) self._reconnect_timeout = time.time() + 60 finally: self._lock.release()
apache-2.0
[ 624, 199, 11532, 367, 5444, 374, 608, 7323, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 3931, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 422, 374, 608, 15, 199, 624, 199, 646, 2050, 199, 646, 5796, 199, 646, 900, 199, 646, 747, 14, 515, 199, 504, 2197, 492, 6871, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 1297, 492, 6392, 63, 9032, 12, 6392, 63, 11958, 199, 504, 8846, 14, 7546, 492, 13172, 199, 504, 8846, 14, 1974, 492, 3868, 12301, 199, 646, 8846, 14, 888, 465, 3743, 63, 1974, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 3122, 608, 389, 16, 14, 845, 14, 17, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 5280, 63, 10555, 63, 19637, 275, 283, 1782, 63, 2171, 7, 199, 3103, 63, 748, 12482, 275, 283, 14160, 7, 199, 3103, 63, 6012, 63, 22855, 5930, 275, 283, 600, 63, 7022, 7, 199, 3103, 63, 16255, 36, 3810, 775, 3960, 275, 283, 3577, 71, 5864, 878, 7, 199, 3103, 63, 4406, 51, 275, 283, 20218, 7, 199, 3103, 63, 25571, 275, 283, 10544, 7, 199, 3103, 63, 4029, 2294, 2749, 53, 8021, 275, 283, 7853, 1168, 85, 458, 7, 199, 3103, 63, 2080, 540, 2679, 3940, 3960, 275, 283, 728, 573, 20893, 7, 199, 3103, 63, 4029, 2294, 29932, 275, 283, 7853, 15176, 7, 199, 7378, 275, 283, 422, 374, 608, 7, 199, 10486, 63, 28342, 3942, 63, 4029, 2294, 29932, 275, 283, 12685, 63, 7853, 15176, 7, 199, 199, 40, 2533, 275, 488, 199, 199, 5569, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 15265, 26, 5236, 14, 6700, 2561, 267, 5236, 14, 8030, 8, 3103, 63, 9032, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 11958, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 748, 12482, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 6012, 63, 22855, 5930, 12, 849, 29, 20, 304, 6277, 14, 8965, 63, 442, 12, 267, 5236, 14, 7012, 8, 3103, 63, 16255, 36, 3810, 775, 3960, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 4406, 51, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 25571, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 4029, 2294, 2749, 53, 8021, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 2080, 540, 2679, 3940, 3960, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 4029, 2294, 29932, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 272, 9998, 199, 1386, 2402, 29, 5650, 14, 12231, 63, 18555, 9, 199, 199, 28342, 3942, 63, 9438, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 5236, 14, 8030, 8, 5280, 63, 10555, 63, 19637, 304, 6277, 14, 875, 199, 1552, 421, 199, 318, 3272, 8, 5387, 12, 1101, 304, 272, 408, 8555, 314, 5444, 374, 608, 3931, 1041, 272, 492, 809, 374, 608, 272, 2288, 869, 2533, 272, 869, 2533, 275, 5444, 374, 608, 15338, 8, 888, 59, 7378, 467, 809, 374, 608, 9, 272, 340, 440, 869, 2533, 14, 2886, 837, 267, 372, 756, 339, 367, 3931, 315, 661, 8956, 297, 283, 5656, 297, 283, 14160, 63, 2785, 63, 7885, 297, 283, 831, 297, 1993, 283, 11928, 735, 267, 13172, 14, 912, 63, 3246, 8, 5387, 12, 3931, 12, 15265, 12, 5479, 1101, 9, 339, 18714, 275, 3743, 63, 1974, 14, 912, 63, 5963, 63, 888, 63, 493, 8, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5950, 14, 5963, 1333, 339, 347, 12296, 63, 7853, 15176, 8, 1364, 304, 267, 408, 16640, 282, 892, 24945, 687, 282, 11179, 15176, 1041, 267, 2243, 63, 344, 275, 2435, 14, 576, 14, 362, 8, 5280, 63, 10555, 63, 19637, 9, 267, 869, 2533, 14, 7853, 15176, 63, 12685, 8, 1782, 63, 344, 9, 267, 485, 10186, 14, 1757, 360, 13519, 4039, 892, 1834, 687, 450, 83, 297, 10762, 63, 10555, 63, 19637, 9, 339, 6298, 14, 5950, 14, 2683, 8, 7378, 12, 16655, 63, 28342, 3942, 63, 4029, 2294, 29932, 12, 2574, 12296, 63, 7853, 15176, 12, 2574, 18714, 59, 7378, 1527, 10486, 63, 28342, 3942, 63, 4029, 2294, 29932, 467, 2574, 4177, 29, 28342, 3942, 63, 9438, 63, 10926, 9, 339, 372, 715, 421, 199, 533, 5444, 374, 608, 15338, 8, 785, 304, 272, 408, 33, 5444, 374, 608, 26726, 4975, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 2881, 63, 888, 12, 809, 374, 608, 304, 267, 408, 9345, 314, 5444, 374, 608, 26726, 1041, 267, 291, 14, 14160, 63, 1205, 275, 1052, 267, 291, 14, 831, 63, 1205, 275, 1052, 267, 291, 14, 2764, 17684, 63, 1205, 275, 1052, 267, 291, 14, 10544, 63, 1205, 275, 1052, 267, 291, 14, 7853, 13963, 63, 1205, 275, 1052, 267, 291, 14, 7853, 15176, 63, 1205, 275, 1052, 267, 291, 14, 7853, 15176, 63, 807, 275, 1052, 398, 291, 14, 888, 275, 2881, 63, 888, 267, 291, 423, 422, 374, 608, 275, 809, 374, 608, 398, 291, 423, 831, 275, 5796, 14, 6432, 342, 398, 327, 3979, 4932, 17773, 365, 330, 7930, 913, 1536, 687, 21964, 652, 15026, 8120, 2739, 282, 267, 327, 298, 10603, 2505, 2, 1245, 14, 2136, 911, 1980, 370, 7269, 2410, 21964, 267, 327, 15270, 402, 626, 1125, 14, 267, 291, 423, 5993, 63, 10603, 63, 2060, 63, 705, 275, 756, 267, 291, 423, 2060, 63, 10937, 275, 413, 267, 291, 423, 29464, 63, 2593, 275, 900, 14, 521, 342, 398, 291, 14, 1662, 63, 5856, 275, 809, 374, 608, 14, 5713, 17773, 8, 288, 2881, 63, 888, 59, 3103, 63, 11958, 467, 288, 2881, 63, 888, 59, 3103, 63, 9032, 566, 339, 347, 4676, 8, 277, 304, 267, 408, 8880, 370, 5444, 374, 608, 4932, 17773, 1041, 267, 862, 26, 288, 291 ]
[ 199, 11532, 367, 5444, 374, 608, 7323, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 3931, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 422, 374, 608, 15, 199, 624, 199, 646, 2050, 199, 646, 5796, 199, 646, 900, 199, 646, 747, 14, 515, 199, 504, 2197, 492, 6871, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 1297, 492, 6392, 63, 9032, 12, 6392, 63, 11958, 199, 504, 8846, 14, 7546, 492, 13172, 199, 504, 8846, 14, 1974, 492, 3868, 12301, 199, 646, 8846, 14, 888, 465, 3743, 63, 1974, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 3122, 608, 389, 16, 14, 845, 14, 17, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 5280, 63, 10555, 63, 19637, 275, 283, 1782, 63, 2171, 7, 199, 3103, 63, 748, 12482, 275, 283, 14160, 7, 199, 3103, 63, 6012, 63, 22855, 5930, 275, 283, 600, 63, 7022, 7, 199, 3103, 63, 16255, 36, 3810, 775, 3960, 275, 283, 3577, 71, 5864, 878, 7, 199, 3103, 63, 4406, 51, 275, 283, 20218, 7, 199, 3103, 63, 25571, 275, 283, 10544, 7, 199, 3103, 63, 4029, 2294, 2749, 53, 8021, 275, 283, 7853, 1168, 85, 458, 7, 199, 3103, 63, 2080, 540, 2679, 3940, 3960, 275, 283, 728, 573, 20893, 7, 199, 3103, 63, 4029, 2294, 29932, 275, 283, 7853, 15176, 7, 199, 7378, 275, 283, 422, 374, 608, 7, 199, 10486, 63, 28342, 3942, 63, 4029, 2294, 29932, 275, 283, 12685, 63, 7853, 15176, 7, 199, 199, 40, 2533, 275, 488, 199, 199, 5569, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 15265, 26, 5236, 14, 6700, 2561, 267, 5236, 14, 8030, 8, 3103, 63, 9032, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 11958, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 748, 12482, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 6012, 63, 22855, 5930, 12, 849, 29, 20, 304, 6277, 14, 8965, 63, 442, 12, 267, 5236, 14, 7012, 8, 3103, 63, 16255, 36, 3810, 775, 3960, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 4406, 51, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 25571, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 4029, 2294, 2749, 53, 8021, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 2080, 540, 2679, 3940, 3960, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 267, 5236, 14, 7012, 8, 3103, 63, 4029, 2294, 29932, 12, 849, 29, 549, 304, 6277, 14, 4871, 12, 272, 9998, 199, 1386, 2402, 29, 5650, 14, 12231, 63, 18555, 9, 199, 199, 28342, 3942, 63, 9438, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 5236, 14, 8030, 8, 5280, 63, 10555, 63, 19637, 304, 6277, 14, 875, 199, 1552, 421, 199, 318, 3272, 8, 5387, 12, 1101, 304, 272, 408, 8555, 314, 5444, 374, 608, 3931, 1041, 272, 492, 809, 374, 608, 272, 2288, 869, 2533, 272, 869, 2533, 275, 5444, 374, 608, 15338, 8, 888, 59, 7378, 467, 809, 374, 608, 9, 272, 340, 440, 869, 2533, 14, 2886, 837, 267, 372, 756, 339, 367, 3931, 315, 661, 8956, 297, 283, 5656, 297, 283, 14160, 63, 2785, 63, 7885, 297, 283, 831, 297, 1993, 283, 11928, 735, 267, 13172, 14, 912, 63, 3246, 8, 5387, 12, 3931, 12, 15265, 12, 5479, 1101, 9, 339, 18714, 275, 3743, 63, 1974, 14, 912, 63, 5963, 63, 888, 63, 493, 8, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5950, 14, 5963, 1333, 339, 347, 12296, 63, 7853, 15176, 8, 1364, 304, 267, 408, 16640, 282, 892, 24945, 687, 282, 11179, 15176, 1041, 267, 2243, 63, 344, 275, 2435, 14, 576, 14, 362, 8, 5280, 63, 10555, 63, 19637, 9, 267, 869, 2533, 14, 7853, 15176, 63, 12685, 8, 1782, 63, 344, 9, 267, 485, 10186, 14, 1757, 360, 13519, 4039, 892, 1834, 687, 450, 83, 297, 10762, 63, 10555, 63, 19637, 9, 339, 6298, 14, 5950, 14, 2683, 8, 7378, 12, 16655, 63, 28342, 3942, 63, 4029, 2294, 29932, 12, 2574, 12296, 63, 7853, 15176, 12, 2574, 18714, 59, 7378, 1527, 10486, 63, 28342, 3942, 63, 4029, 2294, 29932, 467, 2574, 4177, 29, 28342, 3942, 63, 9438, 63, 10926, 9, 339, 372, 715, 421, 199, 533, 5444, 374, 608, 15338, 8, 785, 304, 272, 408, 33, 5444, 374, 608, 26726, 4975, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 2881, 63, 888, 12, 809, 374, 608, 304, 267, 408, 9345, 314, 5444, 374, 608, 26726, 1041, 267, 291, 14, 14160, 63, 1205, 275, 1052, 267, 291, 14, 831, 63, 1205, 275, 1052, 267, 291, 14, 2764, 17684, 63, 1205, 275, 1052, 267, 291, 14, 10544, 63, 1205, 275, 1052, 267, 291, 14, 7853, 13963, 63, 1205, 275, 1052, 267, 291, 14, 7853, 15176, 63, 1205, 275, 1052, 267, 291, 14, 7853, 15176, 63, 807, 275, 1052, 398, 291, 14, 888, 275, 2881, 63, 888, 267, 291, 423, 422, 374, 608, 275, 809, 374, 608, 398, 291, 423, 831, 275, 5796, 14, 6432, 342, 398, 327, 3979, 4932, 17773, 365, 330, 7930, 913, 1536, 687, 21964, 652, 15026, 8120, 2739, 282, 267, 327, 298, 10603, 2505, 2, 1245, 14, 2136, 911, 1980, 370, 7269, 2410, 21964, 267, 327, 15270, 402, 626, 1125, 14, 267, 291, 423, 5993, 63, 10603, 63, 2060, 63, 705, 275, 756, 267, 291, 423, 2060, 63, 10937, 275, 413, 267, 291, 423, 29464, 63, 2593, 275, 900, 14, 521, 342, 398, 291, 14, 1662, 63, 5856, 275, 809, 374, 608, 14, 5713, 17773, 8, 288, 2881, 63, 888, 59, 3103, 63, 11958, 467, 288, 2881, 63, 888, 59, 3103, 63, 9032, 566, 339, 347, 4676, 8, 277, 304, 267, 408, 8880, 370, 5444, 374, 608, 4932, 17773, 1041, 267, 862, 26, 288, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ge0rgi/cinder
cinder/tests/unit/api/v2/test_limits.py
1
29139
# Copyright 2011 OpenStack Foundation # 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 dealing with HTTP rate-limiting. """ from oslo_serialization import jsonutils import six from six.moves import http_client from six.moves import range import webob from cinder.api.v2 import limits from cinder.api import views import cinder.context from cinder import test TEST_LIMITS = [ limits.Limit("GET", "/delayed", "^/delayed", 1, limits.PER_MINUTE), limits.Limit("POST", "*", ".*", 7, limits.PER_MINUTE), limits.Limit("POST", "/volumes", "^/volumes", 3, limits.PER_MINUTE), limits.Limit("PUT", "*", "", 10, limits.PER_MINUTE), limits.Limit("PUT", "/volumes", "^/volumes", 5, limits.PER_MINUTE), ] NS = { 'atom': 'http://www.w3.org/2005/Atom', 'ns': 'http://docs.openstack.org/common/api/v1.0', } class BaseLimitTestSuite(test.TestCase): """Base test suite which provides relevant stubs and time abstraction.""" def setUp(self): super(BaseLimitTestSuite, self).setUp() self.time = 0.0 self.mock_object(limits.Limit, "_get_time", self._get_time) self.absolute_limits = {} def fake_get_project_quotas(context, project_id, usages=True): return {k: dict(limit=v) for k, v in self.absolute_limits.items()} self.mock_object(cinder.quota.QUOTAS, "get_project_quotas", fake_get_project_quotas) def _get_time(self): """Return the "time" according to this test suite.""" return self.time class LimitsControllerTest(BaseLimitTestSuite): """Tests for `limits.LimitsController` class.""" def setUp(self): """Run before each test.""" super(LimitsControllerTest, self).setUp() self.controller = limits.create_resource() def _get_index_request(self, accept_header="application/json"): """Helper to set routing arguments.""" request = webob.Request.blank("/") request.accept = accept_header request.environ["wsgiorg.routing_args"] = (None, { "action": "index", "controller": "", }) context = cinder.context.RequestContext('testuser', 'testproject') request.environ["cinder.context"] = context return request def _populate_limits(self, request): """Put limit info into a request.""" _limits = [ limits.Limit("GET", "*", ".*", 10, 60).display(), limits.Limit("POST", "*", ".*", 5, 60 * 60).display(), limits.Limit("GET", "changes-since*", "changes-since", 5, 60).display(), ] request.environ["cinder.limits"] = _limits return request def test_empty_index_json(self): """Test getting empty limit details in JSON.""" request = self._get_index_request() response = request.get_response(self.controller) expected = { "limits": { "rate": [], "absolute": {}, }, } body = jsonutils.loads(response.body) self.assertEqual(expected, body) def test_index_json(self): """Test getting limit details in JSON.""" request = self._get_index_request() request = self._populate_limits(request) self.absolute_limits = { 'gigabytes': 512, 'volumes': 5, } response = request.get_response(self.controller) expected = { "limits": { "rate": [ { "regex": ".*", "uri": "*", "limit": [ { "verb": "GET", "next-available": "1970-01-01T00:00:00", "unit": "MINUTE", "value": 10, "remaining": 10, }, { "verb": "POST", "next-available": "1970-01-01T00:00:00", "unit": "HOUR", "value": 5, "remaining": 5, }, ], }, { "regex": "changes-since", "uri": "changes-since*", "limit": [ { "verb": "GET", "next-available": "1970-01-01T00:00:00", "unit": "MINUTE", "value": 5, "remaining": 5, }, ], }, ], "absolute": {"maxTotalVolumeGigabytes": 512, "maxTotalVolumes": 5, }, }, } body = jsonutils.loads(response.body) self.assertEqual(expected, body) def _populate_limits_diff_regex(self, request): """Put limit info into a request.""" _limits = [ limits.Limit("GET", "*", ".*", 10, 60).display(), limits.Limit("GET", "*", "*.*", 10, 60).display(), ] request.environ["cinder.limits"] = _limits return request def test_index_diff_regex(self): """Test getting limit details in JSON.""" request = self._get_index_request() request = self._populate_limits_diff_regex(request) response = request.get_response(self.controller) expected = { "limits": { "rate": [ { "regex": ".*", "uri": "*", "limit": [ { "verb": "GET", "next-available": "1970-01-01T00:00:00", "unit": "MINUTE", "value": 10, "remaining": 10, }, ], }, { "regex": "*.*", "uri": "*", "limit": [ { "verb": "GET", "next-available": "1970-01-01T00:00:00", "unit": "MINUTE", "value": 10, "remaining": 10, }, ], }, ], "absolute": {}, }, } body = jsonutils.loads(response.body) self.assertEqual(expected, body) def _test_index_absolute_limits_json(self, expected): request = self._get_index_request() response = request.get_response(self.controller) body = jsonutils.loads(response.body) self.assertEqual(expected, body['limits']['absolute']) def test_index_ignores_extra_absolute_limits_json(self): self.absolute_limits = {'unknown_limit': 9001} self._test_index_absolute_limits_json({}) class TestLimiter(limits.Limiter): pass class LimitMiddlewareTest(BaseLimitTestSuite): """Tests for the `limits.RateLimitingMiddleware` class.""" @webob.dec.wsgify def _empty_app(self, request): """Do-nothing WSGI app.""" pass def setUp(self): """Prepare middleware for use through fake WSGI app.""" super(LimitMiddlewareTest, self).setUp() _limits = '(GET, *, .*, 1, MINUTE)' self.app = limits.RateLimitingMiddleware(self._empty_app, _limits, "%s.TestLimiter" % self.__class__.__module__) def test_limit_class(self): """Test that middleware selected correct limiter class.""" self.assertIsInstance(self.app._limiter, TestLimiter) def test_good_request(self): """Test successful GET request through middleware.""" request = webob.Request.blank("/") response = request.get_response(self.app) self.assertEqual(200, response.status_int) def test_limited_request_json(self): """Test a rate-limited (413) GET request through middleware.""" request = webob.Request.blank("/") response = request.get_response(self.app) self.assertEqual(200, response.status_int) request = webob.Request.blank("/") response = request.get_response(self.app) self.assertEqual(413, response.status_int) self.assertIn('Retry-After', response.headers) retry_after = int(response.headers['Retry-After']) self.assertAlmostEqual(retry_after, 60, 1) body = jsonutils.loads(response.body) expected = "Only 1 GET request(s) can be made to * every minute." value = body["overLimitFault"]["details"].strip() self.assertEqual(expected, value) class LimitTest(BaseLimitTestSuite): """Tests for the `limits.Limit` class.""" def test_GET_no_delay(self): """Test a limit handles 1 GET per second.""" limit = limits.Limit("GET", "*", ".*", 1, 1) delay = limit("GET", "/anything") self.assertIsNone(delay) self.assertEqual(0, limit.next_request) self.assertEqual(0, limit.last_request) def test_GET_delay(self): """Test two calls to 1 GET per second limit.""" limit = limits.Limit("GET", "*", ".*", 1, 1) delay = limit("GET", "/anything") self.assertIsNone(delay) delay = limit("GET", "/anything") self.assertEqual(1, delay) self.assertEqual(1, limit.next_request) self.assertEqual(0, limit.last_request) self.time += 4 delay = limit("GET", "/anything") self.assertIsNone(delay) self.assertEqual(4, limit.next_request) self.assertEqual(4, limit.last_request) def test_invalid_limit(self): """Test that invalid limits are properly checked on construction.""" self.assertRaises(ValueError, limits.Limit, "GET", "*", ".*", 0, 1) class ParseLimitsTest(BaseLimitTestSuite): """Tests for the default limits parser in the `limits.Limiter` class.""" def test_invalid(self): """Test that parse_limits() handles invalid input correctly.""" self.assertRaises(ValueError, limits.Limiter.parse_limits, ';;;;;') def test_bad_rule(self): """Test that parse_limits() handles bad rules correctly.""" self.assertRaises(ValueError, limits.Limiter.parse_limits, 'GET, *, .*, 20, minute') def test_missing_arg(self): """Test that parse_limits() handles missing args correctly.""" self.assertRaises(ValueError, limits.Limiter.parse_limits, '(GET, *, .*, 20)') def test_bad_value(self): """Test that parse_limits() handles bad values correctly.""" self.assertRaises(ValueError, limits.Limiter.parse_limits, '(GET, *, .*, foo, minute)') def test_bad_unit(self): """Test that parse_limits() handles bad units correctly.""" self.assertRaises(ValueError, limits.Limiter.parse_limits, '(GET, *, .*, 20, lightyears)') def test_multiple_rules(self): """Test that parse_limits() handles multiple rules correctly.""" try: l = limits.Limiter.parse_limits('(get, *, .*, 20, minute);' '(PUT, /foo*, /foo.*, 10, hour);' '(POST, /bar*, /bar.*, 5, second);' '(Say, /derp*, /derp.*, 1, day)') except ValueError as e: self.assertFalse(six.text_type(e)) # Make sure the number of returned limits are correct self.assertEqual(4, len(l)) # Check all the verbs... expected = ['GET', 'PUT', 'POST', 'SAY'] self.assertEqual(expected, [t.verb for t in l]) # ...the URIs... expected = ['*', '/foo*', '/bar*', '/derp*'] self.assertEqual(expected, [t.uri for t in l]) # ...the regexes... expected = ['.*', '/foo.*', '/bar.*', '/derp.*'] self.assertEqual(expected, [t.regex for t in l]) # ...the values... expected = [20, 10, 5, 1] self.assertEqual(expected, [t.value for t in l]) # ...and the units... expected = [limits.PER_MINUTE, limits.PER_HOUR, limits.PER_SECOND, limits.PER_DAY] self.assertEqual(expected, [t.unit for t in l]) class LimiterTest(BaseLimitTestSuite): """Tests for the in-memory `limits.Limiter` class.""" def setUp(self): """Run before each test.""" super(LimiterTest, self).setUp() userlimits = {'limits.user3': '', 'limits.user0': '(get, *, .*, 4, minute);' '(put, *, .*, 2, minute)'} self.limiter = limits.Limiter(TEST_LIMITS, **userlimits) def _check(self, num, verb, url, username=None): """Check and yield results from checks.""" for x in range(num): yield self.limiter.check_for_delay(verb, url, username)[0] def _check_sum(self, num, verb, url, username=None): """Check and sum results from checks.""" results = self._check(num, verb, url, username) return sum(item for item in results if item) def test_no_delay_GET(self): """Ensure no delay on a single call for a limit verb we didn't set.""" delay = self.limiter.check_for_delay("GET", "/anything") self.assertEqual((None, None), delay) def test_no_delay_PUT(self): """Ensure no delay on a single call for a known limit.""" delay = self.limiter.check_for_delay("PUT", "/anything") self.assertEqual((None, None), delay) def test_delay_PUT(self): """Test delay on 11th PUT request. Ensure the 11th PUT will result in a delay of 6.0 seconds until the next request will be granced. """ expected = [None] * 10 + [6.0] results = list(self._check(11, "PUT", "/anything")) self.assertEqual(expected, results) def test_delay_POST(self): """Test delay on 8th POST request. Ensure the 8th POST will result in a delay of 6.0 seconds until the next request will be granced. """ expected = [None] * 7 results = list(self._check(7, "POST", "/anything")) self.assertEqual(expected, results) expected = 60.0 / 7.0 results = self._check_sum(1, "POST", "/anything") self.assertAlmostEqual(expected, results, 8) def test_delay_GET(self): """Ensure the 11th GET will result in NO delay.""" expected = [None] * 11 results = list(self._check(11, "GET", "/anything")) self.assertEqual(expected, results) expected = [None] * 4 + [15.0] results = list(self._check(5, "GET", "/foo", "user0")) self.assertEqual(expected, results) def test_delay_PUT_volumes(self): """Test delay on /volumes. Ensure PUT on /volumes limits at 5 requests, and PUT elsewhere is still OK after 5 requests...but then after 11 total requests, PUT limiting kicks in. """ # First 6 requests on PUT /volumes expected = [None] * 5 + [12.0] results = list(self._check(6, "PUT", "/volumes")) self.assertEqual(expected, results) # Next 5 request on PUT /anything expected = [None] * 4 + [6.0] results = list(self._check(5, "PUT", "/anything")) self.assertEqual(expected, results) def test_delay_PUT_wait(self): """Test limit is lifted again. Ensure after hitting the limit and then waiting for the correct amount of time, the limit will be lifted. """ expected = [None] * 10 + [6.0] results = list(self._check(11, "PUT", "/anything")) self.assertEqual(expected, results) # Advance time self.time += 6.0 expected = [None, 6.0] results = list(self._check(2, "PUT", "/anything")) self.assertEqual(expected, results) def test_multiple_delays(self): """Ensure multiple requests still get a delay.""" expected = [None] * 10 + [6.0] * 10 results = list(self._check(20, "PUT", "/anything")) self.assertEqual(expected, results) self.time += 1.0 expected = [5.0] * 10 results = list(self._check(10, "PUT", "/anything")) self.assertEqual(expected, results) expected = [None] * 2 + [30.0] * 8 results = list(self._check(10, "PUT", "/anything", "user0")) self.assertEqual(expected, results) def test_user_limit(self): """Test user-specific limits.""" self.assertEqual([], self.limiter.levels['user3']) self.assertEqual(2, len(self.limiter.levels['user0'])) def test_multiple_users(self): """Tests involving multiple users.""" # User0 expected = [None] * 2 + [30.0] * 8 results = list(self._check(10, "PUT", "/anything", "user0")) self.assertEqual(expected, results) # User1 expected = [None] * 10 + [6.0] * 10 results = list(self._check(20, "PUT", "/anything", "user1")) self.assertEqual(expected, results) # User2 expected = [None] * 10 + [6.0] * 5 results = list(self._check(15, "PUT", "/anything", "user2")) self.assertEqual(expected, results) # User3 expected = [None] * 20 results = list(self._check(20, "PUT", "/anything", "user3")) self.assertEqual(expected, results) self.time += 1.0 # User1 again expected = [5.0] * 10 results = list(self._check(10, "PUT", "/anything", "user1")) self.assertEqual(expected, results) self.time += 1.0 # User1 again expected = [4.0] * 5 results = list(self._check(5, "PUT", "/anything", "user2")) self.assertEqual(expected, results) # User0 again expected = [28.0] results = list(self._check(1, "PUT", "/anything", "user0")) self.assertEqual(expected, results) self.time += 28.0 expected = [None, 30.0] results = list(self._check(2, "PUT", "/anything", "user0")) self.assertEqual(expected, results) class WsgiLimiterTest(BaseLimitTestSuite): """Tests for `limits.WsgiLimiter` class.""" def setUp(self): """Run before each test.""" super(WsgiLimiterTest, self).setUp() self.app = limits.WsgiLimiter(TEST_LIMITS) def _request_data(self, verb, path): """Get data describing a limit request verb/path.""" return jsonutils.dump_as_bytes({"verb": verb, "path": path}) def _request(self, verb, url, username=None): """POST request to given url by given username. Make sure that POSTing to the given url causes the given username to perform the given action. Make the internal rate limiter return delay and make sure that the WSGI app returns the correct response. """ if username: request = webob.Request.blank("/%s" % username) else: request = webob.Request.blank("/") request.method = "POST" request.body = self._request_data(verb, url) response = request.get_response(self.app) if "X-Wait-Seconds" in response.headers: self.assertEqual(403, response.status_int) return response.headers["X-Wait-Seconds"] self.assertEqual(204, response.status_int) def test_invalid_methods(self): """Only POSTs should work.""" for method in ["GET", "PUT", "DELETE", "HEAD", "OPTIONS"]: request = webob.Request.blank("/", method=method) response = request.get_response(self.app) self.assertEqual(405, response.status_int) def test_good_url(self): delay = self._request("GET", "/something") self.assertIsNone(delay) def test_escaping(self): delay = self._request("GET", "/something/jump%20up") self.assertIsNone(delay) def test_response_to_delays(self): delay = self._request("GET", "/delayed") self.assertIsNone(delay) delay = self._request("GET", "/delayed") self.assertEqual('60.00', delay) def test_response_to_delays_usernames(self): delay = self._request("GET", "/delayed", "user1") self.assertIsNone(delay) delay = self._request("GET", "/delayed", "user2") self.assertIsNone(delay) delay = self._request("GET", "/delayed", "user1") self.assertEqual('60.00', delay) delay = self._request("GET", "/delayed", "user2") self.assertEqual('60.00', delay) class FakeHttplibSocket(object): """Fake `http_client.HTTPResponse` replacement.""" def __init__(self, response_string): """Initialize new `FakeHttplibSocket`.""" if isinstance(response_string, six.text_type): response_string = response_string.encode('utf-8') self._buffer = six.BytesIO(response_string) def makefile(self, mode, *args): """Returns the socket's internal buffer.""" return self._buffer class FakeHttplibConnection(object): """Fake `http_client.HTTPConnection`.""" def __init__(self, app, host): """Initialize `FakeHttplibConnection`.""" self.app = app self.host = host def request(self, method, path, body="", headers=None): """Fake request handler. Requests made via this connection actually get translated and routed into our WSGI app, we then wait for the response and turn it back into an `http_client.HTTPResponse`. """ if not headers: headers = {} req = webob.Request.blank(path) req.method = method req.headers = headers req.host = self.host req.body = body resp = str(req.get_response(self.app)) resp = "HTTP/1.0 %s" % resp sock = FakeHttplibSocket(resp) self.http_response = http_client.HTTPResponse(sock) self.http_response.begin() def getresponse(self): """Return our generated response from the request.""" return self.http_response def wire_HTTPConnection_to_WSGI(host, app): """Monkeypatches HTTPConnection. Monkeypatches HTTPConnection so that if you try to connect to host, you are instead routed straight to the given WSGI app. After calling this method, when any code calls http_client.HTTPConnection(host) the connection object will be a fake. Its requests will be sent directly to the given WSGI app rather than through a socket. Code connecting to hosts other than host will not be affected. This method may be called multiple times to map different hosts to different apps. This method returns the original HTTPConnection object, so that the caller can restore the default HTTPConnection interface (for all hosts). """ class HTTPConnectionDecorator(object): """Decorator to mock the HTTPConecction class. Wraps the real HTTPConnection class so that when you instantiate the class you might instead get a fake instance. """ def __init__(self, wrapped): self.wrapped = wrapped def __call__(self, connection_host, *args, **kwargs): if connection_host == host: return FakeHttplibConnection(app, host) else: return self.wrapped(connection_host, *args, **kwargs) oldHTTPConnection = http_client.HTTPConnection new_http_connection = HTTPConnectionDecorator(http_client.HTTPConnection) http_client.HTTPConnection = new_http_connection return oldHTTPConnection class WsgiLimiterProxyTest(BaseLimitTestSuite): """Tests for the `limits.WsgiLimiterProxy` class.""" def setUp(self): """setUp() for WsgiLimiterProxyTest. Do some nifty HTTP/WSGI magic which allows for WSGI to be called directly by something like the `http_client` library. """ super(WsgiLimiterProxyTest, self).setUp() self.app = limits.WsgiLimiter(TEST_LIMITS) oldHTTPConnection = ( wire_HTTPConnection_to_WSGI("169.254.0.1:80", self.app)) self.proxy = limits.WsgiLimiterProxy("169.254.0.1:80") self.addCleanup(self._restore, oldHTTPConnection) def _restore(self, oldHTTPConnection): # restore original HTTPConnection object http_client.HTTPConnection = oldHTTPConnection def test_200(self): """Successful request test.""" delay = self.proxy.check_for_delay("GET", "/anything") self.assertEqual((None, None), delay) def test_403(self): """Forbidden request test.""" delay = self.proxy.check_for_delay("GET", "/delayed") self.assertEqual((None, None), delay) delay, error = self.proxy.check_for_delay("GET", "/delayed") error = error.strip() expected = ("60.00", b"403 Forbidden\n\nOnly 1 GET request(s) can be " b"made to /delayed every minute.") self.assertEqual(expected, (delay, error)) class LimitsViewBuilderTest(test.TestCase): def setUp(self): super(LimitsViewBuilderTest, self).setUp() self.view_builder = views.limits.ViewBuilder() self.rate_limits = [{"URI": "*", "regex": ".*", "value": 10, "verb": "POST", "remaining": 2, "unit": "MINUTE", "resetTime": 1311272226}, {"URI": "*/volumes", "regex": "^/volumes", "value": 50, "verb": "POST", "remaining": 10, "unit": "DAY", "resetTime": 1311272226}] self.absolute_limits = {"gigabytes": 1, "backup_gigabytes": 2, "volumes": 3, "snapshots": 4, "backups": 5} def test_build_limits(self): tdate = "2011-07-21T18:17:06" expected_limits = { "limits": {"rate": [{"uri": "*", "regex": ".*", "limit": [{"value": 10, "verb": "POST", "remaining": 2, "unit": "MINUTE", "next-available": tdate}]}, {"uri": "*/volumes", "regex": "^/volumes", "limit": [{"value": 50, "verb": "POST", "remaining": 10, "unit": "DAY", "next-available": tdate}]}], "absolute": {"maxTotalVolumeGigabytes": 1, "maxTotalBackupGigabytes": 2, "maxTotalVolumes": 3, "maxTotalSnapshots": 4, "maxTotalBackups": 5}}} output = self.view_builder.build(self.rate_limits, self.absolute_limits) self.assertDictEqual(expected_limits, output) def test_build_limits_empty_limits(self): expected_limits = {"limits": {"rate": [], "absolute": {}}} abs_limits = {} rate_limits = [] output = self.view_builder.build(rate_limits, abs_limits) self.assertDictEqual(expected_limits, output)
apache-2.0
[ 3, 1898, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 2925, 23654, 543, 3101, 6634, 13, 3097, 316, 14, 199, 624, 199, 199, 504, 11258, 63, 12161, 492, 18705, 199, 646, 3816, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 504, 3816, 14, 4912, 492, 1425, 199, 646, 14568, 199, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 10976, 199, 504, 13069, 14, 1246, 492, 6858, 199, 646, 13069, 14, 1100, 199, 504, 13069, 492, 511, 421, 199, 2864, 63, 13387, 51, 275, 359, 272, 10976, 14, 8407, 480, 2970, 401, 3286, 21830, 401, 18129, 15, 21830, 401, 413, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4030, 401, 8969, 401, 298, 2795, 401, 1520, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4030, 401, 3286, 8838, 401, 18129, 15, 8838, 401, 650, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4013, 401, 8969, 401, 4873, 1616, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4013, 401, 3286, 8838, 401, 18129, 15, 8838, 401, 959, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 199, 61, 199, 2709, 275, 469, 272, 283, 4188, 356, 283, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 297, 272, 283, 561, 356, 283, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 2330, 15, 1246, 15, 86, 17, 14, 16, 297, 199, 93, 421, 199, 533, 3523, 8407, 10591, 8, 396, 14, 1746, 304, 272, 408, 1563, 511, 5241, 1314, 6571, 12082, 22312, 436, 900, 2236, 29639, 1041, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 1563, 8407, 10591, 12, 291, 680, 5996, 342, 267, 291, 14, 521, 275, 378, 14, 16, 267, 291, 14, 1805, 63, 785, 8, 9368, 14, 8407, 12, 2668, 362, 63, 521, 401, 291, 423, 362, 63, 521, 9, 267, 291, 14, 6116, 63, 9368, 275, 1052, 398, 347, 4026, 63, 362, 63, 1715, 63, 17056, 8, 1100, 12, 2199, 63, 344, 12, 4503, 83, 29, 549, 304, 288, 372, 469, 75, 26, 1211, 8, 3097, 29, 86, 9, 367, 1022, 12, 373, 315, 291, 14, 6116, 63, 9368, 14, 1744, 12737, 398, 291, 14, 1805, 63, 785, 8, 12372, 14, 8848, 14, 18654, 1179, 12, 298, 362, 63, 1715, 63, 17056, 401, 586, 4026, 63, 362, 63, 1715, 63, 17056, 9, 339, 347, 485, 362, 63, 521, 8, 277, 304, 267, 408, 1767, 314, 298, 521, 2, 7182, 370, 642, 511, 5241, 1041, 267, 372, 291, 14, 521, 421, 199, 533, 14620, 1405, 7506, 774, 8, 1563, 8407, 10591, 304, 339, 408, 2925, 367, 658, 9368, 14, 24480, 7506, 64, 1021, 1041, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 1613, 8, 24480, 7506, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 5538, 275, 10976, 14, 981, 63, 1927, 342, 339, 347, 485, 362, 63, 1080, 63, 1069, 8, 277, 12, 4729, 63, 1291, 628, 3578, 15, 1001, 2349, 267, 408, 4433, 370, 663, 14870, 2368, 1041, 267, 1056, 275, 14568, 14, 2017, 14, 2500, 19031, 267, 1056, 14, 5694, 275, 4729, 63, 1291, 267, 1056, 14, 2314, 905, 6508, 1308, 14, 9492, 63, 589, 937, 275, 334, 403, 12, 469, 288, 298, 1287, 582, 298, 1080, 401, 288, 298, 5538, 582, 4873, 267, 3828, 267, 1067, 275, 13069, 14, 1100, 14, 17679, 360, 21029, 297, 283, 396, 1715, 358, 267, 1056, 14, 2314, 905, 12372, 14, 1100, 937, 275, 1067, 267, 372, 1056, 339, 347, 485, 13817, 63, 9368, 8, 277, 12, 1056, 304, 267, 408, 18989, 2304, 2256, 1901, 282, 1056, 1041, 267, 485, 9368, 275, 359, 288, 10976, 14, 8407, 480, 2970, 401, 8969, 401, 298, 2795, 401, 1616, 12, 5212, 680, 2918, 1062, 288, 10976, 14, 8407, 480, 4030, 401, 8969, 401, 298, 2795, 401, 959, 12, 5212, 627, 5212, 680, 2918, 1062, 288, 10976, 14, 8407, 480, 2970, 401, 298, 6627, 13, 8585, 14421, 298, 6627, 13, 8585, 401, 586, 959, 12, 5212, 680, 2918, 1062, 267, 1622, 267, 1056, 14, 2314, 905, 12372, 14, 9368, 937, 275, 485, 9368, 267, 372, 1056, 339, 347, 511, 63, 1667, 63, 1080, 63, 1001, 8, 277, 304, 267, 408, 774, 10232, 2701, 2304, 2436, 315, 4840, 1041, 267, 1056, 275, 291, 423, 362, 63, 1080, 63, 1069, 342, 267, 1177, 275, 1056, 14, 362, 63, 1310, 8, 277, 14, 5538, 9, 267, 1420, 275, 469, 288, 298, 9368, 582, 469, 355, 298, 1866, 582, 990, 355, 298, 6116, 582, 5479, 288, 1660, 267, 789, 267, 2396, 275, 18705, 14, 3640, 8, 1310, 14, 2030, 9, 267, 291, 14, 629, 8, 2062, 12, 2396, 9, 339, 347, 511, 63, 1080, 63, 1001, 8, 277, 304, 267, 408, 774, 10232, 2304, 2436, 315, 4840, 1041, 267, 1056, 275, 291, 423, 362, 63, 1080, 63, 1069, 342, 267, 1056, 275, 291, 423, 13817, 63, 9368, 8, 1069, 9, 267, 291, 14, 6116, 63, 9368, 275, 469, 288, 283, 71, 528, 27601, 356, 10574, 12, 288, 283, 8838, 356, 959, 12, 267, 789, 267, 1177, 275, 1056, 14, 362, 63, 1310, 8, 277, 14, 5538, 9, 267, 1420, 275, 469, 288, 298, 9368, 582, 469, 355, 298, 1866, 582, 359, 490, 469, 717, 298, 3821, 582 ]
[ 1898, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 2925, 23654, 543, 3101, 6634, 13, 3097, 316, 14, 199, 624, 199, 199, 504, 11258, 63, 12161, 492, 18705, 199, 646, 3816, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 504, 3816, 14, 4912, 492, 1425, 199, 646, 14568, 199, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 10976, 199, 504, 13069, 14, 1246, 492, 6858, 199, 646, 13069, 14, 1100, 199, 504, 13069, 492, 511, 421, 199, 2864, 63, 13387, 51, 275, 359, 272, 10976, 14, 8407, 480, 2970, 401, 3286, 21830, 401, 18129, 15, 21830, 401, 413, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4030, 401, 8969, 401, 298, 2795, 401, 1520, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4030, 401, 3286, 8838, 401, 18129, 15, 8838, 401, 650, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4013, 401, 8969, 401, 4873, 1616, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 272, 10976, 14, 8407, 480, 4013, 401, 3286, 8838, 401, 18129, 15, 8838, 401, 959, 12, 10976, 14, 4227, 63, 4896, 4586, 395, 199, 61, 199, 2709, 275, 469, 272, 283, 4188, 356, 283, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 297, 272, 283, 561, 356, 283, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 2330, 15, 1246, 15, 86, 17, 14, 16, 297, 199, 93, 421, 199, 533, 3523, 8407, 10591, 8, 396, 14, 1746, 304, 272, 408, 1563, 511, 5241, 1314, 6571, 12082, 22312, 436, 900, 2236, 29639, 1041, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 1563, 8407, 10591, 12, 291, 680, 5996, 342, 267, 291, 14, 521, 275, 378, 14, 16, 267, 291, 14, 1805, 63, 785, 8, 9368, 14, 8407, 12, 2668, 362, 63, 521, 401, 291, 423, 362, 63, 521, 9, 267, 291, 14, 6116, 63, 9368, 275, 1052, 398, 347, 4026, 63, 362, 63, 1715, 63, 17056, 8, 1100, 12, 2199, 63, 344, 12, 4503, 83, 29, 549, 304, 288, 372, 469, 75, 26, 1211, 8, 3097, 29, 86, 9, 367, 1022, 12, 373, 315, 291, 14, 6116, 63, 9368, 14, 1744, 12737, 398, 291, 14, 1805, 63, 785, 8, 12372, 14, 8848, 14, 18654, 1179, 12, 298, 362, 63, 1715, 63, 17056, 401, 586, 4026, 63, 362, 63, 1715, 63, 17056, 9, 339, 347, 485, 362, 63, 521, 8, 277, 304, 267, 408, 1767, 314, 298, 521, 2, 7182, 370, 642, 511, 5241, 1041, 267, 372, 291, 14, 521, 421, 199, 533, 14620, 1405, 7506, 774, 8, 1563, 8407, 10591, 304, 339, 408, 2925, 367, 658, 9368, 14, 24480, 7506, 64, 1021, 1041, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 1613, 8, 24480, 7506, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 5538, 275, 10976, 14, 981, 63, 1927, 342, 339, 347, 485, 362, 63, 1080, 63, 1069, 8, 277, 12, 4729, 63, 1291, 628, 3578, 15, 1001, 2349, 267, 408, 4433, 370, 663, 14870, 2368, 1041, 267, 1056, 275, 14568, 14, 2017, 14, 2500, 19031, 267, 1056, 14, 5694, 275, 4729, 63, 1291, 267, 1056, 14, 2314, 905, 6508, 1308, 14, 9492, 63, 589, 937, 275, 334, 403, 12, 469, 288, 298, 1287, 582, 298, 1080, 401, 288, 298, 5538, 582, 4873, 267, 3828, 267, 1067, 275, 13069, 14, 1100, 14, 17679, 360, 21029, 297, 283, 396, 1715, 358, 267, 1056, 14, 2314, 905, 12372, 14, 1100, 937, 275, 1067, 267, 372, 1056, 339, 347, 485, 13817, 63, 9368, 8, 277, 12, 1056, 304, 267, 408, 18989, 2304, 2256, 1901, 282, 1056, 1041, 267, 485, 9368, 275, 359, 288, 10976, 14, 8407, 480, 2970, 401, 8969, 401, 298, 2795, 401, 1616, 12, 5212, 680, 2918, 1062, 288, 10976, 14, 8407, 480, 4030, 401, 8969, 401, 298, 2795, 401, 959, 12, 5212, 627, 5212, 680, 2918, 1062, 288, 10976, 14, 8407, 480, 2970, 401, 298, 6627, 13, 8585, 14421, 298, 6627, 13, 8585, 401, 586, 959, 12, 5212, 680, 2918, 1062, 267, 1622, 267, 1056, 14, 2314, 905, 12372, 14, 9368, 937, 275, 485, 9368, 267, 372, 1056, 339, 347, 511, 63, 1667, 63, 1080, 63, 1001, 8, 277, 304, 267, 408, 774, 10232, 2701, 2304, 2436, 315, 4840, 1041, 267, 1056, 275, 291, 423, 362, 63, 1080, 63, 1069, 342, 267, 1177, 275, 1056, 14, 362, 63, 1310, 8, 277, 14, 5538, 9, 267, 1420, 275, 469, 288, 298, 9368, 582, 469, 355, 298, 1866, 582, 990, 355, 298, 6116, 582, 5479, 288, 1660, 267, 789, 267, 2396, 275, 18705, 14, 3640, 8, 1310, 14, 2030, 9, 267, 291, 14, 629, 8, 2062, 12, 2396, 9, 339, 347, 511, 63, 1080, 63, 1001, 8, 277, 304, 267, 408, 774, 10232, 2304, 2436, 315, 4840, 1041, 267, 1056, 275, 291, 423, 362, 63, 1080, 63, 1069, 342, 267, 1056, 275, 291, 423, 13817, 63, 9368, 8, 1069, 9, 267, 291, 14, 6116, 63, 9368, 275, 469, 288, 283, 71, 528, 27601, 356, 10574, 12, 288, 283, 8838, 356, 959, 12, 267, 789, 267, 1177, 275, 1056, 14, 362, 63, 1310, 8, 277, 14, 5538, 9, 267, 1420, 275, 469, 288, 298, 9368, 582, 469, 355, 298, 1866, 582, 359, 490, 469, 717, 298, 3821, 582, 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 ]
glaubitz/fs-uae-debian
launcher/OpenGL/raw/WGL/ARB/create_context.py
8
1139
'''Autogenerated by xml_generate script, do not edit!''' from OpenGL import platform as _p, arrays # Code generation uses this from OpenGL.raw.WGL import _types as _cs # End users want this... from OpenGL.raw.WGL._types import * from OpenGL.raw.WGL import _errors from OpenGL.constant import Constant as _C import ctypes _EXTENSION_NAME = 'WGL_ARB_create_context' def _f( function ): return _p.createFunction( function,_p.PLATFORM.WGL,'WGL_ARB_create_context',error_checker=_errors._error_checker) ERROR_INVALID_VERSION_ARB=_C('ERROR_INVALID_VERSION_ARB',0x2095) WGL_CONTEXT_DEBUG_BIT_ARB=_C('WGL_CONTEXT_DEBUG_BIT_ARB',0x00000001) WGL_CONTEXT_FLAGS_ARB=_C('WGL_CONTEXT_FLAGS_ARB',0x2094) WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB=_C('WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB',0x00000002) WGL_CONTEXT_LAYER_PLANE_ARB=_C('WGL_CONTEXT_LAYER_PLANE_ARB',0x2093) WGL_CONTEXT_MAJOR_VERSION_ARB=_C('WGL_CONTEXT_MAJOR_VERSION_ARB',0x2091) WGL_CONTEXT_MINOR_VERSION_ARB=_C('WGL_CONTEXT_MINOR_VERSION_ARB',0x2092) @_f @_p.types(_cs.HGLRC,_cs.HDC,_cs.HGLRC,ctypes.POINTER(_cs.c_int)) def wglCreateContextAttribsARB(hDC,hShareContext,attribList):pass
gpl-2.0
[ 2344, 23570, 16741, 701, 2748, 63, 4208, 2884, 12, 886, 440, 5283, 1, 2344, 199, 504, 24374, 492, 4298, 465, 485, 80, 12, 6572, 199, 3, 5495, 10152, 4440, 642, 199, 504, 24374, 14, 1773, 14, 31568, 492, 485, 1313, 465, 485, 1259, 199, 3, 9599, 4390, 2934, 642, 1396, 199, 504, 24374, 14, 1773, 14, 31568, 423, 1313, 492, 627, 199, 504, 24374, 14, 1773, 14, 31568, 492, 485, 2550, 199, 504, 24374, 14, 4083, 492, 19991, 465, 485, 35, 199, 199, 646, 5577, 199, 63, 15498, 63, 2339, 275, 283, 31568, 63, 8611, 63, 981, 63, 1100, 7, 199, 318, 485, 70, 8, 805, 3461, 272, 372, 485, 80, 14, 981, 3481, 8, 805, 16987, 80, 14, 17805, 14, 31568, 2584, 31568, 63, 8611, 63, 981, 63, 1100, 297, 705, 63, 6743, 3699, 2550, 423, 705, 63, 6743, 9, 199, 3170, 63, 9692, 63, 4612, 63, 8611, 3699, 35, 360, 3170, 63, 9692, 63, 4612, 63, 8611, 297, 16, 88, 1165, 2720, 9, 199, 31568, 63, 9059, 63, 5287, 63, 11970, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 5287, 63, 11970, 63, 8611, 297, 16, 88, 23848, 9, 199, 31568, 63, 9059, 63, 4831, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 4831, 63, 8611, 297, 16, 88, 1165, 2635, 9, 199, 31568, 63, 9059, 63, 29700, 63, 29720, 7187, 63, 11970, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 29700, 63, 29720, 7187, 63, 11970, 63, 8611, 297, 16, 88, 32764, 9, 199, 31568, 63, 9059, 63, 24167, 63, 2749, 879, 37, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 24167, 63, 2749, 879, 37, 63, 8611, 297, 16, 88, 1165, 3129, 9, 199, 31568, 63, 9059, 63, 29241, 63, 4612, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 29241, 63, 4612, 63, 8611, 297, 16, 88, 1165, 3328, 9, 199, 31568, 63, 9059, 63, 4896, 726, 63, 4612, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 4896, 726, 63, 4612, 63, 8611, 297, 16, 88, 1165, 2942, 9, 199, 17608, 70, 199, 17608, 80, 14, 1313, 1547, 1259, 14, 40, 2226, 8205, 16987, 1259, 14, 40, 5196, 16987, 1259, 14, 40, 2226, 8205, 12, 9798, 14, 11260, 1547, 1259, 14, 67, 63, 442, 430, 199, 318, 336, 3528, 2499, 2998, 1271, 19577, 8611, 8, 72, 5196, 12, 72, 18713, 2998, 12, 6640, 1296, 304, 1529, 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 ]
[ 23570, 16741, 701, 2748, 63, 4208, 2884, 12, 886, 440, 5283, 1, 2344, 199, 504, 24374, 492, 4298, 465, 485, 80, 12, 6572, 199, 3, 5495, 10152, 4440, 642, 199, 504, 24374, 14, 1773, 14, 31568, 492, 485, 1313, 465, 485, 1259, 199, 3, 9599, 4390, 2934, 642, 1396, 199, 504, 24374, 14, 1773, 14, 31568, 423, 1313, 492, 627, 199, 504, 24374, 14, 1773, 14, 31568, 492, 485, 2550, 199, 504, 24374, 14, 4083, 492, 19991, 465, 485, 35, 199, 199, 646, 5577, 199, 63, 15498, 63, 2339, 275, 283, 31568, 63, 8611, 63, 981, 63, 1100, 7, 199, 318, 485, 70, 8, 805, 3461, 272, 372, 485, 80, 14, 981, 3481, 8, 805, 16987, 80, 14, 17805, 14, 31568, 2584, 31568, 63, 8611, 63, 981, 63, 1100, 297, 705, 63, 6743, 3699, 2550, 423, 705, 63, 6743, 9, 199, 3170, 63, 9692, 63, 4612, 63, 8611, 3699, 35, 360, 3170, 63, 9692, 63, 4612, 63, 8611, 297, 16, 88, 1165, 2720, 9, 199, 31568, 63, 9059, 63, 5287, 63, 11970, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 5287, 63, 11970, 63, 8611, 297, 16, 88, 23848, 9, 199, 31568, 63, 9059, 63, 4831, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 4831, 63, 8611, 297, 16, 88, 1165, 2635, 9, 199, 31568, 63, 9059, 63, 29700, 63, 29720, 7187, 63, 11970, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 29700, 63, 29720, 7187, 63, 11970, 63, 8611, 297, 16, 88, 32764, 9, 199, 31568, 63, 9059, 63, 24167, 63, 2749, 879, 37, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 24167, 63, 2749, 879, 37, 63, 8611, 297, 16, 88, 1165, 3129, 9, 199, 31568, 63, 9059, 63, 29241, 63, 4612, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 29241, 63, 4612, 63, 8611, 297, 16, 88, 1165, 3328, 9, 199, 31568, 63, 9059, 63, 4896, 726, 63, 4612, 63, 8611, 3699, 35, 360, 31568, 63, 9059, 63, 4896, 726, 63, 4612, 63, 8611, 297, 16, 88, 1165, 2942, 9, 199, 17608, 70, 199, 17608, 80, 14, 1313, 1547, 1259, 14, 40, 2226, 8205, 16987, 1259, 14, 40, 5196, 16987, 1259, 14, 40, 2226, 8205, 12, 9798, 14, 11260, 1547, 1259, 14, 67, 63, 442, 430, 199, 318, 336, 3528, 2499, 2998, 1271, 19577, 8611, 8, 72, 5196, 12, 72, 18713, 2998, 12, 6640, 1296, 304, 1529, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jneves/python-social-auth
social/backends/lastfm.py
70
1888
import hashlib from social.utils import handle_http_errors from social.backends.base import BaseAuth class LastFmAuth(BaseAuth): """ Last.Fm authentication backend. Requires two settings: SOCIAL_AUTH_LASTFM_KEY SOCIAL_AUTH_LASTFM_SECRET Don't forget to set the Last.fm callback to something sensible like http://your.site/lastfm/complete """ name = 'lastfm' AUTH_URL = 'http://www.last.fm/api/auth/?api_key={api_key}' EXTRA_DATA = [ ('key', 'session_key') ] def auth_url(self): return self.AUTH_URL.format(api_key=self.setting('KEY')) @handle_http_errors def auth_complete(self, *args, **kwargs): """Completes login process, must return user instance""" key, secret = self.get_key_and_secret() token = self.data['token'] signature = hashlib.md5(''.join( ('api_key', key, 'methodauth.getSession', 'token', token, secret) ).encode()).hexdigest() response = self.get_json('http://ws.audioscrobbler.com/2.0/', data={ 'method': 'auth.getSession', 'api_key': key, 'token': token, 'api_sig': signature, 'format': 'json' }, method='POST') kwargs.update({'response': response['session'], 'backend': self}) return self.strategy.authenticate(*args, **kwargs) def get_user_id(self, details, response): """Return a unique ID for the current user, by default from server response.""" return response.get('name') def get_user_details(self, response): fullname, first_name, last_name = self.get_user_names(response['name']) return { 'username': response['name'], 'email': '', 'fullname': fullname, 'first_name': first_name, 'last_name': last_name }
bsd-3-clause
[ 646, 8337, 199, 199, 504, 20295, 14, 1208, 492, 2429, 63, 1014, 63, 2550, 199, 504, 20295, 14, 7765, 14, 1095, 492, 3523, 2817, 421, 199, 533, 15237, 38, 77, 2817, 8, 1563, 2817, 304, 272, 408, 272, 15237, 14, 38, 77, 6299, 4865, 14, 15127, 2877, 2202, 26, 267, 3562, 21212, 63, 5580, 63, 16901, 22367, 63, 3078, 267, 3562, 21212, 63, 5580, 63, 16901, 22367, 63, 12961, 339, 7529, 1133, 19459, 370, 663, 314, 15237, 14, 10886, 3233, 370, 6020, 27962, 2839, 267, 1455, 921, 12695, 14, 2124, 15, 2019, 10886, 15, 4883, 272, 408, 272, 536, 275, 283, 2019, 10886, 7, 272, 7560, 63, 2632, 275, 283, 1014, 921, 1544, 14, 2019, 14, 10886, 15, 1246, 15, 1178, 10197, 1246, 63, 498, 3126, 1246, 63, 498, 6834, 272, 3651, 13954, 63, 3998, 275, 359, 267, 661, 498, 297, 283, 1730, 63, 498, 358, 272, 1622, 339, 347, 1790, 63, 633, 8, 277, 304, 267, 372, 291, 14, 5580, 63, 2632, 14, 908, 8, 1246, 63, 498, 29, 277, 14, 6031, 360, 3078, 1333, 339, 768, 2479, 63, 1014, 63, 2550, 272, 347, 1790, 63, 4883, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 6600, 744, 4676, 2112, 12, 1471, 372, 922, 1256, 624, 267, 790, 12, 7565, 275, 291, 14, 362, 63, 498, 63, 460, 63, 4731, 342, 267, 1526, 275, 291, 14, 576, 459, 1418, 418, 398, 4955, 275, 8337, 14, 1064, 21, 17840, 904, 8, 288, 661, 1246, 63, 498, 297, 790, 12, 283, 765, 1178, 14, 362, 4434, 297, 283, 1418, 297, 1526, 12, 7565, 9, 267, 7092, 2143, 8801, 11453, 342, 398, 1177, 275, 291, 14, 362, 63, 1001, 360, 1014, 921, 3569, 14, 8130, 551, 293, 26722, 14, 957, 15, 18, 14, 16, 3678, 666, 3126, 288, 283, 765, 356, 283, 1178, 14, 362, 4434, 297, 288, 283, 1246, 63, 498, 356, 790, 12, 288, 283, 1418, 356, 1526, 12, 288, 283, 1246, 63, 4093, 356, 4955, 12, 288, 283, 908, 356, 283, 1001, 7, 267, 1660, 1083, 534, 4030, 358, 398, 2074, 14, 873, 3252, 1310, 356, 1177, 459, 1730, 995, 283, 4620, 356, 291, 1552, 267, 372, 291, 14, 8590, 14, 13975, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 751, 63, 344, 8, 277, 12, 2436, 12, 1177, 304, 267, 408, 1767, 282, 3747, 2870, 367, 314, 1453, 922, 12, 701, 849, 687, 1654, 267, 1177, 1041, 267, 372, 1177, 14, 362, 360, 354, 358, 339, 347, 664, 63, 751, 63, 5087, 8, 277, 12, 1177, 304, 267, 11064, 12, 1642, 63, 354, 12, 2061, 63, 354, 275, 291, 14, 362, 63, 751, 63, 1247, 8, 1310, 459, 354, 1105, 267, 372, 469, 288, 283, 2473, 356, 1177, 459, 354, 995, 288, 283, 2123, 356, 3260, 288, 283, 9930, 356, 11064, 12, 288, 283, 2246, 63, 354, 356, 1642, 63, 354, 12, 288, 283, 2019, 63, 354, 356, 2061, 63, 354, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8337, 199, 199, 504, 20295, 14, 1208, 492, 2429, 63, 1014, 63, 2550, 199, 504, 20295, 14, 7765, 14, 1095, 492, 3523, 2817, 421, 199, 533, 15237, 38, 77, 2817, 8, 1563, 2817, 304, 272, 408, 272, 15237, 14, 38, 77, 6299, 4865, 14, 15127, 2877, 2202, 26, 267, 3562, 21212, 63, 5580, 63, 16901, 22367, 63, 3078, 267, 3562, 21212, 63, 5580, 63, 16901, 22367, 63, 12961, 339, 7529, 1133, 19459, 370, 663, 314, 15237, 14, 10886, 3233, 370, 6020, 27962, 2839, 267, 1455, 921, 12695, 14, 2124, 15, 2019, 10886, 15, 4883, 272, 408, 272, 536, 275, 283, 2019, 10886, 7, 272, 7560, 63, 2632, 275, 283, 1014, 921, 1544, 14, 2019, 14, 10886, 15, 1246, 15, 1178, 10197, 1246, 63, 498, 3126, 1246, 63, 498, 6834, 272, 3651, 13954, 63, 3998, 275, 359, 267, 661, 498, 297, 283, 1730, 63, 498, 358, 272, 1622, 339, 347, 1790, 63, 633, 8, 277, 304, 267, 372, 291, 14, 5580, 63, 2632, 14, 908, 8, 1246, 63, 498, 29, 277, 14, 6031, 360, 3078, 1333, 339, 768, 2479, 63, 1014, 63, 2550, 272, 347, 1790, 63, 4883, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 6600, 744, 4676, 2112, 12, 1471, 372, 922, 1256, 624, 267, 790, 12, 7565, 275, 291, 14, 362, 63, 498, 63, 460, 63, 4731, 342, 267, 1526, 275, 291, 14, 576, 459, 1418, 418, 398, 4955, 275, 8337, 14, 1064, 21, 17840, 904, 8, 288, 661, 1246, 63, 498, 297, 790, 12, 283, 765, 1178, 14, 362, 4434, 297, 283, 1418, 297, 1526, 12, 7565, 9, 267, 7092, 2143, 8801, 11453, 342, 398, 1177, 275, 291, 14, 362, 63, 1001, 360, 1014, 921, 3569, 14, 8130, 551, 293, 26722, 14, 957, 15, 18, 14, 16, 3678, 666, 3126, 288, 283, 765, 356, 283, 1178, 14, 362, 4434, 297, 288, 283, 1246, 63, 498, 356, 790, 12, 288, 283, 1418, 356, 1526, 12, 288, 283, 1246, 63, 4093, 356, 4955, 12, 288, 283, 908, 356, 283, 1001, 7, 267, 1660, 1083, 534, 4030, 358, 398, 2074, 14, 873, 3252, 1310, 356, 1177, 459, 1730, 995, 283, 4620, 356, 291, 1552, 267, 372, 291, 14, 8590, 14, 13975, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 751, 63, 344, 8, 277, 12, 2436, 12, 1177, 304, 267, 408, 1767, 282, 3747, 2870, 367, 314, 1453, 922, 12, 701, 849, 687, 1654, 267, 1177, 1041, 267, 372, 1177, 14, 362, 360, 354, 358, 339, 347, 664, 63, 751, 63, 5087, 8, 277, 12, 1177, 304, 267, 11064, 12, 1642, 63, 354, 12, 2061, 63, 354, 275, 291, 14, 362, 63, 751, 63, 1247, 8, 1310, 459, 354, 1105, 267, 372, 469, 288, 283, 2473, 356, 1177, 459, 354, 995, 288, 283, 2123, 356, 3260, 288, 283, 9930, 356, 11064, 12, 288, 283, 2246, 63, 354, 356, 1642, 63, 354, 12, 288, 283, 2019, 63, 354, 356, 2061, 63, 354, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
freenas/samba
third_party/waf/wafadmin/Tools/gas.py
32
1108
#!/usr/bin/env python # encoding: utf-8 # Thomas Nagy, 2008 (ita) "as and gas" import os, sys import Task from TaskGen import extension, taskgen, after, before EXT_ASM = ['.s', '.S', '.asm', '.ASM', '.spp', '.SPP'] as_str = '${AS} ${ASFLAGS} ${_ASINCFLAGS} ${SRC} -o ${TGT}' Task.simple_task_type('asm', as_str, 'PINK', ext_out='.o', shell=False) @extension(EXT_ASM) def asm_hook(self, node): # create the compilation task: cpp or cc try: obj_ext = self.obj_ext except AttributeError: obj_ext = '_%d.o' % self.idx task = self.create_task('asm', node, node.change_ext(obj_ext)) self.compiled_tasks.append(task) self.meths.append('asm_incflags') @after('apply_obj_vars_cc') @after('apply_obj_vars_cxx') @before('apply_link') def asm_incflags(self): self.env.append_value('_ASINCFLAGS', self.env.ASINCFLAGS) var = ('cxx' in self.features) and 'CXX' or 'CC' self.env.append_value('_ASINCFLAGS', self.env['_%sINCFLAGS' % var]) def detect(conf): conf.find_program(['gas', 'as'], var='AS') if not conf.env.AS: conf.env.AS = conf.env.CC #conf.env.ASFLAGS = ['-c'] <- may be necesary for .S files
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 27864, 653, 643, 89, 12, 9079, 334, 21492, 9, 199, 199, 2, 305, 436, 486, 305, 2, 199, 199, 646, 747, 12, 984, 199, 646, 8495, 199, 504, 8495, 8168, 492, 3329, 12, 2120, 2268, 12, 2410, 12, 2544, 199, 199, 2472, 63, 27322, 275, 18953, 83, 297, 1987, 51, 297, 1987, 11374, 297, 1987, 27322, 297, 1987, 681, 80, 297, 1987, 5763, 48, 418, 199, 199, 305, 63, 495, 275, 20044, 1179, 93, 10839, 1179, 4831, 93, 10839, 63, 1179, 568, 14804, 93, 10839, 12447, 93, 446, 79, 10839, 26422, 6834, 199, 4476, 14, 4129, 63, 1765, 63, 466, 360, 11374, 297, 465, 63, 495, 12, 283, 48, 12394, 297, 1599, 63, 548, 15637, 79, 297, 5218, 29, 797, 9, 199, 199, 32, 3435, 8, 2472, 63, 27322, 9, 199, 318, 21875, 63, 3664, 8, 277, 12, 1031, 304, 199, 198, 3, 1218, 314, 18653, 2120, 26, 7246, 503, 7429, 199, 198, 893, 26, 1559, 63, 832, 275, 291, 14, 1113, 63, 832, 199, 198, 2590, 4281, 26, 1559, 63, 832, 275, 2513, 5, 68, 14, 79, 7, 450, 291, 14, 2996, 421, 198, 1765, 275, 291, 14, 981, 63, 1765, 360, 11374, 297, 1031, 12, 1031, 14, 1461, 63, 832, 8, 1113, 63, 832, 430, 199, 198, 277, 14, 8427, 63, 5054, 14, 740, 8, 1765, 9, 199, 198, 277, 14, 5247, 83, 14, 740, 360, 11374, 63, 262, 14002, 358, 199, 199, 32, 4399, 360, 4998, 63, 1113, 63, 2936, 63, 2055, 358, 199, 32, 4399, 360, 4998, 63, 1113, 63, 2936, 63, 9634, 358, 199, 32, 5182, 360, 4998, 63, 1073, 358, 199, 318, 21875, 63, 262, 14002, 8, 277, 304, 199, 198, 277, 14, 1813, 14, 740, 63, 585, 6412, 1179, 568, 14804, 297, 291, 14, 1813, 14, 1179, 568, 14804, 9, 199, 198, 1391, 275, 661, 9634, 7, 315, 291, 14, 3179, 9, 436, 283, 12206, 7, 503, 283, 2571, 7, 199, 198, 277, 14, 1813, 14, 740, 63, 585, 6412, 1179, 568, 14804, 297, 291, 14, 1813, 459, 4970, 83, 568, 14804, 7, 450, 2729, 566, 199, 199, 318, 9696, 8, 2190, 304, 199, 198, 2190, 14, 1623, 63, 6815, 2941, 24364, 297, 283, 305, 995, 2729, 534, 1179, 358, 199, 198, 692, 440, 3743, 14, 1813, 14, 1179, 26, 3743, 14, 1813, 14, 1179, 275, 3743, 14, 1813, 14, 2571, 199, 198, 3, 2190, 14, 1813, 14, 1179, 4831, 275, 11573, 67, 418, 25549, 1443, 506, 1279, 823, 695, 367, 1275, 51, 1584, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 27864, 653, 643, 89, 12, 9079, 334, 21492, 9, 199, 199, 2, 305, 436, 486, 305, 2, 199, 199, 646, 747, 12, 984, 199, 646, 8495, 199, 504, 8495, 8168, 492, 3329, 12, 2120, 2268, 12, 2410, 12, 2544, 199, 199, 2472, 63, 27322, 275, 18953, 83, 297, 1987, 51, 297, 1987, 11374, 297, 1987, 27322, 297, 1987, 681, 80, 297, 1987, 5763, 48, 418, 199, 199, 305, 63, 495, 275, 20044, 1179, 93, 10839, 1179, 4831, 93, 10839, 63, 1179, 568, 14804, 93, 10839, 12447, 93, 446, 79, 10839, 26422, 6834, 199, 4476, 14, 4129, 63, 1765, 63, 466, 360, 11374, 297, 465, 63, 495, 12, 283, 48, 12394, 297, 1599, 63, 548, 15637, 79, 297, 5218, 29, 797, 9, 199, 199, 32, 3435, 8, 2472, 63, 27322, 9, 199, 318, 21875, 63, 3664, 8, 277, 12, 1031, 304, 199, 198, 3, 1218, 314, 18653, 2120, 26, 7246, 503, 7429, 199, 198, 893, 26, 1559, 63, 832, 275, 291, 14, 1113, 63, 832, 199, 198, 2590, 4281, 26, 1559, 63, 832, 275, 2513, 5, 68, 14, 79, 7, 450, 291, 14, 2996, 421, 198, 1765, 275, 291, 14, 981, 63, 1765, 360, 11374, 297, 1031, 12, 1031, 14, 1461, 63, 832, 8, 1113, 63, 832, 430, 199, 198, 277, 14, 8427, 63, 5054, 14, 740, 8, 1765, 9, 199, 198, 277, 14, 5247, 83, 14, 740, 360, 11374, 63, 262, 14002, 358, 199, 199, 32, 4399, 360, 4998, 63, 1113, 63, 2936, 63, 2055, 358, 199, 32, 4399, 360, 4998, 63, 1113, 63, 2936, 63, 9634, 358, 199, 32, 5182, 360, 4998, 63, 1073, 358, 199, 318, 21875, 63, 262, 14002, 8, 277, 304, 199, 198, 277, 14, 1813, 14, 740, 63, 585, 6412, 1179, 568, 14804, 297, 291, 14, 1813, 14, 1179, 568, 14804, 9, 199, 198, 1391, 275, 661, 9634, 7, 315, 291, 14, 3179, 9, 436, 283, 12206, 7, 503, 283, 2571, 7, 199, 198, 277, 14, 1813, 14, 740, 63, 585, 6412, 1179, 568, 14804, 297, 291, 14, 1813, 459, 4970, 83, 568, 14804, 7, 450, 2729, 566, 199, 199, 318, 9696, 8, 2190, 304, 199, 198, 2190, 14, 1623, 63, 6815, 2941, 24364, 297, 283, 305, 995, 2729, 534, 1179, 358, 199, 198, 692, 440, 3743, 14, 1813, 14, 1179, 26, 3743, 14, 1813, 14, 1179, 275, 3743, 14, 1813, 14, 2571, 199, 198, 3, 2190, 14, 1813, 14, 1179, 4831, 275, 11573, 67, 418, 25549, 1443, 506, 1279, 823, 695, 367, 1275, 51, 1584, 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, 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 ]
themurph/openshift-tools
ansible/roles/lib_openshift_3.2/library/oc_label.py
3
40059
#!/usr/bin/env python # pylint: disable=too-many-lines # ___ ___ _ _ ___ ___ _ _____ ___ ___ # / __| __| \| | __| _ \ /_\_ _| __| \ # | (_ | _|| .` | _|| / / _ \| | | _|| |) | # \___|___|_|\_|___|_|_\/_/_\_\_|_|___|___/_ _____ # | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _| # | |) | (_) | | .` | (_) || | | _|| |) | | | | # |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_| ''' OpenShiftCLI class that wraps the oc commands in a subprocess ''' # pylint: disable=too-many-lines import atexit import json import os import re import shutil import subprocess import ruamel.yaml as yaml #import yaml # ## This is here because of a bug that causes yaml ## to incorrectly handle timezone info on timestamps #def timestamp_constructor(_, node): # '''return timestamps as strings''' # return str(node.value) #yaml.add_constructor(u'tag:yaml.org,2002:timestamp', timestamp_constructor) class OpenShiftCLIError(Exception): '''Exception class for openshiftcli''' pass # pylint: disable=too-few-public-methods class OpenShiftCLI(object): ''' Class to wrap the command line tools ''' def __init__(self, namespace, kubeconfig='/etc/origin/master/admin.kubeconfig', verbose=False, all_namespaces=False): ''' Constructor for OpenshiftCLI ''' self.namespace = namespace self.verbose = verbose self.kubeconfig = kubeconfig self.all_namespaces = all_namespaces # Pylint allows only 5 arguments to be passed. # pylint: disable=too-many-arguments def _replace_content(self, resource, rname, content, force=False, sep='.'): ''' replace the current object with the content ''' res = self._get(resource, rname) if not res['results']: return res fname = '/tmp/%s' % rname yed = Yedit(fname, res['results'][0], separator=sep) changes = [] for key, value in content.items(): changes.append(yed.put(key, value)) if any([change[0] for change in changes]): yed.write() atexit.register(Utils.cleanup, [fname]) return self._replace(fname, force) return {'returncode': 0, 'updated': False} def _replace(self, fname, force=False): '''return all pods ''' cmd = ['-n', self.namespace, 'replace', '-f', fname] if force: cmd.append('--force') return self.openshift_cmd(cmd) def _create_from_content(self, rname, content): '''return all pods ''' fname = '/tmp/%s' % rname yed = Yedit(fname, content=content) yed.write() atexit.register(Utils.cleanup, [fname]) return self._create(fname) def _create(self, fname): '''return all pods ''' return self.openshift_cmd(['create', '-f', fname, '-n', self.namespace]) def _delete(self, resource, rname, selector=None): '''return all pods ''' cmd = ['delete', resource, rname, '-n', self.namespace] if selector: cmd.append('--selector=%s' % selector) return self.openshift_cmd(cmd) def _process(self, template_name, create=False, params=None, template_data=None): '''return all pods ''' cmd = ['process', '-n', self.namespace] if template_data: cmd.extend(['-f', '-']) else: cmd.append(template_name) if params: param_str = ["%s=%s" % (key, value) for key, value in params.items()] cmd.append('-v') cmd.extend(param_str) results = self.openshift_cmd(cmd, output=True, input_data=template_data) if results['returncode'] != 0 or not create: return results fname = '/tmp/%s' % template_name yed = Yedit(fname, results['results']) yed.write() atexit.register(Utils.cleanup, [fname]) return self.openshift_cmd(['-n', self.namespace, 'create', '-f', fname]) def _get(self, resource, rname=None, selector=None): '''return a resource by name ''' cmd = ['get', resource] if selector: cmd.append('--selector=%s' % selector) if self.all_namespaces: cmd.extend(['--all-namespaces']) elif self.namespace: cmd.extend(['-n', self.namespace]) cmd.extend(['-o', 'json']) if rname: cmd.append(rname) rval = self.openshift_cmd(cmd, output=True) # Ensure results are retuned in an array if rval.has_key('items'): rval['results'] = rval['items'] elif not isinstance(rval['results'], list): rval['results'] = [rval['results']] return rval def _schedulable(self, node=None, selector=None, schedulable=True): ''' perform oadm manage-node scheduable ''' cmd = ['manage-node'] if node: cmd.extend(node) else: cmd.append('--selector=%s' % selector) cmd.append('--schedulable=%s' % schedulable) return self.openshift_cmd(cmd, oadm=True, output=True, output_type='raw') def _list_pods(self, node=None, selector=None, pod_selector=None): ''' perform oadm manage-node evacuate ''' cmd = ['manage-node'] if node: cmd.extend(node) else: cmd.append('--selector=%s' % selector) if pod_selector: cmd.append('--pod-selector=%s' % pod_selector) cmd.extend(['--list-pods', '-o', 'json']) return self.openshift_cmd(cmd, oadm=True, output=True, output_type='raw') #pylint: disable=too-many-arguments def _evacuate(self, node=None, selector=None, pod_selector=None, dry_run=False, grace_period=None, force=False): ''' perform oadm manage-node evacuate ''' cmd = ['manage-node'] if node: cmd.extend(node) else: cmd.append('--selector=%s' % selector) if dry_run: cmd.append('--dry-run') if pod_selector: cmd.append('--pod-selector=%s' % pod_selector) if grace_period: cmd.append('--grace-period=%s' % int(grace_period)) if force: cmd.append('--force') cmd.append('--evacuate') return self.openshift_cmd(cmd, oadm=True, output=True, output_type='raw') def _import_image(self, url=None, name=None, tag=None): ''' perform image import ''' cmd = ['import-image'] image = '{0}'.format(name) if tag: image += ':{0}'.format(tag) cmd.append(image) if url: cmd.append('--from={0}/{1}'.format(url, image)) cmd.append('-n{0}'.format(self.namespace)) cmd.append('--confirm') return self.openshift_cmd(cmd) #pylint: disable=too-many-arguments def openshift_cmd(self, cmd, oadm=False, output=False, output_type='json', input_data=None): '''Base command for oc ''' cmds = [] if oadm: cmds = ['/usr/bin/oadm'] else: cmds = ['/usr/bin/oc'] cmds.extend(cmd) rval = {} results = '' err = None if self.verbose: print ' '.join(cmds) proc = subprocess.Popen(cmds, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={'KUBECONFIG': self.kubeconfig}) stdout, stderr = proc.communicate(input_data) rval = {"returncode": proc.returncode, "results": results, "cmd": ' '.join(cmds), } if proc.returncode == 0: if output: if output_type == 'json': try: rval['results'] = json.loads(stdout) except ValueError as err: if "No JSON object could be decoded" in err.message: err = err.message elif output_type == 'raw': rval['results'] = stdout if self.verbose: print stdout print stderr if err: rval.update({"err": err, "stderr": stderr, "stdout": stdout, "cmd": cmds }) else: rval.update({"stderr": stderr, "stdout": stdout, "results": {}, }) return rval class Utils(object): ''' utilities for openshiftcli modules ''' @staticmethod def create_file(rname, data, ftype='yaml'): ''' create a file in tmp with name and contents''' path = os.path.join('/tmp', rname) with open(path, 'w') as fds: if ftype == 'yaml': fds.write(yaml.dump(data, Dumper=yaml.RoundTripDumper)) elif ftype == 'json': fds.write(json.dumps(data)) else: fds.write(data) # Register cleanup when module is done atexit.register(Utils.cleanup, [path]) return path @staticmethod def create_files_from_contents(content, content_type=None): '''Turn an array of dict: filename, content into a files array''' if not isinstance(content, list): content = [content] files = [] for item in content: path = Utils.create_file(item['path'], item['data'], ftype=content_type) files.append({'name': os.path.basename(path), 'path': path}) return files @staticmethod def cleanup(files): '''Clean up on exit ''' for sfile in files: if os.path.exists(sfile): if os.path.isdir(sfile): shutil.rmtree(sfile) elif os.path.isfile(sfile): os.remove(sfile) @staticmethod def exists(results, _name): ''' Check to see if the results include the name ''' if not results: return False if Utils.find_result(results, _name): return True return False @staticmethod def find_result(results, _name): ''' Find the specified result by name''' rval = None for result in results: if result.has_key('metadata') and result['metadata']['name'] == _name: rval = result break return rval @staticmethod def get_resource_file(sfile, sfile_type='yaml'): ''' return the service file ''' contents = None with open(sfile) as sfd: contents = sfd.read() if sfile_type == 'yaml': contents = yaml.load(contents, yaml.RoundTripLoader) elif sfile_type == 'json': contents = json.loads(contents) return contents # Disabling too-many-branches. This is a yaml dictionary comparison function # pylint: disable=too-many-branches,too-many-return-statements,too-many-statements @staticmethod def check_def_equal(user_def, result_def, skip_keys=None, debug=False): ''' Given a user defined definition, compare it with the results given back by our query. ''' # Currently these values are autogenerated and we do not need to check them skip = ['metadata', 'status'] if skip_keys: skip.extend(skip_keys) for key, value in result_def.items(): if key in skip: continue # Both are lists if isinstance(value, list): if not user_def.has_key(key): if debug: print 'User data does not have key [%s]' % key print 'User data: %s' % user_def return False if not isinstance(user_def[key], list): if debug: print 'user_def[key] is not a list key=[%s] user_def[key]=%s' % (key, user_def[key]) return False if len(user_def[key]) != len(value): if debug: print "List lengths are not equal." print "key=[%s]: user_def[%s] != value[%s]" % (key, len(user_def[key]), len(value)) print "user_def: %s" % user_def[key] print "value: %s" % value return False for values in zip(user_def[key], value): if isinstance(values[0], dict) and isinstance(values[1], dict): if debug: print 'sending list - list' print type(values[0]) print type(values[1]) result = Utils.check_def_equal(values[0], values[1], skip_keys=skip_keys, debug=debug) if not result: print 'list compare returned false' return False elif value != user_def[key]: if debug: print 'value should be identical' print value print user_def[key] return False # recurse on a dictionary elif isinstance(value, dict): if not user_def.has_key(key): if debug: print "user_def does not have key [%s]" % key return False if not isinstance(user_def[key], dict): if debug: print "dict returned false: not instance of dict" return False # before passing ensure keys match api_values = set(value.keys()) - set(skip) user_values = set(user_def[key].keys()) - set(skip) if api_values != user_values: if debug: print "keys are not equal in dict" print api_values print user_values return False result = Utils.check_def_equal(user_def[key], value, skip_keys=skip_keys, debug=debug) if not result: if debug: print "dict returned false" print result return False # Verify each key, value pair is the same else: if not user_def.has_key(key) or value != user_def[key]: if debug: print "value not equal; user_def does not have key" print key print value if user_def.has_key(key): print user_def[key] return False if debug: print 'returning true' return True class OpenShiftCLIConfig(object): '''Generic Config''' def __init__(self, rname, namespace, kubeconfig, options): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace self._options = options @property def config_options(self): ''' return config options ''' return self._options def to_option_list(self): '''return all options as a string''' return self.stringify() def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] for key, data in self.config_options.items(): if data['include'] \ and (data['value'] or isinstance(data['value'], int)): rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) return rval class YeditException(Exception): ''' Exception class for Yedit ''' pass class Yedit(object): ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" com_sep = set(['.', '#', '|', ':']) # pylint: disable=too-many-arguments def __init__(self, filename=None, content=None, content_type='yaml', separator='.', backup=False): self.content = content self._separator = separator self.filename = filename self.__yaml_dict = content self.content_type = content_type self.backup = backup self.load(content_type=self.content_type) if self.__yaml_dict == None: self.__yaml_dict = {} @property def separator(self): ''' getter method for yaml_dict ''' return self._separator @separator.setter def separator(self): ''' getter method for yaml_dict ''' return self._separator @property def yaml_dict(self): ''' getter method for yaml_dict ''' return self.__yaml_dict @yaml_dict.setter def yaml_dict(self, value): ''' setter method for yaml_dict ''' self.__yaml_dict = value @staticmethod def parse_key(key, sep='.'): '''parse the key allowing the appropriate separator''' common_separators = list(Yedit.com_sep - set([sep])) return re.findall(Yedit.re_key % ''.join(common_separators), key) @staticmethod def valid_key(key, sep='.'): '''validate the incoming key''' common_separators = list(Yedit.com_sep - set([sep])) if not re.match(Yedit.re_valid_key % ''.join(common_separators), key): return False return True @staticmethod def remove_entry(data, key, sep='.'): ''' remove data at location key ''' if key == '' and isinstance(data, dict): data.clear() return True elif key == '' and isinstance(data, list): del data[:] return True if not (key and Yedit.valid_key(key, sep)) and isinstance(data, (list, dict)): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes[:-1]: if dict_key and isinstance(data, dict): data = data.get(dict_key, None) elif arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1: data = data[int(arr_ind)] else: return None # process last index for remove # expected list entry if key_indexes[-1][0]: if isinstance(data, list) and int(key_indexes[-1][0]) <= len(data) - 1: del data[int(key_indexes[-1][0])] return True # expected dict entry elif key_indexes[-1][1]: if isinstance(data, dict): del data[key_indexes[-1][1]] return True @staticmethod def add_entry(data, key, item=None, sep='.'): ''' Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a#b return c ''' if key == '': pass elif not (key and Yedit.valid_key(key, sep)) and isinstance(data, (list, dict)): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes[:-1]: if dict_key: if isinstance(data, dict) and data.has_key(dict_key) and data[dict_key]: data = data[dict_key] continue elif data and not isinstance(data, dict): raise YeditException("Unexpected item type found while going through key " + "path: {} (at key: {})".format(key, dict_key)) data[dict_key] = {} data = data[dict_key] elif arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1: data = data[int(arr_ind)] else: raise YeditException("Unexpected item type found while going through key path: {}".format(key)) if key == '': data = item # process last index for add # expected list entry elif key_indexes[-1][0] and isinstance(data, list) and int(key_indexes[-1][0]) <= len(data) - 1: data[int(key_indexes[-1][0])] = item # expected dict entry elif key_indexes[-1][1] and isinstance(data, dict): data[key_indexes[-1][1]] = item # didn't add/update to an existing list, nor add/update key to a dict # so we must have been provided some syntax like a.b.c[<int>] = "data" for a # non-existent array else: raise YeditException("Error adding data to object at path: {}".format(key)) return data @staticmethod def get_entry(data, key, sep='.'): ''' Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a.b return c ''' if key == '': pass elif not (key and Yedit.valid_key(key, sep)) and isinstance(data, (list, dict)): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes: if dict_key and isinstance(data, dict): data = data.get(dict_key, None) elif arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1: data = data[int(arr_ind)] else: return None return data def write(self): ''' write to file ''' if not self.filename: raise YeditException('Please specify a filename.') if self.backup and self.file_exists(): shutil.copy(self.filename, self.filename + '.orig') tmp_filename = self.filename + '.yedit' try: with open(tmp_filename, 'w') as yfd: # pylint: disable=no-member,maybe-no-member if hasattr(self.yaml_dict, 'fa'): self.yaml_dict.fa.set_block_style() yfd.write(yaml.dump(self.yaml_dict, Dumper=yaml.RoundTripDumper)) except Exception as err: raise YeditException(err.message) os.rename(tmp_filename, self.filename) return (True, self.yaml_dict) def read(self): ''' read from file ''' # check if it exists if self.filename == None or not self.file_exists(): return None contents = None with open(self.filename) as yfd: contents = yfd.read() return contents def file_exists(self): ''' return whether file exists ''' if os.path.exists(self.filename): return True return False def load(self, content_type='yaml'): ''' return yaml file ''' contents = self.read() if not contents and not self.content: return None if self.content: if isinstance(self.content, dict): self.yaml_dict = self.content return self.yaml_dict elif isinstance(self.content, str): contents = self.content # check if it is yaml try: if content_type == 'yaml' and contents: self.yaml_dict = yaml.load(contents, yaml.RoundTripLoader) # pylint: disable=no-member,maybe-no-member if hasattr(self.yaml_dict, 'fa'): self.yaml_dict.fa.set_block_style() elif content_type == 'json' and contents: self.yaml_dict = json.loads(contents) except yaml.YAMLError as err: # Error loading yaml or json raise YeditException('Problem with loading yaml file. %s' % err) return self.yaml_dict def get(self, key): ''' get a specified key''' try: entry = Yedit.get_entry(self.yaml_dict, key, self.separator) except KeyError as _: entry = None return entry def pop(self, path, key_or_item): ''' remove a key, value pair from a dict or an item for a list''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError as _: entry = None if entry == None: return (False, self.yaml_dict) if isinstance(entry, dict): # pylint: disable=no-member,maybe-no-member if entry.has_key(key_or_item): entry.pop(key_or_item) return (True, self.yaml_dict) return (False, self.yaml_dict) elif isinstance(entry, list): # pylint: disable=no-member,maybe-no-member ind = None try: ind = entry.index(key_or_item) except ValueError: return (False, self.yaml_dict) entry.pop(ind) return (True, self.yaml_dict) return (False, self.yaml_dict) def delete(self, path): ''' remove path from a dict''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError as _: entry = None if entry == None: return (False, self.yaml_dict) result = Yedit.remove_entry(self.yaml_dict, path, self.separator) if not result: return (False, self.yaml_dict) return (True, self.yaml_dict) def exists(self, path, value): ''' check if value exists at path''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError as _: entry = None if isinstance(entry, list): if value in entry: return True return False elif isinstance(entry, dict): if isinstance(value, dict): rval = False for key, val in value.items(): if entry[key] != val: rval = False break else: rval = True return rval return value in entry return entry == value def append(self, path, value): '''append value to a list''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError as _: entry = None if entry is None: self.put(path, []) entry = Yedit.get_entry(self.yaml_dict, path, self.separator) if not isinstance(entry, list): return (False, self.yaml_dict) # pylint: disable=no-member,maybe-no-member entry.append(value) return (True, self.yaml_dict) # pylint: disable=too-many-arguments def update(self, path, value, index=None, curr_value=None): ''' put path, value into a dict ''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError as _: entry = None if isinstance(entry, dict): # pylint: disable=no-member,maybe-no-member if not isinstance(value, dict): raise YeditException('Cannot replace key, value entry in dict with non-dict type.' \ ' value=[%s] [%s]' % (value, type(value))) entry.update(value) return (True, self.yaml_dict) elif isinstance(entry, list): # pylint: disable=no-member,maybe-no-member ind = None if curr_value: try: ind = entry.index(curr_value) except ValueError: return (False, self.yaml_dict) elif index != None: ind = index if ind != None and entry[ind] != value: entry[ind] = value return (True, self.yaml_dict) # see if it exists in the list try: ind = entry.index(value) except ValueError: # doesn't exist, append it entry.append(value) return (True, self.yaml_dict) #already exists, return if ind != None: return (False, self.yaml_dict) return (False, self.yaml_dict) def put(self, path, value): ''' put path, value into a dict ''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError as _: entry = None if entry == value: return (False, self.yaml_dict) # deepcopy didn't work tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict, default_flow_style=False), yaml.RoundTripLoader) # pylint: disable=no-member if hasattr(self.yaml_dict, 'fa'): tmp_copy.fa.set_block_style() result = Yedit.add_entry(tmp_copy, path, value, self.separator) if not result: return (False, self.yaml_dict) self.yaml_dict = tmp_copy return (True, self.yaml_dict) def create(self, path, value): ''' create a yaml file ''' if not self.file_exists(): # deepcopy didn't work tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict, default_flow_style=False), yaml.RoundTripLoader) # pylint: disable=no-member if hasattr(self.yaml_dict, 'fa'): tmp_copy.fa.set_block_style() result = Yedit.add_entry(tmp_copy, path, value, self.separator) if result: self.yaml_dict = tmp_copy return (True, self.yaml_dict) return (False, self.yaml_dict) # vim: expandtab:tabstop=4:shiftwidth=4 # pylint: skip-file # pylint: disable=too-many-instance-attributes class OCLabel(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' # pylint allows 5 # pylint: disable=too-many-arguments def __init__(self, name, namespace, kind, kubeconfig, labels=None, selector=None, verbose=False): ''' Constructor for OCLabel ''' super(OCLabel, self).__init__(namespace, kubeconfig) self.name = name self.namespace = namespace self.kind = kind self.kubeconfig = kubeconfig self.labels = labels self.selector = selector def get_current_labels(self): ''' get the current labels on object ''' return self.get()['results']['labels'] def compare_labels(self, host_labels): ''' compare incoming labels against current labels''' for label in self.labels: if label['key'] not in host_labels or \ label['value'] != host_labels[label['key']]: return False return True def all_user_labels_exist(self): ''' return whether all the labels already exist ''' current_labels = self.get_current_labels() for current_host_labels in current_labels: rbool = self.compare_labels(current_host_labels) if rbool == False: return False return True def any_label_exists(self): ''' return whether any single label already exists ''' current_labels = self.get_current_labels() for current_host_labels in current_labels: for label in self.labels: if label['key'] in current_host_labels: return True return False def get_user_keys(self): ''' go through list of user key:values and return all keys ''' user_keys = [] for label in self.labels: user_keys.append(label['key']) return user_keys def get_current_label_keys(self): ''' collect all the current label keys ''' current_label_keys = [] current_labels = self.get_current_labels() for current_host_labels in current_labels: current_label_keys.append(current_host_labels.keys()) return list(set(current_label_keys)) def get_extra_current_labels(self): ''' return list of labels that are currently stored, but aren't in user-provided list ''' current_labels = self.get_current_labels() extra_labels = [] user_label_keys = self.get_user_keys() current_label_keys = self.get_current_label_keys() for current_key in current_label_keys: if current_key not in user_label_keys: extra_labels.append(current_key) return extra_labels def extra_current_labels(self): ''' return whether there are labels currently stored that user hasn't directly provided ''' extra_labels = self.get_extra_current_labels() if len(extra_labels) > 0: return True else: return False def replace(self): ''' replace currently stored labels with user provided labels ''' cmd = self.cmd_template() # First delete any extra labels extra_labels = self.get_extra_current_labels() if len(extra_labels) > 0: for label in extra_labels: cmd.append("{}-".format(label)) # Now add/modify the user-provided label list if len(self.labels) > 0: for label in self.labels: cmd.append("{}={}".format(label['key'], label['value'])) # --overwrite for the case where we are updating existing labels cmd.append("--overwrite") return self.openshift_cmd(cmd) def get(self): '''return label information ''' result_dict = {} label_list = [] if self.name: result = self._get(resource=self.kind, rname=self.name, selector=self.selector) if 'labels' in result['results'][0]['metadata']: label_list.append(result['results'][0]['metadata']['labels']) else: label_list.append({}) else: result = self._get(resource=self.kind, selector=self.selector) for item in result['results'][0]['items']: if 'labels' in item['metadata']: label_list.append(item['metadata']['labels']) else: label_list.append({}) result_dict['labels'] = label_list result_dict['item_count'] = len(label_list) result['results'] = result_dict return result def cmd_template(self): ''' boilerplate oc command for modifying lables on this object ''' # let's build the cmd with what we have passed in cmd = [] if self.namespace: cmd = cmd + ["-n", self.namespace] if self.selector: cmd = cmd + ["--selector", self.selector] cmd = cmd + ["--config", self.kubeconfig, "label", self.kind] if self.name: cmd = cmd + [self.name] return cmd def add(self): ''' add labels ''' cmd = self.cmd_template() for label in self.labels: cmd.append("{}={}".format(label['key'], label['value'])) cmd.append("--overwrite") return self.openshift_cmd(cmd) def delete(self): '''delete the labels''' cmd = self.cmd_template() for label in self.labels: cmd.append("{}-".format(label['key'])) return self.openshift_cmd(cmd) # vim: expandtab:tabstop=4:shiftwidth=4 # pylint: skip-file #pylint: disable=too-many-branches def main(): ''' ansible oc module for labels ''' module = AnsibleModule( argument_spec=dict( kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'), state=dict(default='present', type='str', choices=['present', 'absent', 'list', 'add']), debug=dict(default=False, type='bool'), kind=dict(default=None, type='str', required=True, choices=['node', 'pod', 'namespace']), name=dict(default=None, type='str'), namespace=dict(default=None, type='str'), labels=dict(default=None, type='list'), selector=dict(default=None, type='str'), host=dict(default=None, type='str'), ), supports_check_mode=True, mutually_exclusive = (['name', 'selector']), ) oc_label = OCLabel(module.params['name'], module.params['namespace'], module.params['kind'], module.params['kubeconfig'], module.params['labels'], module.params['selector'], verbose=module.params['debug']) state = module.params['state'] name = module.params['name'] selector = module.params['selector'] api_rval = oc_label.get() ##### # Get ##### if state == 'list': module.exit_json(changed=False, results=api_rval['results'], state="list") ####### # Add ####### if state == 'add': if not (name or selector): module.fail_json( msg="Parameter 'name' or 'selector' is required if state == 'add'") if not oc_label.all_user_labels_exist(): if module.check_mode: module.exit_json(changed=False, msg='Would have performed an addition.') api_rval = oc_label.add() if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) module.exit_json(changed=True, results=api_rval, state="add") module.exit_json(changed=False, state="add") ######## # Delete ######## if state == 'absent': if not (name or selector): module.fail_json( msg="Parameter 'name' or 'selector' is required if state == 'absent'") if oc_label.any_label_exists(): if module.check_mode: module.exit_json(changed=False, msg='Would have performed a delete.') api_rval = oc_label.delete() if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) module.exit_json(changed=True, results=api_rval, state="absent") module.exit_json(changed=False, state="absent") if state == 'present': ######## # Update ######## if not (name or selector): module.fail_json( msg="Parameter 'name' or 'selector' is required if state == 'present'") # if all the labels passed in don't already exist # or if there are currently stored labels that haven't # been passed in if not oc_label.all_user_labels_exist() or \ oc_label.extra_current_labels(): if module.check_mode: module.exit_json(changed=False, msg='Would have made changes.') api_rval = oc_label.replace() if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) # return the created object api_rval = oc_label.get() if api_rval['returncode'] != 0: module.fail_json(msg=api_rval) module.exit_json(changed=True, results=api_rval, state="present") module.exit_json(changed=False, results=api_rval, state="present") module.exit_json(failed=True, changed=False, results='Unknown state passed. %s' % state, state="unknown") # pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import, locally-disabled # import module snippets. This are required from ansible.module_utils.basic import * main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 1278, 199, 3, 258, 31111, 31111, 485, 221, 485, 31111, 31111, 259, 485, 636, 8989, 31111, 31111, 199, 3, 259, 1182, 636, 92, 636, 92, 971, 92, 1204, 636, 92, 485, 971, 221, 1182, 18005, 63, 257, 485, 92, 636, 92, 257, 971, 199, 3, 257, 1204, 6110, 1204, 485, 10644, 1275, 64, 1204, 485, 10644, 257, 1182, 1182, 485, 971, 92, 1204, 1204, 485, 10644, 1204, 9, 1204, 199, 3, 259, 971, 8989, 92, 8989, 30007, 6113, 63, 92, 8989, 30007, 92, 18005, 15607, 15607, 60, 18005, 63, 30007, 92, 8989, 92, 8989, 15607, 636, 8989, 199, 3, 257, 1204, 257, 971, 1182, 485, 971, 221, 1204, 971, 92, 1204, 15, 485, 971, 63, 257, 485, 92, 1204, 636, 92, 257, 971, 63, 485, 30007, 257, 485, 92, 199, 3, 257, 1204, 1204, 9, 1204, 334, 4602, 1204, 1204, 1275, 64, 1204, 334, 4602, 12208, 1204, 257, 1204, 485, 10644, 1204, 9, 1204, 1204, 221, 1204, 1204, 199, 3, 257, 1204, 8989, 15, 971, 8989, 15, 221, 1204, 63, 6113, 63, 6113, 8989, 15, 1204, 63, 92, 257, 1204, 8989, 92, 8989, 15, 8989, 92, 1204, 63, 92, 199, 2344, 2043, 3232, 14379, 7802, 1021, 626, 14018, 314, 4244, 3718, 315, 282, 3873, 199, 2344, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 1278, 199, 199, 646, 19840, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 519, 85, 14868, 14, 5963, 465, 8864, 199, 3, 646, 8864, 199, 3, 199, 309, 961, 365, 2348, 2952, 402, 282, 6519, 626, 14486, 8864, 199, 309, 370, 22743, 2429, 7137, 2256, 641, 22496, 199, 3, 318, 4913, 63, 1880, 1547, 12, 1031, 304, 199, 3, 259, 1449, 1107, 22496, 465, 3326, 2344, 199, 3, 259, 372, 620, 8, 932, 14, 585, 9, 199, 3, 5963, 14, 525, 63, 1880, 8, 85, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 3954, 297, 4913, 63, 1880, 9, 199, 199, 533, 3232, 14379, 7802, 547, 8, 1726, 304, 272, 1449, 1726, 1021, 367, 1551, 4723, 2764, 2344, 272, 986, 199, 199, 3, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 199, 533, 3232, 14379, 7802, 8, 785, 304, 272, 1449, 8089, 370, 4816, 314, 1414, 1004, 7249, 1449, 272, 347, 636, 826, 721, 277, 12, 326, 3231, 12, 326, 23091, 888, 8805, 6839, 15, 6493, 15, 4133, 15, 2113, 14, 29192, 297, 326, 3376, 29, 797, 12, 326, 1006, 63, 9247, 29, 797, 304, 267, 1449, 20297, 367, 3232, 4723, 7802, 1449, 267, 291, 14, 3251, 275, 3231, 267, 291, 14, 3832, 275, 3376, 267, 291, 14, 29192, 275, 23091, 888, 267, 291, 14, 452, 63, 9247, 275, 1006, 63, 9247, 339, 327, 1611, 3854, 6127, 1454, 959, 2368, 370, 506, 3032, 14, 272, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 4958, 272, 347, 485, 1814, 63, 1317, 8, 277, 12, 2073, 12, 519, 354, 12, 1564, 12, 3542, 29, 797, 12, 7375, 15637, 735, 267, 1449, 3350, 314, 1453, 909, 543, 314, 1564, 1449, 267, 522, 275, 291, 423, 362, 8, 1927, 12, 519, 354, 9, 267, 340, 440, 522, 459, 2604, 2565, 288, 372, 522, 398, 6748, 275, 1994, 2791, 3149, 83, 7, 450, 519, 354, 267, 612, 379, 275, 28774, 8, 5252, 12, 522, 459, 2604, 3488, 16, 467, 9432, 29, 4127, 9, 267, 4493, 275, 942, 267, 367, 790, 12, 574, 315, 1564, 14, 1744, 837, 288, 4493, 14, 740, 8, 89, 379, 14, 524, 8, 498, 12, 574, 430, 398, 340, 1263, 779, 1461, 59, 16, 61, 367, 1570, 315, 4493, 4682, 288, 612, 379, 14, 952, 342, 953, 19840, 14, 2683, 8, 7535, 14, 7661, 12, 359, 5252, 566, 953, 372, 291, 423, 1814, 8, 5252, 12, 3542, 9, 398, 372, 791, 9913, 356, 378, 12, 283, 5334, 356, 756, 93, 339, 347, 485, 1814, 8, 277, 12, 6748, 12, 3542, 29, 797, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 2088, 275, 11573, 78, 297, 291, 14, 3251, 12, 283, 1814, 297, 2475, 70, 297, 6748, 61, 267, 340, 3542, 26, 288, 2088, 14, 740, 4517, 3990, 358, 267, 372, 291, 14, 22858, 63, 1760, 8, 1760, 9, 339, 347, 485, 981, 63, 504, 63, 1317, 8, 277, 12, 519, 354, 12, 1564, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 6748, 275, 1994, 2791, 3149, 83, 7, 450, 519, 354, 267, 612, 379, 275, 28774, 8, 5252, 12, 1564, 29, 1317, 9, 267, 612, 379, 14, 952, 342, 398, 19840, 14, 2683, 8, 7535, 14, 7661, 12, 359, 5252, 566, 398, 372, 291, 423, 981, 8, 5252, 9, 339, 347, 485, 981, 8, 277, 12, 6748, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 372, 291, 14, 22858, 63, 1760, 2941, 981, 297, 2475, 70, 297, 6748, 12, 2475, 78, 297, 291, 14, 3251, 566, 339, 347, 485, 1807, 8, 277, 12, 2073, 12, 519, 354, 12, 9759, 29, 403, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 2088, 275, 788, 1807, 297, 2073, 12, 519, 354, 12, 2475, 78, 297, 291, 14, 3251, 61, 267, 340, 9759, 26, 288, 2088, 14, 740, 4517, 6662, 2458, 83, 7, 450, 9759, 9, 398, 372, 291, 14, 22858, 63, 1760, 8, 1760, 9, 339, 347, 485, 1412, 8, 277, 12, 1978, 63, 354, 12, 1218, 29, 797, 12, 1862, 29, 403, 12, 1978, 63, 576, 29, 403, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 2088, 275, 788, 1412, 297, 2475, 78, 297, 291, 14, 3251, 61, 267, 340, 1978, 63, 576, 26, 288, 2088, 14, 2880, 24829, 70, 297, 2475, 1105, 267, 587, 26, 288, 2088, 14, 740, 8, 1160, 63, 354, 9, 267, 340, 1862, 26, 288, 1215, 63, 495, 275, 28585, 83, 2458, 83, 2, 450, 334, 498, 12, 574, 9, 367, 790, 12, 574, 315, 1862, 14, 1744, 5106, 288, 2088, 14, 740, 3654, 86, 358, 288, 2088, 14, 2880, 8, 635, 63, 495, 9, 398, 2058, 275, 291, 14, 22858, 63, 1760, 8, 1760, 12, 1072, 29, 549, 12 ]
[ 2647, 15, 1393, 15, 1813, 2366, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 1278, 199, 3, 258, 31111, 31111, 485, 221, 485, 31111, 31111, 259, 485, 636, 8989, 31111, 31111, 199, 3, 259, 1182, 636, 92, 636, 92, 971, 92, 1204, 636, 92, 485, 971, 221, 1182, 18005, 63, 257, 485, 92, 636, 92, 257, 971, 199, 3, 257, 1204, 6110, 1204, 485, 10644, 1275, 64, 1204, 485, 10644, 257, 1182, 1182, 485, 971, 92, 1204, 1204, 485, 10644, 1204, 9, 1204, 199, 3, 259, 971, 8989, 92, 8989, 30007, 6113, 63, 92, 8989, 30007, 92, 18005, 15607, 15607, 60, 18005, 63, 30007, 92, 8989, 92, 8989, 15607, 636, 8989, 199, 3, 257, 1204, 257, 971, 1182, 485, 971, 221, 1204, 971, 92, 1204, 15, 485, 971, 63, 257, 485, 92, 1204, 636, 92, 257, 971, 63, 485, 30007, 257, 485, 92, 199, 3, 257, 1204, 1204, 9, 1204, 334, 4602, 1204, 1204, 1275, 64, 1204, 334, 4602, 12208, 1204, 257, 1204, 485, 10644, 1204, 9, 1204, 1204, 221, 1204, 1204, 199, 3, 257, 1204, 8989, 15, 971, 8989, 15, 221, 1204, 63, 6113, 63, 6113, 8989, 15, 1204, 63, 92, 257, 1204, 8989, 92, 8989, 15, 8989, 92, 1204, 63, 92, 199, 2344, 2043, 3232, 14379, 7802, 1021, 626, 14018, 314, 4244, 3718, 315, 282, 3873, 199, 2344, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 1278, 199, 199, 646, 19840, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 519, 85, 14868, 14, 5963, 465, 8864, 199, 3, 646, 8864, 199, 3, 199, 309, 961, 365, 2348, 2952, 402, 282, 6519, 626, 14486, 8864, 199, 309, 370, 22743, 2429, 7137, 2256, 641, 22496, 199, 3, 318, 4913, 63, 1880, 1547, 12, 1031, 304, 199, 3, 259, 1449, 1107, 22496, 465, 3326, 2344, 199, 3, 259, 372, 620, 8, 932, 14, 585, 9, 199, 3, 5963, 14, 525, 63, 1880, 8, 85, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 3954, 297, 4913, 63, 1880, 9, 199, 199, 533, 3232, 14379, 7802, 547, 8, 1726, 304, 272, 1449, 1726, 1021, 367, 1551, 4723, 2764, 2344, 272, 986, 199, 199, 3, 4287, 26, 3507, 29, 7354, 13, 70, 546, 13, 3455, 13, 2474, 199, 533, 3232, 14379, 7802, 8, 785, 304, 272, 1449, 8089, 370, 4816, 314, 1414, 1004, 7249, 1449, 272, 347, 636, 826, 721, 277, 12, 326, 3231, 12, 326, 23091, 888, 8805, 6839, 15, 6493, 15, 4133, 15, 2113, 14, 29192, 297, 326, 3376, 29, 797, 12, 326, 1006, 63, 9247, 29, 797, 304, 267, 1449, 20297, 367, 3232, 4723, 7802, 1449, 267, 291, 14, 3251, 275, 3231, 267, 291, 14, 3832, 275, 3376, 267, 291, 14, 29192, 275, 23091, 888, 267, 291, 14, 452, 63, 9247, 275, 1006, 63, 9247, 339, 327, 1611, 3854, 6127, 1454, 959, 2368, 370, 506, 3032, 14, 272, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 4958, 272, 347, 485, 1814, 63, 1317, 8, 277, 12, 2073, 12, 519, 354, 12, 1564, 12, 3542, 29, 797, 12, 7375, 15637, 735, 267, 1449, 3350, 314, 1453, 909, 543, 314, 1564, 1449, 267, 522, 275, 291, 423, 362, 8, 1927, 12, 519, 354, 9, 267, 340, 440, 522, 459, 2604, 2565, 288, 372, 522, 398, 6748, 275, 1994, 2791, 3149, 83, 7, 450, 519, 354, 267, 612, 379, 275, 28774, 8, 5252, 12, 522, 459, 2604, 3488, 16, 467, 9432, 29, 4127, 9, 267, 4493, 275, 942, 267, 367, 790, 12, 574, 315, 1564, 14, 1744, 837, 288, 4493, 14, 740, 8, 89, 379, 14, 524, 8, 498, 12, 574, 430, 398, 340, 1263, 779, 1461, 59, 16, 61, 367, 1570, 315, 4493, 4682, 288, 612, 379, 14, 952, 342, 953, 19840, 14, 2683, 8, 7535, 14, 7661, 12, 359, 5252, 566, 953, 372, 291, 423, 1814, 8, 5252, 12, 3542, 9, 398, 372, 791, 9913, 356, 378, 12, 283, 5334, 356, 756, 93, 339, 347, 485, 1814, 8, 277, 12, 6748, 12, 3542, 29, 797, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 2088, 275, 11573, 78, 297, 291, 14, 3251, 12, 283, 1814, 297, 2475, 70, 297, 6748, 61, 267, 340, 3542, 26, 288, 2088, 14, 740, 4517, 3990, 358, 267, 372, 291, 14, 22858, 63, 1760, 8, 1760, 9, 339, 347, 485, 981, 63, 504, 63, 1317, 8, 277, 12, 519, 354, 12, 1564, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 6748, 275, 1994, 2791, 3149, 83, 7, 450, 519, 354, 267, 612, 379, 275, 28774, 8, 5252, 12, 1564, 29, 1317, 9, 267, 612, 379, 14, 952, 342, 398, 19840, 14, 2683, 8, 7535, 14, 7661, 12, 359, 5252, 566, 398, 372, 291, 423, 981, 8, 5252, 9, 339, 347, 485, 981, 8, 277, 12, 6748, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 372, 291, 14, 22858, 63, 1760, 2941, 981, 297, 2475, 70, 297, 6748, 12, 2475, 78, 297, 291, 14, 3251, 566, 339, 347, 485, 1807, 8, 277, 12, 2073, 12, 519, 354, 12, 9759, 29, 403, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 2088, 275, 788, 1807, 297, 2073, 12, 519, 354, 12, 2475, 78, 297, 291, 14, 3251, 61, 267, 340, 9759, 26, 288, 2088, 14, 740, 4517, 6662, 2458, 83, 7, 450, 9759, 9, 398, 372, 291, 14, 22858, 63, 1760, 8, 1760, 9, 339, 347, 485, 1412, 8, 277, 12, 1978, 63, 354, 12, 1218, 29, 797, 12, 1862, 29, 403, 12, 1978, 63, 576, 29, 403, 304, 267, 1449, 1107, 1006, 15329, 83, 1449, 267, 2088, 275, 788, 1412, 297, 2475, 78, 297, 291, 14, 3251, 61, 267, 340, 1978, 63, 576, 26, 288, 2088, 14, 2880, 24829, 70, 297, 2475, 1105, 267, 587, 26, 288, 2088, 14, 740, 8, 1160, 63, 354, 9, 267, 340, 1862, 26, 288, 1215, 63, 495, 275, 28585, 83, 2458, 83, 2, 450, 334, 498, 12, 574, 9, 367, 790, 12, 574, 315, 1862, 14, 1744, 5106, 288, 2088, 14, 740, 3654, 86, 358, 288, 2088, 14, 2880, 8, 635, 63, 495, 9, 398, 2058, 275, 291, 14, 22858, 63, 1760, 8, 1760, 12, 1072, 29, 549, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
Amneamnius/eve-wspace
evewspace/SiteTracker/templatetags/sitetracker.py
10
3218
# Eve W-Space # Copyright (C) 2013 Andrew Austin and other contributors # # 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. An additional term under section # 7 of the GPL is included in the LICENSE file. # # 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 __future__ import absolute_import from django import template from SiteTracker.models import Fleet, SiteType, UserSite register = template.Library() def get_st_context(user): """ Returns a dict of myfleets, availfleets, and fleetcount. """ myfleets = user.sitetrackerlogs.filter(leavetime=None).all() availfleets = [] for fleet in Fleet.objects.filter(ended=None): if fleet.members.filter(user=user, leavetime=None).count() == 0: availfleets.append(fleet) fleetcount = Fleet.objects.filter(ended=None).count() return {'myfleets': myfleets, 'availfleets': availfleets, 'fleetcount': fleetcount, 'user': user} @register.inclusion_tag("st_status_bar.html", takes_context=True) def st_status_bar(context, refresh=False): """ Displays the SiteTracker status bar. """ dict_values = get_st_context(context['user']) dict_values.update({'refresh': refresh}) return dict_values @register.inclusion_tag("st_status.html") def st_status(user): """ Displays the status text. """ return get_st_context(user) @register.inclusion_tag("st_boss_member.html") def st_boss_member(member): """ Displays the details for a fleet member in the boss panel. """ return {'member': member} @register.inclusion_tag("st_my_fleets.html") def st_my_fleets(user): """ List of fleets which user is a member. """ return get_st_context(user) @register.inclusion_tag("st_fleet_details.html") def st_fleet_details(fleet, user): """ Details of a sitetracker fleet. """ return {'fleet': fleet, 'user': user} @register.inclusion_tag("st_member_sitelist.html") def st_member_site_list(fleet, user): """ List of sites for a user in a fleet. """ pending_sites = [] for log in UserSite.objects.filter(user=user, pending=True).all(): pending_sites.append(log.site) return {'fleet': fleet, 'pending_sites': pending_sites, 'user': user} @register.inclusion_tag("st_avail_fleets.html") def st_avail_fleets(user): """ List of available fleets. """ return get_st_context(user) @register.inclusion_tag("st_fleet_details_boss.html") def st_fleet_details_boss(fleet, user): """ Details of a sitetracker fleet when we are the boss. """ return {'fleet': fleet, 'site_types': SiteType.objects.all(), 'user': user}
gpl-3.0
[ 3, 259, 662, 432, 644, 13, 7643, 199, 3, 259, 1898, 334, 35, 9, 6171, 221, 6061, 5257, 437, 833, 262, 436, 1163, 8417, 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, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 1626, 4722, 6707, 1334, 3420, 199, 3, 259, 1520, 402, 314, 14629, 365, 5120, 315, 314, 5113, 570, 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, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 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, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 1639, 492, 1978, 199, 504, 11666, 13652, 14, 992, 492, 481, 274, 386, 12, 11666, 804, 12, 2876, 8972, 199, 199, 2683, 275, 1978, 14, 7424, 342, 199, 199, 318, 664, 63, 270, 63, 1100, 8, 751, 304, 272, 408, 272, 1803, 282, 1211, 402, 3002, 21599, 8716, 12, 2289, 5789, 276, 274, 8716, 12, 436, 289, 274, 386, 835, 14, 272, 408, 272, 3002, 21599, 8716, 275, 922, 14, 2124, 8877, 7270, 14, 1541, 8, 12422, 521, 29, 403, 680, 452, 342, 272, 2289, 5789, 276, 274, 8716, 275, 942, 272, 367, 289, 274, 386, 315, 481, 274, 386, 14, 1462, 14, 1541, 8, 8960, 29, 403, 304, 267, 340, 289, 274, 386, 14, 6334, 14, 1541, 8, 751, 29, 751, 12, 10137, 521, 29, 403, 680, 835, 342, 508, 221, 378, 26, 288, 2289, 5789, 276, 274, 8716, 14, 740, 8, 21599, 386, 9, 272, 289, 274, 386, 835, 275, 481, 274, 386, 14, 1462, 14, 1541, 8, 8960, 29, 403, 680, 835, 342, 272, 372, 791, 1662, 21599, 8716, 356, 3002, 21599, 8716, 12, 283, 3812, 17588, 274, 8716, 356, 2289, 5789, 276, 274, 8716, 12, 288, 283, 21599, 386, 835, 356, 289, 274, 386, 835, 12, 283, 751, 356, 922, 93, 421, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1205, 63, 1700, 14, 1360, 401, 6181, 63, 1100, 29, 549, 9, 199, 318, 410, 63, 1205, 63, 1700, 8, 1100, 12, 9236, 29, 797, 304, 272, 408, 272, 28750, 314, 11666, 13652, 2004, 4681, 14, 272, 408, 272, 1211, 63, 1459, 275, 664, 63, 270, 63, 1100, 8, 1100, 459, 751, 1105, 272, 1211, 63, 1459, 14, 873, 3252, 6635, 356, 9236, 1552, 272, 372, 1211, 63, 1459, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1205, 14, 1360, 531, 199, 318, 410, 63, 1205, 8, 751, 304, 272, 408, 272, 28750, 314, 2004, 1318, 14, 272, 408, 272, 372, 664, 63, 270, 63, 1100, 8, 751, 9, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 25020, 63, 1114, 14, 1360, 531, 199, 318, 410, 63, 25020, 63, 1114, 8, 1114, 304, 272, 408, 272, 28750, 314, 2436, 367, 282, 289, 274, 386, 3653, 315, 314, 1234, 385, 12748, 14, 272, 408, 272, 372, 791, 1114, 356, 3653, 93, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1662, 63, 21599, 8716, 14, 1360, 531, 199, 318, 410, 63, 1662, 63, 21599, 8716, 8, 751, 304, 272, 408, 272, 3820, 402, 289, 274, 8716, 1314, 922, 365, 282, 3653, 14, 272, 408, 272, 372, 664, 63, 270, 63, 1100, 8, 751, 9, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 21599, 386, 63, 5087, 14, 1360, 531, 199, 318, 410, 63, 21599, 386, 63, 5087, 8, 21599, 386, 12, 922, 304, 272, 408, 272, 15621, 402, 282, 4770, 8877, 289, 274, 386, 14, 272, 408, 272, 372, 791, 21599, 386, 356, 289, 274, 386, 12, 283, 751, 356, 922, 93, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1114, 63, 2124, 513, 14, 1360, 531, 199, 318, 410, 63, 1114, 63, 2124, 63, 513, 8, 21599, 386, 12, 922, 304, 272, 408, 272, 3820, 402, 15424, 367, 282, 922, 315, 282, 289, 274, 386, 14, 272, 408, 272, 9413, 63, 8619, 275, 942, 272, 367, 943, 315, 2876, 8972, 14, 1462, 14, 1541, 8, 751, 29, 751, 12, 9413, 29, 549, 680, 452, 837, 267, 9413, 63, 8619, 14, 740, 8, 793, 14, 2124, 9, 272, 372, 791, 21599, 386, 356, 289, 274, 386, 12, 283, 6455, 63, 8619, 356, 9413, 63, 8619, 12, 283, 751, 356, 922, 93, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 18961, 63, 21599, 8716, 14, 1360, 531, 199, 318, 410, 63, 18961, 63, 21599, 8716, 8, 751, 304, 272, 408, 272, 3820, 402, 2808, 289, 274, 8716, 14, 272, 408, 272, 372, 664, 63, 270, 63, 1100, 8, 751, 9, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 21599, 386, 63, 5087, 63, 25020, 14, 1360, 531, 199, 318, 410, 63, 21599, 386, 63, 5087, 63, 25020, 8, 21599, 386, 12, 922, 304, 272, 408, 272, 15621, 402, 282, 4770, 8877, 289, 274, 386, 1380, 781, 787, 314, 1234, 385, 14, 272, 408, 272, 372, 791, 21599, 386, 356, 289, 274, 386, 12, 283, 2124, 63, 1313, 356, 11666, 804, 14, 1462, 14, 452, 1062, 283, 751, 356, 922, 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 ]
[ 259, 662, 432, 644, 13, 7643, 199, 3, 259, 1898, 334, 35, 9, 6171, 221, 6061, 5257, 437, 833, 262, 436, 1163, 8417, 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, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 1626, 4722, 6707, 1334, 3420, 199, 3, 259, 1520, 402, 314, 14629, 365, 5120, 315, 314, 5113, 570, 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, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 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, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 1639, 492, 1978, 199, 504, 11666, 13652, 14, 992, 492, 481, 274, 386, 12, 11666, 804, 12, 2876, 8972, 199, 199, 2683, 275, 1978, 14, 7424, 342, 199, 199, 318, 664, 63, 270, 63, 1100, 8, 751, 304, 272, 408, 272, 1803, 282, 1211, 402, 3002, 21599, 8716, 12, 2289, 5789, 276, 274, 8716, 12, 436, 289, 274, 386, 835, 14, 272, 408, 272, 3002, 21599, 8716, 275, 922, 14, 2124, 8877, 7270, 14, 1541, 8, 12422, 521, 29, 403, 680, 452, 342, 272, 2289, 5789, 276, 274, 8716, 275, 942, 272, 367, 289, 274, 386, 315, 481, 274, 386, 14, 1462, 14, 1541, 8, 8960, 29, 403, 304, 267, 340, 289, 274, 386, 14, 6334, 14, 1541, 8, 751, 29, 751, 12, 10137, 521, 29, 403, 680, 835, 342, 508, 221, 378, 26, 288, 2289, 5789, 276, 274, 8716, 14, 740, 8, 21599, 386, 9, 272, 289, 274, 386, 835, 275, 481, 274, 386, 14, 1462, 14, 1541, 8, 8960, 29, 403, 680, 835, 342, 272, 372, 791, 1662, 21599, 8716, 356, 3002, 21599, 8716, 12, 283, 3812, 17588, 274, 8716, 356, 2289, 5789, 276, 274, 8716, 12, 288, 283, 21599, 386, 835, 356, 289, 274, 386, 835, 12, 283, 751, 356, 922, 93, 421, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1205, 63, 1700, 14, 1360, 401, 6181, 63, 1100, 29, 549, 9, 199, 318, 410, 63, 1205, 63, 1700, 8, 1100, 12, 9236, 29, 797, 304, 272, 408, 272, 28750, 314, 11666, 13652, 2004, 4681, 14, 272, 408, 272, 1211, 63, 1459, 275, 664, 63, 270, 63, 1100, 8, 1100, 459, 751, 1105, 272, 1211, 63, 1459, 14, 873, 3252, 6635, 356, 9236, 1552, 272, 372, 1211, 63, 1459, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1205, 14, 1360, 531, 199, 318, 410, 63, 1205, 8, 751, 304, 272, 408, 272, 28750, 314, 2004, 1318, 14, 272, 408, 272, 372, 664, 63, 270, 63, 1100, 8, 751, 9, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 25020, 63, 1114, 14, 1360, 531, 199, 318, 410, 63, 25020, 63, 1114, 8, 1114, 304, 272, 408, 272, 28750, 314, 2436, 367, 282, 289, 274, 386, 3653, 315, 314, 1234, 385, 12748, 14, 272, 408, 272, 372, 791, 1114, 356, 3653, 93, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1662, 63, 21599, 8716, 14, 1360, 531, 199, 318, 410, 63, 1662, 63, 21599, 8716, 8, 751, 304, 272, 408, 272, 3820, 402, 289, 274, 8716, 1314, 922, 365, 282, 3653, 14, 272, 408, 272, 372, 664, 63, 270, 63, 1100, 8, 751, 9, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 21599, 386, 63, 5087, 14, 1360, 531, 199, 318, 410, 63, 21599, 386, 63, 5087, 8, 21599, 386, 12, 922, 304, 272, 408, 272, 15621, 402, 282, 4770, 8877, 289, 274, 386, 14, 272, 408, 272, 372, 791, 21599, 386, 356, 289, 274, 386, 12, 283, 751, 356, 922, 93, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 1114, 63, 2124, 513, 14, 1360, 531, 199, 318, 410, 63, 1114, 63, 2124, 63, 513, 8, 21599, 386, 12, 922, 304, 272, 408, 272, 3820, 402, 15424, 367, 282, 922, 315, 282, 289, 274, 386, 14, 272, 408, 272, 9413, 63, 8619, 275, 942, 272, 367, 943, 315, 2876, 8972, 14, 1462, 14, 1541, 8, 751, 29, 751, 12, 9413, 29, 549, 680, 452, 837, 267, 9413, 63, 8619, 14, 740, 8, 793, 14, 2124, 9, 272, 372, 791, 21599, 386, 356, 289, 274, 386, 12, 283, 6455, 63, 8619, 356, 9413, 63, 8619, 12, 283, 751, 356, 922, 93, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 18961, 63, 21599, 8716, 14, 1360, 531, 199, 318, 410, 63, 18961, 63, 21599, 8716, 8, 751, 304, 272, 408, 272, 3820, 402, 2808, 289, 274, 8716, 14, 272, 408, 272, 372, 664, 63, 270, 63, 1100, 8, 751, 9, 199, 199, 32, 2683, 14, 24265, 63, 1450, 480, 270, 63, 21599, 386, 63, 5087, 63, 25020, 14, 1360, 531, 199, 318, 410, 63, 21599, 386, 63, 5087, 63, 25020, 8, 21599, 386, 12, 922, 304, 272, 408, 272, 15621, 402, 282, 4770, 8877, 289, 274, 386, 1380, 781, 787, 314, 1234, 385, 14, 272, 408, 272, 372, 791, 21599, 386, 356, 289, 274, 386, 12, 283, 2124, 63, 1313, 356, 11666, 804, 14, 1462, 14, 452, 1062, 283, 751, 356, 922, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
studiomohawk/publicdraft
node_modules/grunt/node_modules/js-yaml/support/pyyaml-src/events.py
985
2445
# Abstract classes. class Event(object): def __init__(self, start_mark=None, end_mark=None): self.start_mark = start_mark self.end_mark = end_mark def __repr__(self): attributes = [key for key in ['anchor', 'tag', 'implicit', 'value'] if hasattr(self, key)] arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) for key in attributes]) return '%s(%s)' % (self.__class__.__name__, arguments) class NodeEvent(Event): def __init__(self, anchor, start_mark=None, end_mark=None): self.anchor = anchor self.start_mark = start_mark self.end_mark = end_mark class CollectionStartEvent(NodeEvent): def __init__(self, anchor, tag, implicit, start_mark=None, end_mark=None, flow_style=None): self.anchor = anchor self.tag = tag self.implicit = implicit self.start_mark = start_mark self.end_mark = end_mark self.flow_style = flow_style class CollectionEndEvent(Event): pass # Implementations. class StreamStartEvent(Event): def __init__(self, start_mark=None, end_mark=None, encoding=None): self.start_mark = start_mark self.end_mark = end_mark self.encoding = encoding class StreamEndEvent(Event): pass class DocumentStartEvent(Event): def __init__(self, start_mark=None, end_mark=None, explicit=None, version=None, tags=None): self.start_mark = start_mark self.end_mark = end_mark self.explicit = explicit self.version = version self.tags = tags class DocumentEndEvent(Event): def __init__(self, start_mark=None, end_mark=None, explicit=None): self.start_mark = start_mark self.end_mark = end_mark self.explicit = explicit class AliasEvent(NodeEvent): pass class ScalarEvent(NodeEvent): def __init__(self, anchor, tag, implicit, value, start_mark=None, end_mark=None, style=None): self.anchor = anchor self.tag = tag self.implicit = implicit self.value = value self.start_mark = start_mark self.end_mark = end_mark self.style = style class SequenceStartEvent(CollectionStartEvent): pass class SequenceEndEvent(CollectionEndEvent): pass class MappingStartEvent(CollectionStartEvent): pass class MappingEndEvent(CollectionEndEvent): pass
mit
[ 199, 3, 11836, 3992, 14, 199, 199, 533, 6763, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 272, 347, 636, 2722, 721, 277, 304, 267, 3004, 275, 359, 498, 367, 790, 315, 788, 11498, 297, 283, 1450, 297, 283, 11886, 297, 283, 585, 418, 355, 340, 2688, 8, 277, 12, 790, 1874, 267, 2368, 275, 1656, 1987, 904, 26861, 83, 2458, 82, 7, 450, 334, 498, 12, 2519, 8, 277, 12, 790, 430, 355, 367, 790, 315, 3004, 566, 267, 372, 1543, 83, 4042, 83, 3171, 450, 334, 277, 855, 533, 4914, 354, 3108, 2368, 9, 199, 199, 533, 5013, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 12514, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 304, 267, 291, 14, 11498, 275, 12514, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 18003, 3162, 2390, 8, 1716, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 12514, 12, 1947, 12, 9227, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 6369, 63, 2487, 29, 403, 304, 267, 291, 14, 11498, 275, 12514, 267, 291, 14, 1450, 275, 1947, 267, 291, 14, 11886, 275, 9227, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 1659, 63, 2487, 275, 6369, 63, 2487, 199, 199, 533, 18003, 3005, 2390, 8, 2390, 304, 272, 986, 199, 199, 3, 22467, 1298, 14, 199, 199, 533, 8271, 3162, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 2644, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2991, 275, 2644, 199, 199, 533, 8271, 3005, 2390, 8, 2390, 304, 272, 986, 199, 199, 533, 7543, 3162, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 5027, 29, 403, 12, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 10306, 275, 5027, 267, 291, 14, 1023, 275, 1015, 267, 291, 14, 2969, 275, 3762, 199, 199, 533, 7543, 3005, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 5027, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 10306, 275, 5027, 199, 199, 533, 24777, 2390, 8, 1716, 2390, 304, 272, 986, 199, 199, 533, 24289, 2390, 8, 1716, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 12514, 12, 1947, 12, 9227, 12, 574, 12, 288, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 3449, 29, 403, 304, 267, 291, 14, 11498, 275, 12514, 267, 291, 14, 1450, 275, 1947, 267, 291, 14, 11886, 275, 9227, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2487, 275, 3449, 199, 199, 533, 10975, 3162, 2390, 8, 7768, 3162, 2390, 304, 272, 986, 199, 199, 533, 10975, 3005, 2390, 8, 7768, 3005, 2390, 304, 272, 986, 199, 199, 533, 12340, 3162, 2390, 8, 7768, 3162, 2390, 304, 272, 986, 199, 199, 533, 12340, 3005, 2390, 8, 7768, 3005, 2390, 304, 272, 986, 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 ]
[ 3, 11836, 3992, 14, 199, 199, 533, 6763, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 272, 347, 636, 2722, 721, 277, 304, 267, 3004, 275, 359, 498, 367, 790, 315, 788, 11498, 297, 283, 1450, 297, 283, 11886, 297, 283, 585, 418, 355, 340, 2688, 8, 277, 12, 790, 1874, 267, 2368, 275, 1656, 1987, 904, 26861, 83, 2458, 82, 7, 450, 334, 498, 12, 2519, 8, 277, 12, 790, 430, 355, 367, 790, 315, 3004, 566, 267, 372, 1543, 83, 4042, 83, 3171, 450, 334, 277, 855, 533, 4914, 354, 3108, 2368, 9, 199, 199, 533, 5013, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 12514, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 304, 267, 291, 14, 11498, 275, 12514, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 199, 199, 533, 18003, 3162, 2390, 8, 1716, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 12514, 12, 1947, 12, 9227, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 6369, 63, 2487, 29, 403, 304, 267, 291, 14, 11498, 275, 12514, 267, 291, 14, 1450, 275, 1947, 267, 291, 14, 11886, 275, 9227, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 1659, 63, 2487, 275, 6369, 63, 2487, 199, 199, 533, 18003, 3005, 2390, 8, 2390, 304, 272, 986, 199, 199, 3, 22467, 1298, 14, 199, 199, 533, 8271, 3162, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 2644, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2991, 275, 2644, 199, 199, 533, 8271, 3005, 2390, 8, 2390, 304, 272, 986, 199, 199, 533, 7543, 3162, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 5027, 29, 403, 12, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 10306, 275, 5027, 267, 291, 14, 1023, 275, 1015, 267, 291, 14, 2969, 275, 3762, 199, 199, 533, 7543, 3005, 2390, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 288, 5027, 29, 403, 304, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 10306, 275, 5027, 199, 199, 533, 24777, 2390, 8, 1716, 2390, 304, 272, 986, 199, 199, 533, 24289, 2390, 8, 1716, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 12514, 12, 1947, 12, 9227, 12, 574, 12, 288, 1343, 63, 1657, 29, 403, 12, 1284, 63, 1657, 29, 403, 12, 3449, 29, 403, 304, 267, 291, 14, 11498, 275, 12514, 267, 291, 14, 1450, 275, 1947, 267, 291, 14, 11886, 275, 9227, 267, 291, 14, 585, 275, 574, 267, 291, 14, 928, 63, 1657, 275, 1343, 63, 1657, 267, 291, 14, 500, 63, 1657, 275, 1284, 63, 1657, 267, 291, 14, 2487, 275, 3449, 199, 199, 533, 10975, 3162, 2390, 8, 7768, 3162, 2390, 304, 272, 986, 199, 199, 533, 10975, 3005, 2390, 8, 7768, 3005, 2390, 304, 272, 986, 199, 199, 533, 12340, 3162, 2390, 8, 7768, 3162, 2390, 304, 272, 986, 199, 199, 533, 12340, 3005, 2390, 8, 7768, 3005, 2390, 304, 272, 986, 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, 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 ]
havard024/prego
crm/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/adapter.py
222
1557
""" This object provides quoting for GEOS geometries into PostgreSQL/PostGIS. """ from __future__ import unicode_literals from psycopg2 import Binary from psycopg2.extensions import ISQLQuote class PostGISAdapter(object): def __init__(self, geom): "Initializes on the geometry." # Getting the WKB (in string form, to allow easy pickling of # the adaptor) and the SRID from the geometry. self.ewkb = bytes(geom.ewkb) self.srid = geom.srid self._adapter = Binary(self.ewkb) def __conform__(self, proto): # Does the given protocol conform to what Psycopg2 expects? if proto == ISQLQuote: return self else: raise Exception('Error implementing psycopg2 protocol. Is psycopg2 installed?') def __eq__(self, other): if not isinstance(other, PostGISAdapter): return False return (self.ewkb == other.ewkb) and (self.srid == other.srid) def __str__(self): return self.getquoted() def prepare(self, conn): """ This method allows escaping the binary in the style required by the server's `standard_conforming_string` setting. """ self._adapter.prepare(conn) def getquoted(self): "Returns a properly quoted string for use in PostgreSQL/PostGIS." # psycopg will figure out whether to use E'\\000' or '\000' return str('ST_GeomFromEWKB(%s)' % self._adapter.getquoted().decode()) def prepare_database_save(self, unused): return self
mit
[ 624, 199, 961, 909, 6571, 18593, 367, 11920, 24883, 1901, 20175, 15, 6564, 11092, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 15492, 18, 492, 14161, 199, 504, 15492, 18, 14, 5359, 492, 2281, 2940, 12838, 199, 199, 533, 20929, 10200, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 9671, 304, 267, 298, 23489, 641, 314, 3400, 2122, 267, 327, 20703, 314, 644, 12780, 334, 262, 1059, 1824, 12, 370, 2040, 8837, 24394, 402, 267, 327, 314, 19520, 269, 9, 436, 314, 22425, 687, 314, 3400, 14, 267, 291, 14, 546, 7862, 275, 2783, 8, 6481, 14, 546, 7862, 9, 267, 291, 14, 10498, 275, 9671, 14, 10498, 267, 291, 423, 10394, 275, 14161, 8, 277, 14, 546, 7862, 9, 339, 347, 636, 388, 964, 721, 277, 12, 4104, 304, 267, 327, 12078, 314, 1627, 4113, 26449, 370, 4052, 510, 1786, 11476, 18, 14292, 31, 267, 340, 4104, 508, 2281, 2940, 12838, 26, 288, 372, 291, 267, 587, 26, 288, 746, 2186, 360, 547, 18234, 15492, 18, 4113, 14, 6596, 15492, 18, 4903, 18478, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 20929, 10200, 304, 288, 372, 756, 267, 372, 334, 277, 14, 546, 7862, 508, 1163, 14, 546, 7862, 9, 436, 334, 277, 14, 10498, 508, 1163, 14, 10498, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 362, 9888, 342, 339, 347, 9275, 8, 277, 12, 2557, 304, 267, 408, 267, 961, 1083, 6127, 21375, 314, 3366, 315, 314, 3449, 1415, 701, 314, 267, 1654, 1159, 658, 6807, 63, 388, 964, 316, 63, 875, 64, 4260, 14, 267, 408, 267, 291, 423, 10394, 14, 6726, 8, 1631, 9, 339, 347, 664, 9888, 8, 277, 304, 267, 298, 3407, 282, 7684, 10999, 1059, 367, 675, 315, 20175, 15, 6564, 11092, 2122, 267, 327, 15492, 911, 9658, 734, 3775, 370, 675, 662, 8124, 1493, 7, 503, 1557, 1493, 7, 267, 372, 620, 360, 840, 63, 13427, 2532, 37, 28328, 4042, 83, 3171, 450, 291, 423, 10394, 14, 362, 9888, 1252, 2708, 1012, 339, 347, 9275, 63, 4659, 63, 2117, 8, 277, 12, 9563, 304, 267, 372, 291, 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 ]
[ 199, 961, 909, 6571, 18593, 367, 11920, 24883, 1901, 20175, 15, 6564, 11092, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 15492, 18, 492, 14161, 199, 504, 15492, 18, 14, 5359, 492, 2281, 2940, 12838, 199, 199, 533, 20929, 10200, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 9671, 304, 267, 298, 23489, 641, 314, 3400, 2122, 267, 327, 20703, 314, 644, 12780, 334, 262, 1059, 1824, 12, 370, 2040, 8837, 24394, 402, 267, 327, 314, 19520, 269, 9, 436, 314, 22425, 687, 314, 3400, 14, 267, 291, 14, 546, 7862, 275, 2783, 8, 6481, 14, 546, 7862, 9, 267, 291, 14, 10498, 275, 9671, 14, 10498, 267, 291, 423, 10394, 275, 14161, 8, 277, 14, 546, 7862, 9, 339, 347, 636, 388, 964, 721, 277, 12, 4104, 304, 267, 327, 12078, 314, 1627, 4113, 26449, 370, 4052, 510, 1786, 11476, 18, 14292, 31, 267, 340, 4104, 508, 2281, 2940, 12838, 26, 288, 372, 291, 267, 587, 26, 288, 746, 2186, 360, 547, 18234, 15492, 18, 4113, 14, 6596, 15492, 18, 4903, 18478, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 20929, 10200, 304, 288, 372, 756, 267, 372, 334, 277, 14, 546, 7862, 508, 1163, 14, 546, 7862, 9, 436, 334, 277, 14, 10498, 508, 1163, 14, 10498, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 362, 9888, 342, 339, 347, 9275, 8, 277, 12, 2557, 304, 267, 408, 267, 961, 1083, 6127, 21375, 314, 3366, 315, 314, 3449, 1415, 701, 314, 267, 1654, 1159, 658, 6807, 63, 388, 964, 316, 63, 875, 64, 4260, 14, 267, 408, 267, 291, 423, 10394, 14, 6726, 8, 1631, 9, 339, 347, 664, 9888, 8, 277, 304, 267, 298, 3407, 282, 7684, 10999, 1059, 367, 675, 315, 20175, 15, 6564, 11092, 2122, 267, 327, 15492, 911, 9658, 734, 3775, 370, 675, 662, 8124, 1493, 7, 503, 1557, 1493, 7, 267, 372, 620, 360, 840, 63, 13427, 2532, 37, 28328, 4042, 83, 3171, 450, 291, 423, 10394, 14, 362, 9888, 1252, 2708, 1012, 339, 347, 9275, 63, 4659, 63, 2117, 8, 277, 12, 9563, 304, 267, 372, 291, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AnishShah/tensorflow
tensorflow/python/lib/io/file_io_test.py
20
22901
# This Python file uses the following encoding: utf-8 # Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================= """Testing File IO operations in file_io.py.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os.path from tensorflow.python.framework import errors from tensorflow.python.lib.io import file_io from tensorflow.python.platform import test class FileIoTest(test.TestCase): def setUp(self): self._base_dir = os.path.join(self.get_temp_dir(), "base_dir") file_io.create_dir(self._base_dir) def tearDown(self): file_io.delete_recursively(self._base_dir) def testEmptyFilename(self): f = file_io.FileIO("", mode="r") with self.assertRaises(errors.NotFoundError): _ = f.read() def testFileDoesntExist(self): file_path = os.path.join(self._base_dir, "temp_file") self.assertFalse(file_io.file_exists(file_path)) with self.assertRaises(errors.NotFoundError): _ = file_io.read_file_to_string(file_path) def testWriteToString(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.write_string_to_file(file_path, "testing") self.assertTrue(file_io.file_exists(file_path)) file_contents = file_io.read_file_to_string(file_path) self.assertEqual("testing", file_contents) def testAtomicWriteStringToFile(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.atomic_write_string_to_file(file_path, "testing") self.assertTrue(file_io.file_exists(file_path)) file_contents = file_io.read_file_to_string(file_path) self.assertEqual("testing", file_contents) def testAtomicWriteStringToFileOverwriteFalse(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.atomic_write_string_to_file(file_path, "old", overwrite=False) with self.assertRaises(errors.AlreadyExistsError): file_io.atomic_write_string_to_file(file_path, "new", overwrite=False) file_contents = file_io.read_file_to_string(file_path) self.assertEqual("old", file_contents) file_io.delete_file(file_path) file_io.atomic_write_string_to_file(file_path, "new", overwrite=False) file_contents = file_io.read_file_to_string(file_path) self.assertEqual("new", file_contents) def testReadBinaryMode(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.write_string_to_file(file_path, "testing") with file_io.FileIO(file_path, mode="rb") as f: self.assertEqual(b"testing", f.read()) def testWriteBinaryMode(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, "wb").write("testing") with file_io.FileIO(file_path, mode="r") as f: self.assertEqual("testing", f.read()) def testAppend(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="w") as f: f.write("begin\n") with file_io.FileIO(file_path, mode="a") as f: f.write("a1\n") with file_io.FileIO(file_path, mode="a") as f: f.write("a2\n") with file_io.FileIO(file_path, mode="r") as f: file_contents = f.read() self.assertEqual("begin\na1\na2\n", file_contents) def testMultipleFiles(self): file_prefix = os.path.join(self._base_dir, "temp_file") for i in range(5000): f = file_io.FileIO(file_prefix + str(i), mode="w+") f.write("testing") f.flush() self.assertEqual("testing", f.read()) f.close() def testMultipleWrites(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="w") as f: f.write("line1\n") f.write("line2") file_contents = file_io.read_file_to_string(file_path) self.assertEqual("line1\nline2", file_contents) def testFileWriteBadMode(self): file_path = os.path.join(self._base_dir, "temp_file") with self.assertRaises(errors.PermissionDeniedError): file_io.FileIO(file_path, mode="r").write("testing") def testFileReadBadMode(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") self.assertTrue(file_io.file_exists(file_path)) with self.assertRaises(errors.PermissionDeniedError): file_io.FileIO(file_path, mode="w").read() def testFileDelete(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") file_io.delete_file(file_path) self.assertFalse(file_io.file_exists(file_path)) def testFileDeleteFail(self): file_path = os.path.join(self._base_dir, "temp_file") with self.assertRaises(errors.NotFoundError): file_io.delete_file(file_path) def testGetMatchingFiles(self): dir_path = os.path.join(self._base_dir, "temp_dir") file_io.create_dir(dir_path) files = ["file1.txt", "file2.txt", "file3.txt"] for name in files: file_path = os.path.join(dir_path, name) file_io.FileIO(file_path, mode="w").write("testing") expected_match = [os.path.join(dir_path, name) for name in files] self.assertItemsEqual( file_io.get_matching_files(os.path.join(dir_path, "file*.txt")), expected_match) self.assertItemsEqual(file_io.get_matching_files(tuple()), []) files_subset = [ os.path.join(dir_path, files[0]), os.path.join(dir_path, files[2]) ] self.assertItemsEqual( file_io.get_matching_files(files_subset), files_subset) file_io.delete_recursively(dir_path) self.assertFalse(file_io.file_exists(os.path.join(dir_path, "file3.txt"))) def testCreateRecursiveDir(self): dir_path = os.path.join(self._base_dir, "temp_dir/temp_dir1/temp_dir2") file_io.recursive_create_dir(dir_path) file_io.recursive_create_dir(dir_path) # repeat creation file_path = os.path.join(dir_path, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") self.assertTrue(file_io.file_exists(file_path)) file_io.delete_recursively(os.path.join(self._base_dir, "temp_dir")) self.assertFalse(file_io.file_exists(file_path)) def testCopy(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") copy_path = os.path.join(self._base_dir, "copy_file") file_io.copy(file_path, copy_path) self.assertTrue(file_io.file_exists(copy_path)) f = file_io.FileIO(file_path, mode="r") self.assertEqual("testing", f.read()) self.assertEqual(7, f.tell()) def testCopyOverwrite(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") copy_path = os.path.join(self._base_dir, "copy_file") file_io.FileIO(copy_path, mode="w").write("copy") file_io.copy(file_path, copy_path, overwrite=True) self.assertTrue(file_io.file_exists(copy_path)) self.assertEqual("testing", file_io.FileIO(file_path, mode="r").read()) def testCopyOverwriteFalse(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") copy_path = os.path.join(self._base_dir, "copy_file") file_io.FileIO(copy_path, mode="w").write("copy") with self.assertRaises(errors.AlreadyExistsError): file_io.copy(file_path, copy_path, overwrite=False) def testRename(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") rename_path = os.path.join(self._base_dir, "rename_file") file_io.rename(file_path, rename_path) self.assertTrue(file_io.file_exists(rename_path)) self.assertFalse(file_io.file_exists(file_path)) def testRenameOverwrite(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") rename_path = os.path.join(self._base_dir, "rename_file") file_io.FileIO(rename_path, mode="w").write("rename") file_io.rename(file_path, rename_path, overwrite=True) self.assertTrue(file_io.file_exists(rename_path)) self.assertFalse(file_io.file_exists(file_path)) def testRenameOverwriteFalse(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") rename_path = os.path.join(self._base_dir, "rename_file") file_io.FileIO(rename_path, mode="w").write("rename") with self.assertRaises(errors.AlreadyExistsError): file_io.rename(file_path, rename_path, overwrite=False) self.assertTrue(file_io.file_exists(rename_path)) self.assertTrue(file_io.file_exists(file_path)) def testDeleteRecursivelyFail(self): fake_dir_path = os.path.join(self._base_dir, "temp_dir") with self.assertRaises(errors.NotFoundError): file_io.delete_recursively(fake_dir_path) def testIsDirectory(self): dir_path = os.path.join(self._base_dir, "test_dir") # Failure for a non-existing dir. self.assertFalse(file_io.is_directory(dir_path)) file_io.create_dir(dir_path) self.assertTrue(file_io.is_directory(dir_path)) file_path = os.path.join(dir_path, "test_file") file_io.FileIO(file_path, mode="w").write("test") # False for a file. self.assertFalse(file_io.is_directory(file_path)) # Test that the value returned from `stat()` has `is_directory` set. file_statistics = file_io.stat(dir_path) self.assertTrue(file_statistics.is_directory) def testListDirectory(self): dir_path = os.path.join(self._base_dir, "test_dir") file_io.create_dir(dir_path) files = ["file1.txt", "file2.txt", "file3.txt"] for name in files: file_path = os.path.join(dir_path, name) file_io.FileIO(file_path, mode="w").write("testing") subdir_path = os.path.join(dir_path, "sub_dir") file_io.create_dir(subdir_path) subdir_file_path = os.path.join(subdir_path, "file4.txt") file_io.FileIO(subdir_file_path, mode="w").write("testing") dir_list = file_io.list_directory(dir_path) self.assertItemsEqual(files + ["sub_dir"], dir_list) def testListDirectoryFailure(self): dir_path = os.path.join(self._base_dir, "test_dir") with self.assertRaises(errors.NotFoundError): file_io.list_directory(dir_path) def _setupWalkDirectories(self, dir_path): # Creating a file structure as follows # test_dir -> file: file1.txt; dirs: subdir1_1, subdir1_2, subdir1_3 # subdir1_1 -> file: file3.txt # subdir1_2 -> dir: subdir2 file_io.create_dir(dir_path) file_io.FileIO( os.path.join(dir_path, "file1.txt"), mode="w").write("testing") sub_dirs1 = ["subdir1_1", "subdir1_2", "subdir1_3"] for name in sub_dirs1: file_io.create_dir(os.path.join(dir_path, name)) file_io.FileIO( os.path.join(dir_path, "subdir1_1/file2.txt"), mode="w").write("testing") file_io.create_dir(os.path.join(dir_path, "subdir1_2/subdir2")) def testWalkInOrder(self): dir_path = os.path.join(self._base_dir, "test_dir") self._setupWalkDirectories(dir_path) # Now test the walk (in_order = True) all_dirs = [] all_subdirs = [] all_files = [] for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=True): all_dirs.append(w_dir) all_subdirs.append(w_subdirs) all_files.append(w_files) self.assertItemsEqual(all_dirs, [dir_path] + [ os.path.join(dir_path, item) for item in ["subdir1_1", "subdir1_2", "subdir1_2/subdir2", "subdir1_3"] ]) self.assertEqual(dir_path, all_dirs[0]) self.assertLess( all_dirs.index(os.path.join(dir_path, "subdir1_2")), all_dirs.index(os.path.join(dir_path, "subdir1_2/subdir2"))) self.assertItemsEqual(all_subdirs[1:5], [[], ["subdir2"], [], []]) self.assertItemsEqual(all_subdirs[0], ["subdir1_1", "subdir1_2", "subdir1_3"]) self.assertItemsEqual(all_files, [["file1.txt"], ["file2.txt"], [], [], []]) self.assertLess( all_files.index(["file1.txt"]), all_files.index(["file2.txt"])) def testWalkPostOrder(self): dir_path = os.path.join(self._base_dir, "test_dir") self._setupWalkDirectories(dir_path) # Now test the walk (in_order = False) all_dirs = [] all_subdirs = [] all_files = [] for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=False): all_dirs.append(w_dir) all_subdirs.append(w_subdirs) all_files.append(w_files) self.assertItemsEqual(all_dirs, [ os.path.join(dir_path, item) for item in ["subdir1_1", "subdir1_2/subdir2", "subdir1_2", "subdir1_3"] ] + [dir_path]) self.assertEqual(dir_path, all_dirs[4]) self.assertLess( all_dirs.index(os.path.join(dir_path, "subdir1_2/subdir2")), all_dirs.index(os.path.join(dir_path, "subdir1_2"))) self.assertItemsEqual(all_subdirs[0:4], [[], [], ["subdir2"], []]) self.assertItemsEqual(all_subdirs[4], ["subdir1_1", "subdir1_2", "subdir1_3"]) self.assertItemsEqual(all_files, [["file2.txt"], [], [], [], ["file1.txt"]]) self.assertLess( all_files.index(["file2.txt"]), all_files.index(["file1.txt"])) def testWalkFailure(self): dir_path = os.path.join(self._base_dir, "test_dir") # Try walking a directory that wasn't created. all_dirs = [] all_subdirs = [] all_files = [] for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=False): all_dirs.append(w_dir) all_subdirs.append(w_subdirs) all_files.append(w_files) self.assertItemsEqual(all_dirs, []) self.assertItemsEqual(all_subdirs, []) self.assertItemsEqual(all_files, []) def testStat(self): file_path = os.path.join(self._base_dir, "temp_file") file_io.FileIO(file_path, mode="w").write("testing") file_statistics = file_io.stat(file_path) os_statistics = os.stat(file_path) self.assertEqual(7, file_statistics.length) self.assertEqual( int(os_statistics.st_mtime), int(file_statistics.mtime_nsec / 1e9)) self.assertFalse(file_statistics.is_directory) def testReadLine(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="r+") as f: f.write("testing1\ntesting2\ntesting3\n\ntesting5") self.assertEqual(36, f.size()) self.assertEqual("testing1\n", f.readline()) self.assertEqual("testing2\n", f.readline()) self.assertEqual("testing3\n", f.readline()) self.assertEqual("\n", f.readline()) self.assertEqual("testing5", f.readline()) self.assertEqual("", f.readline()) def testRead(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="r+") as f: f.write("testing1\ntesting2\ntesting3\n\ntesting5") self.assertEqual(36, f.size()) self.assertEqual("testing1\n", f.read(9)) self.assertEqual("testing2\n", f.read(9)) self.assertEqual("t", f.read(1)) self.assertEqual("esting3\n\ntesting5", f.read()) def testTell(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="r+") as f: f.write("testing1\ntesting2\ntesting3\n\ntesting5") self.assertEqual(0, f.tell()) self.assertEqual("testing1\n", f.readline()) self.assertEqual(9, f.tell()) self.assertEqual("testing2\n", f.readline()) self.assertEqual(18, f.tell()) self.assertEqual("testing3\n", f.readline()) self.assertEqual(27, f.tell()) self.assertEqual("\n", f.readline()) self.assertEqual(28, f.tell()) self.assertEqual("testing5", f.readline()) self.assertEqual(36, f.tell()) self.assertEqual("", f.readline()) self.assertEqual(36, f.tell()) def testSeek(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="r+") as f: f.write("testing1\ntesting2\ntesting3\n\ntesting5") self.assertEqual("testing1\n", f.readline()) self.assertEqual(9, f.tell()) # Seek to 18 f.seek(18) self.assertEqual(18, f.tell()) self.assertEqual("testing3\n", f.readline()) # Seek back to 9 f.seek(9) self.assertEqual(9, f.tell()) self.assertEqual("testing2\n", f.readline()) f.seek(0) self.assertEqual(0, f.tell()) self.assertEqual("testing1\n", f.readline()) with self.assertRaises(errors.InvalidArgumentError): f.seek(-1) with self.assertRaises(TypeError): f.seek() # TODO(jhseu): Delete after position deprecation. with self.assertRaises(TypeError): f.seek(offset=0, position=0) f.seek(position=9) self.assertEqual(9, f.tell()) self.assertEqual("testing2\n", f.readline()) def testSeekFromWhat(self): file_path = os.path.join(self._base_dir, "temp_file") with file_io.FileIO(file_path, mode="r+") as f: f.write("testing1\ntesting2\ntesting3\n\ntesting5") self.assertEqual("testing1\n", f.readline()) self.assertEqual(9, f.tell()) # Seek to 18 f.seek(9, 1) self.assertEqual(18, f.tell()) self.assertEqual("testing3\n", f.readline()) # Seek back to 9 f.seek(9, 0) self.assertEqual(9, f.tell()) self.assertEqual("testing2\n", f.readline()) f.seek(-f.size(), 2) self.assertEqual(0, f.tell()) self.assertEqual("testing1\n", f.readline()) with self.assertRaises(errors.InvalidArgumentError): f.seek(0, 3) def testReadingIterator(self): file_path = os.path.join(self._base_dir, "temp_file") data = ["testing1\n", "testing2\n", "testing3\n", "\n", "testing5"] with file_io.FileIO(file_path, mode="r+") as f: f.write("".join(data)) actual_data = [] for line in f: actual_data.append(line) self.assertSequenceEqual(actual_data, data) def testReadlines(self): file_path = os.path.join(self._base_dir, "temp_file") data = ["testing1\n", "testing2\n", "testing3\n", "\n", "testing5"] f = file_io.FileIO(file_path, mode="r+") f.write("".join(data)) f.flush() lines = f.readlines() self.assertSequenceEqual(lines, data) def testUTF8StringPath(self): file_path = os.path.join(self._base_dir, "UTF8测试_file") file_io.write_string_to_file(file_path, "testing") with file_io.FileIO(file_path, mode="rb") as f: self.assertEqual(b"testing", f.read()) def testEof(self): """Test that reading past EOF does not raise an exception.""" file_path = os.path.join(self._base_dir, "temp_file") f = file_io.FileIO(file_path, mode="r+") content = "testing" f.write(content) f.flush() self.assertEqual(content, f.read(len(content) + 1)) def testUTF8StringPathExists(self): file_path = os.path.join(self._base_dir, "UTF8测试_file_exist") file_io.write_string_to_file(file_path, "testing") v = file_io.file_exists(file_path) self.assertEqual(v, True) def testFilecmp(self): file1 = os.path.join(self._base_dir, "file1") file_io.write_string_to_file(file1, "This is a sentence\n" * 100) file2 = os.path.join(self._base_dir, "file2") file_io.write_string_to_file(file2, "This is another sentence\n" * 100) file3 = os.path.join(self._base_dir, "file3") file_io.write_string_to_file(file3, u"This is another sentence\n" * 100) self.assertFalse(file_io.filecmp(file1, file2)) self.assertTrue(file_io.filecmp(file2, file3)) def testFilecmpSameSize(self): file1 = os.path.join(self._base_dir, "file1") file_io.write_string_to_file(file1, "This is a sentence\n" * 100) file2 = os.path.join(self._base_dir, "file2") file_io.write_string_to_file(file2, "This is b sentence\n" * 100) file3 = os.path.join(self._base_dir, "file3") file_io.write_string_to_file(file3, u"This is b sentence\n" * 100) self.assertFalse(file_io.filecmp(file1, file2)) self.assertTrue(file_io.filecmp(file2, file3)) def testFilecmpBinary(self): file1 = os.path.join(self._base_dir, "file1") file_io.FileIO(file1, "wb").write("testing\n\na") file2 = os.path.join(self._base_dir, "file2") file_io.FileIO(file2, "wb").write("testing\n\nb") file3 = os.path.join(self._base_dir, "file3") file_io.FileIO(file3, "wb").write("testing\n\nb") file4 = os.path.join(self._base_dir, "file4") file_io.FileIO(file4, "wb").write("testing\n\ntesting") self.assertFalse(file_io.filecmp(file1, file2)) self.assertFalse(file_io.filecmp(file1, file4)) self.assertTrue(file_io.filecmp(file2, file3)) def testFileCrc32(self): file1 = os.path.join(self._base_dir, "file1") file_io.write_string_to_file(file1, "This is a sentence\n" * 100) crc1 = file_io.file_crc32(file1) file2 = os.path.join(self._base_dir, "file2") file_io.write_string_to_file(file2, "This is another sentence\n" * 100) crc2 = file_io.file_crc32(file2) file3 = os.path.join(self._base_dir, "file3") file_io.write_string_to_file(file3, "This is another sentence\n" * 100) crc3 = file_io.file_crc32(file3) self.assertTrue(crc1 != crc2) self.assertEqual(crc2, crc3) def testFileCrc32WithBytes(self): file1 = os.path.join(self._base_dir, "file1") file_io.write_string_to_file(file1, "This is a sentence\n" * 100) crc1 = file_io.file_crc32(file1, block_size=24) file2 = os.path.join(self._base_dir, "file2") file_io.write_string_to_file(file2, "This is another sentence\n" * 100) crc2 = file_io.file_crc32(file2, block_size=24) file3 = os.path.join(self._base_dir, "file3") file_io.write_string_to_file(file3, "This is another sentence\n" * 100) crc3 = file_io.file_crc32(file3, block_size=-1) self.assertTrue(crc1 != crc2) self.assertEqual(crc2, crc3) def testFileCrc32Binary(self): file1 = os.path.join(self._base_dir, "file1") file_io.FileIO(file1, "wb").write("testing\n\n") crc1 = file_io.file_crc32(file1) file2 = os.path.join(self._base_dir, "file2") file_io.FileIO(file2, "wb").write("testing\n\n\n") crc2 = file_io.file_crc32(file2) file3 = os.path.join(self._base_dir, "file3") file_io.FileIO(file3, "wb").write("testing\n\n\n") crc3 = file_io.file_crc32(file3) self.assertTrue(crc1 != crc2) self.assertEqual(crc2, crc3) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 961, 2018, 570, 4440, 314, 2569, 2644, 26, 2774, 13, 24, 199, 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 26237, 199, 624, 9029, 3814, 5004, 5331, 315, 570, 63, 2308, 14, 647, 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, 747, 14, 515, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 199, 504, 3228, 14, 1548, 14, 773, 14, 2308, 492, 570, 63, 2308, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 3814, 16512, 774, 8, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 1095, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 362, 63, 808, 63, 694, 1062, 298, 1095, 63, 694, 531, 272, 570, 63, 2308, 14, 981, 63, 694, 8, 277, 423, 1095, 63, 694, 9, 819, 347, 6766, 8, 277, 304, 272, 570, 63, 2308, 14, 1807, 63, 6794, 9840, 8, 277, 423, 1095, 63, 694, 9, 819, 347, 511, 4699, 8117, 8, 277, 304, 272, 289, 275, 570, 63, 2308, 14, 26126, 12398, 818, 628, 82, 531, 272, 543, 291, 14, 1855, 8, 2550, 14, 10870, 304, 489, 485, 275, 289, 14, 739, 342, 819, 347, 511, 1173, 6586, 343, 6439, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 291, 14, 3334, 8, 493, 63, 2308, 14, 493, 63, 2444, 8, 493, 63, 515, 430, 272, 543, 291, 14, 1855, 8, 2550, 14, 10870, 304, 489, 485, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 819, 347, 511, 3534, 7756, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 4776, 531, 272, 291, 14, 1815, 8, 493, 63, 2308, 14, 493, 63, 2444, 8, 493, 63, 515, 430, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 4776, 401, 570, 63, 4407, 9, 819, 347, 511, 31931, 3534, 1558, 24320, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 4776, 531, 272, 291, 14, 1815, 8, 493, 63, 2308, 14, 493, 63, 2444, 8, 493, 63, 515, 430, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 4776, 401, 570, 63, 4407, 9, 819, 347, 511, 31931, 3534, 1558, 24320, 5674, 952, 797, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 1753, 401, 8970, 29, 797, 9, 272, 543, 291, 14, 1855, 8, 2550, 14, 16760, 23839, 304, 489, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 1222, 401, 8970, 29, 797, 9, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 1753, 401, 570, 63, 4407, 9, 272, 570, 63, 2308, 14, 1807, 63, 493, 8, 493, 63, 515, 9, 272, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 1222, 401, 8970, 29, 797, 9, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 1222, 401, 570, 63, 4407, 9, 819, 347, 511, 3284, 6636, 1385, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 4776, 531, 272, 543, 570, 63, 2308, 14, 26126, 8, 493, 63, 515, 12, 818, 628, 4848, 531, 465, 289, 26, 489, 291, 14, 629, 8, 66, 2, 4776, 401, 289, 14, 739, 1012, 819, 347, 511, 3534, 6636, 1385, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 26126, 8, 493, 63, 515, 12, 298, 6603, 3471, 952, 480, 4776, 531, 272, 543, 570, 63, 2308, 14, 26126, 8, 493, 63, 515, 12, 818, 628, 82, 531, 465, 289, 26, 489, 291, 14, 629, 480, 4776, 401, 289, 14, 739, 1012, 819, 347, 511, 8310, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493 ]
[ 961, 2018, 570, 4440, 314, 2569, 2644, 26, 2774, 13, 24, 199, 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 26237, 199, 624, 9029, 3814, 5004, 5331, 315, 570, 63, 2308, 14, 647, 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, 747, 14, 515, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 199, 504, 3228, 14, 1548, 14, 773, 14, 2308, 492, 570, 63, 2308, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 3814, 16512, 774, 8, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 1095, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 362, 63, 808, 63, 694, 1062, 298, 1095, 63, 694, 531, 272, 570, 63, 2308, 14, 981, 63, 694, 8, 277, 423, 1095, 63, 694, 9, 819, 347, 6766, 8, 277, 304, 272, 570, 63, 2308, 14, 1807, 63, 6794, 9840, 8, 277, 423, 1095, 63, 694, 9, 819, 347, 511, 4699, 8117, 8, 277, 304, 272, 289, 275, 570, 63, 2308, 14, 26126, 12398, 818, 628, 82, 531, 272, 543, 291, 14, 1855, 8, 2550, 14, 10870, 304, 489, 485, 275, 289, 14, 739, 342, 819, 347, 511, 1173, 6586, 343, 6439, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 291, 14, 3334, 8, 493, 63, 2308, 14, 493, 63, 2444, 8, 493, 63, 515, 430, 272, 543, 291, 14, 1855, 8, 2550, 14, 10870, 304, 489, 485, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 819, 347, 511, 3534, 7756, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 4776, 531, 272, 291, 14, 1815, 8, 493, 63, 2308, 14, 493, 63, 2444, 8, 493, 63, 515, 430, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 4776, 401, 570, 63, 4407, 9, 819, 347, 511, 31931, 3534, 1558, 24320, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 4776, 531, 272, 291, 14, 1815, 8, 493, 63, 2308, 14, 493, 63, 2444, 8, 493, 63, 515, 430, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 4776, 401, 570, 63, 4407, 9, 819, 347, 511, 31931, 3534, 1558, 24320, 5674, 952, 797, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 1753, 401, 8970, 29, 797, 9, 272, 543, 291, 14, 1855, 8, 2550, 14, 16760, 23839, 304, 489, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 1222, 401, 8970, 29, 797, 9, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 1753, 401, 570, 63, 4407, 9, 272, 570, 63, 2308, 14, 1807, 63, 493, 8, 493, 63, 515, 9, 272, 570, 63, 2308, 14, 10910, 63, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 1222, 401, 8970, 29, 797, 9, 272, 570, 63, 4407, 275, 570, 63, 2308, 14, 739, 63, 493, 63, 475, 63, 875, 8, 493, 63, 515, 9, 272, 291, 14, 629, 480, 1222, 401, 570, 63, 4407, 9, 819, 347, 511, 3284, 6636, 1385, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 952, 63, 875, 63, 475, 63, 493, 8, 493, 63, 515, 12, 298, 4776, 531, 272, 543, 570, 63, 2308, 14, 26126, 8, 493, 63, 515, 12, 818, 628, 4848, 531, 465, 289, 26, 489, 291, 14, 629, 8, 66, 2, 4776, 401, 289, 14, 739, 1012, 819, 347, 511, 3534, 6636, 1385, 8, 277, 304, 272, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 423, 1095, 63, 694, 12, 298, 808, 63, 493, 531, 272, 570, 63, 2308, 14, 26126, 8, 493, 63, 515, 12, 298, 6603, 3471, 952, 480, 4776, 531, 272, 543, 570, 63, 2308, 14, 26126, 8, 493, 63, 515, 12, 818, 628, 82, 531, 465, 289, 26, 489, 291, 14, 629, 480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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 ]
cysnake4713/odoo
addons/website_membership/models/product.py
338
1264
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv, fields class product_template(osv.Model): _inherit = 'product.template' _columns = { 'website_published': fields.boolean('Available in the website', copy=False), } _defaults = { 'website_published': False, }
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 6171, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 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, 9506, 12, 1504, 199, 199, 533, 3336, 63, 1160, 8, 4795, 14, 1685, 304, 272, 485, 6486, 275, 283, 2558, 14, 1160, 7, 339, 485, 3406, 275, 469, 267, 283, 7360, 63, 8987, 356, 1504, 14, 4871, 360, 11464, 315, 314, 10691, 297, 1331, 29, 797, 395, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 7360, 63, 8987, 356, 756, 12, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 6171, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 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, 9506, 12, 1504, 199, 199, 533, 3336, 63, 1160, 8, 4795, 14, 1685, 304, 272, 485, 6486, 275, 283, 2558, 14, 1160, 7, 339, 485, 3406, 275, 469, 267, 283, 7360, 63, 8987, 356, 1504, 14, 4871, 360, 11464, 315, 314, 10691, 297, 1331, 29, 797, 395, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 7360, 63, 8987, 356, 756, 12, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
thesgc/cbh_datastore_ws
runtests.py
1
1190
import sys try: from django.conf import settings from django.test.utils import get_runner settings.configure( DEBUG=True, USE_TZ=True, DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", } }, ROOT_URLCONF="cbh_datastore_ws.urls", INSTALLED_APPS=[ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sites", "cbh_datastore_ws", ], SITE_ID=1, MIDDLEWARE_CLASSES=(), ) try: import django setup = django.setup except AttributeError: pass else: setup() except ImportError: import traceback traceback.print_exc() raise ImportError( "To fix this error, run: pip install -r requirements-test.txt") def run_tests(*test_args): if not test_args: test_args = ['tests'] # Run tests TestRunner = get_runner(settings) test_runner = TestRunner() failures = test_runner.run_tests(test_args) if failures: sys.exit(bool(failures)) if __name__ == '__main__': run_tests(*sys.argv[1:])
mit
[ 646, 984, 199, 199, 893, 26, 272, 687, 1639, 14, 2190, 492, 2202, 272, 687, 1639, 14, 396, 14, 1208, 492, 664, 63, 5933, 339, 2202, 14, 6472, 8, 267, 10990, 29, 549, 12, 267, 4815, 63, 14226, 29, 549, 12, 267, 26931, 21983, 3126, 288, 298, 885, 582, 469, 355, 298, 15956, 582, 298, 1176, 14, 697, 14, 7765, 14, 10659, 19, 401, 288, 789, 267, 1660, 267, 16547, 63, 18125, 628, 2894, 72, 63, 11450, 63, 3569, 14, 3603, 401, 267, 31061, 63, 14219, 1524, 288, 298, 1176, 14, 2828, 14, 1178, 401, 288, 298, 1176, 14, 2828, 14, 10778, 401, 288, 298, 1176, 14, 2828, 14, 8619, 401, 288, 298, 2894, 72, 63, 11450, 63, 3569, 401, 267, 2156, 267, 428, 4427, 63, 998, 29, 17, 12, 267, 30718, 63, 13748, 16729, 272, 776, 339, 862, 26, 267, 492, 1639, 267, 3272, 275, 1639, 14, 2758, 272, 871, 4281, 26, 267, 986, 272, 587, 26, 267, 3272, 342, 199, 199, 2590, 3545, 26, 272, 492, 5190, 272, 5190, 14, 1361, 63, 2804, 342, 272, 746, 3545, 8, 267, 298, 1378, 5325, 642, 1125, 12, 1255, 26, 7305, 3907, 446, 82, 9760, 13, 396, 14, 2424, 531, 421, 199, 318, 1255, 63, 2219, 2031, 396, 63, 589, 304, 272, 340, 440, 511, 63, 589, 26, 267, 511, 63, 589, 275, 788, 2219, 418, 339, 327, 3378, 2295, 272, 1379, 7446, 275, 664, 63, 5933, 8, 1751, 9, 272, 511, 63, 5933, 275, 1379, 7446, 342, 339, 9081, 275, 511, 63, 5933, 14, 1065, 63, 2219, 8, 396, 63, 589, 9, 339, 340, 9081, 26, 267, 984, 14, 2224, 8, 2245, 8, 9968, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1255, 63, 2219, 2031, 1274, 14, 3020, 59, 17, 5728, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 199, 893, 26, 272, 687, 1639, 14, 2190, 492, 2202, 272, 687, 1639, 14, 396, 14, 1208, 492, 664, 63, 5933, 339, 2202, 14, 6472, 8, 267, 10990, 29, 549, 12, 267, 4815, 63, 14226, 29, 549, 12, 267, 26931, 21983, 3126, 288, 298, 885, 582, 469, 355, 298, 15956, 582, 298, 1176, 14, 697, 14, 7765, 14, 10659, 19, 401, 288, 789, 267, 1660, 267, 16547, 63, 18125, 628, 2894, 72, 63, 11450, 63, 3569, 14, 3603, 401, 267, 31061, 63, 14219, 1524, 288, 298, 1176, 14, 2828, 14, 1178, 401, 288, 298, 1176, 14, 2828, 14, 10778, 401, 288, 298, 1176, 14, 2828, 14, 8619, 401, 288, 298, 2894, 72, 63, 11450, 63, 3569, 401, 267, 2156, 267, 428, 4427, 63, 998, 29, 17, 12, 267, 30718, 63, 13748, 16729, 272, 776, 339, 862, 26, 267, 492, 1639, 267, 3272, 275, 1639, 14, 2758, 272, 871, 4281, 26, 267, 986, 272, 587, 26, 267, 3272, 342, 199, 199, 2590, 3545, 26, 272, 492, 5190, 272, 5190, 14, 1361, 63, 2804, 342, 272, 746, 3545, 8, 267, 298, 1378, 5325, 642, 1125, 12, 1255, 26, 7305, 3907, 446, 82, 9760, 13, 396, 14, 2424, 531, 421, 199, 318, 1255, 63, 2219, 2031, 396, 63, 589, 304, 272, 340, 440, 511, 63, 589, 26, 267, 511, 63, 589, 275, 788, 2219, 418, 339, 327, 3378, 2295, 272, 1379, 7446, 275, 664, 63, 5933, 8, 1751, 9, 272, 511, 63, 5933, 275, 1379, 7446, 342, 339, 9081, 275, 511, 63, 5933, 14, 1065, 63, 2219, 8, 396, 63, 589, 9, 339, 340, 9081, 26, 267, 984, 14, 2224, 8, 2245, 8, 9968, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1255, 63, 2219, 2031, 1274, 14, 3020, 59, 17, 5728, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
GbalsaC/bitnamiP
venv/lib/python2.7/site-packages/Crypto/SelfTest/Protocol/test_AllOrNothing.py
120
3024
# # Test script for Crypto.Protocol.AllOrNothing # # Part of the Python Cryptography Toolkit # # Written by Andrew Kuchling and others # # =================================================================== # The contents of this file are dedicated to the public domain. To # the extent that dedication to the public domain is not available, # everyone is granted a worldwide, perpetual, royalty-free, # non-exclusive license to exercise all rights associated with the # contents of this file for any purpose whatsoever. # No rights are reserved. # # 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. # =================================================================== __revision__ = "$Id$" import unittest from Crypto.Protocol import AllOrNothing from Crypto.Util.py3compat import * text = b("""\ When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation. We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed. That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. """) class AllOrNothingTest (unittest.TestCase): def runTest(self): "Simple test of AllOrNothing" from Crypto.Cipher import AES import base64 # The current AllOrNothing will fail # every so often. Repeat the test # several times to force this. for i in range(50): x = AllOrNothing.AllOrNothing(AES) msgblocks = x.digest(text) # get a new undigest-only object so there's no leakage y = AllOrNothing.AllOrNothing(AES) text2 = y.undigest(msgblocks) self.assertEqual(text, text2) def get_tests(config={}): return [AllOrNothingTest()] if __name__ == "__main__": unittest.main()
agpl-3.0
[ 3, 199, 3, 1379, 2884, 367, 18855, 14, 3658, 14, 2422, 2844, 19627, 199, 3, 199, 3, 14320, 402, 314, 2018, 18855, 9773, 15650, 6065, 199, 3, 199, 3, 27694, 701, 6061, 5257, 1804, 2133, 2983, 436, 11789, 199, 3, 199, 3, 7819, 389, 199, 3, 710, 4072, 402, 642, 570, 787, 29711, 370, 314, 4575, 2881, 14, 221, 4005, 199, 3, 314, 13675, 626, 477, 21171, 370, 314, 4575, 2881, 365, 440, 2808, 12, 199, 3, 4036, 368, 365, 10009, 282, 6701, 13062, 12, 1126, 321, 1688, 12, 882, 89, 13248, 13, 4624, 12, 199, 3, 2222, 13, 12730, 4190, 370, 26511, 1006, 4481, 4568, 543, 314, 199, 3, 4072, 402, 642, 570, 367, 1263, 12016, 4052, 1152, 5907, 14, 199, 3, 3091, 4481, 787, 4644, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 199, 3, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 7819, 389, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 646, 2882, 199, 504, 18855, 14, 3658, 492, 2900, 2844, 19627, 199, 504, 18855, 14, 9562, 14, 647, 19, 5819, 492, 627, 199, 199, 505, 275, 330, 21723, 199, 11423, 315, 314, 5531, 402, 11779, 4474, 12, 652, 15410, 5784, 367, 1373, 13135, 370, 199, 328, 385, 3344, 314, 1115, 317, 3294, 30565, 1314, 1172, 8539, 3062, 543, 4573, 12, 436, 370, 199, 21946, 16885, 314, 13131, 1192, 402, 314, 8413, 273, 12, 314, 7396, 436, 4472, 16518, 370, 1314, 199, 1589, 491, 7231, 402, 653, 1463, 436, 402, 653, 1463, 1159, 598, 364, 655, 1213, 3062, 12, 282, 477, 2946, 14021, 370, 314, 199, 411, 262, 15293, 402, 2169, 5091, 5074, 626, 2985, 1077, 20771, 314, 14486, 1314, 1742, 352, 199, 1589, 77, 370, 314, 4216, 425, 14, 199, 199, 6004, 10266, 3520, 16865, 83, 370, 506, 291, 13, 69, 433, 1326, 12, 626, 1006, 12953, 787, 2737, 4472, 12, 626, 199, 29002, 787, 1284, 583, 379, 701, 3932, 9750, 707, 543, 9842, 625, 10874, 4296, 5924, 12, 626, 16885, 199, 29032, 787, 491, 16839, 12, 24157, 605, 369, 12, 436, 314, 5861, 83, 4993, 402, 869, 571, 9585, 14, 10314, 370, 11153, 3520, 199, 17307, 12, 598, 1883, 78, 1470, 787, 2727, 390, 4241, 16885, 603, 287, 12, 5405, 4007, 3932, 2951, 13131, 1192, 687, 199, 1589, 406, 1150, 402, 314, 10413, 14, 10314, 18119, 1263, 8204, 402, 598, 27639, 15410, 199, 271, 9853, 857, 402, 3520, 11187, 12, 652, 365, 314, 20854, 402, 314, 11379, 7939, 370, 17355, 503, 370, 199, 13113, 1891, 652, 12, 436, 370, 2727, 390, 938, 892, 598, 27639, 12, 27305, 316, 2399, 1911, 425, 641, 4066, 199, 2700, 10352, 2978, 436, 20765, 9147, 2399, 13131, 1192, 315, 4066, 1824, 12, 465, 370, 3062, 10989, 17021, 4750, 199, 24227, 370, 7763, 3932, 14969, 369, 436, 869, 571, 9585, 14, 199, 6141, 199, 199, 533, 2900, 2844, 19627, 774, 334, 2796, 14, 1746, 304, 339, 347, 29779, 8, 277, 304, 267, 298, 3184, 511, 402, 2900, 2844, 19627, 2, 398, 687, 18855, 14, 21967, 492, 19093, 267, 492, 1300, 772, 398, 327, 710, 1453, 2900, 2844, 19627, 911, 2449, 267, 327, 4036, 880, 14115, 14, 21973, 292, 314, 511, 267, 327, 9978, 5431, 370, 3542, 642, 14, 267, 367, 284, 315, 1425, 8, 1400, 304, 288, 671, 275, 2900, 2844, 19627, 14, 2422, 2844, 19627, 8, 14494, 9, 953, 1499, 4166, 275, 671, 14, 5671, 8, 505, 9, 7846, 327, 664, 282, 892, 625, 5671, 13, 2118, 909, 880, 2337, 1159, 949, 25831, 474, 288, 612, 275, 2900, 2844, 19627, 14, 2422, 2844, 19627, 8, 14494, 9, 288, 1318, 18, 275, 612, 14, 324, 5671, 8, 1328, 4166, 9, 288, 291, 14, 629, 8, 505, 12, 1318, 18, 9, 199, 199, 318, 664, 63, 2219, 8, 888, 16420, 272, 372, 359, 2422, 2844, 19627, 774, 5106, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1379, 2884, 367, 18855, 14, 3658, 14, 2422, 2844, 19627, 199, 3, 199, 3, 14320, 402, 314, 2018, 18855, 9773, 15650, 6065, 199, 3, 199, 3, 27694, 701, 6061, 5257, 1804, 2133, 2983, 436, 11789, 199, 3, 199, 3, 7819, 389, 199, 3, 710, 4072, 402, 642, 570, 787, 29711, 370, 314, 4575, 2881, 14, 221, 4005, 199, 3, 314, 13675, 626, 477, 21171, 370, 314, 4575, 2881, 365, 440, 2808, 12, 199, 3, 4036, 368, 365, 10009, 282, 6701, 13062, 12, 1126, 321, 1688, 12, 882, 89, 13248, 13, 4624, 12, 199, 3, 2222, 13, 12730, 4190, 370, 26511, 1006, 4481, 4568, 543, 314, 199, 3, 4072, 402, 642, 570, 367, 1263, 12016, 4052, 1152, 5907, 14, 199, 3, 3091, 4481, 787, 4644, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 199, 3, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 7819, 389, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 646, 2882, 199, 504, 18855, 14, 3658, 492, 2900, 2844, 19627, 199, 504, 18855, 14, 9562, 14, 647, 19, 5819, 492, 627, 199, 199, 505, 275, 330, 21723, 199, 11423, 315, 314, 5531, 402, 11779, 4474, 12, 652, 15410, 5784, 367, 1373, 13135, 370, 199, 328, 385, 3344, 314, 1115, 317, 3294, 30565, 1314, 1172, 8539, 3062, 543, 4573, 12, 436, 370, 199, 21946, 16885, 314, 13131, 1192, 402, 314, 8413, 273, 12, 314, 7396, 436, 4472, 16518, 370, 1314, 199, 1589, 491, 7231, 402, 653, 1463, 436, 402, 653, 1463, 1159, 598, 364, 655, 1213, 3062, 12, 282, 477, 2946, 14021, 370, 314, 199, 411, 262, 15293, 402, 2169, 5091, 5074, 626, 2985, 1077, 20771, 314, 14486, 1314, 1742, 352, 199, 1589, 77, 370, 314, 4216, 425, 14, 199, 199, 6004, 10266, 3520, 16865, 83, 370, 506, 291, 13, 69, 433, 1326, 12, 626, 1006, 12953, 787, 2737, 4472, 12, 626, 199, 29002, 787, 1284, 583, 379, 701, 3932, 9750, 707, 543, 9842, 625, 10874, 4296, 5924, 12, 626, 16885, 199, 29032, 787, 491, 16839, 12, 24157, 605, 369, 12, 436, 314, 5861, 83, 4993, 402, 869, 571, 9585, 14, 10314, 370, 11153, 3520, 199, 17307, 12, 598, 1883, 78, 1470, 787, 2727, 390, 4241, 16885, 603, 287, 12, 5405, 4007, 3932, 2951, 13131, 1192, 687, 199, 1589, 406, 1150, 402, 314, 10413, 14, 10314, 18119, 1263, 8204, 402, 598, 27639, 15410, 199, 271, 9853, 857, 402, 3520, 11187, 12, 652, 365, 314, 20854, 402, 314, 11379, 7939, 370, 17355, 503, 370, 199, 13113, 1891, 652, 12, 436, 370, 2727, 390, 938, 892, 598, 27639, 12, 27305, 316, 2399, 1911, 425, 641, 4066, 199, 2700, 10352, 2978, 436, 20765, 9147, 2399, 13131, 1192, 315, 4066, 1824, 12, 465, 370, 3062, 10989, 17021, 4750, 199, 24227, 370, 7763, 3932, 14969, 369, 436, 869, 571, 9585, 14, 199, 6141, 199, 199, 533, 2900, 2844, 19627, 774, 334, 2796, 14, 1746, 304, 339, 347, 29779, 8, 277, 304, 267, 298, 3184, 511, 402, 2900, 2844, 19627, 2, 398, 687, 18855, 14, 21967, 492, 19093, 267, 492, 1300, 772, 398, 327, 710, 1453, 2900, 2844, 19627, 911, 2449, 267, 327, 4036, 880, 14115, 14, 21973, 292, 314, 511, 267, 327, 9978, 5431, 370, 3542, 642, 14, 267, 367, 284, 315, 1425, 8, 1400, 304, 288, 671, 275, 2900, 2844, 19627, 14, 2422, 2844, 19627, 8, 14494, 9, 953, 1499, 4166, 275, 671, 14, 5671, 8, 505, 9, 7846, 327, 664, 282, 892, 625, 5671, 13, 2118, 909, 880, 2337, 1159, 949, 25831, 474, 288, 612, 275, 2900, 2844, 19627, 14, 2422, 2844, 19627, 8, 14494, 9, 288, 1318, 18, 275, 612, 14, 324, 5671, 8, 1328, 4166, 9, 288, 291, 14, 629, 8, 505, 12, 1318, 18, 9, 199, 199, 318, 664, 63, 2219, 8, 888, 16420, 272, 372, 359, 2422, 2844, 19627, 774, 5106, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
t1m0thy/django-extensions
django_extensions/management/commands/unreferenced_files.py
26
1844
import os from collections import defaultdict from django.conf import settings from django.core.management.base import NoArgsCommand from django.db import models from django.db.models.loading import cache from django_extensions.management.utils import signalcommand class Command(NoArgsCommand): help = "Prints a list of all files in MEDIA_ROOT that are not referenced in the database." @signalcommand def handle_noargs(self, **options): if settings.MEDIA_ROOT == '': print("MEDIA_ROOT is not set, nothing to do") return # Get a list of all files under MEDIA_ROOT media = [] for root, dirs, files in os.walk(settings.MEDIA_ROOT): for f in files: media.append(os.path.abspath(os.path.join(root, f))) # Get list of all fields (value) for each model (key) # that is a FileField or subclass of a FileField model_dict = defaultdict(list) for app in cache.get_apps(): model_list = cache.get_models(app) for model in model_list: for field in model._meta.fields: if issubclass(field.__class__, models.FileField): model_dict[model].append(field) # Get a list of all files referenced in the database referenced = [] for model in model_dict: all = model.objects.all().iterator() for object in all: for field in model_dict[model]: target_file = getattr(object, field.name) if target_file: referenced.append(os.path.abspath(target_file.path)) # Print each file in MEDIA_ROOT that is not referenced in the database for m in media: if m not in referenced: print(m)
mit
[ 646, 747, 199, 504, 5055, 492, 10018, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 2581, 199, 199, 504, 1639, 63, 5359, 14, 8110, 14, 1208, 492, 4673, 1531, 421, 199, 533, 5817, 8, 27099, 3110, 304, 272, 1720, 275, 298, 26113, 282, 769, 402, 1006, 1584, 315, 31460, 63, 5441, 626, 787, 440, 11812, 315, 314, 3050, 2122, 339, 768, 4653, 1531, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 398, 340, 2202, 14, 13669, 63, 5441, 508, 8061, 288, 870, 480, 13669, 63, 5441, 365, 440, 663, 12, 6548, 370, 886, 531, 288, 372, 398, 327, 2372, 282, 769, 402, 1006, 1584, 1334, 31460, 63, 5441, 267, 5898, 275, 942, 267, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 1751, 14, 13669, 63, 5441, 304, 288, 367, 289, 315, 1584, 26, 355, 5898, 14, 740, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 289, 1724, 398, 327, 2372, 769, 402, 1006, 1504, 334, 585, 9, 367, 1924, 1402, 334, 498, 9, 267, 327, 626, 365, 282, 3814, 792, 503, 5516, 402, 282, 3814, 792, 267, 1402, 63, 807, 275, 10018, 8, 513, 9, 267, 367, 1145, 315, 2581, 14, 362, 63, 5181, 837, 288, 1402, 63, 513, 275, 2581, 14, 362, 63, 992, 8, 571, 9, 288, 367, 1402, 315, 1402, 63, 513, 26, 355, 367, 901, 315, 1402, 423, 2024, 14, 955, 26, 490, 340, 11602, 8, 698, 855, 533, 3108, 1709, 14, 23252, 304, 717, 1402, 63, 807, 59, 1238, 1055, 740, 8, 698, 9, 398, 327, 2372, 282, 769, 402, 1006, 1584, 11812, 315, 314, 3050, 267, 11812, 275, 942, 267, 367, 1402, 315, 1402, 63, 807, 26, 288, 1006, 275, 1402, 14, 1462, 14, 452, 1252, 5778, 342, 288, 367, 909, 315, 1006, 26, 355, 367, 901, 315, 1402, 63, 807, 59, 1238, 2189, 490, 1347, 63, 493, 275, 2519, 8, 785, 12, 901, 14, 354, 9, 490, 340, 1347, 63, 493, 26, 717, 11812, 14, 740, 8, 736, 14, 515, 14, 4832, 8, 1375, 63, 493, 14, 515, 430, 398, 327, 9101, 1924, 570, 315, 31460, 63, 5441, 626, 365, 440, 11812, 315, 314, 3050, 267, 367, 333, 315, 5898, 26, 288, 340, 333, 440, 315, 11812, 26, 355, 870, 8, 77, 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 ]
[ 747, 199, 504, 5055, 492, 10018, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 2581, 199, 199, 504, 1639, 63, 5359, 14, 8110, 14, 1208, 492, 4673, 1531, 421, 199, 533, 5817, 8, 27099, 3110, 304, 272, 1720, 275, 298, 26113, 282, 769, 402, 1006, 1584, 315, 31460, 63, 5441, 626, 787, 440, 11812, 315, 314, 3050, 2122, 339, 768, 4653, 1531, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 398, 340, 2202, 14, 13669, 63, 5441, 508, 8061, 288, 870, 480, 13669, 63, 5441, 365, 440, 663, 12, 6548, 370, 886, 531, 288, 372, 398, 327, 2372, 282, 769, 402, 1006, 1584, 1334, 31460, 63, 5441, 267, 5898, 275, 942, 267, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 1751, 14, 13669, 63, 5441, 304, 288, 367, 289, 315, 1584, 26, 355, 5898, 14, 740, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 289, 1724, 398, 327, 2372, 769, 402, 1006, 1504, 334, 585, 9, 367, 1924, 1402, 334, 498, 9, 267, 327, 626, 365, 282, 3814, 792, 503, 5516, 402, 282, 3814, 792, 267, 1402, 63, 807, 275, 10018, 8, 513, 9, 267, 367, 1145, 315, 2581, 14, 362, 63, 5181, 837, 288, 1402, 63, 513, 275, 2581, 14, 362, 63, 992, 8, 571, 9, 288, 367, 1402, 315, 1402, 63, 513, 26, 355, 367, 901, 315, 1402, 423, 2024, 14, 955, 26, 490, 340, 11602, 8, 698, 855, 533, 3108, 1709, 14, 23252, 304, 717, 1402, 63, 807, 59, 1238, 1055, 740, 8, 698, 9, 398, 327, 2372, 282, 769, 402, 1006, 1584, 11812, 315, 314, 3050, 267, 11812, 275, 942, 267, 367, 1402, 315, 1402, 63, 807, 26, 288, 1006, 275, 1402, 14, 1462, 14, 452, 1252, 5778, 342, 288, 367, 909, 315, 1006, 26, 355, 367, 901, 315, 1402, 63, 807, 59, 1238, 2189, 490, 1347, 63, 493, 275, 2519, 8, 785, 12, 901, 14, 354, 9, 490, 340, 1347, 63, 493, 26, 717, 11812, 14, 740, 8, 736, 14, 515, 14, 4832, 8, 1375, 63, 493, 14, 515, 430, 398, 327, 9101, 1924, 570, 315, 31460, 63, 5441, 626, 365, 440, 11812, 315, 314, 3050, 267, 367, 333, 315, 5898, 26, 288, 340, 333, 440, 315, 11812, 26, 355, 870, 8, 77, 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, 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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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 ]
ogferreiro/Arduino
arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/_collections.py
309
2903
# urllib3/_collections.py # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt) # # This module is part of urllib3 and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from collections import MutableMapping from threading import Lock try: # Python 2.7+ from collections import OrderedDict except ImportError: from .packages.ordered_dict import OrderedDict __all__ = ['RecentlyUsedContainer'] _Null = object() class RecentlyUsedContainer(MutableMapping): """ Provides a thread-safe dict-like container which maintains up to ``maxsize`` keys while throwing away the least-recently-used keys beyond ``maxsize``. :param maxsize: Maximum number of recent elements to retain. :param dispose_func: Every time an item is evicted from the container, ``dispose_func(value)`` is called. Callback which will get called """ ContainerCls = OrderedDict def __init__(self, maxsize=10, dispose_func=None): self._maxsize = maxsize self.dispose_func = dispose_func self._container = self.ContainerCls() self._lock = Lock() def __getitem__(self, key): # Re-insert the item, moving it to the end of the eviction line. with self._lock: item = self._container.pop(key) self._container[key] = item return item def __setitem__(self, key, value): evicted_value = _Null with self._lock: # Possibly evict the existing value of 'key' evicted_value = self._container.get(key, _Null) self._container[key] = value # If we didn't evict an existing value, we might have to evict the # least recently used item from the beginning of the container. if len(self._container) > self._maxsize: _key, evicted_value = self._container.popitem(last=False) if self.dispose_func and evicted_value is not _Null: self.dispose_func(evicted_value) def __delitem__(self, key): with self._lock: value = self._container.pop(key) if self.dispose_func: self.dispose_func(value) def __len__(self): with self._lock: return len(self._container) def __iter__(self): raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.') def clear(self): with self._lock: # Copy pointers to all values, then wipe the mapping # under Python 2, this copies the list of values twice :-| values = list(self._container.values()) self._container.clear() if self.dispose_func: for value in values: self.dispose_func(value) def keys(self): with self._lock: return self._container.keys()
lgpl-2.1
[ 3, 4011, 19, 15607, 7882, 14, 647, 199, 3, 1898, 9079, 13, 7409, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 5055, 492, 29396, 199, 504, 5796, 492, 15536, 199, 199, 893, 26, 327, 2018, 499, 14, 23, 11, 272, 687, 5055, 492, 8773, 199, 2590, 3545, 26, 272, 687, 1275, 5154, 14, 8235, 63, 807, 492, 8773, 421, 199, 363, 452, 363, 275, 788, 29574, 590, 9167, 4076, 418, 421, 199, 63, 8849, 275, 909, 342, 421, 199, 533, 799, 2946, 590, 9167, 4076, 8, 17707, 7674, 304, 272, 408, 272, 21552, 282, 2462, 13, 3489, 1211, 13, 2930, 3970, 1314, 11075, 83, 1536, 370, 272, 1124, 13634, 1040, 2883, 1830, 7978, 316, 13437, 314, 5210, 13, 14951, 590, 13, 2972, 2883, 20561, 272, 1124, 13634, 4345, 339, 520, 635, 19791, 26, 267, 14212, 1329, 402, 8058, 4008, 370, 8074, 14, 339, 520, 635, 2153, 4070, 63, 1532, 26, 267, 18414, 900, 376, 1242, 365, 24656, 1522, 687, 314, 3970, 12, 267, 1124, 29842, 63, 1532, 8, 585, 9719, 365, 2797, 14, 221, 17555, 1314, 911, 664, 2797, 272, 408, 339, 15395, 24342, 275, 8773, 339, 347, 636, 826, 721, 277, 12, 19791, 29, 709, 12, 2153, 4070, 63, 1532, 29, 403, 304, 267, 291, 423, 13634, 275, 19791, 267, 291, 14, 29842, 63, 1532, 275, 2153, 4070, 63, 1532, 398, 291, 423, 3600, 275, 291, 14, 4076, 24342, 342, 267, 291, 423, 831, 275, 15536, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 799, 13, 3176, 314, 1242, 12, 12876, 652, 370, 314, 1284, 402, 314, 24656, 414, 1004, 14, 267, 543, 291, 423, 831, 26, 288, 1242, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 1242, 288, 372, 1242, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 24656, 1522, 63, 585, 275, 485, 8849, 267, 543, 291, 423, 831, 26, 288, 327, 25987, 9312, 24656, 319, 314, 3411, 574, 402, 283, 498, 7, 288, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 362, 8, 498, 12, 485, 8849, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 574, 953, 327, 982, 781, 9980, 1133, 24656, 319, 376, 3411, 574, 12, 781, 5594, 1172, 370, 24656, 319, 314, 288, 327, 5210, 23568, 1202, 1242, 687, 314, 9608, 402, 314, 3970, 14, 288, 340, 822, 8, 277, 423, 3600, 9, 690, 291, 423, 13634, 26, 355, 485, 498, 12, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 24882, 8, 2019, 29, 797, 9, 398, 340, 291, 14, 29842, 63, 1532, 436, 24656, 1522, 63, 585, 365, 440, 485, 8849, 26, 288, 291, 14, 29842, 63, 1532, 8, 69, 433, 1522, 63, 585, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 543, 291, 423, 831, 26, 288, 574, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 636, 552, 721, 277, 304, 267, 543, 291, 423, 831, 26, 288, 372, 822, 8, 277, 423, 3600, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 746, 4279, 360, 8666, 1806, 642, 1021, 365, 625, 24227, 370, 506, 2462, 3489, 2659, 339, 347, 5436, 8, 277, 304, 267, 543, 291, 423, 831, 26, 288, 327, 11247, 21116, 370, 1006, 1338, 12, 2066, 336, 3662, 314, 4412, 288, 327, 1334, 2018, 499, 12, 642, 6866, 314, 769, 402, 1338, 13373, 22901, 92, 288, 1338, 275, 769, 8, 277, 423, 3600, 14, 1459, 1012, 288, 291, 423, 3600, 14, 3584, 342, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 367, 574, 315, 1338, 26, 355, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 2883, 8, 277, 304, 267, 543, 291, 423, 831, 26, 288, 372, 291, 423, 3600, 14, 1612, 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 ]
[ 4011, 19, 15607, 7882, 14, 647, 199, 3, 1898, 9079, 13, 7409, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 5055, 492, 29396, 199, 504, 5796, 492, 15536, 199, 199, 893, 26, 327, 2018, 499, 14, 23, 11, 272, 687, 5055, 492, 8773, 199, 2590, 3545, 26, 272, 687, 1275, 5154, 14, 8235, 63, 807, 492, 8773, 421, 199, 363, 452, 363, 275, 788, 29574, 590, 9167, 4076, 418, 421, 199, 63, 8849, 275, 909, 342, 421, 199, 533, 799, 2946, 590, 9167, 4076, 8, 17707, 7674, 304, 272, 408, 272, 21552, 282, 2462, 13, 3489, 1211, 13, 2930, 3970, 1314, 11075, 83, 1536, 370, 272, 1124, 13634, 1040, 2883, 1830, 7978, 316, 13437, 314, 5210, 13, 14951, 590, 13, 2972, 2883, 20561, 272, 1124, 13634, 4345, 339, 520, 635, 19791, 26, 267, 14212, 1329, 402, 8058, 4008, 370, 8074, 14, 339, 520, 635, 2153, 4070, 63, 1532, 26, 267, 18414, 900, 376, 1242, 365, 24656, 1522, 687, 314, 3970, 12, 267, 1124, 29842, 63, 1532, 8, 585, 9719, 365, 2797, 14, 221, 17555, 1314, 911, 664, 2797, 272, 408, 339, 15395, 24342, 275, 8773, 339, 347, 636, 826, 721, 277, 12, 19791, 29, 709, 12, 2153, 4070, 63, 1532, 29, 403, 304, 267, 291, 423, 13634, 275, 19791, 267, 291, 14, 29842, 63, 1532, 275, 2153, 4070, 63, 1532, 398, 291, 423, 3600, 275, 291, 14, 4076, 24342, 342, 267, 291, 423, 831, 275, 15536, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 799, 13, 3176, 314, 1242, 12, 12876, 652, 370, 314, 1284, 402, 314, 24656, 414, 1004, 14, 267, 543, 291, 423, 831, 26, 288, 1242, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 1242, 288, 372, 1242, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 24656, 1522, 63, 585, 275, 485, 8849, 267, 543, 291, 423, 831, 26, 288, 327, 25987, 9312, 24656, 319, 314, 3411, 574, 402, 283, 498, 7, 288, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 362, 8, 498, 12, 485, 8849, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 574, 953, 327, 982, 781, 9980, 1133, 24656, 319, 376, 3411, 574, 12, 781, 5594, 1172, 370, 24656, 319, 314, 288, 327, 5210, 23568, 1202, 1242, 687, 314, 9608, 402, 314, 3970, 14, 288, 340, 822, 8, 277, 423, 3600, 9, 690, 291, 423, 13634, 26, 355, 485, 498, 12, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 24882, 8, 2019, 29, 797, 9, 398, 340, 291, 14, 29842, 63, 1532, 436, 24656, 1522, 63, 585, 365, 440, 485, 8849, 26, 288, 291, 14, 29842, 63, 1532, 8, 69, 433, 1522, 63, 585, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 543, 291, 423, 831, 26, 288, 574, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 636, 552, 721, 277, 304, 267, 543, 291, 423, 831, 26, 288, 372, 822, 8, 277, 423, 3600, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 746, 4279, 360, 8666, 1806, 642, 1021, 365, 625, 24227, 370, 506, 2462, 3489, 2659, 339, 347, 5436, 8, 277, 304, 267, 543, 291, 423, 831, 26, 288, 327, 11247, 21116, 370, 1006, 1338, 12, 2066, 336, 3662, 314, 4412, 288, 327, 1334, 2018, 499, 12, 642, 6866, 314, 769, 402, 1338, 13373, 22901, 92, 288, 1338, 275, 769, 8, 277, 423, 3600, 14, 1459, 1012, 288, 291, 423, 3600, 14, 3584, 342, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 367, 574, 315, 1338, 26, 355, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 2883, 8, 277, 304, 267, 543, 291, 423, 831, 26, 288, 372, 291, 423, 3600, 14, 1612, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jkshaver/virtualenv-1.8.2
env/lib/python2.7/site-packages/django/contrib/gis/geos/prototypes/__init__.py
314
1305
""" This module contains all of the GEOS ctypes function prototypes. Each prototype handles the interaction between the GEOS library and Python via ctypes. """ # Coordinate sequence routines. from django.contrib.gis.geos.prototypes.coordseq import (create_cs, get_cs, cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz, cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims) # Geometry routines. from django.contrib.gis.geos.prototypes.geom import (from_hex, from_wkb, from_wkt, create_point, create_linestring, create_linearring, create_polygon, create_collection, destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone, geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid, get_dims, get_num_coords, get_num_geoms, to_hex, to_wkb, to_wkt) # Miscellaneous routines. from django.contrib.gis.geos.prototypes.misc import * # Predicates from django.contrib.gis.geos.prototypes.predicates import (geos_hasz, geos_isempty, geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses, geos_disjoint, geos_equals, geos_equalsexact, geos_intersects, geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within) # Topology routines from django.contrib.gis.geos.prototypes.topology import *
mit
[ 624, 199, 961, 859, 3509, 1006, 402, 314, 11920, 5577, 805, 19393, 83, 14, 7048, 199, 19393, 10022, 314, 18752, 3382, 314, 11920, 3555, 436, 2018, 199, 4799, 5577, 14, 199, 624, 199, 199, 3, 25334, 323, 3414, 14975, 14, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 7988, 3610, 492, 334, 981, 63, 1259, 12, 664, 63, 1259, 12, 272, 7117, 63, 6311, 12, 7117, 63, 362, 4055, 323, 12, 7117, 63, 409, 4055, 323, 12, 7117, 63, 362, 88, 12, 7117, 63, 362, 89, 12, 7117, 63, 362, 90, 12, 272, 7117, 63, 409, 88, 12, 7117, 63, 261, 369, 12, 7117, 63, 409, 90, 12, 7117, 63, 20733, 12, 7117, 63, 362, 5380, 9, 199, 199, 3, 10579, 14975, 14, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 6481, 492, 334, 504, 63, 4097, 12, 687, 63, 18914, 12, 687, 63, 11412, 12, 272, 1218, 63, 1403, 12, 1218, 63, 604, 875, 12, 1218, 63, 604, 5250, 316, 12, 1218, 63, 16295, 12, 1218, 63, 3627, 12, 272, 11972, 63, 6481, 12, 664, 63, 832, 5985, 12, 664, 63, 442, 5985, 12, 664, 63, 7865, 780, 12, 664, 63, 6481, 78, 12, 9671, 63, 6311, 12, 272, 30259, 63, 7721, 12, 30259, 63, 466, 12, 30259, 63, 22749, 12, 30259, 63, 362, 63, 10498, 12, 30259, 63, 409, 63, 10498, 12, 272, 664, 63, 5380, 12, 664, 63, 1507, 63, 8032, 12, 664, 63, 1507, 63, 29580, 12, 272, 370, 63, 4097, 12, 370, 63, 18914, 12, 370, 63, 11412, 9, 199, 199, 3, 12481, 19549, 14975, 14, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 9923, 492, 627, 199, 199, 3, 5543, 16292, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 14463, 83, 492, 334, 12151, 63, 1989, 90, 12, 30259, 63, 572, 1171, 12, 272, 30259, 63, 374, 5985, 12, 30259, 63, 374, 4129, 12, 30259, 63, 374, 1078, 12, 30259, 63, 6134, 12, 30259, 63, 20363, 874, 12, 272, 30259, 63, 31880, 12, 30259, 63, 11332, 12, 30259, 63, 15788, 535, 1800, 319, 12, 30259, 63, 1058, 25353, 12, 272, 30259, 63, 1058, 25353, 12, 30259, 63, 20798, 12, 30259, 63, 17322, 3401, 12, 30259, 63, 12376, 397, 12, 30259, 63, 12541, 9, 199, 199, 3, 14132, 7085, 14975, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 10775, 492, 627, 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 ]
[ 199, 961, 859, 3509, 1006, 402, 314, 11920, 5577, 805, 19393, 83, 14, 7048, 199, 19393, 10022, 314, 18752, 3382, 314, 11920, 3555, 436, 2018, 199, 4799, 5577, 14, 199, 624, 199, 199, 3, 25334, 323, 3414, 14975, 14, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 7988, 3610, 492, 334, 981, 63, 1259, 12, 664, 63, 1259, 12, 272, 7117, 63, 6311, 12, 7117, 63, 362, 4055, 323, 12, 7117, 63, 409, 4055, 323, 12, 7117, 63, 362, 88, 12, 7117, 63, 362, 89, 12, 7117, 63, 362, 90, 12, 272, 7117, 63, 409, 88, 12, 7117, 63, 261, 369, 12, 7117, 63, 409, 90, 12, 7117, 63, 20733, 12, 7117, 63, 362, 5380, 9, 199, 199, 3, 10579, 14975, 14, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 6481, 492, 334, 504, 63, 4097, 12, 687, 63, 18914, 12, 687, 63, 11412, 12, 272, 1218, 63, 1403, 12, 1218, 63, 604, 875, 12, 1218, 63, 604, 5250, 316, 12, 1218, 63, 16295, 12, 1218, 63, 3627, 12, 272, 11972, 63, 6481, 12, 664, 63, 832, 5985, 12, 664, 63, 442, 5985, 12, 664, 63, 7865, 780, 12, 664, 63, 6481, 78, 12, 9671, 63, 6311, 12, 272, 30259, 63, 7721, 12, 30259, 63, 466, 12, 30259, 63, 22749, 12, 30259, 63, 362, 63, 10498, 12, 30259, 63, 409, 63, 10498, 12, 272, 664, 63, 5380, 12, 664, 63, 1507, 63, 8032, 12, 664, 63, 1507, 63, 29580, 12, 272, 370, 63, 4097, 12, 370, 63, 18914, 12, 370, 63, 11412, 9, 199, 199, 3, 12481, 19549, 14975, 14, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 9923, 492, 627, 199, 199, 3, 5543, 16292, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 14463, 83, 492, 334, 12151, 63, 1989, 90, 12, 30259, 63, 572, 1171, 12, 272, 30259, 63, 374, 5985, 12, 30259, 63, 374, 4129, 12, 30259, 63, 374, 1078, 12, 30259, 63, 6134, 12, 30259, 63, 20363, 874, 12, 272, 30259, 63, 31880, 12, 30259, 63, 11332, 12, 30259, 63, 15788, 535, 1800, 319, 12, 30259, 63, 1058, 25353, 12, 272, 30259, 63, 1058, 25353, 12, 30259, 63, 20798, 12, 30259, 63, 17322, 3401, 12, 30259, 63, 12376, 397, 12, 30259, 63, 12541, 9, 199, 199, 3, 14132, 7085, 14975, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 10775, 492, 627, 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, 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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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 ]
kylelutz/chemkit
tests/auto/plugins/mmff/analyze.py
1
3504
#!/usr/bin/python # this script compares the mmff94.expected and mmff94.actual files # and outputs the differences import os import sys import xml.dom.minidom COLORS_ENABLED = False class AtomResults: def __init__(self, type, charge): self.type = type self.charge = charge class MoleculeResults: def __init__(self, name, energy): self.name = name self.energy = energy self.atoms = [] class ResultsFile: def __init__(self, fileName): self.fileName = fileName self.molecules = [] def read(self): doc = xml.dom.minidom.parse(self.fileName) for moleculeElem in doc.getElementsByTagName('molecule'): name = moleculeElem.getAttribute('name') energy = float(moleculeElem.getAttribute('energy')) moleculeResults = MoleculeResults(name, energy) for atomElem in moleculeElem.getElementsByTagName('atom'): type = atomElem.getAttribute('type') charge = float(atomElem.getAttribute('charge')) moleculeResults.atoms.append(AtomResults(type, charge)) self.molecules.append(moleculeResults) if __name__ == '__main__': actualResultsFile = 'mmff94.actual' expectedResultsFile = 'mmff94.expected' if not os.path.exists(actualResultsFile): print 'could not find actual results file (%s)' % actualResultsFile sys.exit(-1) if not os.path.exists(expectedResultsFile): print 'could not find expected results file (%s)' % expectedResultsFile sys.exit(-1) actualResults = ResultsFile(actualResultsFile) actualResults.read() expectedResults = ResultsFile(expectedResultsFile) expectedResults.read() # escape codes to color text RED_COLOR = '\033[91m' END_COLOR = '\033[0m' if not COLORS_ENABLED: RED_COLOR = '' END_COLOR = '' ATOMS_FAILED = 0 MOLECULES_FAILED = 0 # compare files expectedMoleculeIndex = 0 for i, actualMolecule in enumerate(actualResults.molecules): expectedMolecule = expectedResults.molecules[expectedMoleculeIndex] while expectedMolecule.name != actualMolecule.name: expectedMoleculeIndex += 1 expectedMolecule = expectedResults.molecules[expectedMoleculeIndex] print '%i. %s' % (expectedMoleculeIndex+1, actualMolecule.name) for j in range(len(actualMolecule.atoms)): actualAtom = actualMolecule.atoms[j] expectedAtom = expectedMolecule.atoms[j] expectedTypeText = '' colorCode = '' if(actualAtom.type != expectedAtom.type or (abs(actualAtom.charge - expectedAtom.charge) > 0.01)): ATOMS_FAILED += 1 colorCode = RED_COLOR expectedTypeText = '%s[%s, %s] -- FAILED%s' % (colorCode, expectedAtom.type, expectedAtom.charge, END_COLOR) print ' %i. %s, %s %s' % (j+1, actualAtom.type, actualAtom.charge, expectedTypeText) colorCode = '' if(int(actualMolecule.energy) != int(expectedMolecule.energy)): MOLECULES_FAILED += 1 colorCode = RED_COLOR print 'energy: %f %s[%f]%s' % (actualMolecule.energy, colorCode, expectedMolecule.energy, END_COLOR) # print some statistics print >> sys.stderr, '' print >> sys.stderr, 'atoms: %i failed' % ATOMS_FAILED print >> sys.stderr, 'molecules: %i failed' % MOLECULES_FAILED
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 642, 2884, 30827, 314, 8562, 556, 2635, 14, 2062, 436, 8562, 556, 2635, 14, 6514, 1584, 199, 3, 436, 4704, 314, 15109, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2748, 14, 4556, 14, 21827, 199, 199, 25671, 63, 15704, 275, 756, 9948, 199, 533, 18840, 6579, 26, 272, 347, 636, 826, 721, 277, 12, 730, 12, 11204, 304, 267, 291, 14, 466, 275, 730, 267, 291, 14, 16441, 275, 11204, 199, 199, 533, 3930, 14413, 6579, 26, 272, 347, 636, 826, 721, 277, 12, 536, 12, 12304, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 8443, 275, 12304, 267, 291, 14, 11521, 275, 942, 199, 199, 533, 24288, 1173, 26, 272, 347, 636, 826, 721, 277, 12, 18305, 304, 267, 291, 14, 15450, 275, 18305, 267, 291, 14, 26310, 83, 275, 942, 339, 347, 1586, 8, 277, 304, 267, 1382, 275, 2748, 14, 4556, 14, 21827, 14, 1122, 8, 277, 14, 15450, 9, 398, 367, 26350, 28284, 315, 1382, 14, 15045, 360, 26310, 735, 288, 536, 275, 26350, 28284, 14, 12956, 360, 354, 358, 288, 12304, 275, 2069, 8, 26310, 28284, 14, 12956, 360, 8443, 1333, 288, 26350, 6579, 275, 3930, 14413, 6579, 8, 354, 12, 12304, 9, 953, 367, 6222, 28284, 315, 26350, 28284, 14, 15045, 360, 4188, 735, 355, 730, 275, 6222, 28284, 14, 12956, 360, 466, 358, 355, 11204, 275, 2069, 8, 4188, 28284, 14, 12956, 360, 16441, 1333, 355, 26350, 6579, 14, 11521, 14, 740, 8, 12097, 6579, 8, 466, 12, 11204, 430, 953, 291, 14, 26310, 83, 14, 740, 8, 26310, 6579, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 3503, 6579, 1173, 275, 283, 596, 556, 2635, 14, 6514, 7, 272, 1420, 6579, 1173, 275, 283, 596, 556, 2635, 14, 2062, 7, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 6514, 6579, 1173, 304, 267, 870, 283, 15153, 440, 2342, 3503, 2058, 570, 4366, 83, 3171, 450, 3503, 6579, 1173, 267, 984, 14, 2224, 2801, 17, 9, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 2062, 6579, 1173, 304, 267, 870, 283, 15153, 440, 2342, 1420, 2058, 570, 4366, 83, 3171, 450, 1420, 6579, 1173, 267, 984, 14, 2224, 2801, 17, 9, 339, 3503, 6579, 275, 24288, 1173, 8, 6514, 6579, 1173, 9, 272, 3503, 6579, 14, 739, 342, 339, 1420, 6579, 275, 24288, 1173, 8, 2062, 6579, 1173, 9, 272, 1420, 6579, 14, 739, 342, 339, 327, 4772, 9479, 370, 3164, 1318, 272, 23443, 63, 7134, 275, 1557, 8762, 59, 3328, 77, 7, 272, 7729, 63, 7134, 275, 1557, 8762, 59, 16, 77, 7, 272, 340, 440, 13513, 4149, 63, 15704, 26, 267, 23443, 63, 7134, 275, 2125, 267, 7729, 63, 7134, 275, 2125, 339, 437, 2566, 3053, 63, 12299, 275, 378, 272, 10362, 906, 35, 24392, 63, 12299, 275, 378, 339, 327, 6540, 1584, 272, 1420, 3716, 14413, 2681, 275, 378, 272, 367, 284, 12, 3503, 3716, 14413, 315, 3874, 8, 6514, 6579, 14, 26310, 83, 304, 267, 1420, 3716, 14413, 275, 1420, 6579, 14, 26310, 83, 59, 2062, 3716, 14413, 2681, 61, 398, 1830, 1420, 3716, 14413, 14, 354, 1137, 3503, 3716, 14413, 14, 354, 26, 288, 1420, 3716, 14413, 2681, 847, 413, 288, 1420, 3716, 14413, 275, 1420, 6579, 14, 26310, 83, 59, 2062, 3716, 14413, 2681, 61, 398, 870, 1543, 73, 14, 450, 83, 7, 450, 334, 2062, 3716, 14413, 2681, 11, 17, 12, 3503, 3716, 14413, 14, 354, 9, 2728, 367, 1335, 315, 1425, 8, 552, 8, 6514, 3716, 14413, 14, 11521, 2298, 288, 3503, 12097, 275, 3503, 3716, 14413, 14, 11521, 59, 74, 61, 288, 1420, 12097, 275, 1420, 3716, 14413, 14, 11521, 59, 74, 61, 953, 1420, 804, 1872, 275, 2125, 288, 3164, 3034, 275, 2125, 288, 340, 8, 6514, 12097, 14, 466, 1137, 1420, 12097, 14, 466, 503, 19056, 334, 2101, 8, 6514, 12097, 14, 16441, 446, 1420, 12097, 14, 16441, 9, 690, 378, 14, 614, 2298, 355, 437, 2566, 3053, 63, 12299, 847, 413, 355, 3164, 3034, 275, 23443, 63, 7134, 355, 1420, 804, 1872, 275, 1543, 83, 9722, 83, 12, 450, 83, 61, 1553, 26892, 5, 83, 7, 450, 334, 2326, 3034, 12, 1420, 12097, 14, 466, 12, 1420, 12097, 14, 16441, 12, 7729, 63, 7134, 9, 953, 870, 283, 257, 450, 73, 14, 450, 83, 12, 450, 83, 450, 83, 7, 450, 334, 74, 11, 17, 12, 3503, 12097, 14, 466, 12, 3503, 12097, 14, 16441, 12, 1420, 804, 1872, 9, 398, 3164, 3034, 275, 2125, 267, 340, 8, 442, 8, 6514, 3716, 14413, 14, 8443, 9, 1137, 1109, 8, 2062, 3716, 14413, 14, 8443, 2298, 288, 10362, 906, 35, 24392, 63, 12299, 847, 413, 288, 3164, 3034, 275, 23443, 63, 7134, 398, 870, 283, 8443, 26, 450, 70, 450, 83, 9722, 70, 61, 5, 83, 7, 450, 334, 6514, 3716, 14413, 14, 8443, 12, 3164, 3034, 12, 1420, 3716, 14413, 14, 8443, 12, 7729, 63, 7134, 9, 339, 327, 870, 2005, 11076, 272, 870, 4331, 984, 14, 3083, 12, 2125, 272, 870, 4331, 984, 14, 3083, 12, 283, 11521, 26, 450, 73, 3405, 7, 450, 437, 2566, 3053, 63, 12299, 272, 870, 4331, 984, 14, 3083, 12, 283, 26310, 83, 26, 450, 73, 3405, 7, 450, 10362, 906, 35, 24392, 63, 12299, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 642, 2884, 30827, 314, 8562, 556, 2635, 14, 2062, 436, 8562, 556, 2635, 14, 6514, 1584, 199, 3, 436, 4704, 314, 15109, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2748, 14, 4556, 14, 21827, 199, 199, 25671, 63, 15704, 275, 756, 9948, 199, 533, 18840, 6579, 26, 272, 347, 636, 826, 721, 277, 12, 730, 12, 11204, 304, 267, 291, 14, 466, 275, 730, 267, 291, 14, 16441, 275, 11204, 199, 199, 533, 3930, 14413, 6579, 26, 272, 347, 636, 826, 721, 277, 12, 536, 12, 12304, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 8443, 275, 12304, 267, 291, 14, 11521, 275, 942, 199, 199, 533, 24288, 1173, 26, 272, 347, 636, 826, 721, 277, 12, 18305, 304, 267, 291, 14, 15450, 275, 18305, 267, 291, 14, 26310, 83, 275, 942, 339, 347, 1586, 8, 277, 304, 267, 1382, 275, 2748, 14, 4556, 14, 21827, 14, 1122, 8, 277, 14, 15450, 9, 398, 367, 26350, 28284, 315, 1382, 14, 15045, 360, 26310, 735, 288, 536, 275, 26350, 28284, 14, 12956, 360, 354, 358, 288, 12304, 275, 2069, 8, 26310, 28284, 14, 12956, 360, 8443, 1333, 288, 26350, 6579, 275, 3930, 14413, 6579, 8, 354, 12, 12304, 9, 953, 367, 6222, 28284, 315, 26350, 28284, 14, 15045, 360, 4188, 735, 355, 730, 275, 6222, 28284, 14, 12956, 360, 466, 358, 355, 11204, 275, 2069, 8, 4188, 28284, 14, 12956, 360, 16441, 1333, 355, 26350, 6579, 14, 11521, 14, 740, 8, 12097, 6579, 8, 466, 12, 11204, 430, 953, 291, 14, 26310, 83, 14, 740, 8, 26310, 6579, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 3503, 6579, 1173, 275, 283, 596, 556, 2635, 14, 6514, 7, 272, 1420, 6579, 1173, 275, 283, 596, 556, 2635, 14, 2062, 7, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 6514, 6579, 1173, 304, 267, 870, 283, 15153, 440, 2342, 3503, 2058, 570, 4366, 83, 3171, 450, 3503, 6579, 1173, 267, 984, 14, 2224, 2801, 17, 9, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 2062, 6579, 1173, 304, 267, 870, 283, 15153, 440, 2342, 1420, 2058, 570, 4366, 83, 3171, 450, 1420, 6579, 1173, 267, 984, 14, 2224, 2801, 17, 9, 339, 3503, 6579, 275, 24288, 1173, 8, 6514, 6579, 1173, 9, 272, 3503, 6579, 14, 739, 342, 339, 1420, 6579, 275, 24288, 1173, 8, 2062, 6579, 1173, 9, 272, 1420, 6579, 14, 739, 342, 339, 327, 4772, 9479, 370, 3164, 1318, 272, 23443, 63, 7134, 275, 1557, 8762, 59, 3328, 77, 7, 272, 7729, 63, 7134, 275, 1557, 8762, 59, 16, 77, 7, 272, 340, 440, 13513, 4149, 63, 15704, 26, 267, 23443, 63, 7134, 275, 2125, 267, 7729, 63, 7134, 275, 2125, 339, 437, 2566, 3053, 63, 12299, 275, 378, 272, 10362, 906, 35, 24392, 63, 12299, 275, 378, 339, 327, 6540, 1584, 272, 1420, 3716, 14413, 2681, 275, 378, 272, 367, 284, 12, 3503, 3716, 14413, 315, 3874, 8, 6514, 6579, 14, 26310, 83, 304, 267, 1420, 3716, 14413, 275, 1420, 6579, 14, 26310, 83, 59, 2062, 3716, 14413, 2681, 61, 398, 1830, 1420, 3716, 14413, 14, 354, 1137, 3503, 3716, 14413, 14, 354, 26, 288, 1420, 3716, 14413, 2681, 847, 413, 288, 1420, 3716, 14413, 275, 1420, 6579, 14, 26310, 83, 59, 2062, 3716, 14413, 2681, 61, 398, 870, 1543, 73, 14, 450, 83, 7, 450, 334, 2062, 3716, 14413, 2681, 11, 17, 12, 3503, 3716, 14413, 14, 354, 9, 2728, 367, 1335, 315, 1425, 8, 552, 8, 6514, 3716, 14413, 14, 11521, 2298, 288, 3503, 12097, 275, 3503, 3716, 14413, 14, 11521, 59, 74, 61, 288, 1420, 12097, 275, 1420, 3716, 14413, 14, 11521, 59, 74, 61, 953, 1420, 804, 1872, 275, 2125, 288, 3164, 3034, 275, 2125, 288, 340, 8, 6514, 12097, 14, 466, 1137, 1420, 12097, 14, 466, 503, 19056, 334, 2101, 8, 6514, 12097, 14, 16441, 446, 1420, 12097, 14, 16441, 9, 690, 378, 14, 614, 2298, 355, 437, 2566, 3053, 63, 12299, 847, 413, 355, 3164, 3034, 275, 23443, 63, 7134, 355, 1420, 804, 1872, 275, 1543, 83, 9722, 83, 12, 450, 83, 61, 1553, 26892, 5, 83, 7, 450, 334, 2326, 3034, 12, 1420, 12097, 14, 466, 12, 1420, 12097, 14, 16441, 12, 7729, 63, 7134, 9, 953, 870, 283, 257, 450, 73, 14, 450, 83, 12, 450, 83, 450, 83, 7, 450, 334, 74, 11, 17, 12, 3503, 12097, 14, 466, 12, 3503, 12097, 14, 16441, 12, 1420, 804, 1872, 9, 398, 3164, 3034, 275, 2125, 267, 340, 8, 442, 8, 6514, 3716, 14413, 14, 8443, 9, 1137, 1109, 8, 2062, 3716, 14413, 14, 8443, 2298, 288, 10362, 906, 35, 24392, 63, 12299, 847, 413, 288, 3164, 3034, 275, 23443, 63, 7134, 398, 870, 283, 8443, 26, 450, 70, 450, 83, 9722, 70, 61, 5, 83, 7, 450, 334, 6514, 3716, 14413, 14, 8443, 12, 3164, 3034, 12, 1420, 3716, 14413, 14, 8443, 12, 7729, 63, 7134, 9, 339, 327, 870, 2005, 11076, 272, 870, 4331, 984, 14, 3083, 12, 2125, 272, 870, 4331, 984, 14, 3083, 12, 283, 11521, 26, 450, 73, 3405, 7, 450, 437, 2566, 3053, 63, 12299, 272, 870, 4331, 984, 14, 3083, 12, 283, 26310, 83, 26, 450, 73, 3405, 7, 450, 10362, 906, 35, 24392, 63, 12299, 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, 0 ]
[ 1, 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eoODK/onadata
onadata/apps/viewer/tests/test_exports.py
3
55621
import csv import datetime import json import os import StringIO from time import sleep from django.conf import settings from django.core.files.storage import get_storage_class from django.core.urlresolvers import reverse from django.utils.dateparse import parse_datetime from xlrd import open_workbook from onadata.apps.main.views import delete_data from onadata.apps.main.tests.test_base import TestBase from onadata.apps.viewer.tests.export_helpers import viewer_fixture_path from onadata.apps.viewer.views import delete_export, export_list,\ create_export, export_progress, export_download from onadata.apps.viewer.xls_writer import XlsWriter from onadata.apps.viewer.models.export import Export from onadata.apps.main.models.meta_data import MetaData from onadata.apps.viewer.models.parsed_instance import ParsedInstance from onadata.apps.logger.models import Instance from onadata.apps.viewer.tasks import create_xls_export from onadata.libs.utils.export_tools import generate_export,\ increment_index_in_filename, dict_to_joined_export, clean_keys_of_slashes AMBULANCE_KEY = 'transport/available_transportation_types_to_referral_fac'\ 'ility/ambulance' AMBULANCE_KEY_DOTS = 'transport.available_transportation_types_to_referra'\ 'l_facility.ambulance' def _main_fixture_path(instance_name): return os.path.join(settings.PROJECT_ROOT, 'apps', 'main', 'tests', 'fixtures', 'transportation', 'instances_w_uuid', instance_name, instance_name + '.xml') class TestExports(TestBase): def setUp(self): super(TestExports, self).setUp() self._submission_time = parse_datetime('2013-02-18 15:54:01Z') def test_unique_xls_sheet_name(self): xls_writer = XlsWriter() xls_writer.add_sheet('section9_pit_latrine_with_slab_group') xls_writer.add_sheet('section9_pit_latrine_without_slab_group') # create a set of sheet names keys sheet_names_set = set(xls_writer._sheets.keys()) self.assertEqual(len(sheet_names_set), 2) def test_csv_http_response(self): self._publish_transportation_form() survey = self.surveys[0] self._make_submission( os.path.join( self.this_directory, 'fixtures', 'transportation', 'instances', survey, survey + '.xml'), forced_submission_time=self._submission_time) response = self.client.get(reverse( 'csv_export', kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })) self.assertEqual(response.status_code, 200) test_file_path = viewer_fixture_path('transportation.csv') content = self._get_response_content(response) with open(test_file_path, 'r') as test_file: self.assertEqual(content, test_file.read()) def test_csv_without_na_values(self): self._publish_transportation_form() survey = self.surveys[0] self._make_submission( os.path.join( self.this_directory, 'fixtures', 'transportation', 'instances', survey, survey + '.xml'), forced_submission_time=self._submission_time) na_rep_restore = settings.NA_REP settings.NA_REP = u'' response = self.client.get(reverse( 'csv_export', kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })) self.assertEqual(response.status_code, 200) test_file_path = viewer_fixture_path('transportation_without_na.csv') content = self._get_response_content(response) with open(test_file_path, 'r') as test_file: self.assertEqual(content, test_file.read()) settings.NA_REP = na_rep_restore def test_responses_for_empty_exports(self): self._publish_transportation_form() # test csv though xls uses the same view url = reverse( 'csv_export', kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string } ) self.response = self.client.get(url) self.assertEqual(self.response.status_code, 404) self.assertIn('text/html', self.response['content-type']) def test_create_export(self): self._publish_transportation_form_and_submit_instance() storage = get_storage_class()() # test xls export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) self.assertTrue(storage.exists(export.filepath)) path, ext = os.path.splitext(export.filename) self.assertEqual(ext, '.xls') # test csv export = generate_export(Export.CSV_EXPORT, 'csv', self.user.username, self.xform.id_string) self.assertTrue(storage.exists(export.filepath)) path, ext = os.path.splitext(export.filename) self.assertEqual(ext, '.csv') # test xls with existing export_id existing_export = Export.objects.create(xform=self.xform, export_type=Export.XLS_EXPORT) export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string, existing_export.id) self.assertEqual(existing_export.id, export.id) def test_delete_file_on_export_delete(self): self._publish_transportation_form() self._submit_transport_instance() export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) storage = get_storage_class()() self.assertTrue(storage.exists(export.filepath)) # delete export object export.delete() self.assertFalse(storage.exists(export.filepath)) def test_graceful_exit_on_export_delete_if_file_doesnt_exist(self): self._publish_transportation_form() self._submit_transport_instance() export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) storage = get_storage_class()() # delete file storage.delete(export.filepath) self.assertFalse(storage.exists(export.filepath)) # clear filename, like it would be in an incomplete export export.filename = None export.filedir = None export.save() # delete export record, which should try to delete file as well delete_url = reverse(delete_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) post_data = {'export_id': export.id} response = self.client.post(delete_url, post_data) self.assertEqual(response.status_code, 302) def test_delete_oldest_export_on_limit(self): self._publish_transportation_form() self._submit_transport_instance() # create first export first_export = generate_export( Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) self.assertIsNotNone(first_export.pk) # create exports that exceed set limit for i in range(Export.MAX_EXPORTS): generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) # first export should be deleted exports = Export.objects.filter(id=first_export.id) self.assertEqual(len(exports), 0) def test_create_export_url(self): self._publish_transportation_form() self._submit_transport_instance() num_exports = Export.objects.count() # create export create_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.XLS_EXPORT }) # anonymous user has to login first response = self.anon.post(create_export_url) self.assertEqual(response.status_code, 302) self.assertIn("/accounts/login", response['location']) response = self.client.post(create_export_url) self.assertEqual(response.status_code, 302) self.assertEqual(Export.objects.count(), num_exports + 1) def test_delete_export_url(self): self._publish_transportation_form() self._submit_transport_instance() # create export export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) exports = Export.objects.filter(id=export.id) self.assertEqual(len(exports), 1) delete_url = reverse(delete_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) post_data = {'export_id': export.id} # anonymous user has to login first response = self.anon.post(delete_url, post_data) self.assertEqual(response.status_code, 302) self.assertIn("/accounts/login", response['location']) response = self.client.post(delete_url, post_data) self.assertEqual(response.status_code, 302) exports = Export.objects.filter(id=export.id) self.assertEqual(len(exports), 0) def test_export_progress_output(self): self._publish_transportation_form() self._submit_transport_instance() # create exports for i in range(2): generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) self.assertEqual(Export.objects.count(), 2) # progress for multiple exports progress_url = reverse(export_progress, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) get_data = {'export_ids': [e.id for e in Export.objects.all()]} response = self.client.get(progress_url, get_data) content = json.loads(response.content) self.assertEqual(len(content), 2) self.assertEqual(sorted(['url', 'export_id', 'complete', 'filename']), sorted(content[0].keys())) def test_auto_export_if_none_exists(self): self._publish_transportation_form() self._submit_transport_instance() # get export list url num_exports = Export.objects.count() export_list_url = reverse(export_list, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.XLS_EXPORT }) self.client.get(export_list_url) self.assertEqual(Export.objects.count(), num_exports + 1) def test_dont_auto_export_if_exports_exist(self): self._publish_transportation_form() self._submit_transport_instance() # create export create_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.XLS_EXPORT }) self.client.post(create_export_url) num_exports = Export.objects.count() export_list_url = reverse(export_list, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.XLS_EXPORT }) self.client.get(export_list_url) self.assertEqual(Export.objects.count(), num_exports) def test_last_submission_time_on_export(self): self._publish_transportation_form() self._submit_transport_instance() # create export generate_export( Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) num_exports = Export.objects.filter( xform=self.xform, export_type=Export.XLS_EXPORT).count() # check that our function knows there are no more submissions self.assertFalse( Export.exports_outdated(xform=self.xform, export_type=Export.XLS_EXPORT)) sleep(1) # force new last submission date on xform last_submission = self.xform.instances.order_by('-date_created')[0] last_submission.date_created += datetime.timedelta(hours=1) last_submission.save() # check that our function knows data has changed self.assertTrue( Export.exports_outdated(xform=self.xform, export_type=Export.XLS_EXPORT)) # check that requesting list url will generate a new export export_list_url = reverse(export_list, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.XLS_EXPORT }) self.client.get(export_list_url) self.assertEqual( Export.objects.filter(xform=self.xform, export_type=Export.XLS_EXPORT).count(), num_exports + 1) # make sure another export type causes auto-generation num_exports = Export.objects.filter( xform=self.xform, export_type=Export.CSV_EXPORT).count() export_list_url = reverse(export_list, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.CSV_EXPORT }) self.client.get(export_list_url) self.assertEqual( Export.objects.filter(xform=self.xform, export_type=Export.CSV_EXPORT).count(), num_exports + 1) def test_last_submission_time_empty(self): self._publish_transportation_form() self._submit_transport_instance() # create export export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) # set time of last submission to None export.time_of_last_submission = None export.save() self.assertTrue(Export.exports_outdated(xform=self.xform, export_type=Export.XLS_EXPORT)) def test_invalid_export_type(self): self._publish_transportation_form() self._submit_transport_instance() export_list_url = reverse(export_list, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'invalid' }) response = self.client.get(export_list_url) self.assertEqual(response.status_code, 400) # test create url create_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'invalid' }) response = self.client.post(create_export_url) self.assertEqual(response.status_code, 400) def test_add_index_to_filename(self): filename = "file_name-123f.txt" new_filename = increment_index_in_filename(filename) expected_filename = "file_name-123f-1.txt" self.assertEqual(new_filename, expected_filename) # test file that already has an index filename = "file_name-123.txt" new_filename = increment_index_in_filename(filename) expected_filename = "file_name-124.txt" self.assertEqual(new_filename, expected_filename) def test_duplicate_export_filename_is_renamed(self): self._publish_transportation_form() self._submit_transport_instance() # TODO: mock the time # only works if the time we time we generate the basename # is exact to the second with the time the 2nd export is created # create an export object in the db basename = "%s_%s" % ( self.xform.id_string, datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")) filename = basename + ".csv" export = Export.objects.create( xform=self.xform, export_type=Export.CSV_EXPORT, filename=filename) # 2nd export export_2 = generate_export( Export.CSV_EXPORT, 'csv', self.user.username, self.xform.id_string) if export.created_on.timetuple() == export_2.created_on.timetuple(): new_filename = increment_index_in_filename(filename) self.assertEqual(new_filename, export_2.filename) else: self.skipTest("duplicate export filename test skipped " "because export times differ.") def test_export_download_url(self): self._publish_transportation_form() self._submit_transport_instance() export = generate_export(Export.CSV_EXPORT, 'csv', self.user.username, self.xform.id_string) csv_export_url = reverse(export_download, kwargs={ "username": self.user.username, "id_string": self.xform.id_string, "export_type": Export.CSV_EXPORT, "filename": export.filename }) response = self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) # test xls export = generate_export(Export.XLS_EXPORT, 'xls', self.user.username, self.xform.id_string) xls_export_url = reverse(export_download, kwargs={ "username": self.user.username, "id_string": self.xform.id_string, "export_type": Export.XLS_EXPORT, "filename": export.filename }) response = self.client.get(xls_export_url) self.assertEqual(response.status_code, 200) def test_404_on_export_io_error(self): """ Test that we return a 404 when the response_with_mimetype_and_name encounters an IOError """ self._publish_transportation_form() self._submit_transport_instance() export = generate_export(Export.CSV_EXPORT, 'csv', self.user.username, self.xform.id_string) export_url = reverse(export_download, kwargs={ "username": self.user.username, "id_string": self.xform.id_string, "export_type": Export.CSV_EXPORT, "filename": export.filename }) # delete the export export.delete() # access the export response = self.client.get(export_url) self.assertEqual(response.status_code, 404) def test_deleted_submission_not_in_export(self): self._publish_transportation_form() initial_count = ParsedInstance.query_mongo( self.user.username, self.xform.id_string, '{}', '[]', '{}', count=True)[0]['count'] self._submit_transport_instance(0) self._submit_transport_instance(1) count = ParsedInstance.query_mongo( self.user.username, self.xform.id_string, '{}', '[]', '{}', count=True)[0]['count'] self.assertEqual(count, initial_count + 2) # get id of second submission instance_id = Instance.objects.filter( xform=self.xform).order_by('id').reverse()[0].id delete_url = reverse( delete_data, kwargs={"username": self.user.username, "id_string": self.xform.id_string}) params = {'id': instance_id} self.client.post(delete_url, params) count = ParsedInstance.query_mongo( self.user.username, self.xform.id_string, '{}', '[]', '{}', count=True)[0]['count'] self.assertEqual(count, initial_count + 1) # create the export csv_export_url = reverse( 'csv_export', kwargs={"username": self.user.username, "id_string": self.xform.id_string}) response = self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) f = StringIO.StringIO(self._get_response_content(response)) csv_reader = csv.reader(f) num_rows = len([row for row in csv_reader]) f.close() # number of rows == 2 i.e. initial_count + header plus one row self.assertEqual(num_rows, initial_count + 2) def test_edited_submissions_in_exports(self): self._publish_transportation_form() initial_count = ParsedInstance.query_mongo( self.user.username, self.xform.id_string, '{}', '[]', '{}', count=True)[0]['count'] instance_name = 'transport_2011-07-25_19-05-36' path = _main_fixture_path(instance_name) self._make_submission(path) count = ParsedInstance.query_mongo( self.user.username, self.xform.id_string, '{}', '[]', '{}', count=True)[0]['count'] self.assertEqual(count, initial_count + 1) # make edited submission - simulating what enketo would return instance_name = 'transport_2011-07-25_19-05-36-edited' path = _main_fixture_path(instance_name) self._make_submission(path) count = ParsedInstance.query_mongo( self.user.username, self.xform.id_string, '{}', '[]', '{}', count=True)[0]['count'] self.assertEqual(count, initial_count + 1) # create the export csv_export_url = reverse( 'csv_export', kwargs={"username": self.user.username, "id_string": self.xform.id_string}) response = self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) f = StringIO.StringIO(self._get_response_content(response)) csv_reader = csv.DictReader(f) data = [row for row in csv_reader] f.close() num_rows = len(data) # number of rows == initial_count + 1 self.assertEqual(num_rows, initial_count + 1) key = 'transport/loop_over_transport_types_frequency/ambulance/'\ 'frequency_to_referral_facility' self.assertEqual(data[initial_count][key], "monthly") def test_export_ids_dont_have_comma_separation(self): """ It seems using {{ }} to output numbers greater than 1000 formats the number with a thousand separator """ self._publish_transportation_form() self._submit_transport_instance() # create an in-complete export export = Export.objects.create(id=1234, xform=self.xform, export_type=Export.XLS_EXPORT) self.assertEqual(export.pk, 1234) export_list_url = reverse( export_list, kwargs={ "username": self.user.username, "id_string": self.xform.id_string, "export_type": Export.XLS_EXPORT }) response = self.client.get(export_list_url) self.assertContains(response, '#delete-1234"') self.assertNotContains(response, '#delete-1,234"') def test_export_progress_updates(self): """ Test that after generate_export is called, we change out state to pending and after its complete, we change it to complete, if we fail between the two, updates, we have failed """ self._publish_transportation_form() # generate an export that fails because of the NoRecordsFound exception export = Export.objects.create(xform=self.xform, export_type=Export.XLS_EXPORT) # check that progress url says pending progress_url = reverse(export_progress, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) params = {'export_ids': [export.id]} response = self.client.get(progress_url, params) status = json.loads(response.content)[0] self.assertEqual(status["complete"], False) self.assertEqual(status["filename"], None) export.internal_status = Export.FAILED export.save() # check that progress url says failed progress_url = reverse(export_progress, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) params = {'export_ids': [export.id]} response = self.client.get(progress_url, params) status = json.loads(response.content)[0] self.assertEqual(status["complete"], True) self.assertEqual(status["filename"], None) # make a submission and create a valid export self._submit_transport_instance() create_xls_export( self.user.username, self.xform.id_string, export.id) params = {'export_ids': [export.id]} response = self.client.get(progress_url, params) status = json.loads(response.content)[0] self.assertEqual(status["complete"], True) self.assertIsNotNone(status["filename"]) def test_direct_export_returns_newset_export_if_not_updated_since(self): self._publish_transportation_form() self._submit_transport_instance() self.assertEqual(self.response.status_code, 201) sleep(1) self._submit_transport_instance_w_uuid("transport_2011-07-25_19-05-36") self.assertEqual(self.response.status_code, 201) initial_num_csv_exports = Export.objects.filter( xform=self.xform, export_type=Export.CSV_EXPORT).count() initial_num_xls_exports = Export.objects.filter( xform=self.xform, export_type=Export.XLS_EXPORT).count() # request a direct csv export csv_export_url = reverse('csv_export', kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) xls_export_url = reverse('xls_export', kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) response = self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) # we should have initial_num_exports + 1 exports num_csv_exports = Export.objects.filter( xform=self.xform, export_type=Export.CSV_EXPORT).count() self.assertEqual(num_csv_exports, initial_num_csv_exports + 1) # request another export without changing the data response = self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) # we should still only have a single export object num_csv_exports = Export.objects.filter( xform=self.xform, export_type=Export.CSV_EXPORT).count() self.assertEqual(num_csv_exports, initial_num_csv_exports + 1) # this should not affect a direct XLS export # and XLS should still re-generate response = self.client.get(xls_export_url) self.assertEqual(response.status_code, 200) num_xls_exports = Export.objects.filter( xform=self.xform, export_type=Export.XLS_EXPORT).count() self.assertEqual(num_xls_exports, initial_num_xls_exports + 1) # make sure xls doesnt re-generate if data hasn't changed response = self.client.get(xls_export_url) self.assertEqual(response.status_code, 200) num_xls_exports = Export.objects.filter( xform=self.xform, export_type=Export.XLS_EXPORT).count() self.assertEqual(num_xls_exports, initial_num_xls_exports + 1) sleep(1) # check that data edits cause a re-generation self._submit_transport_instance_w_uuid( "transport_2011-07-25_19-05-36-edited") self.assertEqual(self.response.status_code, 201) self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) # we should have an extra export now that the data has been updated num_csv_exports = Export.objects.filter( xform=self.xform, export_type=Export.CSV_EXPORT).count() self.assertEqual(num_csv_exports, initial_num_csv_exports + 2) sleep(1) # and when we delete delete_url = reverse(delete_data, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) instance = Instance.objects.filter().order_by('-pk')[0] response = self.client.post(delete_url, {'id': instance.id}) self.assertEqual(response.status_code, 200) response = self.client.get(csv_export_url) self.assertEqual(response.status_code, 200) # we should have an extra export now that the data # has been updated by the delete num_csv_exports = Export.objects.filter( xform=self.xform, export_type=Export.CSV_EXPORT).count() self.assertEqual(num_csv_exports, initial_num_csv_exports + 3) def test_exports_outdated_doesnt_consider_failed_exports(self): self._publish_transportation_form() self._submit_transport_instance() # create a bad export export = Export.objects.create( xform=self.xform, export_type=Export.XLS_EXPORT, internal_status=Export.FAILED) self.assertTrue( Export.exports_outdated(self.xform, export.export_type)) def test_exports_outdated_considers_pending_exports(self): self._publish_transportation_form() self._submit_transport_instance() # create a pending export export = Export.objects.create( xform=self.xform, export_type=Export.XLS_EXPORT, internal_status=Export.PENDING) self.assertFalse( Export.exports_outdated(self.xform, export.export_type)) def _get_csv_data(self, filepath): storage = get_storage_class()() csv_file = storage.open(filepath) reader = csv.DictReader(csv_file) data = reader.next() csv_file.close() return data def _get_xls_data(self, filepath): storage = get_storage_class()() with storage.open(filepath) as f: workbook = open_workbook(file_contents=f.read()) transportation_sheet = workbook.sheet_by_name("transportation") self.assertTrue(transportation_sheet.nrows > 1) headers = transportation_sheet.row_values(0) column1 = transportation_sheet.row_values(1) return dict(zip(headers, column1)) def test_column_header_delimiter_export_option(self): self._publish_transportation_form() # survey 1 has ambulance and bicycle as values for # transport/available_transportation_types_to_referral_facility self._submit_transport_instance(survey_at=1) create_csv_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'csv' }) default_params = {} custom_params = { 'options[group_delimiter]': '.', } # test csv with default group delimiter response = self.client.post(create_csv_export_url, default_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='csv').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_csv_data(export.filepath) self.assertTrue(AMBULANCE_KEY in data) self.assertEqual(data[AMBULANCE_KEY], 'True') sleep(1) # test csv with dot delimiter response = self.client.post(create_csv_export_url, custom_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='csv').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_csv_data(export.filepath) self.assertTrue(AMBULANCE_KEY_DOTS in data) self.assertEqual(data[AMBULANCE_KEY_DOTS], 'True') # test xls with default group delimiter create_csv_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) response = self.client.post(create_csv_export_url, default_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='xls').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_xls_data(export.filepath) self.assertTrue(AMBULANCE_KEY in data) # xlrd reader seems to convert bools into integers i.e. 0 or 1 self.assertEqual(data[AMBULANCE_KEY], 1) sleep(1) # test xls with dot delimiter response = self.client.post(create_csv_export_url, custom_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='xls').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_xls_data(export.filepath) self.assertTrue(AMBULANCE_KEY_DOTS in data) # xlrd reader seems to convert bools into integers i.e. 0 or 1 self.assertEqual(data[AMBULANCE_KEY_DOTS], 1) def test_split_select_multiple_export_option(self): self._publish_transportation_form() self._submit_transport_instance(survey_at=1) create_csv_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'csv' }) default_params = {} custom_params = { 'options[dont_split_select_multiples]': 'yes' } # test csv with default split select multiples response = self.client.post(create_csv_export_url, default_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='csv').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_csv_data(export.filepath) # we should have transport/available_transportation_types_to_referral_f # acility/ambulance as a separate column self.assertTrue(AMBULANCE_KEY in data) self.assertEqual(data[AMBULANCE_KEY], 'True') sleep(1) # test csv with default split select multiples, binary select multiples settings.BINARY_SELECT_MULTIPLES = True response = self.client.post(create_csv_export_url, default_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='csv').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_csv_data(export.filepath) # we should have transport/available_transportation_types_to_referral_f # acility/ambulance as a separate column self.assertTrue(AMBULANCE_KEY in data) self.assertEqual(data[AMBULANCE_KEY], '1') settings.BINARY_SELECT_MULTIPLES = False sleep(1) # test csv without default split select multiples response = self.client.post(create_csv_export_url, custom_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='csv').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_csv_data(export.filepath) # transport/available_transportation_types_to_referral_facility/ambulan # ce should not be in its own column self.assertFalse(AMBULANCE_KEY in data) # transport/available_transportation_types_to_referral_facility should # be a column self.assertTrue( 'transport/available_transportation_types_to_referral_facility' in data) # check that ambulance is one the values within the transport/available # _transportation_types_to_referral_facility column self.assertTrue("ambulance" in data[ 'transport/available_transportation_types_to_referral_facility' ].split(" ")) create_xls_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': 'xls' }) # test xls with default split select multiples response = self.client.post(create_xls_export_url, default_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='xls').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_xls_data(export.filepath) # we should have transport/available_transportation_types_to_referral_f # acility/ambulance as a separate column self.assertTrue(AMBULANCE_KEY in data) sleep(1) # test xls without default split select multiples response = self.client.post(create_xls_export_url, custom_params) self.assertEqual(response.status_code, 302) export = Export.objects.filter( xform=self.xform, export_type='xls').latest('created_on') self.assertTrue(bool(export.filepath)) data = self._get_xls_data(export.filepath) # transport/available_transportation_types_to_referral_facility/ambulan # ce should NOT be in its own column self.assertFalse(AMBULANCE_KEY in data) # transport/available_transportation_types_to_referral_facility should # be a column self.assertTrue( 'transport/available_transportation_types_to_referral_facility' in data) # check that ambulance is one the values within the transport/available # _transportation_types_to_referral_facility column self.assertTrue("ambulance" in data[ 'transport/available_transportation_types_to_referral_facility' ].split(" ")) def test_dict_to_joined_export_works(self): data =\ { 'name': 'Abe', 'age': '35', '_geolocation': [None, None], 'attachments': ['abcd.jpg', 'efgh.jpg'], 'children': [ { 'children/name': 'Mike', 'children/age': '5', 'children/cartoons': [ { 'children/cartoons/name': 'Tom & Jerry', 'children/cartoons/why': 'Tom is silly', }, { 'children/cartoons/name': 'Flinstones', 'children/cartoons/why': u"I like bamb bam\u0107", } ] }, { 'children/name': 'John', 'children/age': '2', 'children/cartoons': [] }, { 'children/name': 'Imora', 'children/age': '3', 'children/cartoons': [ { 'children/cartoons/name': 'Shrek', 'children/cartoons/why': 'He\'s so funny' }, { 'children/cartoons/name': 'Dexter\'s Lab', 'children/cartoons/why': 'He thinks hes smart', 'children/cartoons/characters': [ { 'children/cartoons/characters/name': 'Dee Dee', 'children/cartoons/characters/good_or_' 'evil': 'good' }, { 'children/cartoons/characters/name': 'Dexter', 'children/cartoons/characters/good_or_' 'evil': 'evil' }, ] } ] } ] } expected_output =\ { 'survey': { 'name': 'Abe', 'age': '35' }, 'children': [ { 'children/name': 'Mike', 'children/age': '5', '_index': 1, '_parent_table_name': 'survey', '_parent_index': 1 }, { 'children/name': 'John', 'children/age': '2', '_index': 2, '_parent_table_name': 'survey', '_parent_index': 1 }, { 'children/name': 'Imora', 'children/age': '3', '_index': 3, '_parent_table_name': 'survey', '_parent_index': 1 }, ], 'children/cartoons': [ { 'children/cartoons/name': 'Tom & Jerry', 'children/cartoons/why': 'Tom is silly', '_index': 1, '_parent_table_name': 'children', '_parent_index': 1 }, { 'children/cartoons/name': 'Flinstones', 'children/cartoons/why': u"I like bamb bam\u0107", '_index': 2, '_parent_table_name': 'children', '_parent_index': 1 }, { 'children/cartoons/name': 'Shrek', 'children/cartoons/why': 'He\'s so funny', '_index': 3, '_parent_table_name': 'children', '_parent_index': 3 }, { 'children/cartoons/name': 'Dexter\'s Lab', 'children/cartoons/why': 'He thinks hes smart', '_index': 4, '_parent_table_name': 'children', '_parent_index': 3 } ], 'children/cartoons/characters': [ { 'children/cartoons/characters/name': 'Dee Dee', 'children/cartoons/characters/good_or_evil': 'good', '_index': 1, '_parent_table_name': 'children/cartoons', '_parent_index': 4 }, { 'children/cartoons/characters/name': 'Dexter', 'children/cartoons/characters/good_or_evil': 'evil', '_index': 2, '_parent_table_name': 'children/cartoons', '_parent_index': 4 } ] } survey_name = 'survey' indices = {survey_name: 0} output = dict_to_joined_export(data, 1, indices, survey_name) self.assertEqual(output[survey_name], expected_output[survey_name]) # 1st level self.assertEqual(len(output['children']), 3) for child in enumerate(['Mike', 'John', 'Imora']): index = child[0] name = child[1] self.assertEqual( filter( lambda x: x['children/name'] == name, output['children'])[0], expected_output['children'][index]) # 2nd level self.assertEqual(len(output['children/cartoons']), 4) for cartoon in enumerate( ['Tom & Jerry', 'Flinstones', 'Shrek', 'Dexter\'s Lab']): index = cartoon[0] name = cartoon[1] self.assertEqual( filter( lambda x: x['children/cartoons/name'] == name, output['children/cartoons'])[0], expected_output['children/cartoons'][index]) # 3rd level self.assertEqual(len(output['children/cartoons/characters']), 2) for characters in enumerate(['Dee Dee', 'Dexter']): index = characters[0] name = characters[1] self.assertEqual( filter( lambda x: x['children/cartoons/characters/name'] == name, output['children/cartoons/characters'])[0], expected_output['children/cartoons/characters'][index]) def test_generate_csv_zip_export(self): # publish xls form self._publish_transportation_form_and_submit_instance() # create export db object export = generate_export( Export.CSV_ZIP_EXPORT, "zip", self.user.username, self.xform.id_string, group_delimiter='/', split_select_multiples=True) storage = get_storage_class()() self.assertTrue(storage.exists(export.filepath)) path, ext = os.path.splitext(export.filename) self.assertEqual(ext, '.zip') def test_dict_to_joined_export_notes(self): submission = { "_id": 579828, "_submission_time": "2013-07-03T08:26:10", "_uuid": "5b4752eb-e13c-483e-87cb-e67ca6bb61e5", "_bamboo_dataset_id": "", "_xform_id_string": "test_data_types", "_userform_id": "larryweya_test_data_types", "_status": "submitted_via_web", "_notes": [ { "note": "Note 1", "date_created": "2013-07-03T08:26:10", "id": 356, "date_modified": "2013-07-03T08:26:10" }, { "note": "Note 2", "date_created": "2013-07-03T08:34:40", "id": 357, "date_modified": "2013-07-03T08:34:40" }, { "note": "Note 3", "date_created": "2013-07-03T08:56:14", "id": 361, "date_modified": "2013-07-03T08:56:14" } ], "meta/instanceID": "uuid:5b4752eb-e13c-483e-87cb-e67ca6bb61e5", "formhub/uuid": "633ec390e024411ba5ce634db7807e62", "amount": "", } survey_name = 'tutorial' indices = {survey_name: 0} data = dict_to_joined_export(submission, 1, indices, survey_name) expected_data = { 'tutorial': { '_id': 579828, '_submission_time': '2013-07-03T08:26:10', '_uuid': '5b4752eb-e13c-483e-87cb-e67ca6bb61e5', '_bamboo_dataset_id': '', 'amount': '', '_xform_id_string': 'test_data_types', '_userform_id': 'larryweya_test_data_types', '_status': 'submitted_via_web', '_notes': 'Note 1\nNote 2\nNote 3', 'meta/instanceID': 'uuid:5b4752eb-e13c-483e-87cb-e67ca6bb61e5', 'formhub/uuid': '633ec390e024411ba5ce634db7807e62' } } self.assertEqual(sorted(data), sorted(expected_data)) def test_create_xls_export_non_existent_id(self): self._publish_transportation_form() # make a submission and create a valid export self._submit_transport_instance() non_existent_id = 42 result = create_xls_export( self.user.username, self.xform.id_string, non_existent_id) self.assertEqual(result, None) def test_create_external_export_url(self): self._publish_transportation_form() self._submit_transport_instance() num_exports = Export.objects.count() server = 'http://localhost:8080/xls/23fa4c38c0054748a984ffd89021a295' data_value = 'template 1 |{0}'.format(server) meta = MetaData.external_export(self.xform, data_value) custom_params = { 'meta': meta.id, } # create export create_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.EXTERNAL_EXPORT }) response = self.client.post(create_export_url, custom_params) self.assertEqual(response.status_code, 302) self.assertEqual(Export.objects.count(), num_exports + 1) def test_create_external_export_without_template(self): self._publish_transportation_form() self._submit_transport_instance() num_exports = Export.objects.count() # create export create_export_url = reverse(create_export, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string, 'export_type': Export.EXTERNAL_EXPORT }) response = self.client.post(create_export_url) self.assertEqual(response.status_code, 403) self.assertEquals(response.content, u'No XLS Template set.') self.assertEqual(Export.objects.count(), num_exports) def test_all_keys_cleaned_of_slashes(self): data =\ { 'name': 'Abe', 'age': '35', '_geolocation': [None, None], 'attachments': ['abcd.jpg', 'efgh.jpg'], 'section1/location': True, 'children': [ { 'children/name': 'Mike', 'children/age': '5', 'children/cartoons': [ { 'children/cartoons/name': 'Tom & Jerry', 'children/cartoons/why': 'Tom is silly', }, { 'children/cartoons/name': 'Flinstones', 'children/cartoons/why': u"I like bamb bam\u0107", } ] }, { 'children/name': 'John', 'children/age': '2', 'children/cartoons': [] }, { 'children/name': 'Imora', 'children/age': '3', 'children/cartoons': [ { 'children/cartoons/name': 'Shrek', 'children/cartoons/why': 'He\'s so funny' }, { 'children/cartoons/name': 'Dexter\'s Lab', 'children/cartoons/why': 'He thinks hes smart', 'children/cartoons/characters': [ { 'children/cartoons/characters/name': 'Dee Dee', 'children/cartoons/characters/good_or_' 'evil': 'good' }, { 'children/cartoons/characters/name': 'Dexter', 'children/cartoons/characters/good_or_' 'evil': 'evil' }, ] } ] } ] } expected_data = { 'name': 'Abe', 'age': '35', '_geolocation': [None, None], 'attachments': ['abcd.jpg', 'efgh.jpg'], 'section1_location': True, 'children': [ { 'children_name': 'Mike', 'children_age': '5', 'children_cartoons': [ { 'children_cartoons_name': 'Tom & Jerry', 'children_cartoons_why': 'Tom is silly', }, { 'children_cartoons_name': 'Flinstones', 'children_cartoons_why': u"I like bamb bam\u0107", } ] }, { 'children_name': 'John', 'children_age': '2', 'children_cartoons': [] }, { 'children_name': 'Imora', 'children_age': '3', 'children_cartoons': [ { 'children_cartoons_name': 'Shrek', 'children_cartoons_why': 'He\'s so funny' }, { 'children_cartoons_name': 'Dexter\'s Lab', 'children_cartoons_why': 'He thinks hes smart', 'children_cartoons_characters': [ { 'children_cartoons_characters_name': 'Dee Dee', 'children_cartoons_characters_good_or_' 'evil': 'good' }, { 'children_cartoons_characters_name': 'Dexter', 'children_cartoons_characters_good_or_' 'evil': 'evil' }, ] } ] } ] } result_data = clean_keys_of_slashes(data) self.assertEquals(expected_data, result_data)
bsd-2-clause
[ 646, 7392, 199, 646, 2197, 199, 646, 2022, 199, 646, 747, 199, 646, 5228, 199, 504, 900, 492, 9435, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 664, 63, 3494, 63, 533, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 2083, 199, 504, 25077, 6883, 492, 1551, 63, 30765, 199, 199, 504, 641, 1517, 14, 5181, 14, 973, 14, 4196, 492, 3145, 63, 576, 199, 504, 641, 1517, 14, 5181, 14, 973, 14, 2219, 14, 396, 63, 1095, 492, 1379, 1563, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 2219, 14, 3790, 63, 7546, 492, 27354, 63, 5997, 63, 515, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 4196, 492, 3145, 63, 3790, 12, 4843, 63, 513, 4202, 272, 1218, 63, 3790, 12, 4843, 63, 5734, 12, 4843, 63, 4249, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 19023, 63, 5491, 492, 1323, 478, 6261, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 992, 14, 3790, 492, 20220, 199, 504, 641, 1517, 14, 5181, 14, 973, 14, 992, 14, 2024, 63, 576, 492, 24905, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 992, 14, 6751, 63, 842, 492, 2235, 939, 3244, 199, 504, 641, 1517, 14, 5181, 14, 2921, 14, 992, 492, 10066, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 5054, 492, 1218, 63, 19023, 63, 3790, 199, 504, 641, 1517, 14, 8450, 14, 1208, 14, 3790, 63, 2537, 492, 3550, 63, 3790, 4202, 272, 11609, 63, 1080, 63, 262, 63, 1501, 12, 1211, 63, 475, 63, 11806, 63, 3790, 12, 3633, 63, 1612, 63, 1618, 63, 24032, 199, 199, 1156, 34, 1293, 7140, 63, 3078, 275, 283, 5545, 15, 4561, 63, 5545, 425, 63, 1313, 63, 475, 63, 1121, 1508, 279, 63, 12668, 1154, 355, 283, 2012, 15, 11020, 348, 554, 7, 199, 1156, 34, 1293, 7140, 63, 3078, 63, 13203, 51, 275, 283, 5545, 14, 4561, 63, 5545, 425, 63, 1313, 63, 475, 63, 21928, 345, 1154, 2151, 283, 76, 63, 22354, 14, 11020, 348, 554, 7, 421, 199, 318, 485, 973, 63, 5997, 63, 515, 8, 842, 63, 354, 304, 272, 372, 747, 14, 515, 14, 904, 8, 1751, 14, 10797, 63, 5441, 12, 283, 5181, 297, 283, 973, 297, 283, 2219, 297, 717, 283, 8769, 297, 283, 5545, 425, 297, 283, 5990, 63, 87, 63, 2580, 297, 717, 1256, 63, 354, 12, 1256, 63, 354, 435, 1987, 1652, 358, 421, 199, 533, 1379, 920, 5203, 8, 14440, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 920, 5203, 12, 291, 680, 5996, 342, 267, 291, 423, 12542, 63, 521, 275, 2198, 63, 2083, 360, 6965, 13, 996, 13, 1085, 4114, 26, 1477, 26, 614, 58, 358, 339, 347, 511, 63, 3235, 63, 19023, 63, 5069, 63, 354, 8, 277, 304, 267, 671, 478, 63, 5491, 275, 1323, 478, 6261, 342, 267, 671, 478, 63, 5491, 14, 525, 63, 5069, 360, 2792, 25, 63, 80, 390, 63, 4452, 82, 1132, 63, 1045, 63, 2482, 371, 63, 923, 358, 267, 671, 478, 63, 5491, 14, 525, 63, 5069, 360, 2792, 25, 63, 80, 390, 63, 4452, 82, 1132, 63, 7395, 63, 2482, 371, 63, 923, 358, 267, 327, 1218, 282, 663, 402, 12083, 1561, 2883, 267, 12083, 63, 1247, 63, 409, 275, 663, 8, 19023, 63, 5491, 423, 24376, 14, 1612, 1012, 267, 291, 14, 629, 8, 552, 8, 5069, 63, 1247, 63, 409, 395, 499, 9, 339, 347, 511, 63, 4737, 63, 1014, 63, 1310, 8, 277, 304, 267, 291, 423, 4763, 63, 5545, 425, 63, 964, 342, 267, 16576, 275, 291, 14, 5105, 432, 588, 59, 16, 61, 267, 291, 423, 1875, 63, 12542, 8, 288, 747, 14, 515, 14, 904, 8, 355, 291, 14, 3749, 63, 3619, 12, 283, 8769, 297, 283, 5545, 425, 297, 355, 283, 5990, 297, 16576, 12, 16576, 435, 1987, 1652, 659, 288, 19565, 63, 12542, 63, 521, 29, 277, 423, 12542, 63, 521, 9, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 8, 288, 283, 4737, 63, 3790, 297, 288, 2074, 3126, 355, 283, 2473, 356, 291, 14, 751, 14, 2473, 12, 355, 283, 344, 63, 875, 356, 291, 14, 24226, 14, 344, 63, 875, 288, 23451, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 511, 63, 493, 63, 515, 275, 27354, 63, 5997, 63, 515, 360, 5545, 425, 14, 4737, 358, 267, 1564, 275, 291, 423, 362, 63, 1310, 63, 1317, 8, 1310, 9, 267, 543, 1551, 8, 396, 63, 493, 63, 515, 12, 283, 82, 358, 465, 511, 63, 493, 26, 288, 291, 14, 629, 8, 1317, 12, 511, 63, 493, 14, 739, 1012, 339, 347, 511, 63, 4737, 63, 7395, 63, 3540, 63, 1459, 8, 277, 304, 267, 291, 423, 4763, 63, 5545, 425, 63, 964, 342, 267, 16576, 275, 291, 14, 5105, 432, 588, 59, 16, 61, 267, 291, 423, 1875, 63, 12542, 8, 288, 747, 14, 515, 14, 904, 8, 355, 291, 14, 3749, 63, 3619, 12, 283, 8769, 297, 283, 5545, 425, 297, 355, 283, 5990, 297, 16576, 12, 16576, 435, 1987, 1652, 659, 288, 19565, 63, 12542, 63, 521, 29, 277, 423, 12542, 63, 521, 9, 267, 11802, 63, 1155, 63, 8011, 275, 2202, 14, 7170, 63, 22554, 267, 2202, 14, 7170, 63, 22554, 275, 399, 891, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 8, 288, 283, 4737, 63, 3790, 297, 288, 2074, 3126, 355, 283, 2473, 356, 291, 14, 751, 14, 2473, 12, 355, 283, 344, 63, 875, 356, 291, 14, 24226, 14, 344, 63, 875, 288, 23451, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 511, 63, 493, 63, 515, 275, 27354, 63, 5997, 63, 515, 360, 5545, 425, 63, 7395, 63, 3540, 14, 4737, 358, 267, 1564, 275, 291, 423, 362, 63, 1310, 63, 1317, 8, 1310, 9, 267, 543, 1551, 8, 396, 63, 493, 63, 515, 12, 283, 82, 358, 465, 511, 63, 493, 26, 288, 291, 14, 629, 8, 1317, 12, 511, 63, 493 ]
[ 7392, 199, 646, 2197, 199, 646, 2022, 199, 646, 747, 199, 646, 5228, 199, 504, 900, 492, 9435, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 664, 63, 3494, 63, 533, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 2083, 199, 504, 25077, 6883, 492, 1551, 63, 30765, 199, 199, 504, 641, 1517, 14, 5181, 14, 973, 14, 4196, 492, 3145, 63, 576, 199, 504, 641, 1517, 14, 5181, 14, 973, 14, 2219, 14, 396, 63, 1095, 492, 1379, 1563, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 2219, 14, 3790, 63, 7546, 492, 27354, 63, 5997, 63, 515, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 4196, 492, 3145, 63, 3790, 12, 4843, 63, 513, 4202, 272, 1218, 63, 3790, 12, 4843, 63, 5734, 12, 4843, 63, 4249, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 19023, 63, 5491, 492, 1323, 478, 6261, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 992, 14, 3790, 492, 20220, 199, 504, 641, 1517, 14, 5181, 14, 973, 14, 992, 14, 2024, 63, 576, 492, 24905, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 992, 14, 6751, 63, 842, 492, 2235, 939, 3244, 199, 504, 641, 1517, 14, 5181, 14, 2921, 14, 992, 492, 10066, 199, 504, 641, 1517, 14, 5181, 14, 16645, 14, 5054, 492, 1218, 63, 19023, 63, 3790, 199, 504, 641, 1517, 14, 8450, 14, 1208, 14, 3790, 63, 2537, 492, 3550, 63, 3790, 4202, 272, 11609, 63, 1080, 63, 262, 63, 1501, 12, 1211, 63, 475, 63, 11806, 63, 3790, 12, 3633, 63, 1612, 63, 1618, 63, 24032, 199, 199, 1156, 34, 1293, 7140, 63, 3078, 275, 283, 5545, 15, 4561, 63, 5545, 425, 63, 1313, 63, 475, 63, 1121, 1508, 279, 63, 12668, 1154, 355, 283, 2012, 15, 11020, 348, 554, 7, 199, 1156, 34, 1293, 7140, 63, 3078, 63, 13203, 51, 275, 283, 5545, 14, 4561, 63, 5545, 425, 63, 1313, 63, 475, 63, 21928, 345, 1154, 2151, 283, 76, 63, 22354, 14, 11020, 348, 554, 7, 421, 199, 318, 485, 973, 63, 5997, 63, 515, 8, 842, 63, 354, 304, 272, 372, 747, 14, 515, 14, 904, 8, 1751, 14, 10797, 63, 5441, 12, 283, 5181, 297, 283, 973, 297, 283, 2219, 297, 717, 283, 8769, 297, 283, 5545, 425, 297, 283, 5990, 63, 87, 63, 2580, 297, 717, 1256, 63, 354, 12, 1256, 63, 354, 435, 1987, 1652, 358, 421, 199, 533, 1379, 920, 5203, 8, 14440, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 920, 5203, 12, 291, 680, 5996, 342, 267, 291, 423, 12542, 63, 521, 275, 2198, 63, 2083, 360, 6965, 13, 996, 13, 1085, 4114, 26, 1477, 26, 614, 58, 358, 339, 347, 511, 63, 3235, 63, 19023, 63, 5069, 63, 354, 8, 277, 304, 267, 671, 478, 63, 5491, 275, 1323, 478, 6261, 342, 267, 671, 478, 63, 5491, 14, 525, 63, 5069, 360, 2792, 25, 63, 80, 390, 63, 4452, 82, 1132, 63, 1045, 63, 2482, 371, 63, 923, 358, 267, 671, 478, 63, 5491, 14, 525, 63, 5069, 360, 2792, 25, 63, 80, 390, 63, 4452, 82, 1132, 63, 7395, 63, 2482, 371, 63, 923, 358, 267, 327, 1218, 282, 663, 402, 12083, 1561, 2883, 267, 12083, 63, 1247, 63, 409, 275, 663, 8, 19023, 63, 5491, 423, 24376, 14, 1612, 1012, 267, 291, 14, 629, 8, 552, 8, 5069, 63, 1247, 63, 409, 395, 499, 9, 339, 347, 511, 63, 4737, 63, 1014, 63, 1310, 8, 277, 304, 267, 291, 423, 4763, 63, 5545, 425, 63, 964, 342, 267, 16576, 275, 291, 14, 5105, 432, 588, 59, 16, 61, 267, 291, 423, 1875, 63, 12542, 8, 288, 747, 14, 515, 14, 904, 8, 355, 291, 14, 3749, 63, 3619, 12, 283, 8769, 297, 283, 5545, 425, 297, 355, 283, 5990, 297, 16576, 12, 16576, 435, 1987, 1652, 659, 288, 19565, 63, 12542, 63, 521, 29, 277, 423, 12542, 63, 521, 9, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 8, 288, 283, 4737, 63, 3790, 297, 288, 2074, 3126, 355, 283, 2473, 356, 291, 14, 751, 14, 2473, 12, 355, 283, 344, 63, 875, 356, 291, 14, 24226, 14, 344, 63, 875, 288, 23451, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 511, 63, 493, 63, 515, 275, 27354, 63, 5997, 63, 515, 360, 5545, 425, 14, 4737, 358, 267, 1564, 275, 291, 423, 362, 63, 1310, 63, 1317, 8, 1310, 9, 267, 543, 1551, 8, 396, 63, 493, 63, 515, 12, 283, 82, 358, 465, 511, 63, 493, 26, 288, 291, 14, 629, 8, 1317, 12, 511, 63, 493, 14, 739, 1012, 339, 347, 511, 63, 4737, 63, 7395, 63, 3540, 63, 1459, 8, 277, 304, 267, 291, 423, 4763, 63, 5545, 425, 63, 964, 342, 267, 16576, 275, 291, 14, 5105, 432, 588, 59, 16, 61, 267, 291, 423, 1875, 63, 12542, 8, 288, 747, 14, 515, 14, 904, 8, 355, 291, 14, 3749, 63, 3619, 12, 283, 8769, 297, 283, 5545, 425, 297, 355, 283, 5990, 297, 16576, 12, 16576, 435, 1987, 1652, 659, 288, 19565, 63, 12542, 63, 521, 29, 277, 423, 12542, 63, 521, 9, 267, 11802, 63, 1155, 63, 8011, 275, 2202, 14, 7170, 63, 22554, 267, 2202, 14, 7170, 63, 22554, 275, 399, 891, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 8, 288, 283, 4737, 63, 3790, 297, 288, 2074, 3126, 355, 283, 2473, 356, 291, 14, 751, 14, 2473, 12, 355, 283, 344, 63, 875, 356, 291, 14, 24226, 14, 344, 63, 875, 288, 23451, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 511, 63, 493, 63, 515, 275, 27354, 63, 5997, 63, 515, 360, 5545, 425, 63, 7395, 63, 3540, 14, 4737, 358, 267, 1564, 275, 291, 423, 362, 63, 1310, 63, 1317, 8, 1310, 9, 267, 543, 1551, 8, 396, 63, 493, 63, 515, 12, 283, 82, 358, 465, 511, 63, 493, 26, 288, 291, 14, 629, 8, 1317, 12, 511, 63, 493, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
BFriedland/UserDataBase-Heroku
venv/Lib/site-packages/pip/_vendor/requests/packages/chardet/sjisprober.py
1182
3734
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### import sys from .mbcharsetprober import MultiByteCharSetProber from .codingstatemachine import CodingStateMachine from .chardistribution import SJISDistributionAnalysis from .jpcntx import SJISContextAnalysis from .mbcssm import SJISSMModel from . import constants class SJISProber(MultiByteCharSetProber): def __init__(self): MultiByteCharSetProber.__init__(self) self._mCodingSM = CodingStateMachine(SJISSMModel) self._mDistributionAnalyzer = SJISDistributionAnalysis() self._mContextAnalyzer = SJISContextAnalysis() self.reset() def reset(self): MultiByteCharSetProber.reset(self) self._mContextAnalyzer.reset() def get_charset_name(self): return "SHIFT_JIS" def feed(self, aBuf): aLen = len(aBuf) for i in range(0, aLen): codingState = self._mCodingSM.next_state(aBuf[i]) if codingState == constants.eError: if constants._debug: sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') self._mState = constants.eNotMe break elif codingState == constants.eItsMe: self._mState = constants.eFoundIt break elif codingState == constants.eStart: charLen = self._mCodingSM.get_current_charlen() if i == 0: self._mLastChar[1] = aBuf[0] self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:], charLen) self._mDistributionAnalyzer.feed(self._mLastChar, charLen) else: self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3 - charLen], charLen) self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], charLen) self._mLastChar[0] = aBuf[aLen - 1] if self.get_state() == constants.eDetecting: if (self._mContextAnalyzer.got_enough_data() and (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): self._mState = constants.eFoundIt return self.get_state() def get_confidence(self): contxtCf = self._mContextAnalyzer.get_confidence() distribCf = self._mDistributionAnalyzer.get_confidence() return max(contxtCf, distribCf)
mit
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 646, 984, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 428, 22290, 24906, 199, 504, 1275, 74, 2352, 343, 88, 492, 428, 22290, 2998, 13182, 199, 504, 1275, 887, 3919, 77, 492, 428, 22290, 25335, 199, 504, 1275, 492, 5262, 421, 199, 533, 428, 22290, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 51, 22290, 25335, 9, 267, 291, 423, 77, 8580, 17606, 275, 428, 22290, 24906, 342, 267, 291, 423, 77, 2998, 17606, 275, 428, 22290, 2998, 13182, 342, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 6879, 21312, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 2998, 17606, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 18013, 63, 22290, 2, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 282, 3166, 275, 822, 8, 22353, 9, 267, 367, 284, 315, 1425, 8, 16, 12, 282, 3166, 304, 288, 2803, 2223, 275, 291, 423, 29633, 14, 2184, 63, 929, 8, 22353, 59, 73, 566, 288, 340, 2803, 2223, 508, 5262, 14, 6259, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 277, 14, 362, 63, 6043, 63, 354, 342, 3660, 435, 283, 16118, 9793, 1125, 737, 3696, 283, 435, 620, 8, 73, 9, 3660, 435, 1557, 78, 358, 355, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 13241, 26, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 11724, 26, 355, 29205, 275, 291, 423, 29633, 14, 362, 63, 1818, 63, 1560, 552, 342, 355, 340, 284, 508, 378, 26, 490, 291, 423, 30875, 59, 17, 61, 275, 17407, 59, 16, 61, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 277, 423, 30875, 59, 18, 446, 29205, 8429, 6059, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 277, 423, 30875, 12, 29205, 9, 355, 587, 26, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 22353, 59, 73, 435, 413, 446, 29205, 26, 73, 435, 650, 9349, 446, 29205, 467, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 22353, 59, 73, 446, 413, 26, 73, 435, 413, 467, 9349, 29205, 9, 398, 291, 423, 30875, 59, 16, 61, 275, 17407, 59, 65, 3166, 446, 413, 61, 398, 340, 291, 14, 362, 63, 929, 342, 508, 5262, 14, 69, 20064, 316, 26, 288, 340, 334, 277, 423, 77, 2998, 17606, 14, 7808, 63, 30881, 63, 576, 342, 436, 2049, 334, 277, 14, 362, 63, 13969, 342, 690, 5262, 14, 13003, 24678, 63, 19307, 2298, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 398, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 406, 2424, 24304, 275, 291, 423, 77, 2998, 17606, 14, 362, 63, 13969, 342, 267, 29573, 24304, 275, 291, 423, 77, 8580, 17606, 14, 362, 63, 13969, 342, 267, 372, 1390, 8, 388, 2424, 24304, 12, 29573, 24304, 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 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 646, 984, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 428, 22290, 24906, 199, 504, 1275, 74, 2352, 343, 88, 492, 428, 22290, 2998, 13182, 199, 504, 1275, 887, 3919, 77, 492, 428, 22290, 25335, 199, 504, 1275, 492, 5262, 421, 199, 533, 428, 22290, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 51, 22290, 25335, 9, 267, 291, 423, 77, 8580, 17606, 275, 428, 22290, 24906, 342, 267, 291, 423, 77, 2998, 17606, 275, 428, 22290, 2998, 13182, 342, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 6879, 21312, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 2998, 17606, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 18013, 63, 22290, 2, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 282, 3166, 275, 822, 8, 22353, 9, 267, 367, 284, 315, 1425, 8, 16, 12, 282, 3166, 304, 288, 2803, 2223, 275, 291, 423, 29633, 14, 2184, 63, 929, 8, 22353, 59, 73, 566, 288, 340, 2803, 2223, 508, 5262, 14, 6259, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 277, 14, 362, 63, 6043, 63, 354, 342, 3660, 435, 283, 16118, 9793, 1125, 737, 3696, 283, 435, 620, 8, 73, 9, 3660, 435, 1557, 78, 358, 355, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 13241, 26, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 11724, 26, 355, 29205, 275, 291, 423, 29633, 14, 362, 63, 1818, 63, 1560, 552, 342, 355, 340, 284, 508, 378, 26, 490, 291, 423, 30875, 59, 17, 61, 275, 17407, 59, 16, 61, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 277, 423, 30875, 59, 18, 446, 29205, 8429, 6059, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 277, 423, 30875, 12, 29205, 9, 355, 587, 26, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 22353, 59, 73, 435, 413, 446, 29205, 26, 73, 435, 650, 9349, 446, 29205, 467, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 22353, 59, 73, 446, 413, 26, 73, 435, 413, 467, 9349, 29205, 9, 398, 291, 423, 30875, 59, 16, 61, 275, 17407, 59, 65, 3166, 446, 413, 61, 398, 340, 291, 14, 362, 63, 929, 342, 508, 5262, 14, 69, 20064, 316, 26, 288, 340, 334, 277, 423, 77, 2998, 17606, 14, 7808, 63, 30881, 63, 576, 342, 436, 2049, 334, 277, 14, 362, 63, 13969, 342, 690, 5262, 14, 13003, 24678, 63, 19307, 2298, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 398, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 406, 2424, 24304, 275, 291, 423, 77, 2998, 17606, 14, 362, 63, 13969, 342, 267, 29573, 24304, 275, 291, 423, 77, 8580, 17606, 14, 362, 63, 13969, 342, 267, 372, 1390, 8, 388, 2424, 24304, 12, 29573, 24304, 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, 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,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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 ]
Liangjianghao/powerline
tests/test_cmdline.py
23
4803
# vim:fileencoding=utf-8:noet '''Tests for shell.py parser''' from __future__ import (unicode_literals, division, absolute_import, print_function) import sys if sys.version_info < (3,): from io import BytesIO as StrIO else: from io import StringIO as StrIO from powerline.commands.main import get_argparser, finish_args from tests import TestCase from tests.lib import replace_attr class TestParser(TestCase): def test_main_err(self): parser = get_argparser() out = StrIO() err = StrIO() def flush(): out.truncate(0) err.truncate(0) with replace_attr(sys, 'stdout', out, 'stderr', err): for raising_args, raising_reg in [ ([], 'too few arguments|the following arguments are required: ext'), (['-r'], 'expected one argument'), (['shell', '-r'], 'expected one argument'), (['shell', '-w'], 'expected one argument'), (['shell', '-c'], 'expected one argument'), (['shell', '-t'], 'expected one argument'), (['shell', '-p'], 'expected one argument'), (['shell', '-R'], 'expected one argument'), (['shell', '--renderer-module'], 'expected one argument'), (['shell', '--width'], 'expected one argument'), (['shell', '--last-exit-code'], 'expected one argument'), (['shell', '--last-pipe-status'], 'expected one argument'), (['shell', '--config-override'], 'expected one argument'), (['shell', '--theme-override'], 'expected one argument'), (['shell', '--config-path'], 'expected one argument'), (['shell', '--renderer-arg'], 'expected one argument'), (['shell', '--jobnum'], 'expected one argument'), (['-r', '.zsh'], 'too few arguments|the following arguments are required: ext'), (['shell', '--last-exit-code', 'i'], 'invalid int_or_sig value'), (['shell', '--last-pipe-status', '1 i'], 'invalid <lambda> value'), ]: self.assertRaises(SystemExit, parser.parse_args, raising_args) self.assertFalse(out.getvalue()) self.assertRegexpMatches(err.getvalue(), raising_reg) flush() def test_main_normal(self): parser = get_argparser() out = StrIO() err = StrIO() with replace_attr(sys, 'stdout', out, 'stderr', err): for argv, expargs in [ (['shell', 'left'], {'ext': ['shell'], 'side': 'left'}), (['shell', 'left', '-r', '.zsh'], {'ext': ['shell'], 'renderer_module': '.zsh', 'side': 'left'}), ([ 'shell', 'left', '-r', '.zsh', '--last-exit-code', '10', '--last-pipe-status', '10 20 30', '--jobnum=10', '-w', '100', '-c', 'common.term_truecolor=true', '-c', 'common.spaces=4', '-t', 'default.segment_data.hostname.before=H:', '-p', '.', '-p', '..', '-R', 'smth={"abc":"def"}', ], { 'ext': ['shell'], 'side': 'left', 'renderer_module': '.zsh', 'last_exit_code': 10, 'last_pipe_status': [10, 20, 30], 'jobnum': 10, 'width': 100, 'config_override': {'common': {'term_truecolor': True, 'spaces': 4}}, 'theme_override': { 'default': { 'segment_data': { 'hostname': { 'before': 'H:' } } } }, 'config_path': ['.', '..'], 'renderer_arg': {'smth': {'abc': 'def'}}, }), (['shell', 'left', '-R', 'arg=true'], { 'ext': ['shell'], 'side': 'left', 'renderer_arg': {'arg': True}, }), (['shell', 'left', '-R', 'arg=true', '-R', 'arg='], { 'ext': ['shell'], 'side': 'left', 'renderer_arg': {}, }), (['shell', 'left', '-R', 'arg='], {'ext': ['shell'], 'renderer_arg': {}, 'side': 'left'}), (['shell', 'left', '-t', 'default.segment_info={"hostname": {}}'], { 'ext': ['shell'], 'side': 'left', 'theme_override': { 'default': { 'segment_info': { 'hostname': {} } } }, }), (['shell', 'left', '-c', 'common={ }'], { 'ext': ['shell'], 'side': 'left', 'config_override': {'common': {}}, }), ]: args = parser.parse_args(argv) finish_args({}, args) for key, val in expargs.items(): self.assertEqual(getattr(args, key), val) for key, val in args.__dict__.items(): if key not in expargs: self.assertFalse(val, msg='key {0} is {1} while it should be something false'.format(key, val)) self.assertFalse(err.getvalue() + out.getvalue(), msg='unexpected output: {0!r} {1!r}'.format( err.getvalue(), out.getvalue(), )) if __name__ == '__main__': from tests import main main()
mit
[ 3, 6695, 26, 493, 2991, 29, 1624, 13, 24, 26, 889, 386, 199, 199, 2344, 2925, 367, 5218, 14, 647, 1798, 2344, 199, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 9, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 19, 16095, 199, 198, 504, 5890, 492, 11808, 465, 8303, 2090, 199, 2836, 26, 199, 198, 504, 5890, 492, 5228, 465, 8303, 2090, 199, 199, 504, 7074, 604, 14, 4405, 14, 973, 492, 664, 63, 1273, 2087, 12, 9578, 63, 589, 199, 199, 504, 2295, 492, 7640, 199, 504, 2295, 14, 773, 492, 3350, 63, 962, 421, 199, 533, 1379, 2842, 8, 1746, 304, 199, 198, 318, 511, 63, 973, 63, 1508, 8, 277, 304, 507, 198, 2087, 275, 664, 63, 1273, 2087, 342, 507, 198, 548, 275, 8303, 2090, 342, 507, 198, 1508, 275, 8303, 2090, 342, 2742, 198, 318, 8976, 837, 686, 198, 548, 14, 12517, 8, 16, 9, 686, 198, 1508, 14, 12517, 8, 16, 9, 2742, 198, 1045, 3350, 63, 962, 8, 1274, 12, 283, 2703, 297, 734, 12, 283, 3083, 297, 2329, 304, 686, 198, 509, 17026, 63, 589, 12, 17026, 63, 1135, 315, 359, 1585, 198, 8798, 32542, 283, 7354, 9284, 2368, 92, 1589, 2569, 2368, 787, 1415, 26, 1599, 659, 1585, 198, 24829, 82, 995, 2476, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 82, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 87, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 67, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 84, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 80, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 50, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 12471, 13, 578, 995, 260, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2063, 995, 7861, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 2224, 13, 600, 995, 3515, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 4990, 13, 1205, 995, 263, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 888, 13, 4415, 995, 260, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 7915, 13, 4415, 995, 3515, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 888, 13, 515, 995, 3777, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 12471, 13, 1273, 995, 3322, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2423, 1507, 995, 8295, 283, 2062, 1373, 1423, 659, 1585, 198, 24829, 82, 297, 1987, 90, 609, 995, 12793, 283, 7354, 9284, 2368, 92, 1589, 2569, 2368, 787, 1415, 26, 1599, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 2224, 13, 600, 297, 283, 73, 995, 258, 283, 3197, 1109, 63, 269, 63, 4093, 574, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 4990, 13, 1205, 297, 283, 17, 284, 995, 283, 3197, 665, 2734, 30, 574, 659, 686, 198, 2189, 1585, 198, 277, 14, 1855, 8, 24738, 12, 1798, 14, 1122, 63, 589, 12, 17026, 63, 589, 9, 1585, 198, 277, 14, 3334, 8, 548, 14, 7150, 1012, 1585, 198, 277, 14, 26672, 8, 1508, 14, 7150, 1062, 17026, 63, 1135, 9, 1585, 198, 4939, 342, 421, 198, 318, 511, 63, 973, 63, 3302, 8, 277, 304, 507, 198, 2087, 275, 664, 63, 1273, 2087, 342, 507, 198, 548, 275, 8303, 2090, 342, 507, 198, 1508, 275, 8303, 2090, 342, 507, 198, 1045, 3350, 63, 962, 8, 1274, 12, 283, 2703, 297, 734, 12, 283, 3083, 297, 2329, 304, 686, 198, 509, 9238, 12, 444, 462, 458, 315, 359, 1585, 198, 2941, 5641, 297, 283, 3039, 995, 755, 791, 832, 356, 788, 5641, 995, 283, 2441, 356, 283, 3039, 1604, 1585, 198, 2941, 5641, 297, 283, 3039, 297, 2475, 82, 297, 1987, 90, 609, 995, 791, 832, 356, 788, 5641, 995, 283, 12471, 63, 578, 356, 1987, 90, 609, 297, 283, 2441, 356, 283, 3039, 1604, 1585, 198, 779, 1871, 198, 1159, 72, 1697, 297, 1871, 198, 7, 3039, 297, 1871, 198, 12418, 82, 297, 1987, 90, 609, 297, 1871, 198, 27529, 2019, 13, 2224, 13, 600, 297, 283, 709, 297, 1871, 198, 27529, 2019, 13, 4990, 13, 1205, 297, 283, 709, 3388, 4233, 297, 1871, 198, 27529, 2423, 1507, 29, 709, 297, 1871, 198, 12418, 87, 297, 283, 1960, 297, 1871, 198, 12418, 67, 297, 283, 2330, 14, 5125, 63, 2052, 2326, 29, 2052, 297, 1871, 198, 12418, 67, 297, 283, 2330, 14, 10749, 29, 20, 297, 1871, 198, 12418, 84, 297, 283, 885, 14, 9255, 63, 576, 14, 4269, 14, 5182, 29, 40, 6536, 1871, 198, 12418, 80, 297, 22608, 1871, 198, 12418, 80, 297, 19155, 1871, 198, 12418, 50, 297, 283, 3300, 273, 8871, 3175, 5122, 318, 3570, 297, 1585, 198, 467, 469, 1871, 198, 7, 832, 356, 788, 5641, 995, 1871, 198, 1159, 2655, 356, 283, 3039, 297, 1871, 198, 3984, 78, 5813, 63, 578, 356, 1987, 90, 609, 297, 1871, 198, 7, 2019, 63, 2224, 63, 600, 356, 1616, 12, 1871, 198, 7, 2019, 63, 4990, 63, 1205, 356, 359, 709, 12, 3388, 12, 4233, 467, 1871, 198, 7, 2423, 1507, 356, 1616, 12, 1871, 198, 7, 2063, 356, 2948, 12, 1871, 198, 7, 888, 63, 4415, 356, 791, 2330, 356, 791, 5125, 63, 2052, 2326, 356, 715, 12, 283, 10749, 356, 841, 13459, 1871, 198, 1133, 426, 278, 63, 4415, 356, 469, 4671, 198, 5121, 69, 1879, 356, 469, 5264, 198, 1159, 69, 4740, 63, 576, 356, 469, 11674, 198, 7, 4269, 356, 469, 22680, 198, 7, 5182, 356, 283, 40, 4881, 11674, 198, 93, 5264, 198, 93, 4671, 198, 93, 1871, 198, 1386, 1871, 198, 7, 888, 63, 515, 356, 788, 3130, 11541, 995, 1871, 198, 3984, 78, 5813, 63, 1273, 356, 791, 3300, 273, 356, 791, 3175, 356, 283, 318, 28400, 1585, 198, 8688, 1585, 198, 2941 ]
[ 6695, 26, 493, 2991, 29, 1624, 13, 24, 26, 889, 386, 199, 199, 2344, 2925, 367, 5218, 14, 647, 1798, 2344, 199, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 9, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 19, 16095, 199, 198, 504, 5890, 492, 11808, 465, 8303, 2090, 199, 2836, 26, 199, 198, 504, 5890, 492, 5228, 465, 8303, 2090, 199, 199, 504, 7074, 604, 14, 4405, 14, 973, 492, 664, 63, 1273, 2087, 12, 9578, 63, 589, 199, 199, 504, 2295, 492, 7640, 199, 504, 2295, 14, 773, 492, 3350, 63, 962, 421, 199, 533, 1379, 2842, 8, 1746, 304, 199, 198, 318, 511, 63, 973, 63, 1508, 8, 277, 304, 507, 198, 2087, 275, 664, 63, 1273, 2087, 342, 507, 198, 548, 275, 8303, 2090, 342, 507, 198, 1508, 275, 8303, 2090, 342, 2742, 198, 318, 8976, 837, 686, 198, 548, 14, 12517, 8, 16, 9, 686, 198, 1508, 14, 12517, 8, 16, 9, 2742, 198, 1045, 3350, 63, 962, 8, 1274, 12, 283, 2703, 297, 734, 12, 283, 3083, 297, 2329, 304, 686, 198, 509, 17026, 63, 589, 12, 17026, 63, 1135, 315, 359, 1585, 198, 8798, 32542, 283, 7354, 9284, 2368, 92, 1589, 2569, 2368, 787, 1415, 26, 1599, 659, 1585, 198, 24829, 82, 995, 2476, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 82, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 87, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 67, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 84, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 80, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2475, 50, 995, 12788, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 12471, 13, 578, 995, 260, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2063, 995, 7861, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 2224, 13, 600, 995, 3515, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 4990, 13, 1205, 995, 263, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 888, 13, 4415, 995, 260, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 7915, 13, 4415, 995, 3515, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 888, 13, 515, 995, 3777, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 12471, 13, 1273, 995, 3322, 283, 2062, 1373, 1423, 659, 1585, 198, 2941, 5641, 297, 2850, 2423, 1507, 995, 8295, 283, 2062, 1373, 1423, 659, 1585, 198, 24829, 82, 297, 1987, 90, 609, 995, 12793, 283, 7354, 9284, 2368, 92, 1589, 2569, 2368, 787, 1415, 26, 1599, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 2224, 13, 600, 297, 283, 73, 995, 258, 283, 3197, 1109, 63, 269, 63, 4093, 574, 659, 1585, 198, 2941, 5641, 297, 2850, 2019, 13, 4990, 13, 1205, 297, 283, 17, 284, 995, 283, 3197, 665, 2734, 30, 574, 659, 686, 198, 2189, 1585, 198, 277, 14, 1855, 8, 24738, 12, 1798, 14, 1122, 63, 589, 12, 17026, 63, 589, 9, 1585, 198, 277, 14, 3334, 8, 548, 14, 7150, 1012, 1585, 198, 277, 14, 26672, 8, 1508, 14, 7150, 1062, 17026, 63, 1135, 9, 1585, 198, 4939, 342, 421, 198, 318, 511, 63, 973, 63, 3302, 8, 277, 304, 507, 198, 2087, 275, 664, 63, 1273, 2087, 342, 507, 198, 548, 275, 8303, 2090, 342, 507, 198, 1508, 275, 8303, 2090, 342, 507, 198, 1045, 3350, 63, 962, 8, 1274, 12, 283, 2703, 297, 734, 12, 283, 3083, 297, 2329, 304, 686, 198, 509, 9238, 12, 444, 462, 458, 315, 359, 1585, 198, 2941, 5641, 297, 283, 3039, 995, 755, 791, 832, 356, 788, 5641, 995, 283, 2441, 356, 283, 3039, 1604, 1585, 198, 2941, 5641, 297, 283, 3039, 297, 2475, 82, 297, 1987, 90, 609, 995, 791, 832, 356, 788, 5641, 995, 283, 12471, 63, 578, 356, 1987, 90, 609, 297, 283, 2441, 356, 283, 3039, 1604, 1585, 198, 779, 1871, 198, 1159, 72, 1697, 297, 1871, 198, 7, 3039, 297, 1871, 198, 12418, 82, 297, 1987, 90, 609, 297, 1871, 198, 27529, 2019, 13, 2224, 13, 600, 297, 283, 709, 297, 1871, 198, 27529, 2019, 13, 4990, 13, 1205, 297, 283, 709, 3388, 4233, 297, 1871, 198, 27529, 2423, 1507, 29, 709, 297, 1871, 198, 12418, 87, 297, 283, 1960, 297, 1871, 198, 12418, 67, 297, 283, 2330, 14, 5125, 63, 2052, 2326, 29, 2052, 297, 1871, 198, 12418, 67, 297, 283, 2330, 14, 10749, 29, 20, 297, 1871, 198, 12418, 84, 297, 283, 885, 14, 9255, 63, 576, 14, 4269, 14, 5182, 29, 40, 6536, 1871, 198, 12418, 80, 297, 22608, 1871, 198, 12418, 80, 297, 19155, 1871, 198, 12418, 50, 297, 283, 3300, 273, 8871, 3175, 5122, 318, 3570, 297, 1585, 198, 467, 469, 1871, 198, 7, 832, 356, 788, 5641, 995, 1871, 198, 1159, 2655, 356, 283, 3039, 297, 1871, 198, 3984, 78, 5813, 63, 578, 356, 1987, 90, 609, 297, 1871, 198, 7, 2019, 63, 2224, 63, 600, 356, 1616, 12, 1871, 198, 7, 2019, 63, 4990, 63, 1205, 356, 359, 709, 12, 3388, 12, 4233, 467, 1871, 198, 7, 2423, 1507, 356, 1616, 12, 1871, 198, 7, 2063, 356, 2948, 12, 1871, 198, 7, 888, 63, 4415, 356, 791, 2330, 356, 791, 5125, 63, 2052, 2326, 356, 715, 12, 283, 10749, 356, 841, 13459, 1871, 198, 1133, 426, 278, 63, 4415, 356, 469, 4671, 198, 5121, 69, 1879, 356, 469, 5264, 198, 1159, 69, 4740, 63, 576, 356, 469, 11674, 198, 7, 4269, 356, 469, 22680, 198, 7, 5182, 356, 283, 40, 4881, 11674, 198, 93, 5264, 198, 93, 4671, 198, 93, 1871, 198, 1386, 1871, 198, 7, 888, 63, 515, 356, 788, 3130, 11541, 995, 1871, 198, 3984, 78, 5813, 63, 1273, 356, 791, 3300, 273, 356, 791, 3175, 356, 283, 318, 28400, 1585, 198, 8688, 1585, 198, 2941, 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, 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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 ]
Teamxrtc/webrtc-streaming-node
third_party/depot_tools/external_bin/gsutil/gsutil_4.15/gsutil/third_party/crcmod/test/examples.py
33
1656
#----------------------------------------------------------------------------- # Demonstrate the use of the code generator from crcmod import Crc g8 = 0x185 g16 = 0x11021 g24 = 0x15D6DCB g32 = 0x104C11DB7 def polyFromBits(bits): p = 0 for n in bits: p = p | (1 << n) return p # The following is from Standard ECMA-182 "Data Interchange on 12,7 mm 48-Track # Magnetic Tape Cartridges -DLT1 Format-", December 1992. g64 = polyFromBits([64, 62, 57, 55, 54, 53, 52, 47, 46, 45, 40, 39, 38, 37, 35, 33, 32, 31, 29, 27, 24, 23, 22, 21, 19, 17, 13, 12, 10, 9, 7, 4, 1, 0]) print('Generating examples.c') out = open('examples.c', 'w') out.write('''// Define the required data types typedef unsigned char UINT8; typedef unsigned short UINT16; typedef unsigned int UINT32; typedef unsigned long long UINT64; ''') Crc(g8, rev=False).generateCode('crc8',out) Crc(g8, rev=True).generateCode('crc8r',out) Crc(g16, rev=False).generateCode('crc16',out) Crc(g16, rev=True).generateCode('crc16r',out) Crc(g24, rev=False).generateCode('crc24',out) Crc(g24, rev=True).generateCode('crc24r',out) Crc(g32, rev=False).generateCode('crc32',out) Crc(g32, rev=True).generateCode('crc32r',out) Crc(g64, rev=False).generateCode('crc64',out) Crc(g64, rev=True).generateCode('crc64r',out) # Check out the XOR-out feature. Crc(g16, initCrc=0, rev=True, xorOut=~0).generateCode('crc16x',out) Crc(g24, initCrc=0, rev=True, xorOut=~0).generateCode('crc24x',out) Crc(g32, initCrc=0, rev=True, xorOut=~0).generateCode('crc32x',out) Crc(g64, initCrc=0, rev=True, xorOut=~0).generateCode('crc64x',out) out.close() print('Done')
mit
[ 18045, 199, 3, 1487, 2106, 18161, 314, 675, 402, 314, 1233, 4306, 199, 504, 18080, 1494, 492, 445, 1195, 199, 199, 71, 24, 275, 378, 88, 10233, 199, 71, 975, 275, 378, 88, 6019, 2025, 199, 71, 1194, 275, 378, 88, 1046, 36, 22, 5196, 34, 199, 71, 708, 275, 378, 88, 6785, 35, 845, 2846, 23, 199, 199, 318, 8446, 2532, 10787, 8, 5609, 304, 272, 299, 275, 378, 272, 367, 302, 315, 5821, 26, 267, 299, 275, 299, 1204, 334, 17, 5213, 302, 9, 272, 372, 299, 199, 199, 3, 710, 2569, 365, 687, 9739, 15352, 2054, 13, 12894, 298, 1451, 6551, 1461, 641, 3144, 12, 23, 8562, 9615, 13, 7927, 199, 3, 603, 29575, 764, 377, 924, 445, 580, 1677, 3389, 446, 8045, 52, 17, 9701, 13, 401, 1487, 26381, 9013, 18, 14, 199, 199, 71, 772, 275, 8446, 2532, 10787, 779, 772, 12, 16202, 12, 12699, 12, 12766, 12, 13470, 12, 13564, 12, 14589, 12, 10954, 12, 12426, 12, 10416, 12, 6335, 12, 10551, 12, 10448, 12, 6877, 12, 288, 8685, 12, 9404, 12, 4337, 12, 7105, 12, 7349, 12, 8087, 12, 5504, 12, 6546, 12, 6928, 12, 7829, 12, 5851, 12, 5557, 12, 4944, 12, 3144, 12, 1616, 12, 1749, 12, 1520, 12, 288, 841, 12, 413, 12, 378, 566, 199, 199, 1361, 360, 29244, 7251, 14, 67, 358, 199, 548, 275, 1551, 360, 8589, 14, 67, 297, 283, 87, 358, 199, 548, 14, 952, 10505, 501, 13930, 314, 1415, 666, 2943, 199, 9594, 7381, 1495, 420, 30151, 24, 27, 199, 9594, 7381, 3974, 258, 30151, 975, 27, 199, 9594, 7381, 1109, 755, 30151, 708, 27, 199, 9594, 7381, 1846, 1846, 30151, 772, 27, 199, 12310, 199, 35, 1195, 8, 71, 24, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 24, 297, 548, 9, 199, 35, 1195, 8, 71, 24, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 24, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 975, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 975, 297, 548, 9, 199, 35, 1195, 8, 71, 975, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 975, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 1194, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 1194, 297, 548, 9, 199, 35, 1195, 8, 71, 1194, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 1194, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 708, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 708, 297, 548, 9, 199, 35, 1195, 8, 71, 708, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 708, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 772, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 772, 297, 548, 9, 199, 35, 1195, 8, 71, 772, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 772, 82, 297, 548, 9, 199, 199, 3, 2670, 734, 314, 1323, 726, 13, 548, 3878, 14, 199, 35, 1195, 8, 71, 975, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 975, 88, 297, 548, 9, 199, 35, 1195, 8, 71, 1194, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 1194, 88, 297, 548, 9, 199, 35, 1195, 8, 71, 708, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 708, 88, 297, 548, 9, 199, 35, 1195, 8, 71, 772, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 772, 88, 297, 548, 9, 199, 199, 548, 14, 1600, 342, 199, 1361, 360, 10759, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1487, 2106, 18161, 314, 675, 402, 314, 1233, 4306, 199, 504, 18080, 1494, 492, 445, 1195, 199, 199, 71, 24, 275, 378, 88, 10233, 199, 71, 975, 275, 378, 88, 6019, 2025, 199, 71, 1194, 275, 378, 88, 1046, 36, 22, 5196, 34, 199, 71, 708, 275, 378, 88, 6785, 35, 845, 2846, 23, 199, 199, 318, 8446, 2532, 10787, 8, 5609, 304, 272, 299, 275, 378, 272, 367, 302, 315, 5821, 26, 267, 299, 275, 299, 1204, 334, 17, 5213, 302, 9, 272, 372, 299, 199, 199, 3, 710, 2569, 365, 687, 9739, 15352, 2054, 13, 12894, 298, 1451, 6551, 1461, 641, 3144, 12, 23, 8562, 9615, 13, 7927, 199, 3, 603, 29575, 764, 377, 924, 445, 580, 1677, 3389, 446, 8045, 52, 17, 9701, 13, 401, 1487, 26381, 9013, 18, 14, 199, 199, 71, 772, 275, 8446, 2532, 10787, 779, 772, 12, 16202, 12, 12699, 12, 12766, 12, 13470, 12, 13564, 12, 14589, 12, 10954, 12, 12426, 12, 10416, 12, 6335, 12, 10551, 12, 10448, 12, 6877, 12, 288, 8685, 12, 9404, 12, 4337, 12, 7105, 12, 7349, 12, 8087, 12, 5504, 12, 6546, 12, 6928, 12, 7829, 12, 5851, 12, 5557, 12, 4944, 12, 3144, 12, 1616, 12, 1749, 12, 1520, 12, 288, 841, 12, 413, 12, 378, 566, 199, 199, 1361, 360, 29244, 7251, 14, 67, 358, 199, 548, 275, 1551, 360, 8589, 14, 67, 297, 283, 87, 358, 199, 548, 14, 952, 10505, 501, 13930, 314, 1415, 666, 2943, 199, 9594, 7381, 1495, 420, 30151, 24, 27, 199, 9594, 7381, 3974, 258, 30151, 975, 27, 199, 9594, 7381, 1109, 755, 30151, 708, 27, 199, 9594, 7381, 1846, 1846, 30151, 772, 27, 199, 12310, 199, 35, 1195, 8, 71, 24, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 24, 297, 548, 9, 199, 35, 1195, 8, 71, 24, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 24, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 975, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 975, 297, 548, 9, 199, 35, 1195, 8, 71, 975, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 975, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 1194, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 1194, 297, 548, 9, 199, 35, 1195, 8, 71, 1194, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 1194, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 708, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 708, 297, 548, 9, 199, 35, 1195, 8, 71, 708, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 708, 82, 297, 548, 9, 199, 35, 1195, 8, 71, 772, 12, 6822, 29, 797, 680, 4208, 3034, 360, 13258, 772, 297, 548, 9, 199, 35, 1195, 8, 71, 772, 12, 6822, 29, 549, 680, 4208, 3034, 360, 13258, 772, 82, 297, 548, 9, 199, 199, 3, 2670, 734, 314, 1323, 726, 13, 548, 3878, 14, 199, 35, 1195, 8, 71, 975, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 975, 88, 297, 548, 9, 199, 35, 1195, 8, 71, 1194, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 1194, 88, 297, 548, 9, 199, 35, 1195, 8, 71, 708, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 708, 88, 297, 548, 9, 199, 35, 1195, 8, 71, 772, 12, 4205, 35, 1195, 29, 16, 12, 6822, 29, 549, 12, 31770, 2204, 29, 94, 16, 680, 4208, 3034, 360, 13258, 772, 88, 297, 548, 9, 199, 199, 548, 14, 1600, 342, 199, 1361, 360, 10759, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ryfeus/lambda-packs
Keras_tensorflow/source/tensorflow/contrib/quantization/__init__.py
178
1441
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Ops for building quantized models.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function # pylint: disable=unused-import,wildcard-import,g-bad-import-order from tensorflow.contrib.quantization.python import array_ops as quantized_array_ops from tensorflow.contrib.quantization.python.math_ops import * from tensorflow.contrib.quantization.python.nn_ops import * from tensorflow.python.ops import gen_array_ops as quantized_gen_array_ops from tensorflow.python.ops.gen_array_ops import dequantize from tensorflow.python.ops.gen_array_ops import quantize_v2 from tensorflow.python.ops.gen_array_ops import quantized_concat # pylint: enable=unused-import,wildcard-import,g-bad-import-order
mit
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 16452, 367, 10015, 13621, 7068, 1709, 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, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 16692, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 504, 3228, 14, 2828, 14, 12316, 13362, 14, 1548, 492, 1625, 63, 1483, 465, 13621, 7068, 63, 1144, 63, 1483, 199, 504, 3228, 14, 2828, 14, 12316, 13362, 14, 1548, 14, 3442, 63, 1483, 492, 627, 199, 504, 3228, 14, 2828, 14, 12316, 13362, 14, 1548, 14, 4411, 63, 1483, 492, 627, 199, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 1144, 63, 1483, 465, 13621, 7068, 63, 2268, 63, 1144, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 14, 2268, 63, 1144, 63, 1483, 492, 477, 25897, 199, 504, 3228, 14, 1548, 14, 1483, 14, 2268, 63, 1144, 63, 1483, 492, 13621, 806, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 1483, 14, 2268, 63, 1144, 63, 1483, 492, 13621, 7068, 63, 9419, 199, 3, 4287, 26, 4756, 29, 8618, 13, 646, 12, 16692, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 16452, 367, 10015, 13621, 7068, 1709, 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, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 16692, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 504, 3228, 14, 2828, 14, 12316, 13362, 14, 1548, 492, 1625, 63, 1483, 465, 13621, 7068, 63, 1144, 63, 1483, 199, 504, 3228, 14, 2828, 14, 12316, 13362, 14, 1548, 14, 3442, 63, 1483, 492, 627, 199, 504, 3228, 14, 2828, 14, 12316, 13362, 14, 1548, 14, 4411, 63, 1483, 492, 627, 199, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 1144, 63, 1483, 465, 13621, 7068, 63, 2268, 63, 1144, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 14, 2268, 63, 1144, 63, 1483, 492, 477, 25897, 199, 504, 3228, 14, 1548, 14, 1483, 14, 2268, 63, 1144, 63, 1483, 492, 13621, 806, 63, 86, 18, 199, 504, 3228, 14, 1548, 14, 1483, 14, 2268, 63, 1144, 63, 1483, 492, 13621, 7068, 63, 9419, 199, 3, 4287, 26, 4756, 29, 8618, 13, 646, 12, 16692, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
domino-team/openwrt-cc
package/gli-pub/openwrt-node-packages-master/node/node-v6.9.1/deps/v8/tools/sanitizers/sancov_merger_test.py
9
2169
# Copyright 2016 the V8 project authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import unittest import sancov_merger # Files on disk after test runner completes. The files are mapped by # executable name -> file list. FILE_MAP = { 'd8': [ 'd8.test.1.sancov', 'd8.test.2.sancov', 'd8.test.3.sancov', 'd8.test.4.sancov', 'd8.test.5.sancov', 'd8.test.6.sancov', 'd8.test.7.sancov', ], 'cctest': [ 'cctest.test.1.sancov', 'cctest.test.2.sancov', 'cctest.test.3.sancov', 'cctest.test.4.sancov', ], } # Inputs for merge process with 2 cpus. The tuples contain: # (flag, path, executable name, intermediate result index, file list). EXPECTED_INPUTS_2 = [ (False, '/some/path', 'cctest', 0, [ 'cctest.test.1.sancov', 'cctest.test.2.sancov']), (False, '/some/path', 'cctest', 1, [ 'cctest.test.3.sancov', 'cctest.test.4.sancov']), (False, '/some/path', 'd8', 0, [ 'd8.test.1.sancov', 'd8.test.2.sancov', 'd8.test.3.sancov', 'd8.test.4.sancov']), (False, '/some/path', 'd8', 1, [ 'd8.test.5.sancov', 'd8.test.6.sancov', 'd8.test.7.sancov']), ] # The same for 4 cpus. EXPECTED_INPUTS_4 = [ (True, '/some/path', 'cctest', 0, [ 'cctest.test.1.sancov', 'cctest.test.2.sancov']), (True, '/some/path', 'cctest', 1, [ 'cctest.test.3.sancov', 'cctest.test.4.sancov']), (True, '/some/path', 'd8', 0, [ 'd8.test.1.sancov', 'd8.test.2.sancov']), (True, '/some/path', 'd8', 1, [ 'd8.test.3.sancov', 'd8.test.4.sancov']), (True, '/some/path', 'd8', 2, [ 'd8.test.5.sancov', 'd8.test.6.sancov']), (True, '/some/path', 'd8', 3, [ 'd8.test.7.sancov'])] class MergerTests(unittest.TestCase): def test_generate_inputs_2_cpu(self): inputs = sancov_merger.generate_inputs( False, '/some/path', FILE_MAP, 2) self.assertEquals(EXPECTED_INPUTS_2, inputs) def test_generate_inputs_4_cpu(self): inputs = sancov_merger.generate_inputs( True, '/some/path', FILE_MAP, 4) self.assertEquals(EXPECTED_INPUTS_4, inputs)
gpl-2.0
[ 3, 1898, 7800, 314, 812, 24, 2199, 11462, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 646, 28698, 8695, 63, 2626, 836, 421, 199, 3, 16920, 641, 4543, 2410, 511, 7876, 29672, 14, 710, 1584, 787, 9994, 701, 199, 3, 7286, 536, 1035, 570, 769, 14, 199, 3817, 63, 5443, 275, 469, 523, 283, 68, 24, 356, 359, 272, 283, 68, 24, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 18, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 20, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 21, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 22, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 23, 14, 18904, 8695, 297, 523, 2156, 523, 283, 2055, 396, 356, 359, 272, 283, 2055, 396, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 18, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 20, 14, 18904, 8695, 297, 523, 2156, 199, 93, 421, 199, 3, 30520, 367, 5389, 2112, 543, 499, 24174, 14, 710, 6346, 1395, 26, 199, 3, 334, 4173, 12, 931, 12, 7286, 536, 12, 13197, 754, 1478, 12, 570, 769, 680, 199, 22358, 63, 7321, 51, 63, 18, 275, 359, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 378, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 18, 14, 18904, 8695, 3815, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 413, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 378, 12, 359, 272, 283, 68, 24, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 18, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 413, 12, 359, 272, 283, 68, 24, 14, 396, 14, 21, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 22, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 23, 14, 18904, 8695, 3815, 199, 61, 421, 199, 3, 710, 2011, 367, 841, 24174, 14, 199, 22358, 63, 7321, 51, 63, 20, 275, 359, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 378, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 18, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 413, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 378, 12, 359, 272, 283, 68, 24, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 18, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 413, 12, 359, 272, 283, 68, 24, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 499, 12, 359, 272, 283, 68, 24, 14, 396, 14, 21, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 22, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 650, 12, 359, 272, 283, 68, 24, 14, 396, 14, 23, 14, 18904, 8695, 24437, 421, 199, 533, 18880, 836, 2925, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 4208, 63, 3711, 63, 18, 63, 3541, 8, 277, 304, 272, 4153, 275, 28698, 8695, 63, 2626, 836, 14, 4208, 63, 3711, 8, 267, 756, 12, 1994, 3972, 15, 515, 297, 13024, 63, 5443, 12, 499, 9, 272, 291, 14, 2947, 8, 22358, 63, 7321, 51, 63, 18, 12, 4153, 9, 819, 347, 511, 63, 4208, 63, 3711, 63, 20, 63, 3541, 8, 277, 304, 272, 4153, 275, 28698, 8695, 63, 2626, 836, 14, 4208, 63, 3711, 8, 267, 715, 12, 1994, 3972, 15, 515, 297, 13024, 63, 5443, 12, 841, 9, 272, 291, 14, 2947, 8, 22358, 63, 7321, 51, 63, 20, 12, 4153, 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 ]
[ 1898, 7800, 314, 812, 24, 2199, 11462, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 646, 28698, 8695, 63, 2626, 836, 421, 199, 3, 16920, 641, 4543, 2410, 511, 7876, 29672, 14, 710, 1584, 787, 9994, 701, 199, 3, 7286, 536, 1035, 570, 769, 14, 199, 3817, 63, 5443, 275, 469, 523, 283, 68, 24, 356, 359, 272, 283, 68, 24, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 18, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 20, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 21, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 22, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 23, 14, 18904, 8695, 297, 523, 2156, 523, 283, 2055, 396, 356, 359, 272, 283, 2055, 396, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 18, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 20, 14, 18904, 8695, 297, 523, 2156, 199, 93, 421, 199, 3, 30520, 367, 5389, 2112, 543, 499, 24174, 14, 710, 6346, 1395, 26, 199, 3, 334, 4173, 12, 931, 12, 7286, 536, 12, 13197, 754, 1478, 12, 570, 769, 680, 199, 22358, 63, 7321, 51, 63, 18, 275, 359, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 378, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 18, 14, 18904, 8695, 3815, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 413, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 378, 12, 359, 272, 283, 68, 24, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 18, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 797, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 413, 12, 359, 272, 283, 68, 24, 14, 396, 14, 21, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 22, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 23, 14, 18904, 8695, 3815, 199, 61, 421, 199, 3, 710, 2011, 367, 841, 24174, 14, 199, 22358, 63, 7321, 51, 63, 20, 275, 359, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 378, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 18, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 2055, 396, 297, 413, 12, 359, 272, 283, 2055, 396, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 2055, 396, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 378, 12, 359, 272, 283, 68, 24, 14, 396, 14, 17, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 18, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 413, 12, 359, 272, 283, 68, 24, 14, 396, 14, 19, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 20, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 499, 12, 359, 272, 283, 68, 24, 14, 396, 14, 21, 14, 18904, 8695, 297, 272, 283, 68, 24, 14, 396, 14, 22, 14, 18904, 8695, 3815, 523, 334, 549, 12, 1994, 3972, 15, 515, 297, 283, 68, 24, 297, 650, 12, 359, 272, 283, 68, 24, 14, 396, 14, 23, 14, 18904, 8695, 24437, 421, 199, 533, 18880, 836, 2925, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 4208, 63, 3711, 63, 18, 63, 3541, 8, 277, 304, 272, 4153, 275, 28698, 8695, 63, 2626, 836, 14, 4208, 63, 3711, 8, 267, 756, 12, 1994, 3972, 15, 515, 297, 13024, 63, 5443, 12, 499, 9, 272, 291, 14, 2947, 8, 22358, 63, 7321, 51, 63, 18, 12, 4153, 9, 819, 347, 511, 63, 4208, 63, 3711, 63, 20, 63, 3541, 8, 277, 304, 272, 4153, 275, 28698, 8695, 63, 2626, 836, 14, 4208, 63, 3711, 8, 267, 715, 12, 1994, 3972, 15, 515, 297, 13024, 63, 5443, 12, 841, 9, 272, 291, 14, 2947, 8, 22358, 63, 7321, 51, 63, 20, 12, 4153, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jetruby/python-goose
goose/parsers.py
3
7697
# -*- coding: utf-8 -*- """\ This is a python port of "Goose" orignialy licensed to Gravity.com under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Python port was written by Xavier Grangier for Recrutae Gravity.com licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import lxml.html from lxml.html import soupparser from lxml import etree from copy import deepcopy from goose.text import innerTrim from goose.text import encodeValue from BeautifulSoup import UnicodeDammit class Parser(object): @classmethod def xpath_re(self, node, expression): regexp_namespace = "http://exslt.org/regular-expressions" items = node.xpath(expression, namespaces={'re': regexp_namespace}) return items @classmethod def drop_tag(self, nodes): if isinstance(nodes, list): for node in nodes: node.drop_tag() else: nodes.drop_tag() @classmethod def css_select(self, node, selector): return node.cssselect(selector) @classmethod def fromstring(self, html): html = self.decode_html(html) self.doc = lxml.html.fromstring(html) return self.doc # TODO: Switch to 'html' method @classmethod def nodeToString(self, node, method='xml'): try: return etree.tostring(node, method=method) except lxml.etree.SerialisationError: # Fix #40 return etree.tostring(node, method=method, encoding='utf-8') @classmethod def replaceTag(self, node, tag): node.tag = tag @classmethod def getElementById(self, node, idd): selector = '//*[@id="%s"]' % idd elems = node.xpath(selector) if elems: return elems[0] return None @classmethod def getElementsByTag(self, node, tag=None, attr=None, value=None, childs=False): NS = "http://exslt.org/regular-expressions" # selector = tag or '*' selector = 'descendant-or-self::%s' % (tag or '*') if attr and value: selector = '%s[re:test(@%s, "%s", "i")]' % (selector, attr, value) elems = node.xpath(selector, namespaces={"re": NS}) # remove the root node # if we have a selection tag if node in elems and (tag or childs): elems.remove(node) return elems @classmethod def appendChild(self, node, child): node.append(child) @classmethod def childNodes(self, node): return list(node) @classmethod def childNodesWithText(self, node): root = node # create the first text node # if we have some text in the node if root.text: t = lxml.html.HtmlElement() t.text = root.text t.tag = 'text' root.text = None root.insert(0, t) # loop childs for c, n in enumerate(list(root)): idx = root.index(n) # don't process texts nodes if n.tag == 'text': continue # create a text node for tail if n.tail: t = self.createElement(tag='text', text=n.tail, tail=None) root.insert(idx + 1, t) return list(root) @classmethod def textToPara(self, text): return self.fromstring(text) @classmethod def getChildren(self, node): return node.getchildren() @classmethod def getElementsByTags(self, node, tags): selector = ','.join(tags) elems = self.css_select(node, selector) # remove the root node # if we have a selection tag if node in elems: elems.remove(node) return elems @classmethod def createElement(self, tag='p', text=None, tail=None): t = lxml.html.HtmlElement() t.tag = tag t.text = text t.tail = tail return t @classmethod def getComments(self, node): return node.xpath('//comment()') @classmethod def getParent(self, node): return node.getparent() @classmethod def remove(self, node): parent = node.getparent() if parent is not None: if node.tail: prev = node.getprevious() if prev is None: if not parent.text: parent.text = '' parent.text += u' ' + node.tail else: if not prev.tail: prev.tail = '' prev.tail += u' ' + node.tail node.clear() parent.remove(node) @classmethod def getTag(self, node): return node.tag @classmethod def getText(self, node): txts = [i for i in node.itertext()] return innerTrim(u' '.join(txts).strip()) @classmethod def previousSiblings(self, node): nodes = [] for c, n in enumerate(node.itersiblings(preceding=True)): nodes.append(n) return nodes @classmethod def previousSibling(self, node): nodes = [] for c, n in enumerate(node.itersiblings(preceding=True)): nodes.append(n) if c == 0: break return nodes[0] if nodes else None @classmethod def nextSibling(self, node): nodes = [] for c, n in enumerate(node.itersiblings(preceding=False)): nodes.append(n) if c == 0: break return nodes[0] if nodes else None @classmethod def isTextNode(self, node): return True if node.tag == 'text' else False @classmethod def getAttribute(self, node, attr=None): if attr: return node.attrib.get(attr, None) return attr @classmethod def delAttribute(self, node, attr=None): if attr: _attr = node.attrib.get(attr, None) if _attr: del node.attrib[attr] @classmethod def setAttribute(self, node, attr=None, value=None): if attr and value: node.set(attr, value) @classmethod def outerHtml(self, node): e0 = node if e0.tail: e0 = deepcopy(e0) e0.tail = None return self.nodeToString(e0) @classmethod def decode_html(self, html_string): converted = UnicodeDammit(html_string, isHTML=True) if not converted.unicode: message = "Failed to detect encoding, tried [%s]" % ', '.join(converted.triedEncodings) raise StandardError(message) return converted.unicode @classmethod def combine_nodes(self, nodes): if len(nodes): if len(nodes) > 1: root = self.createElement('div') for node in nodes: self.appendChild(root, node) return root else: return nodes[0] class ParserSoup(Parser): @classmethod def fromstring(self, html): html = encodeValue(html) self.doc = soupparser.fromstring(html) return self.doc
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 19659, 199, 2765, 365, 282, 2366, 1844, 402, 298, 39, 10518, 2, 503, 1030, 2380, 89, 18233, 370, 10268, 18936, 14, 957, 199, 7138, 1373, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 199, 199, 4718, 1844, 1990, 5313, 701, 1323, 7194, 281, 598, 82, 621, 4446, 367, 799, 1556, 337, 3624, 199, 199, 5761, 18936, 14, 957, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 1014, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 646, 14490, 14, 1360, 199, 504, 14490, 14, 1360, 492, 9108, 2087, 199, 504, 14490, 492, 7559, 199, 504, 1331, 492, 14800, 199, 504, 486, 10518, 14, 505, 492, 6506, 31081, 199, 504, 486, 10518, 14, 505, 492, 3752, 1110, 199, 504, 17132, 492, 6140, 36, 28980, 421, 199, 533, 10191, 8, 785, 304, 339, 768, 3744, 272, 347, 14462, 63, 264, 8, 277, 12, 1031, 12, 3965, 304, 267, 13156, 63, 3251, 275, 298, 1014, 921, 476, 2482, 84, 14, 1308, 15, 7898, 13, 15264, 2, 267, 2974, 275, 1031, 14, 8006, 8, 5599, 12, 10747, 3713, 264, 356, 13156, 63, 3251, 1552, 267, 372, 2974, 339, 768, 3744, 272, 347, 5978, 63, 1450, 8, 277, 12, 3380, 304, 267, 340, 1228, 8, 2415, 12, 769, 304, 288, 367, 1031, 315, 3380, 26, 355, 1031, 14, 4824, 63, 1450, 342, 267, 587, 26, 288, 3380, 14, 4824, 63, 1450, 342, 339, 768, 3744, 272, 347, 11431, 63, 2416, 8, 277, 12, 1031, 12, 9759, 304, 267, 372, 1031, 14, 3919, 2416, 8, 6662, 9, 339, 768, 3744, 272, 347, 687, 875, 8, 277, 12, 3517, 304, 267, 3517, 275, 291, 14, 2708, 63, 1360, 8, 1360, 9, 267, 291, 14, 1301, 275, 14490, 14, 1360, 14, 13521, 8, 1360, 9, 267, 372, 291, 14, 1301, 339, 327, 3254, 26, 17711, 370, 283, 1360, 7, 1083, 272, 768, 3744, 272, 347, 1031, 7756, 8, 277, 12, 1031, 12, 1083, 534, 1652, 735, 267, 862, 26, 288, 372, 7559, 14, 14028, 8, 932, 12, 1083, 29, 765, 9, 267, 871, 14490, 14, 9464, 14, 3571, 374, 5263, 26, 327, 14811, 327, 2167, 288, 372, 7559, 14, 14028, 8, 932, 12, 1083, 29, 765, 12, 2644, 534, 1624, 13, 24, 358, 339, 768, 3744, 272, 347, 3350, 1931, 8, 277, 12, 1031, 12, 1947, 304, 267, 1031, 14, 1450, 275, 1947, 339, 768, 3744, 272, 347, 664, 2162, 18954, 8, 277, 12, 1031, 12, 284, 617, 304, 267, 9759, 275, 18290, 10, 14251, 344, 5961, 83, 937, 7, 450, 284, 617, 267, 20840, 275, 1031, 14, 8006, 8, 6662, 9, 267, 340, 20840, 26, 288, 372, 20840, 59, 16, 61, 267, 372, 488, 339, 768, 3744, 272, 347, 664, 13843, 1931, 8, 277, 12, 1031, 12, 1947, 29, 403, 12, 1921, 29, 403, 12, 574, 29, 403, 12, 1982, 83, 29, 797, 304, 267, 9380, 275, 298, 1014, 921, 476, 2482, 84, 14, 1308, 15, 7898, 13, 15264, 2, 267, 327, 9759, 275, 1947, 503, 13626, 267, 9759, 275, 283, 31759, 13, 269, 13, 277, 447, 5, 83, 7, 450, 334, 1450, 503, 6438, 358, 267, 340, 1921, 436, 574, 26, 288, 9759, 275, 1543, 83, 59, 264, 26, 396, 8, 19437, 83, 12, 2071, 83, 401, 298, 73, 531, 6616, 450, 334, 6662, 12, 1921, 12, 574, 9, 267, 20840, 275, 1031, 14, 8006, 8, 6662, 12, 10747, 8871, 264, 582, 9380, 1552, 267, 327, 2813, 314, 1738, 1031, 267, 327, 340, 781, 1172, 282, 7267, 1947, 267, 340, 1031, 315, 20840, 436, 334, 1450, 503, 1982, 83, 304, 288, 20840, 14, 2168, 8, 932, 9, 267, 372, 20840, 339, 768, 3744, 272, 347, 5666, 3493, 8, 277, 12, 1031, 12, 1982, 304, 267, 1031, 14, 740, 8, 1739, 9, 339, 768, 3744, 272, 347, 1982, 6300, 8, 277, 12, 1031, 304, 267, 372, 769, 8, 932, 9, 339, 768, 3744, 272, 347, 1982, 6300, 3007, 1872, 8, 277, 12, 1031, 304, 267, 1738, 275, 1031, 267, 327, 1218, 314, 1642, 1318, 1031, 267, 327, 340, 781, 1172, 2005, 1318, 315, 314, 1031, 267, 340, 1738, 14, 505, 26, 288, 307, 275, 14490, 14, 1360, 14, 12957, 2162, 342, 288, 307, 14, 505, 275, 1738, 14, 505, 288, 307, 14, 1450, 275, 283, 505, 7, 288, 1738, 14, 505, 275, 488, 288, 1738, 14, 3176, 8, 16, 12, 307, 9, 267, 327, 4438, 1982, 83, 267, 367, 286, 12, 302, 315, 3874, 8, 513, 8, 1231, 2298, 288, 4280, 275, 1738, 14, 1080, 8, 78, 9, 288, 327, 2793, 1133, 2112, 24857, 3380, 288, 340, 302, 14, 1450, 508, 283, 505, 356, 355, 1980, 288, 327, 1218, 282, 1318, 1031, 367, 9483, 288, 340, 302, 14, 1521, 26, 355, 307, 275, 291, 14, 20296, 8, 1450, 534, 505, 297, 1318, 29, 78, 14, 1521, 12, 9483, 29, 403, 9, 355, 1738, 14, 3176, 8, 2996, 435, 413, 12, 307, 9, 267, 372, 769, 8, 1231, 9, 339, 768, 3744, 272, 347, 1318, 1378, 28360, 8, 277, 12, 1318, 304, 267, 372, 291, 14, 13521, 8, 505, 9, 339, 768, 3744, 272, 347, 664, 7139, 8, 277, 12, 1031, 304, 267, 372, 1031, 14, 362, 3223, 342, 339, 768, 3744, 272, 347, 664, 13843, 9440, 8, 277, 12, 1031, 12, 3762, 304, 267, 9759, 275, 12814, 904, 8, 2969, 9, 267, 20840, 275, 291, 14, 3919, 63, 2416, 8, 932, 12, 9759, 9, 267, 327 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 19659, 199, 2765, 365, 282, 2366, 1844, 402, 298, 39, 10518, 2, 503, 1030, 2380, 89, 18233, 370, 10268, 18936, 14, 957, 199, 7138, 1373, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 199, 199, 4718, 1844, 1990, 5313, 701, 1323, 7194, 281, 598, 82, 621, 4446, 367, 799, 1556, 337, 3624, 199, 199, 5761, 18936, 14, 957, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 1014, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 646, 14490, 14, 1360, 199, 504, 14490, 14, 1360, 492, 9108, 2087, 199, 504, 14490, 492, 7559, 199, 504, 1331, 492, 14800, 199, 504, 486, 10518, 14, 505, 492, 6506, 31081, 199, 504, 486, 10518, 14, 505, 492, 3752, 1110, 199, 504, 17132, 492, 6140, 36, 28980, 421, 199, 533, 10191, 8, 785, 304, 339, 768, 3744, 272, 347, 14462, 63, 264, 8, 277, 12, 1031, 12, 3965, 304, 267, 13156, 63, 3251, 275, 298, 1014, 921, 476, 2482, 84, 14, 1308, 15, 7898, 13, 15264, 2, 267, 2974, 275, 1031, 14, 8006, 8, 5599, 12, 10747, 3713, 264, 356, 13156, 63, 3251, 1552, 267, 372, 2974, 339, 768, 3744, 272, 347, 5978, 63, 1450, 8, 277, 12, 3380, 304, 267, 340, 1228, 8, 2415, 12, 769, 304, 288, 367, 1031, 315, 3380, 26, 355, 1031, 14, 4824, 63, 1450, 342, 267, 587, 26, 288, 3380, 14, 4824, 63, 1450, 342, 339, 768, 3744, 272, 347, 11431, 63, 2416, 8, 277, 12, 1031, 12, 9759, 304, 267, 372, 1031, 14, 3919, 2416, 8, 6662, 9, 339, 768, 3744, 272, 347, 687, 875, 8, 277, 12, 3517, 304, 267, 3517, 275, 291, 14, 2708, 63, 1360, 8, 1360, 9, 267, 291, 14, 1301, 275, 14490, 14, 1360, 14, 13521, 8, 1360, 9, 267, 372, 291, 14, 1301, 339, 327, 3254, 26, 17711, 370, 283, 1360, 7, 1083, 272, 768, 3744, 272, 347, 1031, 7756, 8, 277, 12, 1031, 12, 1083, 534, 1652, 735, 267, 862, 26, 288, 372, 7559, 14, 14028, 8, 932, 12, 1083, 29, 765, 9, 267, 871, 14490, 14, 9464, 14, 3571, 374, 5263, 26, 327, 14811, 327, 2167, 288, 372, 7559, 14, 14028, 8, 932, 12, 1083, 29, 765, 12, 2644, 534, 1624, 13, 24, 358, 339, 768, 3744, 272, 347, 3350, 1931, 8, 277, 12, 1031, 12, 1947, 304, 267, 1031, 14, 1450, 275, 1947, 339, 768, 3744, 272, 347, 664, 2162, 18954, 8, 277, 12, 1031, 12, 284, 617, 304, 267, 9759, 275, 18290, 10, 14251, 344, 5961, 83, 937, 7, 450, 284, 617, 267, 20840, 275, 1031, 14, 8006, 8, 6662, 9, 267, 340, 20840, 26, 288, 372, 20840, 59, 16, 61, 267, 372, 488, 339, 768, 3744, 272, 347, 664, 13843, 1931, 8, 277, 12, 1031, 12, 1947, 29, 403, 12, 1921, 29, 403, 12, 574, 29, 403, 12, 1982, 83, 29, 797, 304, 267, 9380, 275, 298, 1014, 921, 476, 2482, 84, 14, 1308, 15, 7898, 13, 15264, 2, 267, 327, 9759, 275, 1947, 503, 13626, 267, 9759, 275, 283, 31759, 13, 269, 13, 277, 447, 5, 83, 7, 450, 334, 1450, 503, 6438, 358, 267, 340, 1921, 436, 574, 26, 288, 9759, 275, 1543, 83, 59, 264, 26, 396, 8, 19437, 83, 12, 2071, 83, 401, 298, 73, 531, 6616, 450, 334, 6662, 12, 1921, 12, 574, 9, 267, 20840, 275, 1031, 14, 8006, 8, 6662, 12, 10747, 8871, 264, 582, 9380, 1552, 267, 327, 2813, 314, 1738, 1031, 267, 327, 340, 781, 1172, 282, 7267, 1947, 267, 340, 1031, 315, 20840, 436, 334, 1450, 503, 1982, 83, 304, 288, 20840, 14, 2168, 8, 932, 9, 267, 372, 20840, 339, 768, 3744, 272, 347, 5666, 3493, 8, 277, 12, 1031, 12, 1982, 304, 267, 1031, 14, 740, 8, 1739, 9, 339, 768, 3744, 272, 347, 1982, 6300, 8, 277, 12, 1031, 304, 267, 372, 769, 8, 932, 9, 339, 768, 3744, 272, 347, 1982, 6300, 3007, 1872, 8, 277, 12, 1031, 304, 267, 1738, 275, 1031, 267, 327, 1218, 314, 1642, 1318, 1031, 267, 327, 340, 781, 1172, 2005, 1318, 315, 314, 1031, 267, 340, 1738, 14, 505, 26, 288, 307, 275, 14490, 14, 1360, 14, 12957, 2162, 342, 288, 307, 14, 505, 275, 1738, 14, 505, 288, 307, 14, 1450, 275, 283, 505, 7, 288, 1738, 14, 505, 275, 488, 288, 1738, 14, 3176, 8, 16, 12, 307, 9, 267, 327, 4438, 1982, 83, 267, 367, 286, 12, 302, 315, 3874, 8, 513, 8, 1231, 2298, 288, 4280, 275, 1738, 14, 1080, 8, 78, 9, 288, 327, 2793, 1133, 2112, 24857, 3380, 288, 340, 302, 14, 1450, 508, 283, 505, 356, 355, 1980, 288, 327, 1218, 282, 1318, 1031, 367, 9483, 288, 340, 302, 14, 1521, 26, 355, 307, 275, 291, 14, 20296, 8, 1450, 534, 505, 297, 1318, 29, 78, 14, 1521, 12, 9483, 29, 403, 9, 355, 1738, 14, 3176, 8, 2996, 435, 413, 12, 307, 9, 267, 372, 769, 8, 1231, 9, 339, 768, 3744, 272, 347, 1318, 1378, 28360, 8, 277, 12, 1318, 304, 267, 372, 291, 14, 13521, 8, 505, 9, 339, 768, 3744, 272, 347, 664, 7139, 8, 277, 12, 1031, 304, 267, 372, 1031, 14, 362, 3223, 342, 339, 768, 3744, 272, 347, 664, 13843, 9440, 8, 277, 12, 1031, 12, 3762, 304, 267, 9759, 275, 12814, 904, 8, 2969, 9, 267, 20840, 275, 291, 14, 3919, 63, 2416, 8, 932, 12, 9759, 9, 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, 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 ]
Venturi/oldcms
env/lib/python2.7/site-packages/django/db/models/aggregates.py
26
5554
""" Classes to represent the definitions of aggregate functions. """ from django.core.exceptions import FieldError from django.db.models.expressions import Func, Star from django.db.models.fields import FloatField, IntegerField __all__ = [ 'Aggregate', 'Avg', 'Count', 'Max', 'Min', 'StdDev', 'Sum', 'Variance', ] class Aggregate(Func): contains_aggregate = True name = None def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False): assert len(self.source_expressions) == 1 # Aggregates are not allowed in UPDATE queries, so ignore for_save c = super(Aggregate, self).resolve_expression(query, allow_joins, reuse, summarize) if c.source_expressions[0].contains_aggregate and not summarize: name = self.source_expressions[0].name raise FieldError("Cannot compute %s('%s'): '%s' is an aggregate" % ( c.name, name, name)) c._patch_aggregate(query) # backward-compatibility support return c @property def input_field(self): return self.source_expressions[0] @property def default_alias(self): if hasattr(self.source_expressions[0], 'name'): return '%s__%s' % (self.source_expressions[0].name, self.name.lower()) raise TypeError("Complex expressions require an alias") def get_group_by_cols(self): return [] def _patch_aggregate(self, query): """ Helper method for patching 3rd party aggregates that do not yet support the new way of subclassing. This method will be removed in Django 1.10. add_to_query(query, alias, col, source, is_summary) will be defined on legacy aggregates which, in turn, instantiates the SQL implementation of the aggregate. In all the cases found, the general implementation of add_to_query looks like: def add_to_query(self, query, alias, col, source, is_summary): klass = SQLImplementationAggregate aggregate = klass(col, source=source, is_summary=is_summary, **self.extra) query.aggregates[alias] = aggregate By supplying a known alias, we can get the SQLAggregate out of the aggregates dict, and use the sql_function and sql_template attributes to patch *this* aggregate. """ if not hasattr(self, 'add_to_query') or self.function is not None: return placeholder_alias = "_XXXXXXXX_" self.add_to_query(query, placeholder_alias, None, None, None) sql_aggregate = query.aggregates.pop(placeholder_alias) if 'sql_function' not in self.extra and hasattr(sql_aggregate, 'sql_function'): self.extra['function'] = sql_aggregate.sql_function if hasattr(sql_aggregate, 'sql_template'): self.extra['template'] = sql_aggregate.sql_template class Avg(Aggregate): function = 'AVG' name = 'Avg' def __init__(self, expression, **extra): super(Avg, self).__init__(expression, output_field=FloatField(), **extra) def convert_value(self, value, expression, connection, context): if value is None: return value return float(value) class Count(Aggregate): function = 'COUNT' name = 'Count' template = '%(function)s(%(distinct)s%(expressions)s)' def __init__(self, expression, distinct=False, **extra): if expression == '*': expression = Star() super(Count, self).__init__( expression, distinct='DISTINCT ' if distinct else '', output_field=IntegerField(), **extra) def __repr__(self): return "{}({}, distinct={})".format( self.__class__.__name__, self.arg_joiner.join(str(arg) for arg in self.source_expressions), 'False' if self.extra['distinct'] == '' else 'True', ) def convert_value(self, value, expression, connection, context): if value is None: return 0 return int(value) class Max(Aggregate): function = 'MAX' name = 'Max' class Min(Aggregate): function = 'MIN' name = 'Min' class StdDev(Aggregate): name = 'StdDev' def __init__(self, expression, sample=False, **extra): self.function = 'STDDEV_SAMP' if sample else 'STDDEV_POP' super(StdDev, self).__init__(expression, output_field=FloatField(), **extra) def __repr__(self): return "{}({}, sample={})".format( self.__class__.__name__, self.arg_joiner.join(str(arg) for arg in self.source_expressions), 'False' if self.function == 'STDDEV_POP' else 'True', ) def convert_value(self, value, expression, connection, context): if value is None: return value return float(value) class Sum(Aggregate): function = 'SUM' name = 'Sum' class Variance(Aggregate): name = 'Variance' def __init__(self, expression, sample=False, **extra): self.function = 'VAR_SAMP' if sample else 'VAR_POP' super(Variance, self).__init__(expression, output_field=FloatField(), **extra) def __repr__(self): return "{}({}, sample={})".format( self.__class__.__name__, self.arg_joiner.join(str(arg) for arg in self.source_expressions), 'False' if self.function == 'VAR_POP' else 'True', ) def convert_value(self, value, expression, connection, context): if value is None: return value return float(value)
apache-2.0
[ 624, 199, 15711, 370, 2954, 314, 10269, 402, 9531, 3423, 14, 199, 624, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 14, 992, 14, 15264, 492, 28794, 12, 1933, 285, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 11140, 792, 12, 26141, 199, 199, 363, 452, 363, 275, 359, 272, 283, 10170, 297, 283, 16650, 297, 283, 2353, 297, 283, 4261, 297, 283, 4649, 297, 283, 11976, 12680, 297, 283, 6959, 297, 283, 31805, 297, 199, 61, 421, 199, 533, 29397, 8, 7465, 304, 272, 3509, 63, 7516, 275, 715, 272, 536, 275, 488, 339, 347, 7512, 63, 5599, 8, 277, 12, 1827, 29, 403, 12, 2040, 63, 20155, 29, 549, 12, 12598, 29, 403, 12, 22301, 29, 797, 12, 367, 63, 2117, 29, 797, 304, 267, 702, 822, 8, 277, 14, 1365, 63, 15264, 9, 508, 413, 267, 327, 21369, 2335, 787, 440, 4370, 315, 17148, 9212, 12, 880, 3686, 367, 63, 2117, 267, 286, 275, 1613, 8, 10170, 12, 291, 680, 6983, 63, 5599, 8, 1131, 12, 2040, 63, 20155, 12, 12598, 12, 22301, 9, 267, 340, 286, 14, 1365, 63, 15264, 59, 16, 1055, 6134, 63, 7516, 436, 440, 22301, 26, 288, 536, 275, 291, 14, 1365, 63, 15264, 59, 16, 1055, 354, 288, 746, 27691, 480, 6612, 4526, 450, 83, 3508, 83, 735, 1543, 83, 7, 365, 376, 9531, 2, 450, 334, 355, 286, 14, 354, 12, 536, 12, 536, 430, 267, 286, 423, 2068, 63, 7516, 8, 1131, 9, 221, 327, 13388, 13, 15390, 2291, 267, 372, 286, 339, 768, 1829, 272, 347, 1324, 63, 698, 8, 277, 304, 267, 372, 291, 14, 1365, 63, 15264, 59, 16, 61, 339, 768, 1829, 272, 347, 849, 63, 3620, 8, 277, 304, 267, 340, 2688, 8, 277, 14, 1365, 63, 15264, 59, 16, 467, 283, 354, 735, 288, 372, 1543, 83, 363, 5, 83, 7, 450, 334, 277, 14, 1365, 63, 15264, 59, 16, 1055, 354, 12, 291, 14, 354, 14, 2325, 1012, 267, 746, 3146, 480, 14500, 8455, 4409, 376, 5162, 531, 339, 347, 664, 63, 923, 63, 991, 63, 4574, 8, 277, 304, 267, 372, 942, 339, 347, 485, 2068, 63, 7516, 8, 277, 12, 1827, 304, 267, 408, 267, 11642, 1083, 367, 3371, 316, 650, 6883, 17135, 27535, 626, 886, 440, 5966, 2291, 267, 314, 892, 4340, 402, 24572, 14, 961, 1083, 911, 506, 4829, 315, 5634, 413, 14, 709, 14, 398, 1050, 63, 475, 63, 1131, 8, 1131, 12, 5162, 12, 1048, 12, 1350, 12, 365, 63, 4705, 9, 911, 506, 3247, 641, 267, 12139, 27535, 1314, 12, 315, 7485, 12, 9034, 2335, 314, 5385, 4514, 402, 267, 314, 9531, 14, 1010, 1006, 314, 5560, 1911, 12, 314, 8605, 4514, 402, 267, 1050, 63, 475, 63, 1131, 10734, 2839, 26, 398, 347, 1050, 63, 475, 63, 1131, 8, 277, 12, 1827, 12, 5162, 12, 1048, 12, 1350, 12, 365, 63, 4705, 304, 288, 8531, 275, 428, 49, 2673, 575, 3117, 10170, 288, 9531, 275, 8531, 8, 761, 12, 1350, 29, 1365, 12, 365, 63, 4705, 29, 374, 63, 4705, 12, 1011, 277, 14, 2911, 9, 288, 1827, 14, 21622, 59, 3620, 61, 275, 9531, 398, 4885, 4973, 6670, 282, 6040, 5162, 12, 781, 883, 664, 314, 5385, 10170, 734, 402, 314, 267, 27535, 1211, 12, 436, 675, 314, 3875, 63, 1593, 436, 3875, 63, 1160, 3004, 267, 370, 3371, 627, 3749, 10, 9531, 14, 267, 408, 267, 340, 440, 2688, 8, 277, 12, 283, 525, 63, 475, 63, 1131, 358, 503, 291, 14, 1593, 365, 440, 488, 26, 288, 372, 398, 10069, 63, 3620, 275, 2668, 13312, 12172, 267, 291, 14, 525, 63, 475, 63, 1131, 8, 1131, 12, 10069, 63, 3620, 12, 488, 12, 488, 12, 488, 9, 267, 3875, 63, 7516, 275, 1827, 14, 21622, 14, 1935, 8, 6199, 63, 3620, 9, 267, 340, 283, 3009, 63, 1593, 7, 440, 315, 291, 14, 2911, 436, 2688, 8, 3009, 63, 7516, 12, 283, 3009, 63, 1593, 735, 288, 291, 14, 2911, 459, 1593, 418, 275, 3875, 63, 7516, 14, 3009, 63, 1593, 398, 340, 2688, 8, 3009, 63, 7516, 12, 283, 3009, 63, 1160, 735, 288, 291, 14, 2911, 459, 1160, 418, 275, 3875, 63, 7516, 14, 3009, 63, 1160, 421, 199, 533, 437, 10929, 8, 10170, 304, 272, 805, 275, 283, 6087, 39, 7, 272, 536, 275, 283, 16650, 7, 339, 347, 636, 826, 721, 277, 12, 3965, 12, 1011, 2911, 304, 267, 1613, 8, 16650, 12, 291, 2843, 826, 721, 5599, 12, 1072, 63, 698, 29, 13019, 1062, 1011, 2911, 9, 339, 347, 3957, 63, 585, 8, 277, 12, 574, 12, 3965, 12, 1950, 12, 1067, 304, 267, 340, 574, 365, 488, 26, 288, 372, 574, 267, 372, 2069, 8, 585, 9, 421, 199, 533, 14826, 8, 10170, 304, 272, 805, 275, 283, 8760, 7, 272, 536, 275, 283, 2353, 7, 272, 1978, 275, 9487, 1593, 9, 83, 12473, 12926, 9, 83, 2840, 15264, 9, 83, 3171, 339, 347, 636, 826, 721, 277, 12, 3965, 12, 15392, 29, 797, 12, 1011, 2911, 304, 267, 340, 3965, 508, 22969, 288, 3965, 275, 1933, 285, 342, 267, 1613, 8, 2353, 12, 291, 2843, 826, 721, 288, 3965, 12, 15392, 534, 13783, 28437, 283, 340, 15392, 587, 3260, 1072, 63, 698, 29, 3901, 1062, 1011, 2911, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 11491, 16037, 15392, 21146, 1674, 908, 8, 288, 291, 855, 533, 4914, 354, 3108, 288, 291, 14, 1273, 63, 904, 281, 14, 904, 8, 495, 8, 1273, 9, 367, 1680, 315, 291, 14, 1365, 63, 15264, 395, 288, 283, 797, 7, 340, 291, 14, 2911, 459, 12926, 418, 508, 2125, 587, 283, 549, 297, 267, 776, 339, 347, 3957, 63, 585, 8, 277, 12, 574, 12, 3965, 12, 1950, 12, 1067, 304, 267, 340, 574, 365, 488, 26, 288, 372, 378, 267, 372, 1109, 8, 585, 9, 421, 199, 533, 8228, 8, 10170, 304, 272, 805, 275, 283, 4283, 7, 272, 536, 275, 283, 4261, 7, 421, 199, 533, 10195, 8, 10170, 304, 272, 805, 275, 283, 4896, 7, 272, 536, 275, 283, 4649, 7, 421, 199, 533, 20992, 12680, 8, 10170, 304 ]
[ 199, 15711, 370, 2954, 314, 10269, 402, 9531, 3423, 14, 199, 624, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 14, 992, 14, 15264, 492, 28794, 12, 1933, 285, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 11140, 792, 12, 26141, 199, 199, 363, 452, 363, 275, 359, 272, 283, 10170, 297, 283, 16650, 297, 283, 2353, 297, 283, 4261, 297, 283, 4649, 297, 283, 11976, 12680, 297, 283, 6959, 297, 283, 31805, 297, 199, 61, 421, 199, 533, 29397, 8, 7465, 304, 272, 3509, 63, 7516, 275, 715, 272, 536, 275, 488, 339, 347, 7512, 63, 5599, 8, 277, 12, 1827, 29, 403, 12, 2040, 63, 20155, 29, 549, 12, 12598, 29, 403, 12, 22301, 29, 797, 12, 367, 63, 2117, 29, 797, 304, 267, 702, 822, 8, 277, 14, 1365, 63, 15264, 9, 508, 413, 267, 327, 21369, 2335, 787, 440, 4370, 315, 17148, 9212, 12, 880, 3686, 367, 63, 2117, 267, 286, 275, 1613, 8, 10170, 12, 291, 680, 6983, 63, 5599, 8, 1131, 12, 2040, 63, 20155, 12, 12598, 12, 22301, 9, 267, 340, 286, 14, 1365, 63, 15264, 59, 16, 1055, 6134, 63, 7516, 436, 440, 22301, 26, 288, 536, 275, 291, 14, 1365, 63, 15264, 59, 16, 1055, 354, 288, 746, 27691, 480, 6612, 4526, 450, 83, 3508, 83, 735, 1543, 83, 7, 365, 376, 9531, 2, 450, 334, 355, 286, 14, 354, 12, 536, 12, 536, 430, 267, 286, 423, 2068, 63, 7516, 8, 1131, 9, 221, 327, 13388, 13, 15390, 2291, 267, 372, 286, 339, 768, 1829, 272, 347, 1324, 63, 698, 8, 277, 304, 267, 372, 291, 14, 1365, 63, 15264, 59, 16, 61, 339, 768, 1829, 272, 347, 849, 63, 3620, 8, 277, 304, 267, 340, 2688, 8, 277, 14, 1365, 63, 15264, 59, 16, 467, 283, 354, 735, 288, 372, 1543, 83, 363, 5, 83, 7, 450, 334, 277, 14, 1365, 63, 15264, 59, 16, 1055, 354, 12, 291, 14, 354, 14, 2325, 1012, 267, 746, 3146, 480, 14500, 8455, 4409, 376, 5162, 531, 339, 347, 664, 63, 923, 63, 991, 63, 4574, 8, 277, 304, 267, 372, 942, 339, 347, 485, 2068, 63, 7516, 8, 277, 12, 1827, 304, 267, 408, 267, 11642, 1083, 367, 3371, 316, 650, 6883, 17135, 27535, 626, 886, 440, 5966, 2291, 267, 314, 892, 4340, 402, 24572, 14, 961, 1083, 911, 506, 4829, 315, 5634, 413, 14, 709, 14, 398, 1050, 63, 475, 63, 1131, 8, 1131, 12, 5162, 12, 1048, 12, 1350, 12, 365, 63, 4705, 9, 911, 506, 3247, 641, 267, 12139, 27535, 1314, 12, 315, 7485, 12, 9034, 2335, 314, 5385, 4514, 402, 267, 314, 9531, 14, 1010, 1006, 314, 5560, 1911, 12, 314, 8605, 4514, 402, 267, 1050, 63, 475, 63, 1131, 10734, 2839, 26, 398, 347, 1050, 63, 475, 63, 1131, 8, 277, 12, 1827, 12, 5162, 12, 1048, 12, 1350, 12, 365, 63, 4705, 304, 288, 8531, 275, 428, 49, 2673, 575, 3117, 10170, 288, 9531, 275, 8531, 8, 761, 12, 1350, 29, 1365, 12, 365, 63, 4705, 29, 374, 63, 4705, 12, 1011, 277, 14, 2911, 9, 288, 1827, 14, 21622, 59, 3620, 61, 275, 9531, 398, 4885, 4973, 6670, 282, 6040, 5162, 12, 781, 883, 664, 314, 5385, 10170, 734, 402, 314, 267, 27535, 1211, 12, 436, 675, 314, 3875, 63, 1593, 436, 3875, 63, 1160, 3004, 267, 370, 3371, 627, 3749, 10, 9531, 14, 267, 408, 267, 340, 440, 2688, 8, 277, 12, 283, 525, 63, 475, 63, 1131, 358, 503, 291, 14, 1593, 365, 440, 488, 26, 288, 372, 398, 10069, 63, 3620, 275, 2668, 13312, 12172, 267, 291, 14, 525, 63, 475, 63, 1131, 8, 1131, 12, 10069, 63, 3620, 12, 488, 12, 488, 12, 488, 9, 267, 3875, 63, 7516, 275, 1827, 14, 21622, 14, 1935, 8, 6199, 63, 3620, 9, 267, 340, 283, 3009, 63, 1593, 7, 440, 315, 291, 14, 2911, 436, 2688, 8, 3009, 63, 7516, 12, 283, 3009, 63, 1593, 735, 288, 291, 14, 2911, 459, 1593, 418, 275, 3875, 63, 7516, 14, 3009, 63, 1593, 398, 340, 2688, 8, 3009, 63, 7516, 12, 283, 3009, 63, 1160, 735, 288, 291, 14, 2911, 459, 1160, 418, 275, 3875, 63, 7516, 14, 3009, 63, 1160, 421, 199, 533, 437, 10929, 8, 10170, 304, 272, 805, 275, 283, 6087, 39, 7, 272, 536, 275, 283, 16650, 7, 339, 347, 636, 826, 721, 277, 12, 3965, 12, 1011, 2911, 304, 267, 1613, 8, 16650, 12, 291, 2843, 826, 721, 5599, 12, 1072, 63, 698, 29, 13019, 1062, 1011, 2911, 9, 339, 347, 3957, 63, 585, 8, 277, 12, 574, 12, 3965, 12, 1950, 12, 1067, 304, 267, 340, 574, 365, 488, 26, 288, 372, 574, 267, 372, 2069, 8, 585, 9, 421, 199, 533, 14826, 8, 10170, 304, 272, 805, 275, 283, 8760, 7, 272, 536, 275, 283, 2353, 7, 272, 1978, 275, 9487, 1593, 9, 83, 12473, 12926, 9, 83, 2840, 15264, 9, 83, 3171, 339, 347, 636, 826, 721, 277, 12, 3965, 12, 15392, 29, 797, 12, 1011, 2911, 304, 267, 340, 3965, 508, 22969, 288, 3965, 275, 1933, 285, 342, 267, 1613, 8, 2353, 12, 291, 2843, 826, 721, 288, 3965, 12, 15392, 534, 13783, 28437, 283, 340, 15392, 587, 3260, 1072, 63, 698, 29, 3901, 1062, 1011, 2911, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 11491, 16037, 15392, 21146, 1674, 908, 8, 288, 291, 855, 533, 4914, 354, 3108, 288, 291, 14, 1273, 63, 904, 281, 14, 904, 8, 495, 8, 1273, 9, 367, 1680, 315, 291, 14, 1365, 63, 15264, 395, 288, 283, 797, 7, 340, 291, 14, 2911, 459, 12926, 418, 508, 2125, 587, 283, 549, 297, 267, 776, 339, 347, 3957, 63, 585, 8, 277, 12, 574, 12, 3965, 12, 1950, 12, 1067, 304, 267, 340, 574, 365, 488, 26, 288, 372, 378, 267, 372, 1109, 8, 585, 9, 421, 199, 533, 8228, 8, 10170, 304, 272, 805, 275, 283, 4283, 7, 272, 536, 275, 283, 4261, 7, 421, 199, 533, 10195, 8, 10170, 304, 272, 805, 275, 283, 4896, 7, 272, 536, 275, 283, 4649, 7, 421, 199, 533, 20992, 12680, 8, 10170, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gosipyan/automation
scripts/jenkins/cloud/gerrit/gerrit_review.py
3
2296
#!/usr/bin/env python import argparse import os import sys sys.path.append(os.path.dirname(__file__)) from gerrit import GerritChange # noqa: E402 from gerrit_settings import gerrit_project_map # noqa: E402 def gerrit_review(change, label=None, vote=1, message=''): if change.gerrit_project not in gerrit_project_map(change.branch): print("Skipping - project {} not in the list of " "allowed projects ".format(change.gerrit_project)) return 1 if not change.is_current: print("Skipping - change {} is not current".format(change)) return 1 change.review(label, vote, message) return 0 def main(): parser = argparse.ArgumentParser( description='Post a Gerrit review') parser.add_argument('change', type=int, help='the Gerrit change number (e.g. 1234)') parser.add_argument('--patch', type=int, default=None, help='the Gerrit patch number (e.g. 3). If not ' 'supplied, the latest patch will be used') parser.add_argument('--label', default=None, choices=['Code-Review', 'Verified', 'Workflow', 'QE-Review'], help='a label to use for voting') parser.add_argument('--vote', default='1', choices=['-2', '-1', '0', '+1', '+2'], help='the vote value given for the label') parser.add_argument('--message', default='', help='string message to be posted with the review') parser.add_argument('--message-file', default=None, help='append file contents to the message to be ' 'posted with the review') args = parser.parse_args() message = args.message if args.message_file: with open(args.message_file) as msg_file: message += msg_file.read() change = GerritChange(str(args.change), patchset=args.patch) gerrit_review(change, args.label, args.vote, message) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 199, 199, 504, 486, 281, 11133, 492, 22261, 11133, 4001, 221, 327, 8151, 26, 662, 13314, 199, 199, 504, 486, 281, 11133, 63, 1751, 492, 486, 281, 11133, 63, 1715, 63, 1130, 221, 327, 8151, 26, 662, 13314, 421, 199, 318, 486, 281, 11133, 63, 8578, 8, 1461, 12, 1768, 29, 403, 12, 24337, 29, 17, 12, 1245, 9280, 272, 340, 1570, 14, 836, 11133, 63, 1715, 440, 315, 486, 281, 11133, 63, 1715, 63, 1130, 8, 1461, 14, 4694, 304, 267, 870, 480, 18297, 446, 2199, 1052, 440, 315, 314, 769, 402, 298, 1598, 298, 6541, 11336, 3680, 908, 8, 1461, 14, 836, 11133, 63, 1715, 430, 267, 372, 413, 339, 340, 440, 1570, 14, 374, 63, 1818, 26, 267, 870, 480, 18297, 446, 1570, 1052, 365, 440, 1453, 1674, 908, 8, 1461, 430, 267, 372, 413, 339, 1570, 14, 8578, 8, 1302, 12, 24337, 12, 1245, 9, 339, 372, 378, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 534, 6564, 282, 22261, 11133, 11248, 358, 272, 1798, 14, 525, 63, 2094, 360, 1461, 297, 730, 29, 442, 12, 717, 1720, 534, 1589, 22261, 11133, 1570, 1329, 334, 69, 14, 71, 14, 14763, 5942, 272, 1798, 14, 525, 63, 2094, 4517, 2068, 297, 730, 29, 442, 12, 717, 849, 29, 403, 12, 717, 1720, 534, 1589, 22261, 11133, 3371, 1329, 334, 69, 14, 71, 14, 650, 680, 982, 440, 283, 2490, 283, 22525, 12, 314, 8839, 3371, 911, 506, 1202, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1302, 297, 717, 849, 29, 403, 12, 717, 3415, 2968, 3034, 13, 21000, 297, 283, 3673, 4541, 297, 639, 283, 17527, 297, 283, 31668, 13, 21000, 995, 717, 1720, 534, 65, 1768, 370, 675, 367, 373, 15866, 358, 272, 1798, 14, 525, 63, 2094, 4517, 14317, 297, 717, 849, 534, 17, 297, 717, 3415, 2968, 13, 18, 297, 2475, 17, 297, 283, 16, 297, 6681, 17, 297, 6681, 18, 995, 717, 1720, 534, 1589, 24337, 574, 1627, 367, 314, 1768, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1188, 297, 717, 849, 4581, 717, 1720, 534, 875, 1245, 370, 506, 22752, 543, 314, 11248, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1188, 13, 493, 297, 717, 849, 29, 403, 12, 717, 1720, 534, 740, 570, 4072, 370, 314, 1245, 370, 506, 283, 2490, 283, 21760, 543, 314, 11248, 358, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 1245, 275, 1249, 14, 1188, 272, 340, 1249, 14, 1188, 63, 493, 26, 267, 543, 1551, 8, 589, 14, 1188, 63, 493, 9, 465, 1499, 63, 493, 26, 288, 1245, 847, 1499, 63, 493, 14, 739, 342, 339, 1570, 275, 22261, 11133, 4001, 8, 495, 8, 589, 14, 1461, 395, 3371, 409, 29, 589, 14, 2068, 9, 339, 486, 281, 11133, 63, 8578, 8, 1461, 12, 2116, 1249, 14, 1302, 12, 2116, 1249, 14, 14317, 12, 2116, 1245, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 199, 199, 504, 486, 281, 11133, 492, 22261, 11133, 4001, 221, 327, 8151, 26, 662, 13314, 199, 199, 504, 486, 281, 11133, 63, 1751, 492, 486, 281, 11133, 63, 1715, 63, 1130, 221, 327, 8151, 26, 662, 13314, 421, 199, 318, 486, 281, 11133, 63, 8578, 8, 1461, 12, 1768, 29, 403, 12, 24337, 29, 17, 12, 1245, 9280, 272, 340, 1570, 14, 836, 11133, 63, 1715, 440, 315, 486, 281, 11133, 63, 1715, 63, 1130, 8, 1461, 14, 4694, 304, 267, 870, 480, 18297, 446, 2199, 1052, 440, 315, 314, 769, 402, 298, 1598, 298, 6541, 11336, 3680, 908, 8, 1461, 14, 836, 11133, 63, 1715, 430, 267, 372, 413, 339, 340, 440, 1570, 14, 374, 63, 1818, 26, 267, 870, 480, 18297, 446, 1570, 1052, 365, 440, 1453, 1674, 908, 8, 1461, 430, 267, 372, 413, 339, 1570, 14, 8578, 8, 1302, 12, 24337, 12, 1245, 9, 339, 372, 378, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 534, 6564, 282, 22261, 11133, 11248, 358, 272, 1798, 14, 525, 63, 2094, 360, 1461, 297, 730, 29, 442, 12, 717, 1720, 534, 1589, 22261, 11133, 1570, 1329, 334, 69, 14, 71, 14, 14763, 5942, 272, 1798, 14, 525, 63, 2094, 4517, 2068, 297, 730, 29, 442, 12, 717, 849, 29, 403, 12, 717, 1720, 534, 1589, 22261, 11133, 3371, 1329, 334, 69, 14, 71, 14, 650, 680, 982, 440, 283, 2490, 283, 22525, 12, 314, 8839, 3371, 911, 506, 1202, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1302, 297, 717, 849, 29, 403, 12, 717, 3415, 2968, 3034, 13, 21000, 297, 283, 3673, 4541, 297, 639, 283, 17527, 297, 283, 31668, 13, 21000, 995, 717, 1720, 534, 65, 1768, 370, 675, 367, 373, 15866, 358, 272, 1798, 14, 525, 63, 2094, 4517, 14317, 297, 717, 849, 534, 17, 297, 717, 3415, 2968, 13, 18, 297, 2475, 17, 297, 283, 16, 297, 6681, 17, 297, 6681, 18, 995, 717, 1720, 534, 1589, 24337, 574, 1627, 367, 314, 1768, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1188, 297, 717, 849, 4581, 717, 1720, 534, 875, 1245, 370, 506, 22752, 543, 314, 11248, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1188, 13, 493, 297, 717, 849, 29, 403, 12, 717, 1720, 534, 740, 570, 4072, 370, 314, 1245, 370, 506, 283, 2490, 283, 21760, 543, 314, 11248, 358, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 1245, 275, 1249, 14, 1188, 272, 340, 1249, 14, 1188, 63, 493, 26, 267, 543, 1551, 8, 589, 14, 1188, 63, 493, 9, 465, 1499, 63, 493, 26, 288, 1245, 847, 1499, 63, 493, 14, 739, 342, 339, 1570, 275, 22261, 11133, 4001, 8, 495, 8, 589, 14, 1461, 395, 3371, 409, 29, 589, 14, 2068, 9, 339, 486, 281, 11133, 63, 8578, 8, 1461, 12, 2116, 1249, 14, 1302, 12, 2116, 1249, 14, 14317, 12, 2116, 1245, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 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, 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,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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 ]
suranap/qiime
qiime/identify_chimeric_seqs.py
15
46969
#!/usr/bin/env python # File created on 05 Oct 2009. from __future__ import division from os.path import split, basename, abspath, exists, join from subprocess import PIPE, Popen from skbio.util import remove_files from burrito.parameters import ValuedParameter from burrito.util import (which, CommandLineApplication, ResultPath, ApplicationError, ApplicationNotFoundError) from skbio.parse.sequences import parse_fasta from qiime.util import (FunctionWithParams, write_degapped_fasta_to_file, split_sequence_file_on_sample_ids_to_files) from qiime.assign_taxonomy import BlastTaxonAssigner from bfillings.formatdb import build_blast_db_from_fasta_path from bfillings.usearch import (usearch61_smallmem_cluster, usearch61_chimera_check_denovo, parse_usearch61_clusters, usearch61_chimera_check_ref) __author__ = "Greg Caporaso" __copyright__ = "Copyright 2011, The QIIME Project" __credits__ = ["Greg Caporaso", "Jens Reeder", "William Walters", "Jai Ram Rideout", "Adam Robbins-Pianka"] __license__ = "GPL" __version__ = "1.9.1-dev" __maintainer__ = "Greg Caporaso" __email__ = "gregcaporaso@gmail.com" # NOTE: The next ChimeraSlayer release will have an option to increase the number of # iterations performed. Currently the hard coded default is 100, which leads to # considerable fluctuations in the classification. As of Brian Haas recommendation # we should increase this value to (optimally to 1000, need to test if a lower value # is a good compromise) class ChimeraChecker(FunctionWithParams): """A ChimeraChecker takes a sequence collection and returns list of chimeric seqs. This is an abstract class: subclasses should implement the __call__ method. Note: sequence ids should be preserved during this process, i.e. the description lines should be saved/restored if the alignment app is destructive to them. """ Name = 'ChimeraChecker' def __init__(self, params): """Return new ChimeraChecker object with specified params. """ self.Params = params def __call__(self, seq_path, result_path=None, log_path=None): """Returns alignment from sequences. Parameters: seq_path: path to file of sequences result_path: path to file of results. If specified, should dump the result to the desired path as fasta, otherwise will return list of sequence identifiers. log_path: path to log, which should include dump of params. """ # return list of the chimeric sequences return self.getResult(seq_path) def getResult(self, seq_path): """ Must be overwritten in subclasses """ raise NotImplementedError("ChimeraChecker is an abstract class") def cleanUp(self): """ Overwrite if any clean-up is necessasry Included here so all ChimeraCheckers can call cleanUp() without having to know if it is defined for a certain sub-class. """ pass class MetaChimeraChecker(ChimeraChecker): """ """ Name = 'MetaChimeraChecker' def __init__(self, params): """ """ try: chimera_checker_constructors = \ params['chimera_checker_constructors'] except KeyError: raise ValueError("Must provide 'chimera_checker_constructors' to define %s." % self.Name) chimera_checkers = [] for constructor, constructor_params in chimera_checker_constructors: chimera_checkers.append(constructor(constructor_params)) self.chimera_checkers = chimera_checkers def getResult(self, seqs_fp): raise NotImplementedError("%s is not yet written" % self.Name) class ChimeraSlayerChimeraChecker(ChimeraChecker): """ """ # Most of the work is done in the ChimeraSlayer_app controller, # so we have a very lean Class here Name = 'ChimeraSlayerChimeraChecker' def __init__(self, params): """Return new ChimeraSlayerChimeraChecker object with specified params.""" _params = {} _params.update(params) ChimeraChecker.__init__(self, _params) def cleanUp(self): """Remove all intermediate files""" # All intermediates should be removed by app controller pass def __call__(self, seq_path, db_FASTA_fp=None, db_NAST_fp=None, result_path=None, log_path=None, min_div_ratio=None, keep_intermediates=False): """Run chimeraSlayer on input seqs.""" chimeras = get_chimeras_from_Nast_aligned( seq_path, ref_db_aligned_fp=db_NAST_fp, ref_db_fasta_fp=db_FASTA_fp, min_div_ratio=min_div_ratio, keep_intermediates=keep_intermediates) return chimeras def chimeraSlayer_identify_chimeras(seqs_fp, db_FASTA_fp=None, db_NAST_fp=None, output_fp=None, min_div_ratio=None, keep_intermediates=False): """ """ params = {} cc = ChimeraSlayerChimeraChecker(params) if output_fp: of = open(output_fp, 'w') for seq_id, parents in cc(seqs_fp, db_FASTA_fp=db_FASTA_fp, db_NAST_fp=db_NAST_fp, min_div_ratio=min_div_ratio, keep_intermediates=keep_intermediates): of.write('\t'.join([seq_id] + parents)) of.write('\n') of.close() result = None else: result = list(cc(seqs_fp, db_FASTA_fp=db_FASTA_fp, db_NAST_fp=db_NAST_fp, min_div_ratio=min_div_ratio, keep_intermediates=keep_intermediates)) if not keep_intermediates: cc.cleanUp() return result class BlastFragmentsChimeraChecker(ChimeraChecker): """ """ Name = 'BlastFragmentsChimeraChecker' def __init__(self, params): """Return new BlastFragmentsChimeraChecker object with specified params. """ _params = {'max_e_value': 1e-30, 'min_pct_id': 0.90, 'num_fragments': 3, 'taxonomy_depth': 4} _params.update(params) try: id_to_taxonomy_fp = params['id_to_taxonomy_fp'] except KeyError: raise ValueError( "id_to_taxonomy_filepath must be provided to %s" % self.Name) # Create the blast database if it hasn't been provided if 'blast_db' not in params or params['blast_db'] is None: try: reference_seqs_fp = params['reference_seqs_fp'] except KeyError: raise ValueError( "refseqs_fp or blast_db must be provided to %s" % self.Name) blast_db, self._db_files_to_remove = \ build_blast_db_from_fasta_path(reference_seqs_fp) else: blast_db = params['blast_db'] self._db_files_to_remove = [] self._taxon_assigner = BlastTaxonAssigner( {'blast_db': blast_db, 'id_to_taxonomy_filepath': id_to_taxonomy_fp, 'Max E value': _params['max_e_value'], 'Min percent identity': _params['min_pct_id'] }) ChimeraChecker.__init__(self, _params) def cleanUp(self): """ Remove temporary blast database files, if applicable """ remove_files(self._db_files_to_remove, error_on_missing=False) def _fragment_seq(self, seq): """ Returns list of n roughly equal-sized fragments of seq Modified from Python Cookbook entry comment at: http://code.activestate.com/recipes/425397/ ** This method needs to be parameterized, as there are other ways we might want to fragment sequences. For example, we might want to specify breakpoints. Currently, this will split seq into self.num_fragments roughly equal-sized fragments. """ num_fragments = self.Params['num_fragments'] results = [] start = 0 for i in range(num_fragments): # My notes: # len(seq[i::n]) gives the number of even multiples of # num_fragments exist between i (inclusive) and the end of the seq. stop = start + len(seq[i::num_fragments]) results.append(seq[start:stop]) start = stop return results def getResult(self, seq_path): """ """ # Iterate over seq_id, seq pairs from seq_path for seq_id, seq in parse_fasta(open(seq_path)): # Generate a list of fragments fragments = self._fragment_seq(seq) # Assign the taxonomy for each of the fragments taxon_assignments = \ [self._get_taxonomy(fragment) for fragment in fragments] # Test whether the taxon_assignments suggest that the # current seq is a chimera if self._is_chimeric(taxon_assignments): # If so, yield the seq_id and the list of taxon_assignments yield seq_id, taxon_assignments def _is_chimeric(self, taxon_assignments): """From list of taxon assignments, determine if sequence is chimeric ** This method needs to be parameterized, as there are other ways we might want to test for chimeras based on taxon_assignments. This method checks that taxon assignments are identical to a depth of depth (the input parameter). Assignments to 'No blast hit' are ignored, as these cannot provide evidence for a sequence being chimeric. This function considers a sequnce non-chimeric until it finds evidence that it is chimeric. Currently only the first blast hit is considered -- this is something we will want to change. When tested against a balanced test set containing 84 chimeric sequences and 84 non-chimeric sequences (precision, recall, f-measure) respectively are: @ depth=3 (0.67,0.36,0.47) @ depth=4 (0.67,0.60,0.63) @ depth=5 (0.56,0.64,0.60) """ depth = self.Params['taxonomy_depth'] # split the assignments, ignoring fragments which had no blast # result (as these cannot provide evidence for a sequence being # chimeric) split_assignments = [ta.split(';') for ta in taxon_assignments if ta != 'No blast hit'] for i in range(depth): try: assignments_at_depth_i =\ [a[i].strip() for a in split_assignments] except IndexError: # We return False if there is no information at current # depth because there is not enough information to call # the sequence chimeric return False if len(set(assignments_at_depth_i)) > 1: return True return False def _get_taxonomy(self, fragment): """ Return the taxonomy of fragment This function is awful right now, because the blast app controller takes a file. This therefore results in each fragment being written to file and subsequently cleaned up. This can be _very_ slow. I recently updated BlastTaxonAssigner to handle this better, but it will involve some re-writes here to get it all going. """ # Pass the temporary file to the taxon assigner, and get the # taxonomy and quality score back r = self._taxon_assigner(seqs=[('fragment', fragment)])['fragment'] taxonomy, quality_score = r[0], r[1] # Return the taxonomy return taxonomy def blast_fragments_identify_chimeras(seqs_fp, id_to_taxonomy_fp, reference_seqs_fp=None, blast_db=None, min_pct_id=0.90, max_e_value=1e-30, num_fragments=3, output_fp=None, taxonomy_depth=4): """ """ params = {'id_to_taxonomy_fp': id_to_taxonomy_fp, 'reference_seqs_fp': reference_seqs_fp, 'blast_db': blast_db, 'min_pct_id': min_pct_id, 'max_e_value': max_e_value, 'num_fragments': num_fragments, 'taxonomy_depth': taxonomy_depth} bcc = BlastFragmentsChimeraChecker(params) if output_fp: of = open(output_fp, 'w') for seq_id, tax_assignments in bcc(seqs_fp): of.write('\t'.join([seq_id] + tax_assignments)) of.write('\n') of.close() result = None else: result = list(bcc(seqs_fp)) bcc.cleanUp() return result # App controller for ChimeraSlayer and convenience functions class ChimeraSlayer(CommandLineApplication): """ ChimeraSlayer ApplicationController """ _command = 'ChimeraSlayer.pl' _input_handler = '_input_as_parameters' _parameters = { # multi-fasta file containing query sequences in alignment format '--query_NAST': ValuedParameter('--', Name='query_NAST', Delimiter=' ', IsPath=True), '--db_NAST': ValuedParameter('--', Name='db_NAST', Delimiter=' ', IsPath=True), '--db_FASTA': ValuedParameter('--', Name='db_FASTA', Delimiter=' ', IsPath=True), '--exec_dir': ValuedParameter('--', Name='exec_dir', Delimiter=' ', IsPath=True), '-R': ValuedParameter('-', Name='R', Delimiter=' ') } _suppress_stdout = False _suppress_stderr = False def _input_as_parameters(self, data): """ Set the input paths (a NAST aligned fasta filepath) """ # The list of values which can be passed on a per-run basis allowed_values = ['--query_NAST', '--db_NAST', '--db_FASTA', '-R'] unsupported_parameters = set(data.keys()) - set(allowed_values) if unsupported_parameters: raise ApplicationError( "Unsupported parameter(s) passed when calling ChimeraSlayer: %s" % ' '.join(unsupported_parameters)) return '' def _get_result_paths(self, data): """ Set the result paths """ result = {} inp_file_name = str(self.Parameters['--query_NAST'].Value) inp_file_name = inp_file_name.rstrip('"') inp_file_name = inp_file_name.lstrip('"') exec_dir = self.Parameters['--exec_dir'] if exec_dir.isOn(): exec_dir = str(exec_dir.Value) exec_dir = exec_dir.lstrip('"') exec_dir = exec_dir.rstrip('"') if inp_file_name[0] == '/': # path is already absolute pass else: inp_file_name = exec_dir + "/" + inp_file_name if not exists(inp_file_name + ".CPS.CPC"): raise ApplicationError("Calling ChimeraSlayer failed.") result['CPS'] = ResultPath(Path=inp_file_name + ".CPS.CPC", IsWritten=True) return result def remove_intermediate_files(self): """Remove all intermediate files.""" # tmp files are written in the current dir, # app controller always jumps into dir specified via exec_dir # Note: blast intermediates are not removed exec_dir = str(self.Parameters['--exec_dir'].Value) inp_file_name = str(self.Parameters['--query_NAST'].Value) exec_dir = exec_dir.rstrip('"') exec_dir = exec_dir.lstrip('"') inp_file_name = inp_file_name.rstrip('"') inp_file_name = inp_file_name.lstrip('"') tmp_suffixes = [".CPS", ".CPS.CPC", ".CPS_RENAST", ".CPS_RENAST.cidx", ".CPS.CPC.wTaxons", ".cidx"] cs_tmp_files = [ exec_dir + '/' + inp_file_name + x for x in tmp_suffixes] remove_files(cs_tmp_files, error_on_missing=False) db_param = self.Parameters['--db_NAST'] if db_param.isOn(): nast_db_name = str(db_param.Value) nast_db_name = nast_db_name.rstrip('"') nast_db_name = nast_db_name.lstrip('"') # Better do not remove this file since other ChimeraSlayer # instances running on the same ref set might use this file # Should be rather deleted in the calling function # remove_files([nast_db_name + ".cidx"], # error_on_missing=False) fasta_param = self.Parameters['--db_FASTA'] if fasta_param.isOn(): fasta_name = str(fasta_param.Value) fasta_name = fasta_name.rstrip('"') fasta_name = fasta_name.lstrip('"') blast_db_files = [ fasta_name + x for x in [ ".nsq", ".nin", ".nhr", ".cidx"]] remove_files(blast_db_files, error_on_missing=False) def getHelp(self): """Method that points to documentation""" help_str =\ """########################################################################################## # # Required: # # --query_NAST multi-fasta file containing query sequences in alignment format # # Common opts: # # --db_NAST db in NAST format # --db_FASTA db in fasta format (megablast formatted) # # # -n number of top matching database sequences to compare to (default 15) # -R min divergence ratio default: 1.007 # -P min percent identity among matching sequences (default: 90) # # ## parameters to tune ChimeraParentSelector: # # Scoring parameters: # -M match score (default: +5) # -N mismatch penalty (default: -4) # -Q min query coverage by matching database sequence (default: 70) # -T maximum traverses of the multiple alignment (default: 1) # # ## parameters to tune ChimeraPhyloChecker: # # # --windowSize default 50 # --windowStep default 5 # --minBS minimum bootstrap support for calling chimera (default: 90) # -S percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 10) # --num_parents_test number of potential parents to test for chimeras (default: 3) # --MAX_CHIMERA_PARENT_PER_ID Chimera/Parent alignments with perID above this are considered non-chimeras (default 100; turned off) # # ## misc opts # # --printFinalAlignments shows alignment between query sequence and pair of candidate chimera parents # --printCSalignments print ChimeraSlayer alignments in ChimeraSlayer output # --exec_dir chdir to here before running # ######################################################################################### """ return help_str # Start functions for processing output files def parse_CPS_file(lines): """Parse the CPS file from ChimeraSlayer. One line if this file look like this: ChimeraSlayer chimera_AJ007403 7000004131495956 S000469847 1.0360 99.35 100 0.9354 89.70 0 YES NAST:4595-4596 ECO:941-942 0 ChimeraSlayer 1 chimera_AJ007403 # the accession of the chimera query 2 S000387216 # reference parent A 3 S000001688 # reference parent B 4 0.9422 # divergence ratio of query to chimera (left_A, right_B) 5 90.00 # percent identity between query and chimera(left_A, right_B) 6 0 # confidence in query as a chimera related to (left_A, right_B) 7 1.0419 # divergence ratio of query to chimera (right_A, left_B) 8 99.52 # percent identity between query and chimera(right_A, left_B) 9 100 # confidence in query as a chimera related to (right_A, left_B) 10 YES # ** verdict as a chimera or not ** 11 NAST:4032-4033 # estimated approximate chimera breakpoint in NAST coordinates 12 ECO:767-768 # estimated approximate chimera breakpoint according to the E. coli unaligned reference seq coordinates """ chimeras = [] for line in lines: record = line.split() try: id = record[1] parent1 = record[2] parent2 = record[3] verdict = record[10] except IndexError: raise ValueError("Error parsing ChimeraSlayer CPS file.") if verdict == "YES": chimeras.append((id, [parent1, parent2])) return chimeras # End functions for processing output files def make_cidx_file(fp): """make a CS index file. fp: reference DB to make an index of ChimeraSlayer implicetely performs this task when the file is not already created and deletes it when done. Especially in a parallel environment it mkaes sense to manually make and delete the file. """ if which("cdbfasta"): # cdbfasta comes with the microbiometools/CS # should always be installed when using CS args = ["cdbfasta", fp] # cdbfasta write one line to stderr stdout, stderr = Popen(args, stderr=PIPE, stdout=PIPE).communicate() else: raise ApplicationNotFoundError # Start convenience functions def get_chimeras_from_Nast_aligned(seqs_fp, ref_db_aligned_fp=None, ref_db_fasta_fp=None, HALT_EXEC=False, min_div_ratio=None, keep_intermediates=False): """remove chimeras from seqs_fp using chimeraSlayer. seqs_fp: a filepath with the seqs to check in the file ref_db_aligned_fp: fp to (pynast) aligned reference sequences ref_db_fasta_fp: same seqs as above, just unaligned. Will be computed on the fly if not provided, HALT_EXEC: stop execution if true min_div_ratio: passed to ChimeraSlayer App """ files_to_remove = [] # might come in as FilePath object with quotes seqs_fp = str(seqs_fp) seqs_fp = seqs_fp.rstrip('"') seqs_fp = seqs_fp.lstrip('"') seqs_dir, new_seqs_fp = split(seqs_fp) # if fp is in current dir, we fake a dir change if seqs_dir == "": seqs_dir = "./" # Chimera Slayer puts some temp files in current dir and some in dir of input file # use exe_dir to change to dir of input file, so to have all tmp files in # one place params = {'--query_NAST': new_seqs_fp, '--exec_dir': seqs_dir} if ref_db_aligned_fp is None and ref_db_fasta_fp is None: # use default db, whose relative position to the # ChimeraSlayer binary is hardcoded pass else: if not ref_db_fasta_fp: # make degapped reference file ref_db_fasta_fp = write_degapped_fasta_to_file(parse_fasta( open(ref_db_aligned_fp))) files_to_remove.append(ref_db_fasta_fp) # use user db params.update({'--db_NAST': abspath(ref_db_aligned_fp), '--db_FASTA': abspath(ref_db_fasta_fp)}) if min_div_ratio is not None: params.update({'-R': min_div_ratio}) app = ChimeraSlayer(params=params, HALT_EXEC=HALT_EXEC) app_results = app() # this is a FilePath object in case of success. # How can we test for failure here? # if not exists(app_results['CPS']): # raise ApplicationError, "ChimeraSlayer failed. No output file." chimeras = parse_CPS_file((app_results['CPS'])) if not keep_intermediates: app.remove_intermediate_files() remove_files(files_to_remove) return chimeras def usearch61_chimera_check(input_seqs_fp, output_dir, reference_seqs_fp=None, suppress_usearch61_intermediates=False, suppress_usearch61_ref=False, suppress_usearch61_denovo=False, split_by_sampleid=False, non_chimeras_retention="union", usearch61_minh=0.28, usearch61_xn=8.0, usearch61_dn=1.4, usearch61_mindiffs=3, usearch61_mindiv=0.8, usearch61_abundance_skew=2.0, percent_id_usearch61=0.97, minlen=64, word_length=8, max_accepts=1, max_rejects=8, verbose=False, threads=1.0, HALT_EXEC=False): """ Main convenience function for usearch61 chimera checking input_seqs_fp: filepath of input fasta file. output_dir: output directory reference_seqs_fp: fasta filepath for reference chimera detection. suppress_usearch61_intermediates: Suppress retention of .uc and log files. suppress_usearch61_ref: Suppress usearch61 reference chimera detection. suppress_usearch61_denovo: Suppress usearch61 de novo chimera detection. split_by_sampleid: Split by sample ID for de novo chimera detection. non_chimeras_retention: Set to "union" or "intersection" to retain non-chimeras between de novo and reference based results. usearch61_minh: Minimum score (h) to be classified as chimera. Increasing this value tends to the number of false positives (and also sensitivity). usearch61_xn: Weight of "no" vote. Increasing this value tends to the number of false positives (and also sensitivity). usearch61_dn: Pseudo-count prior for "no" votes. (n). Increasing this value tends to the number of false positives (and also sensitivity). usearch61_mindiffs: Minimum number of diffs in a segment. Increasing this value tends to reduce the number of false positives while reducing sensitivity to very low-divergence chimeras. usearch61_mindiv: Minimum divergence, i.e. 100% - identity between the query and closest reference database sequence. Expressed as a percentage, so the default is 0.8%, which allows chimeras that are up to 99.2% similar to a reference sequence. usearch61_abundance_skew: abundance skew for de novo chimera comparisons. percent_id_usearch61: identity to cluster sequences at minlen: minimum sequence length for use with usearch61 word_length: length of nucleotide 'words' for usearch61 max_accepts: max number of accepts for hits with usearch61 max_rejects: max number of rejects for usearch61, increasing allows more sensitivity at a cost of speed threads: Specify number of threads used per core per CPU HALT_EXEC=application controller option to halt execution and print command """ """ Need to cluster sequences de novo first to get 1. abundance information and 2 consensus sequence for each cluster. Using dereplication followed by clustering does not appear to automatically update complete cluster size, will directly cluster raw seqs with the small_mem clustering option. This means without additional parsing steps to recalculate actual cluster sizes, the sizeorder option can't be used for de novo clustering and downstream chimera detection.""" files_to_remove = [] # Get absolute paths to avoid issues with calling usearch input_seqs_fp = abspath(input_seqs_fp) output_dir = abspath(output_dir) if reference_seqs_fp: reference_seqs_fp = abspath(reference_seqs_fp) log_fp = join(output_dir, "identify_chimeric_seqs.log") chimeras_fp = join(output_dir, "chimeras.txt") non_chimeras_fp = join(output_dir, "non_chimeras.txt") non_chimeras = [] chimeras = [] log_lines = {'denovo_chimeras': 0, 'denovo_non_chimeras': 0, 'ref_chimeras': 0, 'ref_non_chimeras': 0} if split_by_sampleid: if verbose: print "Splitting fasta according to SampleID..." with open(input_seqs_fp, 'U') as full_seqs: sep_fastas =split_sequence_file_on_sample_ids_to_files( full_seqs, 'fasta', output_dir) if suppress_usearch61_intermediates: files_to_remove += sep_fastas for curr_fasta in sep_fastas: curr_chimeras, curr_non_chimeras, files_to_remove, log_lines =\ identify_chimeras_usearch61(curr_fasta, output_dir, reference_seqs_fp, suppress_usearch61_intermediates, suppress_usearch61_ref, suppress_usearch61_denovo, non_chimeras_retention, usearch61_minh, usearch61_xn, usearch61_dn, usearch61_mindiffs, usearch61_mindiv, usearch61_abundance_skew, percent_id_usearch61, minlen, word_length, max_accepts, max_rejects, files_to_remove, HALT_EXEC, log_lines, verbose, threads) chimeras += curr_chimeras non_chimeras += curr_non_chimeras else: chimeras, non_chimeras, files_to_remove, log_lines =\ identify_chimeras_usearch61(input_seqs_fp, output_dir, reference_seqs_fp, suppress_usearch61_intermediates, suppress_usearch61_ref, suppress_usearch61_denovo, non_chimeras_retention, usearch61_minh, usearch61_xn, usearch61_dn, usearch61_mindiffs, usearch61_mindiv, usearch61_abundance_skew, percent_id_usearch61, minlen, word_length, max_accepts, max_rejects, files_to_remove, HALT_EXEC, log_lines, verbose, threads) # write log, non chimeras, chimeras. write_usearch61_log(log_fp, input_seqs_fp, output_dir, reference_seqs_fp, suppress_usearch61_intermediates, suppress_usearch61_ref, suppress_usearch61_denovo, split_by_sampleid, non_chimeras_retention, usearch61_minh, usearch61_xn, usearch61_dn, usearch61_mindiffs, usearch61_mindiv, usearch61_abundance_skew, percent_id_usearch61, minlen, word_length, max_accepts, max_rejects, HALT_EXEC, log_lines) chimeras_f = open(chimeras_fp, "w") non_chimeras_f = open(non_chimeras_fp, "w") for curr_chimera in chimeras: chimeras_f.write("%s\n" % curr_chimera) for curr_non_chimera in non_chimeras: non_chimeras_f.write("%s\n" % curr_non_chimera) chimeras_f.close() non_chimeras_f.close() remove_files(files_to_remove) def identify_chimeras_usearch61(input_seqs_fp, output_dir, reference_seqs_fp=None, suppress_usearch61_intermediates=False, suppress_usearch61_ref=False, suppress_usearch61_denovo=False, non_chimeras_retention="union", usearch61_minh=0.28, usearch61_xn=8.0, usearch61_dn=1.4, usearch61_mindiffs=3, usearch61_mindiv=0.8, usearch61_abundance_skew=2.0, percent_id_usearch61=0.97, minlen=64, word_length=8, max_accepts=1, max_rejects=8, files_to_remove=[], HALT_EXEC=False, log_lines={}, verbose=False, threads=1.0): """ Calls de novo, ref useach61 chimera checking, returns flagged seqs input_seqs_fp: filepath of input fasta file. output_dir: output directory reference_seqs_fp: fasta filepath for reference chimera detection. suppress_usearch61_intermediates: Suppress retention of .uc and log files. suppress_usearch61_ref: Suppress usearch61 reference chimera detection. suppress_usearch61_denovo: Suppress usearch61 de novo chimera detection. non_chimeras_retention: Set to "union" or "intersection" to retain non-chimeras between de novo and reference based results. usearch61_minh: Minimum score (h) to be classified as chimera. Increasing this value tends to the number of false positives (and also sensitivity). usearch61_xn: Weight of "no" vote. Increasing this value tends to the number of false positives (and also sensitivity). usearch61_dn: Pseudo-count prior for "no" votes. (n). Increasing this value tends to the number of false positives (and also sensitivity). usearch61_mindiffs: Minimum number of diffs in a segment. Increasing this value tends to reduce the number of false positives while reducing sensitivity to very low-divergence chimeras. usearch61_mindiv: Minimum divergence, i.e. 100% - identity between the query and closest reference database sequence. Expressed as a percentage, so the default is 0.8%, which allows chimeras that are up to 99.2% similar to a reference sequence. usearch61_abundance_skew: abundance skew for de novo chimera comparisons. percent_id_usearch61: identity to cluster sequences at minlen: minimum sequence length for use with usearch61 word_length: length of nucleotide 'words' for usearch61 max_accepts: max number of accepts for hits with usearch61 max_rejects: max number of rejects for usearch61, increasing allows more sensitivity at a cost of speed files_to_remove: list of filepaths to remove if intermediate files are to be removed. HALT_EXEC=application controller option to halt execution and print command threads: Specify number of threads used per core per CPU """ output_consensus_fp = join(output_dir, "%s_consensus_with_abundance.fasta" % basename(input_seqs_fp)) filtered_consensus_fp = join(output_dir, "%s_consensus_fixed.fasta" % basename(input_seqs_fp)) output_consensus_uc = join(output_dir, "%s_consensus_with_abundance.uc" % basename(input_seqs_fp)) smallmem_log_fp = join(output_dir, "%s_smallmem_clustered.log" % basename(input_seqs_fp)) uchime_denovo_fp = join(output_dir, "%s_chimeras_denovo.uchime" % basename(input_seqs_fp)) uchime_denovo_log_fp = join(output_dir, "%s_chimeras_denovo.log" % basename(input_seqs_fp)) uchime_ref_fp = join(output_dir, "%s_chimeras_ref.uchime" % basename(input_seqs_fp)) uchime_ref_log_fp = join(output_dir, "%s_chimeras_ref.log" % basename(input_seqs_fp)) if verbose: print "Clustering sequence %s..." % basename(input_seqs_fp) abundance_fp, app_result = usearch61_smallmem_cluster(input_seqs_fp, percent_id=percent_id_usearch61, minlen=minlen, rev=False, output_dir=output_dir, remove_usearch_logs= suppress_usearch61_intermediates, wordlength=word_length, usearch61_maxrejects=max_rejects, usearch61_maxaccepts=max_accepts, HALT_EXEC=HALT_EXEC, output_uc_filepath=output_consensus_uc, log_name=smallmem_log_fp, sizeout=True, consout_filepath=output_consensus_fp) de_novo_clusters, failures =\ parse_usearch61_clusters(open(output_consensus_uc, "U")) # RE's parsing of size=X part of label is position dependent, and only # creates this in correct format with derep and fast cluster options, # so must do manual fix of fasta for later steps. fix_abundance_labels(output_consensus_fp, filtered_consensus_fp) if suppress_usearch61_intermediates: files_to_remove.append(output_consensus_fp) files_to_remove.append(output_consensus_uc) files_to_remove.append(filtered_consensus_fp) chimeras = [] non_chimeras = [] if not suppress_usearch61_denovo: if verbose: print "De novo chimera checking %s..." % basename(input_seqs_fp) denovo_uchime_fp, app_result =\ usearch61_chimera_check_denovo(filtered_consensus_fp, uchime_denovo_fp, minlen=minlen, output_dir=output_dir, remove_usearch_logs= suppress_usearch61_intermediates, uchime_denovo_log_fp= uchime_denovo_log_fp, usearch61_minh=usearch61_minh, usearch61_xn=usearch61_xn, usearch61_dn=usearch61_dn, usearch61_mindiffs=usearch61_mindiffs, usearch61_mindiv=usearch61_mindiv, usearch61_abundance_skew= usearch61_abundance_skew, HALT_EXEC=HALT_EXEC) if suppress_usearch61_intermediates: files_to_remove.append(uchime_denovo_fp) de_novo_chimeras = get_chimera_clusters(denovo_uchime_fp) expanded_denovo_chimeras, expanded_non_denovo_chimeras =\ merge_clusters_chimeras(de_novo_clusters, set(de_novo_chimeras)) log_lines['denovo_chimeras'] += len(expanded_denovo_chimeras) log_lines['denovo_non_chimeras'] += len(expanded_non_denovo_chimeras) if not suppress_usearch61_ref: if verbose: print "Reference chimera checking %s..." % basename(input_seqs_fp) ref_uchime_fp, app_result =\ usearch61_chimera_check_ref(filtered_consensus_fp, uchime_ref_fp, reference_seqs_fp, minlen=minlen, output_dir=output_dir, remove_usearch_logs= suppress_usearch61_intermediates, uchime_ref_log_fp= uchime_ref_log_fp, usearch61_minh=usearch61_minh, usearch61_xn=usearch61_xn, usearch61_dn=usearch61_dn, usearch61_mindiffs=usearch61_mindiffs, usearch61_mindiv=usearch61_mindiv, threads=threads, HALT_EXEC=HALT_EXEC) if suppress_usearch61_intermediates: files_to_remove.append(uchime_ref_fp) ref_chimeras = get_chimera_clusters(uchime_ref_fp) expanded_ref_chimeras, expanded_non_ref_chimeras =\ merge_clusters_chimeras(de_novo_clusters, set(ref_chimeras)) log_lines['ref_chimeras'] += len(expanded_ref_chimeras) log_lines['ref_non_chimeras'] += len(expanded_non_ref_chimeras) if suppress_usearch61_ref: chimeras = expanded_denovo_chimeras non_chimeras = expanded_non_denovo_chimeras elif suppress_usearch61_denovo: chimeras = expanded_ref_chimeras non_chimeras = expanded_non_ref_chimeras else: expanded_non_denovo_chimeras = set(expanded_non_denovo_chimeras) expanded_non_ref_chimeras = set(expanded_non_ref_chimeras) expanded_denovo_chimeras = set(expanded_denovo_chimeras) expanded_ref_chimeras = set(expanded_ref_chimeras) if non_chimeras_retention == "union": non_chimeras = expanded_non_denovo_chimeras.union( expanded_non_ref_chimeras) chimeras = expanded_denovo_chimeras.intersection( expanded_ref_chimeras) else: non_chimeras = expanded_non_denovo_chimeras.intersection( expanded_non_ref_chimeras) chimeras = expanded_denovo_chimeras.union( expanded_ref_chimeras) return chimeras, non_chimeras, files_to_remove, log_lines def write_usearch61_log(log_fp, input_seqs_fp, output_dir, reference_seqs_fp, suppress_usearch61_intermediates, suppress_usearch61_ref, suppress_usearch61_denovo, split_by_sampleid, non_chimeras_retention, usearch61_minh, usearch61_xn, usearch61_dn, usearch61_mindiffs, usearch61_mindiv, usearch61_abundance_skew, percent_id_usearch61, minlen, word_length, max_accepts, max_rejects, HALT_EXEC, log_lines): """ Writes overall log data for identify_chimeric_seqs.py call log_fp: filepath to write log data. """ out_f = open(log_fp, "w") param_names = ["input_seqs_fp", "output_dir", "reference_seqs_fp", "suppress_usearch61_intermediates", "suppress_usearch61_ref", "suppress_usearch61_denovo", "split_by_sampleid", "non_chimeras_retention", "usearch61_minh", "usearch61_xn", "usearch61_dn", "usearch61_mindiffs", "usearch61_mindiv", "usearch61_abundance_skew", "percent_id_usearch61", "minlen", "word_length", "max_accepts", "max_rejects", "HALT_EXEC"] param_values = [input_seqs_fp, output_dir, reference_seqs_fp, suppress_usearch61_intermediates, suppress_usearch61_ref, suppress_usearch61_denovo, split_by_sampleid, non_chimeras_retention, usearch61_minh, usearch61_xn, usearch61_dn, usearch61_mindiffs, usearch61_mindiv, usearch61_abundance_skew, percent_id_usearch61, minlen, word_length, max_accepts, max_rejects, HALT_EXEC] for curr_param in range(len(param_names)): out_f.write("%s\t%s\n" % (param_names[curr_param], param_values[curr_param])) out_f.write("\n") for curr_line in log_lines.keys(): out_f.write("%s\t%s\n" % (curr_line, log_lines[curr_line])) out_f.close() return def fix_abundance_labels(output_consensus_fp, filtered_consensus_fp): """ puts size= part of label as second component after white space output_consensus_fp: consensus filepath with abundance data filtered_consensus_fp: output filepath name """ consensus_f = open(output_consensus_fp, "U") filtered_f = open(filtered_consensus_fp, "w") for label, seq in parse_fasta(consensus_f): fasta_label = label.split()[0] size = "size=" + label.split('size=')[1].replace(';', '') final_label = "%s;%s" % (fasta_label, size) filtered_f.write(">%s\n%s\n" % (final_label, seq)) consensus_f.close() filtered_f.close() def get_chimera_clusters(uchime_fp): """ Parses .uchime file, returns list of seq IDs flagged as chimeras uchime_fp: filepath of uchime file """ uchime_f = open(uchime_fp, "U") chimeras = [] seq_id_ix = 1 flag_ix = 17 for line in uchime_f: if line.startswith("#"): continue if len(line.strip()) == 0: continue curr_line = line.split() if curr_line[flag_ix] == "Y": chimeras.append( curr_line[seq_id_ix].split('centroid=')[1].split(';')[0]) return chimeras def merge_clusters_chimeras(de_novo_clusters, chimeras): """ Merges results of chimeras/clusters into list of chimeras, nonchimeras de_novo_clusters: dict of clusterID: seq IDs chimeras: list of chimeric seq IDs """ expanded_chimeras = [] expanded_non_chimeras = [] for curr_cluster in de_novo_clusters: curr_seq_ids = [] matches_chimera = False for curr_seq in de_novo_clusters[curr_cluster]: if curr_seq in chimeras: matches_chimera = True curr_seq_ids.append(curr_seq) if matches_chimera: expanded_chimeras += curr_seq_ids else: expanded_non_chimeras += curr_seq_ids return expanded_chimeras, expanded_non_chimeras
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3814, 2737, 641, 22528, 18365, 8937, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 747, 14, 515, 492, 3715, 12, 9593, 12, 19529, 12, 3495, 12, 4263, 199, 504, 3873, 492, 22773, 12, 13995, 199, 199, 504, 11448, 2308, 14, 1974, 492, 2813, 63, 1725, 199, 199, 504, 330, 300, 322, 475, 14, 3214, 492, 1594, 68, 4720, 199, 504, 330, 300, 322, 475, 14, 1974, 492, 334, 6777, 12, 5817, 3049, 5039, 12, 10695, 2042, 12, 1169, 13515, 547, 12, 13515, 10870, 9, 199, 504, 11448, 2308, 14, 1122, 14, 13436, 492, 2198, 63, 20309, 199, 199, 504, 31402, 1036, 14, 1974, 492, 334, 3481, 3007, 6007, 12, 2218, 63, 6458, 439, 1915, 63, 20309, 63, 475, 63, 493, 12, 717, 3715, 63, 4041, 63, 493, 63, 265, 63, 3271, 63, 1580, 63, 475, 63, 1725, 9, 199, 504, 31402, 1036, 14, 5038, 63, 20243, 492, 699, 2019, 26019, 265, 9595, 281, 199, 199, 504, 330, 4498, 780, 14, 908, 697, 492, 1900, 63, 66, 2019, 63, 697, 63, 504, 63, 20309, 63, 515, 199, 504, 330, 4498, 780, 14, 1180, 1047, 492, 334, 1180, 1047, 2976, 63, 7241, 5286, 63, 4201, 12, 1169, 675, 1047, 2976, 63, 335, 1036, 345, 63, 1074, 63, 848, 31445, 12, 1169, 2198, 63, 1180, 1047, 2976, 63, 9170, 12, 1169, 675, 1047, 2976, 63, 335, 1036, 345, 63, 1074, 63, 1121, 9, 199, 199, 363, 2502, 363, 275, 298, 39, 1135, 22516, 269, 305, 79, 2, 199, 363, 7307, 363, 275, 298, 7384, 7760, 12, 710, 1413, 41, 3465, 7290, 2, 199, 363, 22461, 363, 275, 2097, 39, 1135, 22516, 269, 305, 79, 401, 298, 42, 8764, 799, 69, 424, 401, 298, 55, 8148, 455, 644, 31185, 401, 2049, 298, 42, 5789, 820, 455, 820, 2655, 548, 401, 298, 32408, 820, 2873, 11329, 13, 10542, 3580, 65, 937, 199, 363, 1682, 363, 275, 298, 12006, 2, 199, 363, 1023, 363, 275, 298, 17, 14, 25, 14, 17, 13, 2374, 2, 199, 363, 26665, 363, 275, 298, 39, 1135, 22516, 269, 305, 79, 2, 199, 363, 2123, 363, 275, 298, 3939, 2874, 269, 305, 79, 32, 6799, 14, 957, 2, 199, 199, 3, 6944, 26, 710, 2163, 2799, 1036, 345, 51, 1897, 4683, 911, 1172, 376, 945, 370, 19781, 314, 1329, 402, 199, 3, 420, 10615, 10585, 14, 13550, 314, 7508, 1233, 68, 849, 365, 2948, 12, 1314, 27401, 370, 199, 3, 420, 8219, 6842, 2717, 918, 18012, 315, 314, 12505, 14, 3709, 402, 699, 18429, 869, 65, 305, 295, 22105, 199, 3, 420, 781, 1077, 19781, 642, 574, 370, 334, 6433, 1183, 370, 5198, 12, 1929, 370, 511, 340, 282, 5117, 574, 199, 3, 420, 365, 282, 6954, 1013, 417, 572, 9, 421, 199, 533, 2799, 1036, 345, 3048, 8, 3481, 3007, 6007, 304, 339, 408, 33, 2799, 1036, 345, 3048, 6181, 282, 3414, 3245, 436, 2529, 769, 402, 682, 1036, 1567, 5412, 83, 14, 339, 961, 365, 376, 9006, 1021, 26, 9180, 1077, 5669, 314, 636, 1250, 363, 272, 1083, 14, 339, 3390, 26, 3414, 2762, 1077, 506, 17731, 5309, 642, 2112, 12, 284, 14, 69, 14, 314, 272, 1369, 2385, 1077, 506, 6290, 15, 3911, 2908, 340, 314, 13177, 1145, 365, 272, 477, 9853, 857, 370, 3062, 14, 272, 408, 272, 2812, 275, 283, 1049, 1036, 345, 3048, 7, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 408, 1767, 892, 2799, 1036, 345, 3048, 909, 543, 2013, 1862, 14, 398, 408, 267, 291, 14, 6007, 275, 1862, 339, 347, 636, 1250, 721, 277, 12, 5412, 63, 515, 12, 754, 63, 515, 29, 403, 12, 943, 63, 515, 29, 403, 304, 267, 408, 3407, 13177, 687, 8013, 14, 398, 3897, 26, 267, 5412, 63, 515, 26, 931, 370, 570, 402, 8013, 267, 754, 63, 515, 26, 931, 370, 570, 402, 2058, 14, 982, 2013, 12, 1077, 268, 5461, 314, 754, 370, 314, 6387, 931, 465, 30544, 12, 4257, 911, 268, 372, 769, 402, 3414, 14154, 14, 267, 943, 63, 515, 26, 931, 370, 943, 12, 1314, 1077, 2387, 5461, 402, 1862, 14, 398, 408, 267, 327, 372, 769, 402, 314, 682, 1036, 1567, 8013, 267, 372, 291, 14, 362, 2889, 8, 3610, 63, 515, 9, 339, 347, 664, 2889, 8, 277, 12, 5412, 63, 515, 304, 267, 408, 9498, 506, 20200, 315, 9180, 408, 267, 746, 4279, 480, 1049, 1036, 345, 3048, 365, 376, 9006, 1021, 531, 339, 347, 3633, 1721, 8, 277, 304, 267, 408, 7259, 952, 340, 1263, 3633, 13, 384, 365, 1279, 670, 305, 651, 953, 32732, 2348, 880, 1006, 2799, 1036, 345, 1799, 1192, 883, 1240, 3633, 1721, 342, 1928, 1467, 9445, 370, 5715, 340, 652, 365, 3247, 367, 282, 9842, 1007, 13, 533, 14, 267, 408, 267, 986, 421, 199, 533, 6288, 1049, 1036, 345, 3048, 8, 1049, 1036, 345, 3048, 304, 339, 408, 408, 272, 2812, 275, 283, 3396, 1049, 1036, 345, 3048, 7, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 408, 267, 408, 398, 862, 26, 288, 682, 1036, 345, 63, 6743, 63, 1880, 83, 275, 971, 355, 1862, 459, 335, 1036, 345, 63, 6743, 63, 1880, 83, 418, 267, 871, 4067, 26, 288, 746, 1722, 480, 13757, 5647, 283, 335, 1036, 345, 63, 6743, 63, 1880, 83, 7, 370, 5627, 450, 83, 2122, 2490, 450, 291, 14, 985, 9, 398, 682, 1036, 345, 63, 32514, 275, 942, 267, 367, 3787, 12, 3787, 63, 1162, 315, 682, 1036, 345, 63, 6743, 63, 1880, 83, 26, 288, 682, 1036, 345, 63, 32514, 14, 740, 8, 1880, 8, 1880, 63, 1162, 430, 267, 291, 14, 335, 1036, 345, 63, 32514, 275, 682, 1036, 345, 63, 32514, 339, 347, 664, 2889, 8, 277, 12, 5412, 83, 63, 3997, 304, 267, 746, 4279, 3647, 83, 365, 440, 5966, 5313, 2, 450, 291, 14, 985, 9, 421, 199, 533, 2799, 1036, 345, 51, 1897, 1049, 1036, 345, 3048, 8, 1049, 1036, 345, 3048, 304, 339, 408, 408, 272, 327, 17536, 402, 314, 1736, 365, 4224, 315, 314, 2799, 1036, 345, 51, 1897, 63, 571, 7614, 12, 272, 327, 880, 781, 1172, 282, 7437, 1026, 290 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3814, 2737, 641, 22528, 18365, 8937, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 747, 14, 515, 492, 3715, 12, 9593, 12, 19529, 12, 3495, 12, 4263, 199, 504, 3873, 492, 22773, 12, 13995, 199, 199, 504, 11448, 2308, 14, 1974, 492, 2813, 63, 1725, 199, 199, 504, 330, 300, 322, 475, 14, 3214, 492, 1594, 68, 4720, 199, 504, 330, 300, 322, 475, 14, 1974, 492, 334, 6777, 12, 5817, 3049, 5039, 12, 10695, 2042, 12, 1169, 13515, 547, 12, 13515, 10870, 9, 199, 504, 11448, 2308, 14, 1122, 14, 13436, 492, 2198, 63, 20309, 199, 199, 504, 31402, 1036, 14, 1974, 492, 334, 3481, 3007, 6007, 12, 2218, 63, 6458, 439, 1915, 63, 20309, 63, 475, 63, 493, 12, 717, 3715, 63, 4041, 63, 493, 63, 265, 63, 3271, 63, 1580, 63, 475, 63, 1725, 9, 199, 504, 31402, 1036, 14, 5038, 63, 20243, 492, 699, 2019, 26019, 265, 9595, 281, 199, 199, 504, 330, 4498, 780, 14, 908, 697, 492, 1900, 63, 66, 2019, 63, 697, 63, 504, 63, 20309, 63, 515, 199, 504, 330, 4498, 780, 14, 1180, 1047, 492, 334, 1180, 1047, 2976, 63, 7241, 5286, 63, 4201, 12, 1169, 675, 1047, 2976, 63, 335, 1036, 345, 63, 1074, 63, 848, 31445, 12, 1169, 2198, 63, 1180, 1047, 2976, 63, 9170, 12, 1169, 675, 1047, 2976, 63, 335, 1036, 345, 63, 1074, 63, 1121, 9, 199, 199, 363, 2502, 363, 275, 298, 39, 1135, 22516, 269, 305, 79, 2, 199, 363, 7307, 363, 275, 298, 7384, 7760, 12, 710, 1413, 41, 3465, 7290, 2, 199, 363, 22461, 363, 275, 2097, 39, 1135, 22516, 269, 305, 79, 401, 298, 42, 8764, 799, 69, 424, 401, 298, 55, 8148, 455, 644, 31185, 401, 2049, 298, 42, 5789, 820, 455, 820, 2655, 548, 401, 298, 32408, 820, 2873, 11329, 13, 10542, 3580, 65, 937, 199, 363, 1682, 363, 275, 298, 12006, 2, 199, 363, 1023, 363, 275, 298, 17, 14, 25, 14, 17, 13, 2374, 2, 199, 363, 26665, 363, 275, 298, 39, 1135, 22516, 269, 305, 79, 2, 199, 363, 2123, 363, 275, 298, 3939, 2874, 269, 305, 79, 32, 6799, 14, 957, 2, 199, 199, 3, 6944, 26, 710, 2163, 2799, 1036, 345, 51, 1897, 4683, 911, 1172, 376, 945, 370, 19781, 314, 1329, 402, 199, 3, 420, 10615, 10585, 14, 13550, 314, 7508, 1233, 68, 849, 365, 2948, 12, 1314, 27401, 370, 199, 3, 420, 8219, 6842, 2717, 918, 18012, 315, 314, 12505, 14, 3709, 402, 699, 18429, 869, 65, 305, 295, 22105, 199, 3, 420, 781, 1077, 19781, 642, 574, 370, 334, 6433, 1183, 370, 5198, 12, 1929, 370, 511, 340, 282, 5117, 574, 199, 3, 420, 365, 282, 6954, 1013, 417, 572, 9, 421, 199, 533, 2799, 1036, 345, 3048, 8, 3481, 3007, 6007, 304, 339, 408, 33, 2799, 1036, 345, 3048, 6181, 282, 3414, 3245, 436, 2529, 769, 402, 682, 1036, 1567, 5412, 83, 14, 339, 961, 365, 376, 9006, 1021, 26, 9180, 1077, 5669, 314, 636, 1250, 363, 272, 1083, 14, 339, 3390, 26, 3414, 2762, 1077, 506, 17731, 5309, 642, 2112, 12, 284, 14, 69, 14, 314, 272, 1369, 2385, 1077, 506, 6290, 15, 3911, 2908, 340, 314, 13177, 1145, 365, 272, 477, 9853, 857, 370, 3062, 14, 272, 408, 272, 2812, 275, 283, 1049, 1036, 345, 3048, 7, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 408, 1767, 892, 2799, 1036, 345, 3048, 909, 543, 2013, 1862, 14, 398, 408, 267, 291, 14, 6007, 275, 1862, 339, 347, 636, 1250, 721, 277, 12, 5412, 63, 515, 12, 754, 63, 515, 29, 403, 12, 943, 63, 515, 29, 403, 304, 267, 408, 3407, 13177, 687, 8013, 14, 398, 3897, 26, 267, 5412, 63, 515, 26, 931, 370, 570, 402, 8013, 267, 754, 63, 515, 26, 931, 370, 570, 402, 2058, 14, 982, 2013, 12, 1077, 268, 5461, 314, 754, 370, 314, 6387, 931, 465, 30544, 12, 4257, 911, 268, 372, 769, 402, 3414, 14154, 14, 267, 943, 63, 515, 26, 931, 370, 943, 12, 1314, 1077, 2387, 5461, 402, 1862, 14, 398, 408, 267, 327, 372, 769, 402, 314, 682, 1036, 1567, 8013, 267, 372, 291, 14, 362, 2889, 8, 3610, 63, 515, 9, 339, 347, 664, 2889, 8, 277, 12, 5412, 63, 515, 304, 267, 408, 9498, 506, 20200, 315, 9180, 408, 267, 746, 4279, 480, 1049, 1036, 345, 3048, 365, 376, 9006, 1021, 531, 339, 347, 3633, 1721, 8, 277, 304, 267, 408, 7259, 952, 340, 1263, 3633, 13, 384, 365, 1279, 670, 305, 651, 953, 32732, 2348, 880, 1006, 2799, 1036, 345, 1799, 1192, 883, 1240, 3633, 1721, 342, 1928, 1467, 9445, 370, 5715, 340, 652, 365, 3247, 367, 282, 9842, 1007, 13, 533, 14, 267, 408, 267, 986, 421, 199, 533, 6288, 1049, 1036, 345, 3048, 8, 1049, 1036, 345, 3048, 304, 339, 408, 408, 272, 2812, 275, 283, 3396, 1049, 1036, 345, 3048, 7, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 408, 267, 408, 398, 862, 26, 288, 682, 1036, 345, 63, 6743, 63, 1880, 83, 275, 971, 355, 1862, 459, 335, 1036, 345, 63, 6743, 63, 1880, 83, 418, 267, 871, 4067, 26, 288, 746, 1722, 480, 13757, 5647, 283, 335, 1036, 345, 63, 6743, 63, 1880, 83, 7, 370, 5627, 450, 83, 2122, 2490, 450, 291, 14, 985, 9, 398, 682, 1036, 345, 63, 32514, 275, 942, 267, 367, 3787, 12, 3787, 63, 1162, 315, 682, 1036, 345, 63, 6743, 63, 1880, 83, 26, 288, 682, 1036, 345, 63, 32514, 14, 740, 8, 1880, 8, 1880, 63, 1162, 430, 267, 291, 14, 335, 1036, 345, 63, 32514, 275, 682, 1036, 345, 63, 32514, 339, 347, 664, 2889, 8, 277, 12, 5412, 83, 63, 3997, 304, 267, 746, 4279, 3647, 83, 365, 440, 5966, 5313, 2, 450, 291, 14, 985, 9, 421, 199, 533, 2799, 1036, 345, 51, 1897, 1049, 1036, 345, 3048, 8, 1049, 1036, 345, 3048, 304, 339, 408, 408, 272, 327, 17536, 402, 314, 1736, 365, 4224, 315, 314, 2799, 1036, 345, 51, 1897, 63, 571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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jjingrong/PONUS-1.2
venv/Lib/genericpath.py
246
3015
""" Path operations common to more than one OS Do not use directly. The OS specific modules import the appropriate functions from this module themselves. """ import os import stat __all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime', 'getsize', 'isdir', 'isfile'] # Does a path exist? # This is false for dangling symbolic links on systems that support them. def exists(path): """Test whether a path exists. Returns False for broken symbolic links""" try: os.stat(path) except os.error: return False return True # This follows symbolic links, so both islink() and isdir() can be true # for the same path ono systems that support symlinks def isfile(path): """Test whether a path is a regular file""" try: st = os.stat(path) except os.error: return False return stat.S_ISREG(st.st_mode) # Is a path a directory? # This follows symbolic links, so both islink() and isdir() # can be true for the same path on systems that support symlinks def isdir(s): """Return true if the pathname refers to an existing directory.""" try: st = os.stat(s) except os.error: return False return stat.S_ISDIR(st.st_mode) def getsize(filename): """Return the size of a file, reported by os.stat().""" return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" return os.stat(filename).st_atime def getctime(filename): """Return the metadata change time of a file, reported by os.stat().""" return os.stat(filename).st_ctime # Return the longest prefix of all list elements. def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' s1 = min(m) s2 = max(m) for i, c in enumerate(s1): if c != s2[i]: return s1[:i] return s1 # Split a path in root and extension. # The extension is everything starting at the last dot in the last # pathname component; the root is everything before that. # It is always true that root + ext == p. # Generic implementation of splitext, to be parametrized with # the separators def _splitext(p, sep, altsep, extsep): """Split the extension from a pathname. Extension is everything from the last dot to the end, ignoring leading dots. Returns "(root, ext)"; ext may be empty.""" sepIndex = p.rfind(sep) if altsep: altsepIndex = p.rfind(altsep) sepIndex = max(sepIndex, altsepIndex) dotIndex = p.rfind(extsep) if dotIndex > sepIndex: # skip all leading dots filenameIndex = sepIndex + 1 while filenameIndex < dotIndex: if p[filenameIndex] != extsep: return p[:dotIndex], p[dotIndex:] filenameIndex += 1 return p, ''
mit
[ 624, 199, 2042, 5331, 2863, 370, 1655, 2419, 1373, 4403, 199, 2585, 440, 675, 5370, 14, 221, 710, 4403, 2488, 4621, 492, 314, 5827, 199, 5777, 687, 642, 859, 17279, 14, 199, 624, 199, 646, 747, 199, 646, 5672, 199, 199, 363, 452, 363, 275, 788, 2330, 1861, 297, 283, 2444, 297, 283, 362, 27867, 297, 283, 362, 20691, 297, 283, 26628, 297, 1779, 283, 20733, 297, 283, 6027, 297, 283, 6292, 418, 421, 199, 3, 12078, 282, 931, 2187, 31, 199, 3, 961, 365, 3055, 367, 366, 26896, 13673, 6220, 641, 10460, 626, 2291, 3062, 14, 199, 318, 3495, 8, 515, 304, 272, 408, 774, 3775, 282, 931, 3495, 14, 221, 1803, 756, 367, 10529, 13673, 6220, 624, 272, 862, 26, 267, 747, 14, 3736, 8, 515, 9, 272, 871, 747, 14, 705, 26, 267, 372, 756, 272, 372, 715, 421, 199, 3, 961, 11924, 13673, 6220, 12, 880, 3865, 365, 1073, 342, 436, 26004, 342, 883, 506, 2549, 199, 3, 367, 314, 2011, 931, 641, 79, 10460, 626, 2291, 19891, 199, 318, 29214, 8, 515, 304, 272, 408, 774, 3775, 282, 931, 365, 282, 5578, 570, 624, 272, 862, 26, 267, 410, 275, 747, 14, 3736, 8, 515, 9, 272, 871, 747, 14, 705, 26, 267, 372, 756, 272, 372, 5672, 14, 51, 63, 1311, 5616, 8, 270, 14, 270, 63, 632, 9, 421, 199, 3, 6596, 282, 931, 282, 2082, 31, 199, 3, 961, 11924, 13673, 6220, 12, 880, 3865, 365, 1073, 342, 436, 26004, 342, 199, 3, 883, 506, 2549, 367, 314, 2011, 931, 641, 10460, 626, 2291, 19891, 199, 318, 26004, 8, 83, 304, 272, 408, 1767, 2549, 340, 314, 11776, 15724, 370, 376, 3411, 2082, 1041, 272, 862, 26, 267, 410, 275, 747, 14, 3736, 8, 83, 9, 272, 871, 747, 14, 705, 26, 267, 372, 756, 272, 372, 5672, 14, 51, 63, 1311, 3022, 8, 270, 14, 270, 63, 632, 9, 421, 199, 318, 664, 890, 8, 1501, 304, 272, 408, 1767, 314, 1568, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 890, 421, 199, 318, 664, 8180, 8, 1501, 304, 272, 408, 1767, 314, 2061, 7100, 900, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 8180, 421, 199, 318, 664, 27867, 8, 1501, 304, 272, 408, 1767, 314, 2061, 2879, 900, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 27867, 421, 199, 318, 664, 20691, 8, 1501, 304, 272, 408, 1767, 314, 3341, 1570, 900, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 20691, 421, 199, 3, 1432, 314, 21303, 2403, 402, 1006, 769, 4008, 14, 199, 318, 2863, 1861, 8, 77, 304, 272, 298, 13735, 282, 769, 402, 931, 1247, 12, 2529, 314, 21303, 2863, 9186, 3931, 2, 272, 340, 440, 333, 26, 372, 2125, 272, 308, 17, 275, 1748, 8, 77, 9, 272, 308, 18, 275, 1390, 8, 77, 9, 272, 367, 284, 12, 286, 315, 3874, 8, 83, 17, 304, 267, 340, 286, 1137, 308, 18, 59, 73, 2189, 288, 372, 308, 17, 1491, 73, 61, 272, 372, 308, 17, 199, 199, 3, 11740, 282, 931, 315, 1738, 436, 3329, 14, 199, 3, 710, 3329, 365, 8137, 6617, 737, 314, 2061, 6308, 315, 314, 2061, 199, 3, 11776, 3931, 27, 314, 1738, 365, 8137, 2544, 626, 14, 199, 3, 2779, 365, 3544, 2549, 626, 1738, 435, 1599, 508, 299, 14, 199, 199, 3, 8307, 4514, 402, 2249, 7699, 12, 370, 506, 18117, 599, 7068, 543, 199, 3, 314, 17658, 199, 318, 485, 7973, 8, 80, 12, 7375, 12, 8791, 4127, 12, 1599, 4127, 304, 272, 408, 8862, 314, 3329, 687, 282, 11776, 14, 339, 13282, 365, 8137, 687, 314, 2061, 6308, 370, 314, 1284, 12, 17289, 272, 9186, 21185, 14, 221, 1803, 7340, 1231, 12, 1599, 2924, 27, 1599, 1443, 506, 2701, 1041, 339, 7375, 2681, 275, 299, 14, 14542, 8, 4127, 9, 272, 340, 8791, 4127, 26, 267, 8791, 4127, 2681, 275, 299, 14, 14542, 8, 4478, 4127, 9, 267, 7375, 2681, 275, 1390, 8, 4127, 2681, 12, 8791, 4127, 2681, 9, 339, 6308, 2681, 275, 299, 14, 14542, 8, 832, 4127, 9, 272, 340, 6308, 2681, 690, 7375, 2681, 26, 267, 327, 3372, 1006, 9186, 21185, 267, 1788, 2681, 275, 7375, 2681, 435, 413, 267, 1830, 1788, 2681, 665, 6308, 2681, 26, 288, 340, 299, 59, 1501, 2681, 61, 1137, 1599, 4127, 26, 355, 372, 299, 1491, 3287, 2681, 467, 299, 59, 3287, 2681, 2938, 288, 1788, 2681, 847, 413, 339, 372, 299, 12, 2125, 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 ]
[ 199, 2042, 5331, 2863, 370, 1655, 2419, 1373, 4403, 199, 2585, 440, 675, 5370, 14, 221, 710, 4403, 2488, 4621, 492, 314, 5827, 199, 5777, 687, 642, 859, 17279, 14, 199, 624, 199, 646, 747, 199, 646, 5672, 199, 199, 363, 452, 363, 275, 788, 2330, 1861, 297, 283, 2444, 297, 283, 362, 27867, 297, 283, 362, 20691, 297, 283, 26628, 297, 1779, 283, 20733, 297, 283, 6027, 297, 283, 6292, 418, 421, 199, 3, 12078, 282, 931, 2187, 31, 199, 3, 961, 365, 3055, 367, 366, 26896, 13673, 6220, 641, 10460, 626, 2291, 3062, 14, 199, 318, 3495, 8, 515, 304, 272, 408, 774, 3775, 282, 931, 3495, 14, 221, 1803, 756, 367, 10529, 13673, 6220, 624, 272, 862, 26, 267, 747, 14, 3736, 8, 515, 9, 272, 871, 747, 14, 705, 26, 267, 372, 756, 272, 372, 715, 421, 199, 3, 961, 11924, 13673, 6220, 12, 880, 3865, 365, 1073, 342, 436, 26004, 342, 883, 506, 2549, 199, 3, 367, 314, 2011, 931, 641, 79, 10460, 626, 2291, 19891, 199, 318, 29214, 8, 515, 304, 272, 408, 774, 3775, 282, 931, 365, 282, 5578, 570, 624, 272, 862, 26, 267, 410, 275, 747, 14, 3736, 8, 515, 9, 272, 871, 747, 14, 705, 26, 267, 372, 756, 272, 372, 5672, 14, 51, 63, 1311, 5616, 8, 270, 14, 270, 63, 632, 9, 421, 199, 3, 6596, 282, 931, 282, 2082, 31, 199, 3, 961, 11924, 13673, 6220, 12, 880, 3865, 365, 1073, 342, 436, 26004, 342, 199, 3, 883, 506, 2549, 367, 314, 2011, 931, 641, 10460, 626, 2291, 19891, 199, 318, 26004, 8, 83, 304, 272, 408, 1767, 2549, 340, 314, 11776, 15724, 370, 376, 3411, 2082, 1041, 272, 862, 26, 267, 410, 275, 747, 14, 3736, 8, 83, 9, 272, 871, 747, 14, 705, 26, 267, 372, 756, 272, 372, 5672, 14, 51, 63, 1311, 3022, 8, 270, 14, 270, 63, 632, 9, 421, 199, 318, 664, 890, 8, 1501, 304, 272, 408, 1767, 314, 1568, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 890, 421, 199, 318, 664, 8180, 8, 1501, 304, 272, 408, 1767, 314, 2061, 7100, 900, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 8180, 421, 199, 318, 664, 27867, 8, 1501, 304, 272, 408, 1767, 314, 2061, 2879, 900, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 27867, 421, 199, 318, 664, 20691, 8, 1501, 304, 272, 408, 1767, 314, 3341, 1570, 900, 402, 282, 570, 12, 14581, 701, 747, 14, 3736, 20693, 272, 372, 747, 14, 3736, 8, 1501, 680, 270, 63, 20691, 421, 199, 3, 1432, 314, 21303, 2403, 402, 1006, 769, 4008, 14, 199, 318, 2863, 1861, 8, 77, 304, 272, 298, 13735, 282, 769, 402, 931, 1247, 12, 2529, 314, 21303, 2863, 9186, 3931, 2, 272, 340, 440, 333, 26, 372, 2125, 272, 308, 17, 275, 1748, 8, 77, 9, 272, 308, 18, 275, 1390, 8, 77, 9, 272, 367, 284, 12, 286, 315, 3874, 8, 83, 17, 304, 267, 340, 286, 1137, 308, 18, 59, 73, 2189, 288, 372, 308, 17, 1491, 73, 61, 272, 372, 308, 17, 199, 199, 3, 11740, 282, 931, 315, 1738, 436, 3329, 14, 199, 3, 710, 3329, 365, 8137, 6617, 737, 314, 2061, 6308, 315, 314, 2061, 199, 3, 11776, 3931, 27, 314, 1738, 365, 8137, 2544, 626, 14, 199, 3, 2779, 365, 3544, 2549, 626, 1738, 435, 1599, 508, 299, 14, 199, 199, 3, 8307, 4514, 402, 2249, 7699, 12, 370, 506, 18117, 599, 7068, 543, 199, 3, 314, 17658, 199, 318, 485, 7973, 8, 80, 12, 7375, 12, 8791, 4127, 12, 1599, 4127, 304, 272, 408, 8862, 314, 3329, 687, 282, 11776, 14, 339, 13282, 365, 8137, 687, 314, 2061, 6308, 370, 314, 1284, 12, 17289, 272, 9186, 21185, 14, 221, 1803, 7340, 1231, 12, 1599, 2924, 27, 1599, 1443, 506, 2701, 1041, 339, 7375, 2681, 275, 299, 14, 14542, 8, 4127, 9, 272, 340, 8791, 4127, 26, 267, 8791, 4127, 2681, 275, 299, 14, 14542, 8, 4478, 4127, 9, 267, 7375, 2681, 275, 1390, 8, 4127, 2681, 12, 8791, 4127, 2681, 9, 339, 6308, 2681, 275, 299, 14, 14542, 8, 832, 4127, 9, 272, 340, 6308, 2681, 690, 7375, 2681, 26, 267, 327, 3372, 1006, 9186, 21185, 267, 1788, 2681, 275, 7375, 2681, 435, 413, 267, 1830, 1788, 2681, 665, 6308, 2681, 26, 288, 340, 299, 59, 1501, 2681, 61, 1137, 1599, 4127, 26, 355, 372, 299, 1491, 3287, 2681, 467, 299, 59, 3287, 2681, 2938, 288, 1788, 2681, 847, 413, 339, 372, 299, 12, 2125, 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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 0, 0, 0, 0, 0, 0, 0 ]
MAECProject/maec-to-oval
cybox_oval_mappings.py
1
10331
#MAEC -> OVAL Translator #v0.94 BETA #Generic mappings class #Generates OVAL tests/objects/states from a CybOX Defined Object import oval57 as oval class cybox_oval_mappings(object): def __init__(self, id_namespace): self.test_id_base = 0 self.obj_id_base = 0 self.ste_id_base = 0 self.def_id_base = 0 self.id_namespace = id_namespace #Mappings #CybOX Condition to OVAL operation mappings self.operator_condition_mappings = {'Equals':'equals','DoesNotEqual':'not equal','Contains':'pattern match',\ 'GreaterThan':'greater than', 'GreaterThanOrEqual':'greater than or equal',\ 'LessThan':'less than','LessThanOrEqual':'less than or equal','FitsPattern':'pattern match',\ 'BitwiseAnd':'bitwise and', 'BitwiseOr':'bitwise or'} #CybOX Object Type to OVAL object mappings self.object_mappings = {'WinRegistryKeyObj:WindowsRegistryKeyObjectType':'registry_object', 'FileObj:FileObjectType':'file_object', 'WinFileObj:WindowsFileObjectType':'file_object', 'WinExecutableFileObj:WindowsExecutableFileObjectType':'file_object'} #CybOX FileObject to OVAL file_object mappings (CybOX element name : {OVAL element name, OVAL element datatype}) self.file_object_mappings = {'File_Path':{'name':'path','datatype':'string'},'Full_Path':{'name':'filepath','datatype':'string'}, 'File_Name':{'name':'filename', 'datatype':'string'}} #CybOX FileObject to OVAL file_state mappings self.file_state_mappings = {'Size_In_Bytes':{'name':'size','datatype':'int'},'Accessed_Time':{'name':'a_time','datatype':'int'},\ 'Modified_Time':{'name':'m_time','datatype':'int'},'Created_Time':{'name':'c_time','datatype':'int'}} #CybOX WinRegistryObject to OVAL registry_object mappings self.registry_object_mappings = {'Key':{'name':'key','datatype':'string'},'Hive':{'name':'hive','datatype':'string'},'Name':{'name':'name','datatype':'string'}} #CybOX WinRegistryObject Values to OVAL registry_state mappings self.registry_state_mappings = {'Name':{'name':'name','datatype':'string'},'Data':{'name':'value','datatype':'string'},'Datatype':{'name':'type','datatype':'string'}} #Creates and returns a dictionary of OVAL test, object, and state (if applicable) def create_oval(self, cybox_defined_object, reference): oval_entities = {} oval_states = [] object_type = cybox_defined_object._XSI_NS + ':' + cybox_defined_object._XSI_TYPE if object_type in self.object_mappings.keys(): oval_object = self.create_oval_object(object_type, cybox_defined_object) if oval_object is not None: if object_type == 'WinRegistryKeyObj:WindowsRegistryKeyObjectType': self.process_registry_values(cybox_defined_object, oval_object, oval_states) else: state = self.create_oval_state(object_type, cybox_defined_object) if state is not None: oval_states.append(self.create_oval_state(object_type, cybox_defined_object)) oval_test = self.create_oval_test(object_type, oval_object, oval_entities, oval_states, reference) oval_entities['test'] = oval_test oval_entities['object'] = oval_object if oval_states is not None and len(oval_states) > 0: oval_entities['state'] = oval_states return oval_entities else: return None #Create the OVAL object def create_oval_object(self, object_type, cybox_defined_object): oval_object_type = self.object_mappings.get(object_type) oval_object_mappings = self.object_mappings.get(object_type) + '_mappings' oval_object = getattr(oval,oval_object_type)() oval_object.set_id(self.generate_obj_id()) oval_object.set_version(1) object_fields = cybox_defined_object._fields # File Object related corner cases if "File" in object_type: if object_fields["Full_Path"]: del object_fields["File_Name"] del object_fields["File_Path"] # Corner case where file_path is meant to be used as the full path to the file elif object_fields["File_Path"] and (not object_fields["Full_Path"] and not object_fields["File_Name"]): object_fields["Full_Path"] = object_fields["File_Path"] del object_fields["File_Path"] for element, value in object_fields.items(): if value is not None: if element in getattr(getattr(self,oval_object_mappings),'keys')(): element_dictionary = getattr(getattr(self,oval_object_mappings),'get')(element) element_name = element_dictionary.get('name') element_datatype = element_dictionary.get('datatype') method = 'set_' + element_name getattr(oval_object,method)(oval.EntityBaseType(datatype = element_datatype, operation = self.operator_condition_mappings.get(value), valueOf_=value)) #Do some basic object sanity checking for certain objects if object_type == 'WinRegistryKeyObj:WindowsRegistryKeyObjectType' and (oval_object.hive is None or oval_object.key is None): return None elif 'FileObjectType' in object_type and (oval_object.filepath is None and (oval_object.path is None or oval_object.filename is None)): return None return oval_object #Create any OVAL states def create_oval_state(self, object_type, cybox_defined_object): oval_state_type = self.object_mappings.get(object_type).split('_')[0] + '_state' oval_state_mappings = oval_state_type + '_mappings' oval_state = getattr(oval,oval_state_type)(version = 1, id = self.generate_ste_id()) oval_state.set_id(self.generate_ste_id()) object_fields = cybox_defined_object._fields for element, value in object_fields.items(): if value is not None: if element in getattr(getattr(self,oval_state_mappings),'keys')(): element_dictionary = getattr(getattr(self,oval_state_mappings),'get')(element) element_name = element_dictionary.get('name') element_datatype = element_dictionary.get('datatype') method = 'set_' + element_name getattr(oval_state,method)(oval.EntityBaseType(datatype = element_datatype, operation = self.operator_condition_mappings.get(value), valueOf_=value.value)) if oval_state.hasContent_(): return oval_state #Create the OVAL test def create_oval_test(self, object_type, oval_object, oval_entities, oval_states, reference = None): oval_test_type = self.object_mappings.get(object_type).split('_')[0] + '_test' #Create the test comment = 'OVAL Test created from MAEC Action ' + reference oval_test = getattr(oval,oval_test_type)(id = self.generate_test_id(), check = 'at least one', version=1.0, comment = comment) oval_test.set_object(oval.ObjectRefType(object_ref = oval_object.get_id())) if len(oval_states) > 0: for state in oval_states: if state is not None: oval_test.add_state(oval.StateRefType(state_ref = state.get_id())) return oval_test #Handle any Values inside a Registry object def process_registry_values(self, cybox_defined_object, oval_object, oval_states): #Special registry Values handling if cybox_defined_object.values is not None: name_set = False for reg_value in cybox_defined_object.values: oval_state = oval.registry_state(version = 1, id = self.generate_ste_id()) for element, value in reg_value._fields.items(): if value is not None: #Corner case for handling multiple name/value pairs in the OVAL object if len(cybox_defined_object.values) == 1 and not name_set: if element in self.registry_object_mappings.keys(): oval_element = self.registry_object_mappings.get(element) method = 'set_' + oval_element.get('name') getattr(oval_object,method)(oval.EntityBaseType(datatype = 'string', operation = self.operator_condition_mappings.get(value), valueOf_=value.value)) name_set = True elif len(cybox_defined_object.values) > 1 and not name_set: oval_object.set_name(oval.EntityBaseType(datatype = 'string', operation = 'pattern match', valueOf_='.*')) name_set = True if element in self.registry_state_mappings.keys(): oval_element = self.registry_state_mappings.get(element) method = 'set_' + oval_element.get('name') getattr(oval_state,method)(oval.EntityBaseType(datatype = 'string', operation = self.operator_condition_mappings.get(value), valueOf_=value.value)) if oval_state.hasContent_(): oval_states.append(oval_state) def generate_test_id(self): self.test_id_base += 1 test_id = 'oval:' + self.id_namespace + ':tst:' + str(self.test_id_base) return test_id def generate_obj_id(self): self.obj_id_base += 1 obj_id = 'oval:' + self.id_namespace + ':obj:' + str(self.obj_id_base) return obj_id def generate_ste_id(self): self.ste_id_base += 1 ste_id = 'oval:' + self.id_namespace + ':ste:' + str(self.ste_id_base) return ste_id def generate_def_id(self): self.def_id_base += 1 def_id = 'oval:' + self.id_namespace + ':def:' + str(self.def_id_base) return def_id
bsd-3-clause
[ 3, 2054, 4220, 1035, 593, 3204, 6266, 13693, 199, 3, 86, 16, 14, 2635, 699, 15808, 199, 3, 9417, 13546, 1021, 199, 3, 20551, 593, 3204, 2295, 15, 1462, 15, 4981, 687, 282, 18461, 66, 29544, 11391, 1942, 6935, 199, 199, 646, 312, 637, 1641, 465, 312, 637, 199, 199, 533, 6325, 1977, 63, 79, 637, 63, 14632, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1305, 63, 3251, 304, 267, 291, 14, 396, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 1113, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 1597, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 318, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 344, 63, 3251, 275, 1305, 63, 3251, 267, 327, 45, 12020, 267, 327, 9156, 66, 29544, 28401, 370, 593, 3204, 3439, 13546, 267, 291, 14, 3856, 63, 5394, 63, 14632, 275, 791, 13317, 5242, 11332, 1673, 7193, 591, 5242, 1397, 4472, 1673, 6906, 5242, 3401, 1336, 30989, 3044, 283, 11891, 19760, 5242, 13154, 2419, 297, 283, 11891, 19760, 2844, 591, 5242, 13154, 2419, 503, 4472, 30989, 3044, 283, 32693, 5242, 2003, 2419, 1673, 32693, 2844, 591, 5242, 2003, 2419, 503, 4472, 1673, 38, 1405, 9959, 5242, 3401, 1336, 30989, 3044, 283, 4734, 2605, 3325, 5242, 28831, 436, 297, 283, 4734, 2605, 2844, 5242, 28831, 503, 936, 267, 327, 9156, 66, 29544, 6935, 2434, 370, 593, 3204, 909, 13546, 267, 291, 14, 785, 63, 14632, 275, 791, 8886, 10899, 1197, 5665, 26, 8647, 10899, 1197, 1692, 804, 5242, 5189, 63, 785, 297, 283, 1173, 5665, 26, 1173, 1692, 804, 5242, 493, 63, 785, 297, 1816, 283, 8886, 1173, 5665, 26, 8647, 1173, 1692, 804, 5242, 493, 63, 785, 297, 283, 8886, 18039, 1173, 5665, 26, 8647, 18039, 1173, 1692, 804, 5242, 493, 63, 785, 936, 267, 327, 9156, 66, 29544, 3814, 1692, 370, 593, 3204, 570, 63, 785, 13546, 334, 9156, 66, 29544, 1819, 536, 520, 469, 47, 3204, 1819, 536, 12, 593, 3204, 1819, 16048, 1552, 267, 291, 14, 493, 63, 785, 63, 14632, 275, 791, 1173, 63, 2042, 3010, 354, 5242, 515, 1673, 14184, 5242, 875, 2267, 7, 9042, 63, 2042, 3010, 354, 5242, 7218, 1673, 14184, 5242, 875, 2267, 3660, 283, 1173, 63, 985, 3010, 354, 5242, 1501, 297, 283, 14184, 5242, 875, 18620, 267, 327, 9156, 66, 29544, 3814, 1692, 370, 593, 3204, 570, 63, 929, 13546, 267, 291, 14, 493, 63, 929, 63, 14632, 275, 791, 2320, 63, 607, 63, 5571, 3010, 354, 5242, 890, 1673, 14184, 5242, 442, 2267, 7, 1945, 4234, 63, 1366, 3010, 354, 5242, 65, 63, 521, 1673, 14184, 5242, 442, 2267, 60, 2511, 283, 11911, 63, 1366, 3010, 354, 5242, 77, 63, 521, 1673, 14184, 5242, 442, 2267, 7, 10502, 63, 1366, 3010, 354, 5242, 67, 63, 521, 1673, 14184, 5242, 442, 18620, 267, 327, 9156, 66, 29544, 13036, 10899, 1692, 370, 593, 3204, 7086, 63, 785, 13546, 267, 291, 14, 5189, 63, 785, 63, 14632, 275, 791, 1197, 3010, 354, 5242, 498, 1673, 14184, 5242, 875, 2267, 7, 30232, 3010, 354, 5242, 17230, 1673, 14184, 5242, 875, 2267, 7, 985, 3010, 354, 5242, 354, 1673, 14184, 5242, 875, 18620, 267, 327, 9156, 66, 29544, 13036, 10899, 1692, 13468, 370, 593, 3204, 7086, 63, 929, 13546, 267, 291, 14, 5189, 63, 929, 63, 14632, 275, 791, 985, 3010, 354, 5242, 354, 1673, 14184, 5242, 875, 2267, 7, 1451, 3010, 354, 5242, 585, 1673, 14184, 5242, 875, 2267, 7, 28369, 8588, 3010, 354, 5242, 466, 1673, 14184, 5242, 875, 18620, 339, 327, 10607, 436, 2529, 282, 2600, 402, 593, 3204, 511, 12, 909, 12, 436, 1174, 334, 692, 3964, 9, 272, 347, 1218, 63, 79, 637, 8, 277, 12, 6325, 1977, 63, 4037, 63, 785, 12, 3659, 304, 267, 312, 637, 63, 8327, 275, 1052, 267, 312, 637, 63, 4981, 275, 942, 267, 909, 63, 466, 275, 6325, 1977, 63, 4037, 63, 785, 423, 56, 2684, 63, 2709, 435, 10871, 435, 6325, 1977, 63, 4037, 63, 785, 423, 56, 2684, 63, 2711, 267, 340, 909, 63, 466, 315, 291, 14, 785, 63, 14632, 14, 1612, 837, 288, 312, 637, 63, 785, 275, 291, 14, 981, 63, 79, 637, 63, 785, 8, 785, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 9, 288, 340, 312, 637, 63, 785, 365, 440, 488, 26, 355, 340, 909, 63, 466, 508, 283, 8886, 10899, 1197, 5665, 26, 8647, 10899, 1197, 1692, 804, 356, 490, 291, 14, 1412, 63, 5189, 63, 1459, 8, 1480, 1977, 63, 4037, 63, 785, 12, 312, 637, 63, 785, 12, 312, 637, 63, 4981, 9, 355, 587, 26, 490, 1174, 275, 291, 14, 981, 63, 79, 637, 63, 929, 8, 785, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 9, 490, 340, 1174, 365, 440, 488, 26, 717, 312, 637, 63, 4981, 14, 740, 8, 277, 14, 981, 63, 79, 637, 63, 929, 8, 785, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 430, 355, 312, 637, 63, 396, 275, 291, 14, 981, 63, 79, 637, 63, 396, 8, 785, 63, 466, 12, 312, 637, 63, 785, 12, 312, 637, 63, 8327, 12, 312, 637, 63, 4981, 12, 3659, 9, 355, 312, 637, 63, 8327, 459, 396, 418, 275, 312, 637, 63, 396, 355, 312, 637, 63, 8327, 459, 785, 418, 275, 312, 637, 63, 785, 355, 340, 312, 637, 63, 4981, 365, 440, 488, 436, 822, 8, 79, 637, 63, 4981, 9, 690, 378, 26, 490, 312, 637, 63, 8327, 459, 929, 418, 275, 312, 637, 63, 4981, 355, 372, 312, 637, 63, 8327, 267, 587, 26, 288, 372, 488, 2286, 327, 2499, 314, 593, 3204, 909, 272, 347, 1218, 63, 79, 637, 63, 785, 8, 277, 12, 909, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 304, 267, 312, 637, 63, 785, 63, 466, 275, 291, 14, 785, 63, 14632, 14, 362, 8, 785, 63, 466, 9, 267, 312, 637, 63, 785, 63, 14632, 275, 291, 14, 785, 63, 14632, 14, 362, 8, 785, 63, 466, 9, 435, 2513, 14632, 7, 267, 312, 637, 63, 785, 275, 2519, 8, 79, 637, 12, 79, 637, 63, 785, 63, 466, 16315, 2728, 312, 637, 63, 785, 14 ]
[ 2054, 4220, 1035, 593, 3204, 6266, 13693, 199, 3, 86, 16, 14, 2635, 699, 15808, 199, 3, 9417, 13546, 1021, 199, 3, 20551, 593, 3204, 2295, 15, 1462, 15, 4981, 687, 282, 18461, 66, 29544, 11391, 1942, 6935, 199, 199, 646, 312, 637, 1641, 465, 312, 637, 199, 199, 533, 6325, 1977, 63, 79, 637, 63, 14632, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1305, 63, 3251, 304, 267, 291, 14, 396, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 1113, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 1597, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 318, 63, 344, 63, 1095, 275, 378, 267, 291, 14, 344, 63, 3251, 275, 1305, 63, 3251, 267, 327, 45, 12020, 267, 327, 9156, 66, 29544, 28401, 370, 593, 3204, 3439, 13546, 267, 291, 14, 3856, 63, 5394, 63, 14632, 275, 791, 13317, 5242, 11332, 1673, 7193, 591, 5242, 1397, 4472, 1673, 6906, 5242, 3401, 1336, 30989, 3044, 283, 11891, 19760, 5242, 13154, 2419, 297, 283, 11891, 19760, 2844, 591, 5242, 13154, 2419, 503, 4472, 30989, 3044, 283, 32693, 5242, 2003, 2419, 1673, 32693, 2844, 591, 5242, 2003, 2419, 503, 4472, 1673, 38, 1405, 9959, 5242, 3401, 1336, 30989, 3044, 283, 4734, 2605, 3325, 5242, 28831, 436, 297, 283, 4734, 2605, 2844, 5242, 28831, 503, 936, 267, 327, 9156, 66, 29544, 6935, 2434, 370, 593, 3204, 909, 13546, 267, 291, 14, 785, 63, 14632, 275, 791, 8886, 10899, 1197, 5665, 26, 8647, 10899, 1197, 1692, 804, 5242, 5189, 63, 785, 297, 283, 1173, 5665, 26, 1173, 1692, 804, 5242, 493, 63, 785, 297, 1816, 283, 8886, 1173, 5665, 26, 8647, 1173, 1692, 804, 5242, 493, 63, 785, 297, 283, 8886, 18039, 1173, 5665, 26, 8647, 18039, 1173, 1692, 804, 5242, 493, 63, 785, 936, 267, 327, 9156, 66, 29544, 3814, 1692, 370, 593, 3204, 570, 63, 785, 13546, 334, 9156, 66, 29544, 1819, 536, 520, 469, 47, 3204, 1819, 536, 12, 593, 3204, 1819, 16048, 1552, 267, 291, 14, 493, 63, 785, 63, 14632, 275, 791, 1173, 63, 2042, 3010, 354, 5242, 515, 1673, 14184, 5242, 875, 2267, 7, 9042, 63, 2042, 3010, 354, 5242, 7218, 1673, 14184, 5242, 875, 2267, 3660, 283, 1173, 63, 985, 3010, 354, 5242, 1501, 297, 283, 14184, 5242, 875, 18620, 267, 327, 9156, 66, 29544, 3814, 1692, 370, 593, 3204, 570, 63, 929, 13546, 267, 291, 14, 493, 63, 929, 63, 14632, 275, 791, 2320, 63, 607, 63, 5571, 3010, 354, 5242, 890, 1673, 14184, 5242, 442, 2267, 7, 1945, 4234, 63, 1366, 3010, 354, 5242, 65, 63, 521, 1673, 14184, 5242, 442, 2267, 60, 2511, 283, 11911, 63, 1366, 3010, 354, 5242, 77, 63, 521, 1673, 14184, 5242, 442, 2267, 7, 10502, 63, 1366, 3010, 354, 5242, 67, 63, 521, 1673, 14184, 5242, 442, 18620, 267, 327, 9156, 66, 29544, 13036, 10899, 1692, 370, 593, 3204, 7086, 63, 785, 13546, 267, 291, 14, 5189, 63, 785, 63, 14632, 275, 791, 1197, 3010, 354, 5242, 498, 1673, 14184, 5242, 875, 2267, 7, 30232, 3010, 354, 5242, 17230, 1673, 14184, 5242, 875, 2267, 7, 985, 3010, 354, 5242, 354, 1673, 14184, 5242, 875, 18620, 267, 327, 9156, 66, 29544, 13036, 10899, 1692, 13468, 370, 593, 3204, 7086, 63, 929, 13546, 267, 291, 14, 5189, 63, 929, 63, 14632, 275, 791, 985, 3010, 354, 5242, 354, 1673, 14184, 5242, 875, 2267, 7, 1451, 3010, 354, 5242, 585, 1673, 14184, 5242, 875, 2267, 7, 28369, 8588, 3010, 354, 5242, 466, 1673, 14184, 5242, 875, 18620, 339, 327, 10607, 436, 2529, 282, 2600, 402, 593, 3204, 511, 12, 909, 12, 436, 1174, 334, 692, 3964, 9, 272, 347, 1218, 63, 79, 637, 8, 277, 12, 6325, 1977, 63, 4037, 63, 785, 12, 3659, 304, 267, 312, 637, 63, 8327, 275, 1052, 267, 312, 637, 63, 4981, 275, 942, 267, 909, 63, 466, 275, 6325, 1977, 63, 4037, 63, 785, 423, 56, 2684, 63, 2709, 435, 10871, 435, 6325, 1977, 63, 4037, 63, 785, 423, 56, 2684, 63, 2711, 267, 340, 909, 63, 466, 315, 291, 14, 785, 63, 14632, 14, 1612, 837, 288, 312, 637, 63, 785, 275, 291, 14, 981, 63, 79, 637, 63, 785, 8, 785, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 9, 288, 340, 312, 637, 63, 785, 365, 440, 488, 26, 355, 340, 909, 63, 466, 508, 283, 8886, 10899, 1197, 5665, 26, 8647, 10899, 1197, 1692, 804, 356, 490, 291, 14, 1412, 63, 5189, 63, 1459, 8, 1480, 1977, 63, 4037, 63, 785, 12, 312, 637, 63, 785, 12, 312, 637, 63, 4981, 9, 355, 587, 26, 490, 1174, 275, 291, 14, 981, 63, 79, 637, 63, 929, 8, 785, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 9, 490, 340, 1174, 365, 440, 488, 26, 717, 312, 637, 63, 4981, 14, 740, 8, 277, 14, 981, 63, 79, 637, 63, 929, 8, 785, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 430, 355, 312, 637, 63, 396, 275, 291, 14, 981, 63, 79, 637, 63, 396, 8, 785, 63, 466, 12, 312, 637, 63, 785, 12, 312, 637, 63, 8327, 12, 312, 637, 63, 4981, 12, 3659, 9, 355, 312, 637, 63, 8327, 459, 396, 418, 275, 312, 637, 63, 396, 355, 312, 637, 63, 8327, 459, 785, 418, 275, 312, 637, 63, 785, 355, 340, 312, 637, 63, 4981, 365, 440, 488, 436, 822, 8, 79, 637, 63, 4981, 9, 690, 378, 26, 490, 312, 637, 63, 8327, 459, 929, 418, 275, 312, 637, 63, 4981, 355, 372, 312, 637, 63, 8327, 267, 587, 26, 288, 372, 488, 2286, 327, 2499, 314, 593, 3204, 909, 272, 347, 1218, 63, 79, 637, 63, 785, 8, 277, 12, 909, 63, 466, 12, 6325, 1977, 63, 4037, 63, 785, 304, 267, 312, 637, 63, 785, 63, 466, 275, 291, 14, 785, 63, 14632, 14, 362, 8, 785, 63, 466, 9, 267, 312, 637, 63, 785, 63, 14632, 275, 291, 14, 785, 63, 14632, 14, 362, 8, 785, 63, 466, 9, 435, 2513, 14632, 7, 267, 312, 637, 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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 ]
drawks/ansible
test/units/modules/network/fortimanager/test_fmgr_fwpol_package.py
38
4044
# Copyright 2018 Fortinet, Inc. # # 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 Ansible. If not, see <https://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import json from ansible.module_utils.network.fortimanager.fortimanager import FortiManagerHandler import pytest try: from ansible.modules.network.fortimanager import fmgr_fwpol_package except ImportError: pytest.skip("Could not load required modules for testing", allow_module_level=True) def load_fixtures(): fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( filename=os.path.splitext(os.path.basename(__file__))[0]) try: with open(fixture_path, "r") as fixture_file: fixture_data = json.load(fixture_file) except IOError: return [] return [fixture_data] @pytest.fixture(autouse=True) def module_mock(mocker): connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') return connection_class_mock @pytest.fixture(autouse=True) def connection_mock(mocker): connection_class_mock = mocker.patch('ansible.modules.network.fortimanager.fmgr_fwpol_package.Connection') return connection_class_mock @pytest.fixture(scope="function", params=load_fixtures()) def fixture_data(request): func_name = request.function.__name__.replace("test_", "") return request.param.get(func_name, None) fmg_instance = FortiManagerHandler(connection_mock, module_mock) def test_fmgr_fwpol_package(fixture_data, mocker): mocker.patch("ansible.module_utils.network.fortimanager.fortimanager.FortiManagerHandler.process_request", side_effect=fixture_data) # Test using fixture 1 # output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[0]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 # Test using fixture 2 # output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[1]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 # Test using fixture 3 # output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[2]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 # Test using fixture 4 # output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[3]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 def test_fmgr_fwpol_package_folder(fixture_data, mocker): mocker.patch("ansible.module_utils.network.fortimanager.fortimanager.FortiManagerHandler.process_request", side_effect=fixture_data) # Test using fixture 1 # output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[0]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 # Test using fixture 2 # output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[1]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 # Test using fixture 3 # output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[2]['paramgram_used']) assert output['raw_response']['status']['code'] == 0 # Test using fixture 4 # output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[3]['paramgram_used']) assert output['raw_response']['status']['code'] == 0
gpl-3.0
[ 3, 1898, 14894, 30205, 10811, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 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, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 509, 280, 2609, 14, 509, 280, 2609, 492, 13694, 2988, 2461, 199, 646, 4613, 199, 199, 893, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 509, 280, 2609, 492, 289, 7755, 63, 8835, 2515, 63, 2491, 199, 2590, 3545, 26, 272, 4613, 14, 2759, 480, 6531, 440, 2248, 1415, 4621, 367, 5343, 401, 2040, 63, 578, 63, 1896, 29, 549, 9, 421, 199, 318, 2248, 63, 8769, 837, 272, 10949, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 435, 3286, 91, 1501, 5565, 1001, 1674, 908, 8, 267, 1788, 29, 736, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 3460, 493, 8964, 59, 16, 566, 272, 862, 26, 267, 543, 1551, 8, 5997, 63, 515, 12, 298, 82, 531, 465, 10949, 63, 493, 26, 288, 10949, 63, 576, 275, 2022, 14, 912, 8, 5997, 63, 493, 9, 272, 871, 5925, 26, 267, 372, 942, 272, 372, 359, 5997, 63, 576, 61, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 859, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 4316, 14, 10047, 2377, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 1950, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 3112, 14, 1200, 14, 509, 280, 2609, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 14, 3225, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 32, 4462, 14, 5997, 8, 2645, 628, 1593, 401, 1862, 29, 912, 63, 8769, 1012, 199, 318, 10949, 63, 576, 8, 1069, 304, 272, 2562, 63, 354, 275, 1056, 14, 1593, 855, 354, 4343, 1814, 480, 396, 29808, 6899, 272, 372, 1056, 14, 635, 14, 362, 8, 1532, 63, 354, 12, 488, 9, 421, 199, 70, 6649, 63, 842, 275, 13694, 2988, 2461, 8, 2105, 63, 1805, 12, 859, 63, 1805, 9, 421, 199, 318, 511, 63, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 5997, 63, 576, 12, 15981, 304, 272, 15981, 14, 2068, 480, 4853, 14, 578, 63, 1208, 14, 1200, 14, 509, 280, 2609, 14, 509, 280, 2609, 14, 28027, 2988, 2461, 14, 1412, 63, 1069, 401, 326, 5366, 63, 5881, 29, 5997, 63, 576, 9, 339, 327, 1379, 1808, 10949, 413, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 16, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 499, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 17, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 650, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 18, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 841, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 19, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 421, 199, 318, 511, 63, 70, 7755, 63, 8835, 2515, 63, 2491, 63, 3741, 8, 5997, 63, 576, 12, 15981, 304, 272, 15981, 14, 2068, 480, 4853, 14, 578, 63, 1208, 14, 1200, 14, 509, 280, 2609, 14, 509, 280, 2609, 14, 28027, 2988, 2461, 14, 1412, 63, 1069, 401, 326, 5366, 63, 5881, 29, 5997, 63, 576, 9, 339, 327, 1379, 1808, 10949, 413, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 63, 3741, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 16, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 499, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 63, 3741, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 17, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 650, 327, 272, 1072, 275, 289, 7755 ]
[ 1898, 14894, 30205, 10811, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 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, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 509, 280, 2609, 14, 509, 280, 2609, 492, 13694, 2988, 2461, 199, 646, 4613, 199, 199, 893, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 509, 280, 2609, 492, 289, 7755, 63, 8835, 2515, 63, 2491, 199, 2590, 3545, 26, 272, 4613, 14, 2759, 480, 6531, 440, 2248, 1415, 4621, 367, 5343, 401, 2040, 63, 578, 63, 1896, 29, 549, 9, 421, 199, 318, 2248, 63, 8769, 837, 272, 10949, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 435, 3286, 91, 1501, 5565, 1001, 1674, 908, 8, 267, 1788, 29, 736, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 3460, 493, 8964, 59, 16, 566, 272, 862, 26, 267, 543, 1551, 8, 5997, 63, 515, 12, 298, 82, 531, 465, 10949, 63, 493, 26, 288, 10949, 63, 576, 275, 2022, 14, 912, 8, 5997, 63, 493, 9, 272, 871, 5925, 26, 267, 372, 942, 272, 372, 359, 5997, 63, 576, 61, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 859, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 4316, 14, 10047, 2377, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 1950, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 3112, 14, 1200, 14, 509, 280, 2609, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 14, 3225, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 32, 4462, 14, 5997, 8, 2645, 628, 1593, 401, 1862, 29, 912, 63, 8769, 1012, 199, 318, 10949, 63, 576, 8, 1069, 304, 272, 2562, 63, 354, 275, 1056, 14, 1593, 855, 354, 4343, 1814, 480, 396, 29808, 6899, 272, 372, 1056, 14, 635, 14, 362, 8, 1532, 63, 354, 12, 488, 9, 421, 199, 70, 6649, 63, 842, 275, 13694, 2988, 2461, 8, 2105, 63, 1805, 12, 859, 63, 1805, 9, 421, 199, 318, 511, 63, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 5997, 63, 576, 12, 15981, 304, 272, 15981, 14, 2068, 480, 4853, 14, 578, 63, 1208, 14, 1200, 14, 509, 280, 2609, 14, 509, 280, 2609, 14, 28027, 2988, 2461, 14, 1412, 63, 1069, 401, 326, 5366, 63, 5881, 29, 5997, 63, 576, 9, 339, 327, 1379, 1808, 10949, 413, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 16, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 499, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 17, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 650, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 18, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 841, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 19, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 421, 199, 318, 511, 63, 70, 7755, 63, 8835, 2515, 63, 2491, 63, 3741, 8, 5997, 63, 576, 12, 15981, 304, 272, 15981, 14, 2068, 480, 4853, 14, 578, 63, 1208, 14, 1200, 14, 509, 280, 2609, 14, 509, 280, 2609, 14, 28027, 2988, 2461, 14, 1412, 63, 1069, 401, 326, 5366, 63, 5881, 29, 5997, 63, 576, 9, 339, 327, 1379, 1808, 10949, 413, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 63, 3741, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 16, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 499, 327, 272, 1072, 275, 289, 7755, 63, 8835, 2515, 63, 2491, 14, 70, 7755, 63, 8835, 2515, 63, 2491, 63, 3741, 8, 70, 6649, 63, 842, 12, 10949, 63, 576, 59, 17, 2733, 635, 1679, 63, 2972, 1105, 272, 702, 1072, 459, 1773, 63, 1310, 2545, 1205, 2545, 600, 418, 508, 378, 272, 327, 1379, 1808, 10949, 650, 327, 272, 1072, 275, 289, 7755, 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,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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 ]
alibbaba/plugin.video.live.streamspro
plugin.video.live.streamspro/resources/lib/resolvers/vk.py
2
2921
# -*- coding: utf-8 -*- ''' Genesis Add-on Copyright (C) 2015 lambda 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/>. ''' import re,urllib,urlparse,json from resources.lib.libraries import client def resolve(url): try: try: oid, id = urlparse.parse_qs(urlparse.urlparse(url).query)['oid'][0] , urlparse.parse_qs(urlparse.urlparse(url).query)['id'][0] except: oid, id = re.compile('\/video(.*)_(.*)').findall(url)[0] try: hash = urlparse.parse_qs(urlparse.urlparse(url).query)['hash'][0] except: hash = _hash(oid, id) u = 'http://api.vk.com/method/video.getEmbed?oid=%s&video_id=%s&embed_hash=%s' % (oid, id, hash) result = client.request(u) result = re.sub(r'[^\x00-\x7F]+',' ', result) try: result = json.loads(result)['response'] except: result = _private(oid, id) url = [] try: url += [{'quality': 'HD', 'url': result['url720']}] except: pass try: url += [{'quality': 'SD', 'url': result['url540']}] except: pass try: url += [{'quality': 'SD', 'url': result['url480']}] except: pass if not url == []: return url try: url += [{'quality': 'SD', 'url': result['url360']}] except: pass if not url == []: return url try: url += [{'quality': 'SD', 'url': result['url240']}] except: pass if not url == []: return url except: return def _hash(oid, id): try: url = 'http://vk.com/al_video.php?act=show_inline&al=1&video=%s_%s' % (oid, id) result = client.request(url) result = result.replace('\'', '"').replace(' ', '') hash = re.compile('"hash2":"(.+?)"').findall(result) hash += re.compile('"hash":"(.+?)"').findall(result) hash = hash[0] return hash except: return def _private(oid, id): try: url = 'http://vk.com/al_video.php?act=show_inline&al=1&video=%s_%s' % (oid, id) result = client.request(url) result = re.compile('var vars *= *({.+?});').findall(result)[0] result = re.sub(r'[^\x00-\x7F]+',' ', result) result = json.loads(result) return result except: return
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 2999, 199, 2344, 1128, 598, 6349, 2316, 2654, 13, 265, 1128, 1898, 334, 35, 9, 6900, 2400, 2958, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1128, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1128, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 1128, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 2958, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1128, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 1128, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1128, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 2958, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 1128, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 202, 199, 2344, 8065, 199, 646, 295, 12, 4078, 12, 10290, 12, 1001, 202, 199, 504, 5944, 14, 773, 14, 10159, 492, 1890, 8065, 199, 318, 7512, 8, 633, 304, 1128, 862, 26, 1039, 862, 26, 20109, 12, 1305, 275, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 633, 680, 1131, 11820, 1170, 3488, 16, 61, 2360, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 633, 680, 1131, 11820, 344, 3488, 16, 61, 1039, 871, 26, 20109, 12, 1305, 275, 295, 14, 2014, 2258, 15, 3722, 8, 12432, 2531, 12432, 1959, 6452, 8, 633, 2788, 16, 61, 1039, 862, 26, 2631, 275, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 633, 680, 1131, 11820, 2227, 3488, 16, 61, 1039, 871, 26, 2631, 275, 485, 2227, 8, 1170, 12, 1305, 9, 4341, 399, 275, 283, 1014, 921, 1246, 14, 21405, 14, 957, 15, 765, 15, 3722, 14, 362, 13200, 31, 1170, 2458, 83, 6, 3722, 63, 344, 2458, 83, 6, 6427, 63, 2227, 2458, 83, 7, 450, 334, 1170, 12, 1305, 12, 2631, 9, 10292, 1039, 754, 275, 1890, 14, 1069, 8, 85, 9, 1039, 754, 275, 295, 14, 954, 8, 82, 29538, 88, 383, 2696, 88, 23, 38, 2807, 1673, 1656, 754, 9, 4341, 862, 26, 754, 275, 2022, 14, 3640, 8, 1099, 11820, 1310, 418, 1039, 871, 26, 754, 275, 485, 4239, 8, 1170, 12, 1305, 9, 4341, 1166, 275, 942, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 14903, 297, 283, 633, 356, 754, 459, 633, 18386, 418, 11049, 1039, 871, 26, 986, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 17814, 418, 11049, 1039, 871, 26, 986, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 21853, 418, 11049, 1039, 871, 26, 986, 1039, 340, 440, 1166, 508, 18410, 372, 1166, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 11197, 418, 11049, 1039, 871, 26, 986, 1039, 340, 440, 1166, 508, 18410, 372, 1166, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 9873, 418, 11049, 1039, 871, 26, 986, 4341, 340, 440, 1166, 508, 18410, 372, 1166, 2958, 871, 26, 1039, 372, 8065, 199, 318, 485, 2227, 8, 1170, 12, 1305, 304, 1128, 862, 26, 1039, 1166, 275, 283, 1014, 921, 21405, 14, 957, 15, 279, 63, 3722, 14, 8624, 31, 2442, 29, 2384, 63, 6460, 6, 279, 29, 17, 6, 3722, 2458, 83, 4970, 83, 7, 450, 334, 1170, 12, 1305, 9, 1039, 754, 275, 1890, 14, 1069, 8, 633, 9, 1039, 754, 275, 754, 14, 1814, 2258, 6448, 5522, 1959, 1814, 360, 1656, 4074, 4341, 2631, 275, 295, 14, 2014, 14088, 2227, 18, 5122, 28149, 2924, 1959, 6452, 8, 1099, 9, 1039, 2631, 847, 295, 14, 2014, 14088, 2227, 5122, 28149, 2924, 1959, 6452, 8, 1099, 9, 1039, 2631, 275, 2631, 59, 16, 61, 4341, 372, 2631, 1128, 871, 26, 1039, 372, 2999, 199, 318, 485, 4239, 8, 1170, 12, 1305, 304, 1128, 862, 26, 1039, 1166, 275, 283, 1014, 921, 21405, 14, 957, 15, 279, 63, 3722, 14, 8624, 31, 2442, 29, 2384, 63, 6460, 6, 279, 29, 17, 6, 3722, 2458, 83, 4970, 83, 7, 450, 334, 1170, 12, 1305, 9, 4341, 754, 275, 1890, 14, 1069, 8, 633, 9, 1039, 754, 275, 295, 14, 2014, 360, 1391, 6802, 9000, 627, 2561, 11198, 32056, 1959, 6452, 8, 1099, 2788, 16, 61, 1039, 754, 275, 295, 14, 954, 8, 82, 29538, 88, 383, 2696, 88, 23, 38, 2807, 1673, 1656, 754, 9, 1039, 754, 275, 2022, 14, 3640, 8, 1099, 9, 4341, 372, 754, 1128, 871, 26, 1039, 372, 10060, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2999, 199, 2344, 1128, 598, 6349, 2316, 2654, 13, 265, 1128, 1898, 334, 35, 9, 6900, 2400, 2958, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1128, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1128, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 1128, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 2958, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1128, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 1128, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1128, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 2958, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 1128, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 202, 199, 2344, 8065, 199, 646, 295, 12, 4078, 12, 10290, 12, 1001, 202, 199, 504, 5944, 14, 773, 14, 10159, 492, 1890, 8065, 199, 318, 7512, 8, 633, 304, 1128, 862, 26, 1039, 862, 26, 20109, 12, 1305, 275, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 633, 680, 1131, 11820, 1170, 3488, 16, 61, 2360, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 633, 680, 1131, 11820, 344, 3488, 16, 61, 1039, 871, 26, 20109, 12, 1305, 275, 295, 14, 2014, 2258, 15, 3722, 8, 12432, 2531, 12432, 1959, 6452, 8, 633, 2788, 16, 61, 1039, 862, 26, 2631, 275, 7097, 14, 1122, 63, 6177, 8, 10290, 14, 10290, 8, 633, 680, 1131, 11820, 2227, 3488, 16, 61, 1039, 871, 26, 2631, 275, 485, 2227, 8, 1170, 12, 1305, 9, 4341, 399, 275, 283, 1014, 921, 1246, 14, 21405, 14, 957, 15, 765, 15, 3722, 14, 362, 13200, 31, 1170, 2458, 83, 6, 3722, 63, 344, 2458, 83, 6, 6427, 63, 2227, 2458, 83, 7, 450, 334, 1170, 12, 1305, 12, 2631, 9, 10292, 1039, 754, 275, 1890, 14, 1069, 8, 85, 9, 1039, 754, 275, 295, 14, 954, 8, 82, 29538, 88, 383, 2696, 88, 23, 38, 2807, 1673, 1656, 754, 9, 4341, 862, 26, 754, 275, 2022, 14, 3640, 8, 1099, 11820, 1310, 418, 1039, 871, 26, 754, 275, 485, 4239, 8, 1170, 12, 1305, 9, 4341, 1166, 275, 942, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 14903, 297, 283, 633, 356, 754, 459, 633, 18386, 418, 11049, 1039, 871, 26, 986, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 17814, 418, 11049, 1039, 871, 26, 986, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 21853, 418, 11049, 1039, 871, 26, 986, 1039, 340, 440, 1166, 508, 18410, 372, 1166, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 11197, 418, 11049, 1039, 871, 26, 986, 1039, 340, 440, 1166, 508, 18410, 372, 1166, 1039, 862, 26, 1166, 847, 9016, 9161, 356, 283, 3693, 297, 283, 633, 356, 754, 459, 633, 9873, 418, 11049, 1039, 871, 26, 986, 4341, 340, 440, 1166, 508, 18410, 372, 1166, 2958, 871, 26, 1039, 372, 8065, 199, 318, 485, 2227, 8, 1170, 12, 1305, 304, 1128, 862, 26, 1039, 1166, 275, 283, 1014, 921, 21405, 14, 957, 15, 279, 63, 3722, 14, 8624, 31, 2442, 29, 2384, 63, 6460, 6, 279, 29, 17, 6, 3722, 2458, 83, 4970, 83, 7, 450, 334, 1170, 12, 1305, 9, 1039, 754, 275, 1890, 14, 1069, 8, 633, 9, 1039, 754, 275, 754, 14, 1814, 2258, 6448, 5522, 1959, 1814, 360, 1656, 4074, 4341, 2631, 275, 295, 14, 2014, 14088, 2227, 18, 5122, 28149, 2924, 1959, 6452, 8, 1099, 9, 1039, 2631, 847, 295, 14, 2014, 14088, 2227, 5122, 28149, 2924, 1959, 6452, 8, 1099, 9, 1039, 2631, 275, 2631, 59, 16, 61, 4341, 372, 2631, 1128, 871, 26, 1039, 372, 2999, 199, 318, 485, 4239, 8, 1170, 12, 1305, 304, 1128, 862, 26, 1039, 1166, 275, 283, 1014, 921, 21405, 14, 957, 15, 279, 63, 3722, 14, 8624, 31, 2442, 29, 2384, 63, 6460, 6, 279, 29, 17, 6, 3722, 2458, 83, 4970, 83, 7, 450, 334, 1170, 12, 1305, 9, 4341, 754, 275, 1890, 14, 1069, 8, 633, 9, 1039, 754, 275, 295, 14, 2014, 360, 1391, 6802, 9000, 627, 2561, 11198, 32056, 1959, 6452, 8, 1099, 2788, 16, 61, 1039, 754, 275, 295, 14, 954, 8, 82, 29538, 88, 383, 2696, 88, 23, 38, 2807, 1673, 1656, 754, 9, 1039, 754, 275, 2022, 14, 3640, 8, 1099, 9, 4341, 372, 754, 1128, 871, 26, 1039, 372, 10060, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
CylonicRaider/websocket-server
websocket_server/exceptions.py
1
1127
# websocket_server -- WebSocket/HTTP server/client library # https://github.com/CylonicRaider/websocket-server """ Exceptions. """ __all__ = ['WebSocketError', 'ProtocolError', 'InvalidDataError', 'ConnectionClosedError'] class WebSocketError(Exception): """ Base class for all exceptions. """ class ProtocolError(WebSocketError): """ Exception for failure of the other side to adher to the protocol. The "code" attribute contains the error code (a CLOSE_* from the constants module) or None. """ def __init__(self, message, code=None): """ __init__(message, code=None) -> None Initialize a ProtocolError instance. message is passed to the superclass constructor, code is stored in the same-named attribute. """ WebSocketError.__init__(self, message) self.code = code class InvalidDataError(ProtocolError, ValueError): """ Invalid data have been encountered. """ class ConnectionClosedError(WebSocketError): """ Raised when trying to write a message after the connection closed. """
mit
[ 3, 24897, 63, 1000, 1553, 18846, 15, 2856, 1654, 15, 1258, 3555, 199, 3, 4178, 921, 5031, 14, 957, 15, 9156, 5298, 530, 1537, 73, 424, 15, 13508, 13, 1000, 199, 199, 624, 199, 16836, 14, 199, 624, 199, 199, 363, 452, 363, 275, 788, 18477, 547, 297, 283, 3658, 547, 297, 283, 3364, 1451, 547, 297, 1779, 283, 3225, 15190, 547, 418, 199, 199, 533, 18846, 547, 8, 1726, 304, 272, 408, 272, 3523, 1021, 367, 1006, 4967, 14, 272, 408, 199, 199, 533, 30797, 8, 18477, 547, 304, 272, 408, 272, 2186, 367, 5988, 402, 314, 1163, 5366, 370, 1503, 2523, 370, 314, 4113, 14, 339, 710, 298, 600, 2, 2225, 3509, 314, 1125, 1233, 334, 65, 445, 1484, 899, 15192, 687, 314, 272, 5262, 859, 9, 503, 488, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1245, 12, 1233, 29, 403, 304, 267, 408, 267, 636, 826, 721, 1188, 12, 1233, 29, 403, 9, 1035, 488, 398, 11578, 282, 30797, 1256, 14, 1245, 365, 3032, 370, 314, 267, 17035, 3787, 12, 1233, 365, 5489, 315, 314, 2011, 13, 4579, 267, 2225, 14, 267, 408, 267, 18846, 547, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 600, 275, 1233, 199, 199, 533, 6378, 1451, 547, 8, 3658, 547, 12, 1722, 304, 272, 408, 272, 6378, 666, 1172, 2757, 14556, 14, 272, 408, 199, 199, 533, 8113, 15190, 547, 8, 18477, 547, 304, 272, 408, 272, 24997, 1380, 9936, 370, 2218, 282, 1245, 2410, 314, 1950, 6876, 14, 272, 408, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 24897, 63, 1000, 1553, 18846, 15, 2856, 1654, 15, 1258, 3555, 199, 3, 4178, 921, 5031, 14, 957, 15, 9156, 5298, 530, 1537, 73, 424, 15, 13508, 13, 1000, 199, 199, 624, 199, 16836, 14, 199, 624, 199, 199, 363, 452, 363, 275, 788, 18477, 547, 297, 283, 3658, 547, 297, 283, 3364, 1451, 547, 297, 1779, 283, 3225, 15190, 547, 418, 199, 199, 533, 18846, 547, 8, 1726, 304, 272, 408, 272, 3523, 1021, 367, 1006, 4967, 14, 272, 408, 199, 199, 533, 30797, 8, 18477, 547, 304, 272, 408, 272, 2186, 367, 5988, 402, 314, 1163, 5366, 370, 1503, 2523, 370, 314, 4113, 14, 339, 710, 298, 600, 2, 2225, 3509, 314, 1125, 1233, 334, 65, 445, 1484, 899, 15192, 687, 314, 272, 5262, 859, 9, 503, 488, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1245, 12, 1233, 29, 403, 304, 267, 408, 267, 636, 826, 721, 1188, 12, 1233, 29, 403, 9, 1035, 488, 398, 11578, 282, 30797, 1256, 14, 1245, 365, 3032, 370, 314, 267, 17035, 3787, 12, 1233, 365, 5489, 315, 314, 2011, 13, 4579, 267, 2225, 14, 267, 408, 267, 18846, 547, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 600, 275, 1233, 199, 199, 533, 6378, 1451, 547, 8, 3658, 547, 12, 1722, 304, 272, 408, 272, 6378, 666, 1172, 2757, 14556, 14, 272, 408, 199, 199, 533, 8113, 15190, 547, 8, 18477, 547, 304, 272, 408, 272, 24997, 1380, 9936, 370, 2218, 282, 1245, 2410, 314, 1950, 6876, 14, 272, 408, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
enckse/system-viewer
bottle.py
1
146747
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with url parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file and with no dependencies other than the Python Standard Library. Homepage and documentation: http://bottlepy.org/ Copyright (c) 2014, Marcel Hellkamp. License: MIT (see LICENSE for details) """ from __future__ import with_statement __author__ = 'Marcel Hellkamp' __version__ = '0.13-dev' __license__ = 'MIT' # The gevent and eventlet server adapters need to patch some modules before # they are imported. This is why we parse the commandline parameters here but # handle them later if __name__ == '__main__': from optparse import OptionParser _cmd_parser = OptionParser(usage="usage: %prog [options] package.module:app") _opt = _cmd_parser.add_option _opt("--version", action="store_true", help="show version number.") _opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.") _opt("-s", "--server", default='wsgiref', help="use SERVER as backend.") _opt("-p", "--plugin", action="append", help="install additional plugin/s.") _opt("--debug", action="store_true", help="start server in debug mode.") _opt("--reload", action="store_true", help="auto-reload on file changes.") _cmd_options, _cmd_args = _cmd_parser.parse_args() if _cmd_options.server: if _cmd_options.server.startswith('gevent'): import gevent.monkey; gevent.monkey.patch_all() elif _cmd_options.server.startswith('eventlet'): import eventlet; eventlet.monkey_patch() import base64, cgi, email.utils, functools, hmac, imp, itertools, mimetypes,\ os, re, subprocess, sys, tempfile, threading, time, warnings from datetime import date as datedate, datetime, timedelta from tempfile import TemporaryFile from traceback import format_exc, print_exc from inspect import getargspec from unicodedata import normalize try: from simplejson import dumps as json_dumps, loads as json_lds except ImportError: # pragma: no cover try: from json import dumps as json_dumps, loads as json_lds except ImportError: try: from django.utils.simplejson import dumps as json_dumps, loads as json_lds except ImportError: def json_dumps(data): raise ImportError("JSON support requires Python 2.6 or simplejson.") json_lds = json_dumps # We now try to fix 2.5/2.6/3.1/3.2 incompatibilities. # It ain't pretty but it works... Sorry for the mess. py = sys.version_info py3k = py >= (3, 0, 0) py25 = py < (2, 6, 0) py31 = (3, 1, 0) <= py < (3, 2, 0) # Workaround for the missing "as" keyword in py3k. def _e(): return sys.exc_info()[1] # Workaround for the "print is a keyword/function" Python 2/3 dilemma # and a fallback for mod_wsgi (resticts stdout/err attribute access) try: _stdout, _stderr = sys.stdout.write, sys.stderr.write except IOError: _stdout = lambda x: sys.stdout.write(x) _stderr = lambda x: sys.stderr.write(x) # Lots of stdlib and builtin differences. if py3k: import http.client as httplib import _thread as thread from urllib.parse import urljoin, SplitResult as UrlSplitResult from urllib.parse import urlencode, quote as urlquote, unquote as urlunquote urlunquote = functools.partial(urlunquote, encoding='latin1') from http.cookies import SimpleCookie from collections import MutableMapping as DictMixin import pickle from io import BytesIO from configparser import ConfigParser basestring = str unicode = str json_loads = lambda s: json_lds(touni(s)) callable = lambda x: hasattr(x, '__call__') imap = map def _raise(*a): raise a[0](a[1]).with_traceback(a[2]) else: # 2.x import httplib import thread from urlparse import urljoin, SplitResult as UrlSplitResult from urllib import urlencode, quote as urlquote, unquote as urlunquote from Cookie import SimpleCookie from itertools import imap import cPickle as pickle from StringIO import StringIO as BytesIO from ConfigParser import SafeConfigParser as ConfigParser if py25: msg = "Python 2.5 support may be dropped in future versions of Bottle." warnings.warn(msg, DeprecationWarning) from UserDict import DictMixin def next(it): return it.next() bytes = str else: # 2.6, 2.7 from collections import MutableMapping as DictMixin unicode = unicode json_loads = json_lds eval(compile('def _raise(*a): raise a[0], a[1], a[2]', '<py3fix>', 'exec')) # Some helpers for string/byte handling def tob(s, enc='utf8'): return s.encode(enc) if isinstance(s, unicode) else bytes(s) def touni(s, enc='utf8', err='strict'): if isinstance(s, bytes): return s.decode(enc, err) else: return unicode(s or ("" if s is None else s)) tonat = touni if py3k else tob # 3.2 fixes cgi.FieldStorage to accept bytes (which makes a lot of sense). # 3.1 needs a workaround. if py31: from io import TextIOWrapper class NCTextIOWrapper(TextIOWrapper): def close(self): pass # Keep wrapped buffer open. # A bug in functools causes it to break if the wrapper is an instance method def update_wrapper(wrapper, wrapped, *a, **ka): try: functools.update_wrapper(wrapper, wrapped, *a, **ka) except AttributeError: pass # These helpers are used at module level and need to be defined first. # And yes, I know PEP-8, but sometimes a lower-case classname makes more sense. def depr(message, strict=False): warnings.warn(message, DeprecationWarning, stacklevel=3) def makelist(data): # This is just to handy if isinstance(data, (tuple, list, set, dict)): return list(data) elif data: return [data] else: return [] class DictProperty(object): """ Property that maps to a key in a local dict-like attribute. """ def __init__(self, attr, key=None, read_only=False): self.attr, self.key, self.read_only = attr, key, read_only def __call__(self, func): functools.update_wrapper(self, func, updated=[]) self.getter, self.key = func, self.key or func.__name__ return self def __get__(self, obj, cls): if obj is None: return self key, storage = self.key, getattr(obj, self.attr) if key not in storage: storage[key] = self.getter(obj) return storage[key] def __set__(self, obj, value): if self.read_only: raise AttributeError("Read-Only property.") getattr(obj, self.attr)[self.key] = value def __delete__(self, obj): if self.read_only: raise AttributeError("Read-Only property.") del getattr(obj, self.attr)[self.key] class cached_property(object): """ A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. """ def __init__(self, func): self.__doc__ = getattr(func, '__doc__') self.func = func def __get__(self, obj, cls): if obj is None: return self value = obj.__dict__[self.func.__name__] = self.func(obj) return value class lazy_attribute(object): """ A property that caches itself to the class object. """ def __init__(self, func): functools.update_wrapper(self, func, updated=[]) self.getter = func def __get__(self, obj, cls): value = self.getter(cls) setattr(cls, self.__name__, value) return value ############################################################################### # Exceptions and Events ######################################################## ############################################################################### class BottleException(Exception): """ A base class for exceptions used by bottle. """ pass ############################################################################### # Routing ###################################################################### ############################################################################### class RouteError(BottleException): """ This is a base class for all routing related exceptions """ class RouteReset(BottleException): """ If raised by a plugin or request handler, the route is reset and all plugins are re-applied. """ class RouterUnknownModeError(RouteError): pass class RouteSyntaxError(RouteError): """ The route parser found something not supported by this router. """ class RouteBuildError(RouteError): """ The route could not be built. """ def _re_flatten(p): """ Turn all capturing groups in a regular expression pattern into non-capturing groups. """ if '(' not in p: return p return re.sub(r'(\\*)(\(\?P<[^>]+>|\((?!\?))', lambda m: m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:', p) class Router(object): """ A Router is an ordered collection of route->target pairs. It is used to efficiently match WSGI requests against a number of routes and return the first target that satisfies the request. The target may be anything, usually a string, ID or callable object. A route consists of a path-rule and a HTTP method. The path-rule is either a static path (e.g. `/contact`) or a dynamic path that contains wildcards (e.g. `/wiki/<page>`). The wildcard syntax and details on the matching order are described in docs:`routing`. """ default_pattern = '[^/]+' default_filter = 're' #: The current CPython regexp implementation does not allow more #: than 99 matching groups per regular expression. _MAX_GROUPS_PER_PATTERN = 99 def __init__(self, strict=False): self.rules = [] # All rules in order self._groups = {} # index of regexes to find them in dyna_routes self.builder = {} # Data structure for the url builder self.static = {} # Search structure for static routes self.dyna_routes = {} self.dyna_regexes = {} # Search structure for dynamic routes #: If true, static routes are no longer checked first. self.strict_order = strict self.filters = { 're': lambda conf: (_re_flatten(conf or self.default_pattern), None, None), 'int': lambda conf: (r'-?\d+', int, lambda x: str(int(x))), 'float': lambda conf: (r'-?[\d.]+', float, lambda x: str(float(x))), 'path': lambda conf: (r'.+?', None, None)} def add_filter(self, name, func): """ Add a filter. The provided function is called with the configuration string as parameter and must return a (regexp, to_python, to_url) tuple. The first element is a string, the last two are callables or None. """ self.filters[name] = func rule_syntax = re.compile('(\\\\*)' '(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)' '|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)' '(?::((?:\\\\.|[^\\\\>]+)+)?)?)?>))') def _itertokens(self, rule): offset, prefix = 0, '' for match in self.rule_syntax.finditer(rule): prefix += rule[offset:match.start()] g = match.groups() if len(g[0])%2: # Escaped wildcard prefix += match.group(0)[len(g[0]):] offset = match.end() continue if prefix: yield prefix, None, None name, filtr, conf = g[4:7] if g[2] is None else g[1:4] yield name, filtr or 'default', conf or None offset, prefix = match.end(), '' if offset <= len(rule) or prefix: yield prefix+rule[offset:], None, None def add(self, rule, method, target, name=None): """ Add a new rule or replace the target for an existing rule. """ anons = 0 # Number of anonymous wildcards found keys = [] # Names of keys pattern = '' # Regular expression pattern with named groups filters = [] # Lists of wildcard input filters builder = [] # Data structure for the URL builder is_static = True for key, mode, conf in self._itertokens(rule): if mode: is_static = False if mode == 'default': mode = self.default_filter mask, in_filter, out_filter = self.filters[mode](conf) if not key: pattern += '(?:%s)' % mask key = 'anon%d' % anons anons += 1 else: pattern += '(?P<%s>%s)' % (key, mask) keys.append(key) if in_filter: filters.append((key, in_filter)) builder.append((key, out_filter or str)) elif key: pattern += re.escape(key) builder.append((None, key)) self.builder[rule] = builder if name: self.builder[name] = builder if is_static and not self.strict_order: self.static.setdefault(method, {}) self.static[method][self.build(rule)] = (target, None) return try: re_pattern = re.compile('^(%s)$' % pattern) re_match = re_pattern.match except re.error: raise RouteSyntaxError("Could not add Route: %s (%s)" % (rule, _e())) if filters: def getargs(path): url_args = re_match(path).groupdict() for name, wildcard_filter in filters: try: url_args[name] = wildcard_filter(url_args[name]) except ValueError: raise HTTPError(400, 'Path has wrong format.') return url_args elif re_pattern.groupindex: def getargs(path): return re_match(path).groupdict() else: getargs = None flatpat = _re_flatten(pattern) whole_rule = (rule, flatpat, target, getargs) if (flatpat, method) in self._groups: if DEBUG: msg = 'Route <%s %s> overwrites a previously defined route' warnings.warn(msg % (method, rule), RuntimeWarning) self.dyna_routes[method][self._groups[flatpat, method]] = whole_rule else: self.dyna_routes.setdefault(method, []).append(whole_rule) self._groups[flatpat, method] = len(self.dyna_routes[method]) - 1 self._compile(method) def _compile(self, method): all_rules = self.dyna_routes[method] comborules = self.dyna_regexes[method] = [] maxgroups = self._MAX_GROUPS_PER_PATTERN for x in range(0, len(all_rules), maxgroups): some = all_rules[x:x+maxgroups] combined = (flatpat for (_, flatpat, _, _) in some) combined = '|'.join('(^%s$)' % flatpat for flatpat in combined) combined = re.compile(combined).match rules = [(target, getargs) for (_, _, target, getargs) in some] comborules.append((combined, rules)) def build(self, _name, *anons, **query): """ Build an URL by filling the wildcards in a rule. """ builder = self.builder.get(_name) if not builder: raise RouteBuildError("No route with that name.", _name) try: for i, value in enumerate(anons): query['anon%d'%i] = value url = ''.join([f(query.pop(n)) if n else f for (n,f) in builder]) return url if not query else url+'?'+urlencode(query) except KeyError: raise RouteBuildError('Missing URL argument: %r' % _e().args[0]) def match(self, environ): """ Return a (target, url_agrs) tuple or raise HTTPError(400/404/405). """ verb = environ['REQUEST_METHOD'].upper() path = environ['PATH_INFO'] or '/' if verb == 'HEAD': methods = ['PROXY', verb, 'GET', 'ANY'] else: methods = ['PROXY', verb, 'ANY'] for method in methods: if method in self.static and path in self.static[method]: target, getargs = self.static[method][path] return target, getargs(path) if getargs else {} elif method in self.dyna_regexes: for combined, rules in self.dyna_regexes[method]: match = combined(path) if match: target, getargs = rules[match.lastindex - 1] return target, getargs(path) if getargs else {} # No matching route found. Collect alternative methods for 405 response allowed = set([]) nocheck = set(methods) for method in set(self.static) - nocheck: if path in self.static[method]: allowed.add(verb) for method in set(self.dyna_regexes) - allowed - nocheck: for combined, rules in self.dyna_regexes[method]: match = combined(path) if match: allowed.add(method) if allowed: allow_header = ",".join(sorted(allowed)) raise HTTPError(405, "Method not allowed.", Allow=allow_header) # No matching route and no alternative method found. We give up raise HTTPError(404, "Not found: " + repr(path)) class Route(object): """ This class wraps a route callback along with route specific metadata and configuration and applies Plugins on demand. It is also responsible for turing an URL path rule into a regular expression usable by the Router. """ def __init__(self, app, rule, method, callback, name=None, plugins=None, skiplist=None, **config): #: The application this route is installed to. self.app = app #: The path-rule string (e.g. ``/wiki/:page``). self.rule = rule #: The HTTP method as a string (e.g. ``GET``). self.method = method #: The original callback with no plugins applied. Useful for introspection. self.callback = callback #: The name of the route (if specified) or ``None``. self.name = name or None #: A list of route-specific plugins (see :meth:`Bottle.route`). self.plugins = plugins or [] #: A list of plugins to not apply to this route (see :meth:`Bottle.route`). self.skiplist = skiplist or [] #: Additional keyword arguments passed to the :meth:`Bottle.route` #: decorator are stored in this dictionary. Used for route-specific #: plugin configuration and meta-data. self.config = ConfigDict().load_dict(config) @cached_property def call(self): """ The route callback with all plugins applied. This property is created on demand and then cached to speed up subsequent requests.""" return self._make_callback() def reset(self): """ Forget any cached values. The next time :attr:`call` is accessed, all plugins are re-applied. """ self.__dict__.pop('call', None) def prepare(self): """ Do all on-demand work immediately (useful for debugging).""" self.call def all_plugins(self): """ Yield all Plugins affecting this route. """ unique = set() for p in reversed(self.app.plugins + self.plugins): if True in self.skiplist: break name = getattr(p, 'name', False) if name and (name in self.skiplist or name in unique): continue if p in self.skiplist or type(p) in self.skiplist: continue if name: unique.add(name) yield p def _make_callback(self): callback = self.callback for plugin in self.all_plugins(): try: if hasattr(plugin, 'apply'): callback = plugin.apply(callback, self) else: callback = plugin(callback) except RouteReset: # Try again with changed configuration. return self._make_callback() if not callback is self.callback: update_wrapper(callback, self.callback) return callback def get_undecorated_callback(self): """ Return the callback. If the callback is a decorated function, try to recover the original function. """ func = self.callback func = getattr(func, '__func__' if py3k else 'im_func', func) closure_attr = '__closure__' if py3k else 'func_closure' while hasattr(func, closure_attr) and getattr(func, closure_attr): func = getattr(func, closure_attr)[0].cell_contents return func def get_callback_args(self): """ Return a list of argument names the callback (most likely) accepts as keyword arguments. If the callback is a decorated function, try to recover the original function before inspection. """ return getargspec(self.get_undecorated_callback())[0] def get_config(self, key, default=None): """ Lookup a config field and return its value, first checking the route.config, then route.app.config.""" for conf in (self.config, self.app.conifg): if key in conf: return conf[key] return default def __repr__(self): cb = self.get_undecorated_callback() return '<%s %r %r>' % (self.method, self.rule, cb) ############################################################################### # Application Object ########################################################### ############################################################################### class Bottle(object): """ Each Bottle object represents a single, distinct web application and consists of routes, callbacks, plugins, resources and configuration. Instances are callable WSGI applications. :param catchall: If true (default), handle all exceptions. Turn off to let debugging middleware handle exceptions. """ def __init__(self, catchall=True, autojson=True): #: A :class:`ConfigDict` for app specific configuration. self.config = ConfigDict() self.config._on_change = functools.partial(self.trigger_hook, 'config') self.config.meta_set('autojson', 'validate', bool) self.config.meta_set('catchall', 'validate', bool) self.config['catchall'] = catchall self.config['autojson'] = autojson #: A :class:`ResourceManager` for application files self.resources = ResourceManager() self.routes = [] # List of installed :class:`Route` instances. self.router = Router() # Maps requests to :class:`Route` instances. self.error_handler = {} # Core plugins self.plugins = [] # List of installed plugins. if self.config['autojson']: self.install(JSONPlugin()) self.install(TemplatePlugin()) #: If true, most exceptions are caught and returned as :exc:`HTTPError` catchall = DictProperty('config', 'catchall') __hook_names = 'before_request', 'after_request', 'app_reset', 'config' __hook_reversed = 'after_request' @cached_property def _hooks(self): return dict((name, []) for name in self.__hook_names) def add_hook(self, name, func): """ Attach a callback to a hook. Three hooks are currently implemented: before_request Executed once before each request. The request context is available, but no routing has happened yet. after_request Executed once after each request regardless of its outcome. app_reset Called whenever :meth:`Bottle.reset` is called. """ if name in self.__hook_reversed: self._hooks[name].insert(0, func) else: self._hooks[name].append(func) def remove_hook(self, name, func): """ Remove a callback from a hook. """ if name in self._hooks and func in self._hooks[name]: self._hooks[name].remove(func) return True def trigger_hook(self, __name, *args, **kwargs): """ Trigger a hook and return a list of results. """ return [hook(*args, **kwargs) for hook in self._hooks[__name][:]] def hook(self, name): """ Return a decorator that attaches a callback to a hook. See :meth:`add_hook` for details.""" def decorator(func): self.add_hook(name, func) return func return decorator def mount(self, prefix, app, **options): """ Mount an application (:class:`Bottle` or plain WSGI) to a specific URL prefix. Example:: root_app.mount('/admin/', admin_app) :param prefix: path prefix or `mount-point`. If it ends in a slash, that slash is mandatory. :param app: an instance of :class:`Bottle` or a WSGI application. All other parameters are passed to the underlying :meth:`route` call. """ segments = [p for p in prefix.split('/') if p] if not segments: raise ValueError('Empty path prefix.') path_depth = len(segments) def mountpoint_wrapper(): try: request.path_shift(path_depth) rs = HTTPResponse([]) def start_response(status, headerlist, exc_info=None): if exc_info: _raise(*exc_info) rs.status = status for name, value in headerlist: rs.add_header(name, value) return rs.body.append body = app(request.environ, start_response) if body and rs.body: body = itertools.chain(rs.body, body) rs.body = body or rs.body return rs finally: request.path_shift(-path_depth) options.setdefault('skip', True) options.setdefault('method', 'PROXY') options.setdefault('mountpoint', {'prefix': prefix, 'target': app}) options['callback'] = mountpoint_wrapper self.route('/%s/<:re:.*>' % '/'.join(segments), **options) if not prefix.endswith('/'): self.route('/' + '/'.join(segments), **options) def merge(self, routes): """ Merge the routes of another :class:`Bottle` application or a list of :class:`Route` objects into this application. The routes keep their 'owner', meaning that the :data:`Route.app` attribute is not changed. """ if isinstance(routes, Bottle): routes = routes.routes for route in routes: self.add_route(route) def install(self, plugin): """ Add a plugin to the list of plugins and prepare it for being applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API. """ if hasattr(plugin, 'setup'): plugin.setup(self) if not callable(plugin) and not hasattr(plugin, 'apply'): raise TypeError("Plugins must be callable or implement .apply()") self.plugins.append(plugin) self.reset() return plugin def uninstall(self, plugin): """ Uninstall plugins. Pass an instance to remove a specific plugin, a type object to remove all plugins that match that type, a string to remove all plugins with a matching ``name`` attribute or ``True`` to remove all plugins. Return the list of removed plugins. """ removed, remove = [], plugin for i, plugin in list(enumerate(self.plugins))[::-1]: if remove is True or remove is plugin or remove is type(plugin) \ or getattr(plugin, 'name', True) == remove: removed.append(plugin) del self.plugins[i] if hasattr(plugin, 'close'): plugin.close() if removed: self.reset() return removed def reset(self, route=None): """ Reset all routes (force plugins to be re-applied) and clear all caches. If an ID or route object is given, only that specific route is affected. """ if route is None: routes = self.routes elif isinstance(route, Route): routes = [route] else: routes = [self.routes[route]] for route in routes: route.reset() if DEBUG: for route in routes: route.prepare() self.trigger_hook('app_reset') def close(self): """ Close the application and all installed plugins. """ for plugin in self.plugins: if hasattr(plugin, 'close'): plugin.close() def run(self, **kwargs): """ Calls :func:`run` with the same parameters. """ run(self, **kwargs) def match(self, environ): """ Search for a matching route and return a (:class:`Route` , urlargs) tuple. The second value is a dictionary with parameters extracted from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.""" return self.router.match(environ) def get_url(self, routename, **kargs): """ Return a string that matches a named route """ scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/' location = self.router.build(routename, **kargs).lstrip('/') return urljoin(urljoin('/', scriptname), location) def add_route(self, route): """ Add a route object, but do not change the :data:`Route.app` attribute.""" self.routes.append(route) self.router.add(route.rule, route.method, route, name=route.name) if DEBUG: route.prepare() def route(self, path=None, method='GET', callback=None, name=None, apply=None, skip=None, **config): """ A decorator to bind a function to a request URL. Example:: @app.route('/hello/:name') def hello(name): return 'Hello %s' % name The ``:name`` part is a wildcard. See :class:`Router` for syntax details. :param path: Request path or a list of paths to listen to. If no path is specified, it is automatically generated from the signature of the function. :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. (default: `GET`) :param callback: An optional shortcut to avoid the decorator syntax. ``route(..., callback=func)`` equals ``route(...)(func)`` :param name: The name for this route. (default: None) :param apply: A decorator or plugin or a list of plugins. These are applied to the route callback in addition to installed plugins. :param skip: A list of plugins, plugin classes or names. Matching plugins are not installed to this route. ``True`` skips all. Any additional keyword arguments are stored as route-specific configuration and passed to plugins (see :meth:`Plugin.apply`). """ if callable(path): path, callback = None, path plugins = makelist(apply) skiplist = makelist(skip) def decorator(callback): if isinstance(callback, basestring): callback = load(callback) for rule in makelist(path) or yieldroutes(callback): for verb in makelist(method): verb = verb.upper() route = Route(self, rule, verb, callback, name=name, plugins=plugins, skiplist=skiplist, **config) self.add_route(route) return callback return decorator(callback) if callback else decorator def get(self, path=None, method='GET', **options): """ Equals :meth:`route`. """ return self.route(path, method, **options) def post(self, path=None, method='POST', **options): """ Equals :meth:`route` with a ``POST`` method parameter. """ return self.route(path, method, **options) def put(self, path=None, method='PUT', **options): """ Equals :meth:`route` with a ``PUT`` method parameter. """ return self.route(path, method, **options) def delete(self, path=None, method='DELETE', **options): """ Equals :meth:`route` with a ``DELETE`` method parameter. """ return self.route(path, method, **options) def patch(self, path=None, method='PATCH', **options): """ Equals :meth:`route` with a ``PATCH`` method parameter. """ return self.route(path, method, **options) def error(self, code=500): """ Decorator: Register an output handler for a HTTP error code""" def wrapper(handler): self.error_handler[int(code)] = handler return handler return wrapper def default_error_handler(self, res): return tob(template(ERROR_PAGE_TEMPLATE, e=res)) def _handle(self, environ): path = environ['bottle.raw_path'] = environ['PATH_INFO'] if py3k: try: environ['PATH_INFO'] = path.encode('latin1').decode('utf8') except UnicodeError: return HTTPError(400, 'Invalid path string. Expected UTF-8') try: environ['bottle.app'] = self request.bind(environ) response.bind() try: self.trigger_hook('before_request') route, args = self.router.match(environ) environ['route.handle'] = route environ['bottle.route'] = route environ['route.url_args'] = args return route.call(**args) finally: self.trigger_hook('after_request') except HTTPResponse: return _e() except RouteReset: route.reset() return self._handle(environ) except (KeyboardInterrupt, SystemExit, MemoryError): raise except Exception: if not self.catchall: raise stacktrace = format_exc() environ['wsgi.errors'].write(stacktrace) return HTTPError(500, "Internal Server Error", _e(), stacktrace) def _cast(self, out, peek=None): """ Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes """ # Empty output is done here if not out: if 'Content-Length' not in response: response['Content-Length'] = 0 return [] # Join lists of byte or unicode strings. Mixed lists are NOT supported if isinstance(out, (tuple, list))\ and isinstance(out[0], (bytes, unicode)): out = out[0][0:0].join(out) # b'abc'[0:0] -> b'' # Encode unicode strings if isinstance(out, unicode): out = out.encode(response.charset) # Byte Strings are just returned if isinstance(out, bytes): if 'Content-Length' not in response: response['Content-Length'] = len(out) return [out] # HTTPError or HTTPException (recursive, because they may wrap anything) # TODO: Handle these explicitly in handle() or make them iterable. if isinstance(out, HTTPError): out.apply(response) out = self.error_handler.get(out.status_code, self.default_error_handler)(out) return self._cast(out) if isinstance(out, HTTPResponse): out.apply(response) return self._cast(out.body) # File-like objects. if hasattr(out, 'read'): if 'wsgi.file_wrapper' in request.environ: return request.environ['wsgi.file_wrapper'](out) elif hasattr(out, 'close') or not hasattr(out, '__iter__'): return WSGIFileWrapper(out) # Handle Iterables. We peek into them to detect their inner type. try: iout = iter(out) first = next(iout) while not first: first = next(iout) except StopIteration: return self._cast('') except HTTPResponse: first = _e() except (KeyboardInterrupt, SystemExit, MemoryError): raise except: if not self.catchall: raise first = HTTPError(500, 'Unhandled exception', _e(), format_exc()) # These are the inner types allowed in iterator or generator objects. if isinstance(first, HTTPResponse): return self._cast(first) elif isinstance(first, bytes): new_iter = itertools.chain([first], iout) elif isinstance(first, unicode): encoder = lambda x: x.encode(response.charset) new_iter = imap(encoder, itertools.chain([first], iout)) else: msg = 'Unsupported response type: %s' % type(first) return self._cast(HTTPError(500, msg)) if hasattr(out, 'close'): new_iter = _closeiter(new_iter, out.close) return new_iter def wsgi(self, environ, start_response): """ The bottle WSGI-interface. """ try: out = self._cast(self._handle(environ)) # rfc2616 section 4.3 if response._status_code in (100, 101, 204, 304)\ or environ['REQUEST_METHOD'] == 'HEAD': if hasattr(out, 'close'): out.close() out = [] start_response(response._status_line, response.headerlist) return out except (KeyboardInterrupt, SystemExit, MemoryError): raise except: if not self.catchall: raise err = '<h1>Critical error while processing request: %s</h1>' \ % html_escape(environ.get('PATH_INFO', '/')) if DEBUG: err += '<h2>Error:</h2>\n<pre>\n%s\n</pre>\n' \ '<h2>Traceback:</h2>\n<pre>\n%s\n</pre>\n' \ % (html_escape(repr(_e())), html_escape(format_exc())) environ['wsgi.errors'].write(err) headers = [('Content-Type', 'text/html; charset=UTF-8')] start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info()) return [tob(err)] def __call__(self, environ, start_response): """ Each instance of :class:'Bottle' is a WSGI application. """ return self.wsgi(environ, start_response) def __enter__(self): """ Use this application as default for all module-level shortcuts. """ default_app.push(self) return self def __exit__(self, exc_type, exc_value, traceback): default_app.pop() ############################################################################### # HTTP and WSGI Tools ########################################################## ############################################################################### class BaseRequest(object): """ A wrapper for WSGI environment dictionaries that adds a lot of convenient access methods and properties. Most of them are read-only. Adding new attributes to a request actually adds them to the environ dictionary (as 'bottle.request.ext.<name>'). This is the recommended way to store and access request-specific data. """ __slots__ = ('environ', ) #: Maximum size of memory buffer for :attr:`body` in bytes. MEMFILE_MAX = 102400 def __init__(self, environ=None): """ Wrap a WSGI environ dictionary. """ #: The wrapped WSGI environ dictionary. This is the only real attribute. #: All other attributes actually are read-only properties. self.environ = {} if environ is None else environ self.environ['bottle.request'] = self @DictProperty('environ', 'bottle.app', read_only=True) def app(self): """ Bottle application handling this request. """ raise RuntimeError('This request is not connected to an application.') @DictProperty('environ', 'bottle.route', read_only=True) def route(self): """ The bottle :class:`Route` object that matches this request. """ raise RuntimeError('This request is not connected to a route.') @DictProperty('environ', 'route.url_args', read_only=True) def url_args(self): """ The arguments extracted from the URL. """ raise RuntimeError('This request is not connected to a route.') @property def path(self): """ The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken clients and avoid the "empty path" edge case). """ return '/' + self.environ.get('PATH_INFO','').lstrip('/') @property def method(self): """ The ``REQUEST_METHOD`` value as an uppercase string. """ return self.environ.get('REQUEST_METHOD', 'GET').upper() @DictProperty('environ', 'bottle.request.headers', read_only=True) def headers(self): """ A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP request headers. """ return WSGIHeaderDict(self.environ) def get_header(self, name, default=None): """ Return the value of a request header, or a given default value. """ return self.headers.get(name, default) @DictProperty('environ', 'bottle.request.cookies', read_only=True) def cookies(self): """ Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. Use :meth:`get_cookie` if you expect signed cookies. """ cookies = SimpleCookie(self.environ.get('HTTP_COOKIE','')).values() return FormsDict((c.key, c.value) for c in cookies) def get_cookie(self, key, default=None, secret=None): """ Return the content of a cookie. To read a `Signed Cookie`, the `secret` must match the one used to create the cookie (see :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or wrong signature), return a default value. """ value = self.cookies.get(key) if secret and value: dec = cookie_decode(value, secret) # (key, value) tuple or None return dec[1] if dec and dec[0] == key else default return value or default @DictProperty('environ', 'bottle.request.query', read_only=True) def query(self): """ The :attr:`query_string` parsed into a :class:`FormsDict`. These values are sometimes called "URL arguments" or "GET parameters", but not to be confused with "URL wildcards" as they are provided by the :class:`Router`. """ get = self.environ['bottle.get'] = FormsDict() pairs = _parse_qsl(self.environ.get('QUERY_STRING', '')) for key, value in pairs: get[key] = value return get @DictProperty('environ', 'bottle.request.forms', read_only=True) def forms(self): """ Form values parsed from an `url-encoded` or `multipart/form-data` encoded POST or PUT request body. The result is returned as a :class:`FormsDict`. All keys and values are strings. File uploads are stored separately in :attr:`files`. """ forms = FormsDict() for name, item in self.POST.allitems(): if not isinstance(item, FileUpload): forms[name] = item return forms @DictProperty('environ', 'bottle.request.params', read_only=True) def params(self): """ A :class:`FormsDict` with the combined values of :attr:`query` and :attr:`forms`. File uploads are stored in :attr:`files`. """ params = FormsDict() for key, value in self.query.allitems(): params[key] = value for key, value in self.forms.allitems(): params[key] = value return params @DictProperty('environ', 'bottle.request.files', read_only=True) def files(self): """ File uploads parsed from `multipart/form-data` encoded POST or PUT request body. The values are instances of :class:`FileUpload`. """ files = FormsDict() for name, item in self.POST.allitems(): if isinstance(item, FileUpload): files[name] = item return files @DictProperty('environ', 'bottle.request.json', read_only=True) def json(self): """ If the ``Content-Type`` header is ``application/json``, this property holds the parsed content of the request body. Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory exhaustion. """ ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0] if ctype == 'application/json': b = self._get_body_string() if not b: return None return json_loads(b) return None def _iter_body(self, read, bufsize): maxread = max(0, self.content_length) while maxread: part = read(min(maxread, bufsize)) if not part: break yield part maxread -= len(part) @staticmethod def _iter_chunked(read, bufsize): err = HTTPError(400, 'Error while parsing chunked transfer body.') rn, sem, bs = tob('\r\n'), tob(';'), tob('') while True: header = read(1) while header[-2:] != rn: c = read(1) header += c if not c: raise err if len(header) > bufsize: raise err size, _, _ = header.partition(sem) try: maxread = int(tonat(size.strip()), 16) except ValueError: raise err if maxread == 0: break buff = bs while maxread > 0: if not buff: buff = read(min(maxread, bufsize)) part, buff = buff[:maxread], buff[maxread:] if not part: raise err yield part maxread -= len(part) if read(2) != rn: raise err @DictProperty('environ', 'bottle.request.body', read_only=True) def _body(self): body_iter = self._iter_chunked if self.chunked else self._iter_body read_func = self.environ['wsgi.input'].read body, body_size, is_temp_file = BytesIO(), 0, False for part in body_iter(read_func, self.MEMFILE_MAX): body.write(part) body_size += len(part) if not is_temp_file and body_size > self.MEMFILE_MAX: body, tmp = TemporaryFile(mode='w+b'), body body.write(tmp.getvalue()) del tmp is_temp_file = True self.environ['wsgi.input'] = body body.seek(0) return body def _get_body_string(self): """ read body until content-length or MEMFILE_MAX into a string. Raise HTTPError(413) on requests that are to large. """ clen = self.content_length if clen > self.MEMFILE_MAX: raise HTTPError(413, 'Request too large') if clen < 0: clen = self.MEMFILE_MAX + 1 data = self.body.read(clen) if len(data) > self.MEMFILE_MAX: # Fail fast raise HTTPError(413, 'Request too large') return data @property def body(self): """ The HTTP request body as a seek-able file-like object. Depending on :attr:`MEMFILE_MAX`, this is either a temporary file or a :class:`io.BytesIO` instance. Accessing this property for the first time reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses just do a `seek(0)` on the file object. """ self._body.seek(0) return self._body @property def chunked(self): """ True if Chunked transfer encoding was. """ return 'chunked' in self.environ.get('HTTP_TRANSFER_ENCODING', '').lower() #: An alias for :attr:`query`. GET = query @DictProperty('environ', 'bottle.request.post', read_only=True) def POST(self): """ The values of :attr:`forms` and :attr:`files` combined into a single :class:`FormsDict`. Values are either strings (form values) or instances of :class:`cgi.FieldStorage` (file uploads). """ post = FormsDict() # We default to application/x-www-form-urlencoded for everything that # is not multipart and take the fast path (also: 3.1 workaround) if not self.content_type.startswith('multipart/'): pairs = _parse_qsl(tonat(self._get_body_string(), 'latin1')) for key, value in pairs: post[key] = value return post safe_env = {'QUERY_STRING':''} # Build a safe environment for cgi for key in ('REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH'): if key in self.environ: safe_env[key] = self.environ[key] args = dict(fp=self.body, environ=safe_env, keep_blank_values=True) if py31: args['fp'] = NCTextIOWrapper(args['fp'], encoding='utf8', newline='\n') elif py3k: args['encoding'] = 'utf8' data = cgi.FieldStorage(**args) self['_cgi.FieldStorage'] = data #http://bugs.python.org/issue18394#msg207958 data = data.list or [] for item in data: if item.filename: post[item.name] = FileUpload(item.file, item.name, item.filename, item.headers) else: post[item.name] = item.value return post @property def url(self): """ The full request URI including hostname and scheme. If your app lives behind a reverse proxy or load balancer and you get confusing results, make sure that the ``X-Forwarded-Host`` header is set correctly. """ return self.urlparts.geturl() @DictProperty('environ', 'bottle.request.urlparts', read_only=True) def urlparts(self): """ The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple contains (scheme, host, path, query_string and fragment), but the fragment is always empty because it is not visible to the server. """ env = self.environ http = env.get('HTTP_X_FORWARDED_PROTO') or env.get('wsgi.url_scheme', 'http') host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST') if not host: # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients. host = env.get('SERVER_NAME', '127.0.0.1') port = env.get('SERVER_PORT') if port and port != ('80' if http == 'http' else '443'): host += ':' + port path = urlquote(self.fullpath) return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') @property def fullpath(self): """ Request path including :attr:`script_name` (if present). """ return urljoin(self.script_name, self.path.lstrip('/')) @property def query_string(self): """ The raw :attr:`query` part of the URL (everything in between ``?`` and ``#``) as a string. """ return self.environ.get('QUERY_STRING', '') @property def script_name(self): """ The initial portion of the URL's `path` that was removed by a higher level (server or routing middleware) before the application was called. This script path is returned with leading and tailing slashes. """ script_name = self.environ.get('SCRIPT_NAME', '').strip('/') return '/' + script_name + '/' if script_name else '/' def path_shift(self, shift=1): """ Shift path segments from :attr:`path` to :attr:`script_name` and vice versa. :param shift: The number of path segments to shift. May be negative to change the shift direction. (default: 1) """ script = self.environ.get('SCRIPT_NAME','/') self['SCRIPT_NAME'], self['PATH_INFO'] = path_shift(script, self.path, shift) @property def content_length(self): """ The request body length as an integer. The client is responsible to set this header. Otherwise, the real length of the body is unknown and -1 is returned. In this case, :attr:`body` will be empty. """ return int(self.environ.get('CONTENT_LENGTH') or -1) @property def content_type(self): """ The Content-Type header as a lowercase-string (default: empty). """ return self.environ.get('CONTENT_TYPE', '').lower() @property def is_xhr(self): """ True if the request was triggered by a XMLHttpRequest. This only works with JavaScript libraries that support the `X-Requested-With` header (most of the popular libraries do). """ requested_with = self.environ.get('HTTP_X_REQUESTED_WITH','') return requested_with.lower() == 'xmlhttprequest' @property def is_ajax(self): """ Alias for :attr:`is_xhr`. "Ajax" is not the right term. """ return self.is_xhr @property def auth(self): """ HTTP authentication data as a (user, password) tuple. This implementation currently supports basic (not digest) authentication only. If the authentication happened at a higher level (e.g. in the front web-server or a middleware), the password field is None, but the user field is looked up from the ``REMOTE_USER`` environ variable. On any errors, None is returned. """ basic = parse_auth(self.environ.get('HTTP_AUTHORIZATION','')) if basic: return basic ruser = self.environ.get('REMOTE_USER') if ruser: return (ruser, None) return None @property def remote_route(self): """ A list of all IPs that were involved in this request, starting with the client IP and followed by zero or more proxies. This does only work if all proxies support the ```X-Forwarded-For`` header. Note that this information can be forged by malicious clients. """ proxy = self.environ.get('HTTP_X_FORWARDED_FOR') if proxy: return [ip.strip() for ip in proxy.split(',')] remote = self.environ.get('REMOTE_ADDR') return [remote] if remote else [] @property def remote_addr(self): """ The client IP as a string. Note that this information can be forged by malicious clients. """ route = self.remote_route return route[0] if route else None def copy(self): """ Return a new :class:`Request` with a shallow :attr:`environ` copy. """ return Request(self.environ.copy()) def get(self, value, default=None): return self.environ.get(value, default) def __getitem__(self, key): return self.environ[key] def __delitem__(self, key): self[key] = ""; del(self.environ[key]) def __iter__(self): return iter(self.environ) def __len__(self): return len(self.environ) def keys(self): return self.environ.keys() def __setitem__(self, key, value): """ Change an environ value and clear all caches that depend on it. """ if self.environ.get('bottle.request.readonly'): raise KeyError('The environ dictionary is read-only.') self.environ[key] = value todelete = () if key == 'wsgi.input': todelete = ('body', 'forms', 'files', 'params', 'post', 'json') elif key == 'QUERY_STRING': todelete = ('query', 'params') elif key.startswith('HTTP_'): todelete = ('headers', 'cookies') for key in todelete: self.environ.pop('bottle.request.'+key, None) def __repr__(self): return '<%s: %s %s>' % (self.__class__.__name__, self.method, self.url) def __getattr__(self, name): """ Search in self.environ for additional user defined attributes. """ try: var = self.environ['bottle.request.ext.%s'%name] return var.__get__(self) if hasattr(var, '__get__') else var except KeyError: raise AttributeError('Attribute %r not defined.' % name) def __setattr__(self, name, value): if name == 'environ': return object.__setattr__(self, name, value) self.environ['bottle.request.ext.%s'%name] = value def _hkey(s): return s.title().replace('_','-') class HeaderProperty(object): def __init__(self, name, reader=None, writer=str, default=''): self.name, self.default = name, default self.reader, self.writer = reader, writer self.__doc__ = 'Current value of the %r header.' % name.title() def __get__(self, obj, _): if obj is None: return self value = obj.headers.get(self.name, self.default) return self.reader(value) if self.reader else value def __set__(self, obj, value): obj.headers[self.name] = self.writer(value) def __delete__(self, obj): del obj.headers[self.name] class BaseResponse(object): """ Storage class for a response body as well as headers and cookies. This class does support dict-like case-insensitive item-access to headers, but is NOT a dict. Most notably, iterating over a response yields parts of the body and not the headers. :param body: The response body as one of the supported types. :param status: Either an HTTP status code (e.g. 200) or a status line including the reason phrase (e.g. '200 OK'). :param headers: A dictionary or a list of name-value pairs. Additional keyword arguments are added to the list of headers. Underscores in the header name are replaced with dashes. """ default_status = 200 default_content_type = 'text/html; charset=UTF-8' # Header blacklist for specific response codes # (rfc2616 section 10.2.3 and 10.3.5) bad_headers = { 204: set(('Content-Type',)), 304: set(('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-Range', 'Content-Type', 'Content-Md5', 'Last-Modified'))} def __init__(self, body='', status=None, headers=None, **more_headers): self._cookies = None self._headers = {} self.body = body self.status = status or self.default_status if headers: if isinstance(headers, dict): headers = headers.items() for name, value in headers: self.add_header(name, value) if more_headers: for name, value in more_headers.items(): self.add_header(name, value) def copy(self, cls=None): """ Returns a copy of self. """ cls = cls or BaseResponse assert issubclass(cls, BaseResponse) copy = cls() copy.status = self.status copy._headers = dict((k, v[:]) for (k, v) in self._headers.items()) if self._cookies: copy._cookies = SimpleCookie() copy._cookies.load(self._cookies.output()) return copy def __iter__(self): return iter(self.body) def close(self): if hasattr(self.body, 'close'): self.body.close() @property def status_line(self): """ The HTTP status line as a string (e.g. ``404 Not Found``).""" return self._status_line @property def status_code(self): """ The HTTP status code as an integer (e.g. 404).""" return self._status_code def _set_status(self, status): if isinstance(status, int): code, status = status, _HTTP_STATUS_LINES.get(status) elif ' ' in status: status = status.strip() code = int(status.split()[0]) else: raise ValueError('String status line without a reason phrase.') if not 100 <= code <= 999: raise ValueError('Status code out of range.') self._status_code = code self._status_line = str(status or ('%d Unknown' % code)) def _get_status(self): return self._status_line status = property(_get_status, _set_status, None, ''' A writeable property to change the HTTP response status. It accepts either a numeric code (100-999) or a string with a custom reason phrase (e.g. "404 Brain not found"). Both :data:`status_line` and :data:`status_code` are updated accordingly. The return value is always a status string. ''') del _get_status, _set_status @property def headers(self): """ An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the response headers. """ hdict = HeaderDict() hdict.dict = self._headers return hdict def __contains__(self, name): return _hkey(name) in self._headers def __delitem__(self, name): del self._headers[_hkey(name)] def __getitem__(self, name): return self._headers[_hkey(name)][-1] def __setitem__(self, name, value): self._headers[_hkey(name)] = [str(value)] def get_header(self, name, default=None): """ Return the value of a previously defined header. If there is no header with that name, return a default value. """ return self._headers.get(_hkey(name), [default])[-1] def set_header(self, name, value): """ Create a new response header, replacing any previously defined headers with the same name. """ self._headers[_hkey(name)] = [str(value)] def add_header(self, name, value): """ Add an additional response header, not removing duplicates. """ self._headers.setdefault(_hkey(name), []).append(str(value)) def iter_headers(self): """ Yield (header, value) tuples, skipping headers that are not allowed with the current response status code. """ return self.headerlist @property def headerlist(self): """ WSGI conform list of (header, value) tuples. """ out = [] headers = list(self._headers.items()) if 'Content-Type' not in self._headers: headers.append(('Content-Type', [self.default_content_type])) if self._status_code in self.bad_headers: bad_headers = self.bad_headers[self._status_code] headers = [h for h in headers if h[0] not in bad_headers] out += [(name, val) for name, vals in headers for val in vals] if self._cookies: for c in self._cookies.values(): out.append(('Set-Cookie', c.OutputString())) return out content_type = HeaderProperty('Content-Type') content_length = HeaderProperty('Content-Length', reader=int) expires = HeaderProperty('Expires', reader=lambda x: datetime.utcfromtimestamp(parse_date(x)), writer=lambda x: http_date(x)) @property def charset(self, default='UTF-8'): """ Return the charset specified in the content-type header (default: utf8). """ if 'charset=' in self.content_type: return self.content_type.split('charset=')[-1].split(';')[0].strip() return default def set_cookie(self, name, value, secret=None, **options): """ Create a new cookie or replace an old one. If the `secret` parameter is set, create a `Signed Cookie` (described below). :param name: the name of the cookie. :param value: the value of the cookie. :param secret: a signature key required for signed cookies. Additionally, this method accepts all RFC 2109 attributes that are supported by :class:`cookie.Morsel`, including: :param max_age: maximum age in seconds. (default: None) :param expires: a datetime object or UNIX timestamp. (default: None) :param domain: the domain that is allowed to read the cookie. (default: current domain) :param path: limits the cookie to a given path (default: current path) :param secure: limit the cookie to HTTPS connections (default: off). :param httponly: prevents client-side javascript to read this cookie (default: off, requires Python 2.6 or newer). If neither `expires` nor `max_age` is set (default), the cookie will expire at the end of the browser session (as soon as the browser window is closed). Signed cookies may store any pickle-able object and are cryptographically signed to prevent manipulation. Keep in mind that cookies are limited to 4kb in most browsers. Warning: Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling save, not to store secret information at client side. """ if not self._cookies: self._cookies = SimpleCookie() if secret: value = touni(cookie_encode((name, value), secret)) elif not isinstance(value, basestring): raise TypeError('Secret key missing for non-string Cookie.') if len(value) > 4096: raise ValueError('Cookie value to long.') self._cookies[name] = value for key, value in options.items(): if key == 'max_age': if isinstance(value, timedelta): value = value.seconds + value.days * 24 * 3600 if key == 'expires': if isinstance(value, (datedate, datetime)): value = value.timetuple() elif isinstance(value, (int, float)): value = time.gmtime(value) value = time.strftime("%a, %d %b %Y %H:%M:%S GMT", value) self._cookies[name][key.replace('_', '-')] = value def delete_cookie(self, key, **kwargs): """ Delete a cookie. Be sure to use the same `domain` and `path` settings as used to create the cookie. """ kwargs['max_age'] = -1 kwargs['expires'] = 0 self.set_cookie(key, '', **kwargs) def __repr__(self): out = '' for name, value in self.headerlist: out += '%s: %s\n' % (name.title(), value.strip()) return out def _local_property(): ls = threading.local() def fget(_): try: return ls.var except AttributeError: raise RuntimeError("Request context not initialized.") def fset(_, value): ls.var = value def fdel(_): del ls.var return property(fget, fset, fdel, 'Thread-local property') class LocalRequest(BaseRequest): """ A thread-local subclass of :class:`BaseRequest` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`request`). If accessed during a request/response cycle, this instance always refers to the *current* request (even on a multithreaded server). """ bind = BaseRequest.__init__ environ = _local_property() class LocalResponse(BaseResponse): """ A thread-local subclass of :class:`BaseResponse` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`response`). Its attributes are used to build the HTTP response at the end of the request/response cycle. """ bind = BaseResponse.__init__ _status_line = _local_property() _status_code = _local_property() _cookies = _local_property() _headers = _local_property() body = _local_property() Request = BaseRequest Response = BaseResponse class HTTPResponse(Response, BottleException): def __init__(self, body='', status=None, headers=None, **more_headers): super(HTTPResponse, self).__init__(body, status, headers, **more_headers) def apply(self, other): other._status_code = self._status_code other._status_line = self._status_line other._headers = self._headers other._cookies = self._cookies other.body = self.body class HTTPError(HTTPResponse): default_status = 500 def __init__(self, status=None, body=None, exception=None, traceback=None, **options): self.exception = exception self.traceback = traceback super(HTTPError, self).__init__(body, status, **options) ############################################################################### # Plugins ###################################################################### ############################################################################### class PluginError(BottleException): pass class JSONPlugin(object): name = 'json' api = 2 def __init__(self, json_dumps=json_dumps): self.json_dumps = json_dumps def apply(self, callback, _): dumps = self.json_dumps if not dumps: return callback def wrapper(*a, **ka): try: rv = callback(*a, **ka) except HTTPError: rv = _e() if isinstance(rv, dict): #Attempt to serialize, raises exception on failure json_response = dumps(rv) #Set content type only if serialization successful response.content_type = 'application/json' return json_response elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict): rv.body = dumps(rv.body) rv.content_type = 'application/json' return rv return wrapper class TemplatePlugin(object): """ This plugin applies the :func:`view` decorator to all routes with a `template` config parameter. If the parameter is a tuple, the second element must be a dict with additional options (e.g. `template_engine`) or default variables for the template. """ name = 'template' api = 2 def apply(self, callback, route): conf = route.config.get('template') if isinstance(conf, (tuple, list)) and len(conf) == 2: return view(conf[0], **conf[1])(callback) elif isinstance(conf, str): return view(conf)(callback) else: return callback #: Not a plugin, but part of the plugin API. TODO: Find a better place. class _ImportRedirect(object): def __init__(self, name, impmask): """ Create a virtual package that redirects imports (see PEP 302). """ self.name = name self.impmask = impmask self.module = sys.modules.setdefault(name, imp.new_module(name)) self.module.__dict__.update({'__file__': __file__, '__path__': [], '__all__': [], '__loader__': self}) sys.meta_path.append(self) def find_module(self, fullname, path=None): if '.' not in fullname: return packname = fullname.rsplit('.', 1)[0] if packname != self.name: return return self def load_module(self, fullname): if fullname in sys.modules: return sys.modules[fullname] modname = fullname.rsplit('.', 1)[1] realname = self.impmask % modname __import__(realname) module = sys.modules[fullname] = sys.modules[realname] setattr(self.module, modname, module) module.__loader__ = self return module ############################################################################### # Common Utilities ############################################################# ############################################################################### class MultiDict(DictMixin): """ This dict stores multiple values per key, but behaves exactly like a normal dict in that it returns only the newest value for any given key. There are special methods available to access the full list of values. """ def __init__(self, *a, **k): self.dict = dict((k, [v]) for (k, v) in dict(*a, **k).items()) def __len__(self): return len(self.dict) def __iter__(self): return iter(self.dict) def __contains__(self, key): return key in self.dict def __delitem__(self, key): del self.dict[key] def __getitem__(self, key): return self.dict[key][-1] def __setitem__(self, key, value): self.append(key, value) def keys(self): return self.dict.keys() if py3k: def values(self): return (v[-1] for v in self.dict.values()) def items(self): return ((k, v[-1]) for k, v in self.dict.items()) def allitems(self): return ((k, v) for k, vl in self.dict.items() for v in vl) iterkeys = keys itervalues = values iteritems = items iterallitems = allitems else: def values(self): return [v[-1] for v in self.dict.values()] def items(self): return [(k, v[-1]) for k, v in self.dict.items()] def iterkeys(self): return self.dict.iterkeys() def itervalues(self): return (v[-1] for v in self.dict.itervalues()) def iteritems(self): return ((k, v[-1]) for k, v in self.dict.iteritems()) def iterallitems(self): return ((k, v) for k, vl in self.dict.iteritems() for v in vl) def allitems(self): return [(k, v) for k, vl in self.dict.iteritems() for v in vl] def get(self, key, default=None, index=-1, type=None): """ Return the most recent value for a key. :param default: The default value to be returned if the key is not present or the type conversion fails. :param index: An index for the list of available values. :param type: If defined, this callable is used to cast the value into a specific type. Exception are suppressed and result in the default value to be returned. """ try: val = self.dict[key][index] return type(val) if type else val except Exception: pass return default def append(self, key, value): """ Add a new value to the list of values for this key. """ self.dict.setdefault(key, []).append(value) def replace(self, key, value): """ Replace the list of values with a single value. """ self.dict[key] = [value] def getall(self, key): """ Return a (possibly empty) list of values for a key. """ return self.dict.get(key) or [] #: Aliases for WTForms to mimic other multi-dict APIs (Django) getone = get getlist = getall class FormsDict(MultiDict): """ This :class:`MultiDict` subclass is used to store request form data. Additionally to the normal dict-like item access methods (which return unmodified data as native strings), this container also supports attribute-like access to its values. Attributes are automatically de- or recoded to match :attr:`input_encoding` (default: 'utf8'). Missing attributes default to an empty string. """ #: Encoding used for attribute values. input_encoding = 'utf8' #: If true (default), unicode strings are first encoded with `latin1` #: and then decoded to match :attr:`input_encoding`. recode_unicode = True def _fix(self, s, encoding=None): if isinstance(s, unicode) and self.recode_unicode: # Python 3 WSGI return s.encode('latin1').decode(encoding or self.input_encoding) elif isinstance(s, bytes): # Python 2 WSGI return s.decode(encoding or self.input_encoding) else: return s def decode(self, encoding=None): """ Returns a copy with all keys and values de- or recoded to match :attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode dictionary. """ copy = FormsDict() enc = copy.input_encoding = encoding or self.input_encoding copy.recode_unicode = False for key, value in self.allitems(): copy.append(self._fix(key, enc), self._fix(value, enc)) return copy def getunicode(self, name, default=None, encoding=None): """ Return the value as a unicode string, or the default. """ try: return self._fix(self[name], encoding) except (UnicodeError, KeyError): return default def __getattr__(self, name, default=unicode()): # Without this guard, pickle generates a cryptic TypeError: if name.startswith('__') and name.endswith('__'): return super(FormsDict, self).__getattr__(name) return self.getunicode(name, default=default) class HeaderDict(MultiDict): """ A case-insensitive version of :class:`MultiDict` that defaults to replace the old value instead of appending it. """ def __init__(self, *a, **ka): self.dict = {} if a or ka: self.update(*a, **ka) def __contains__(self, key): return _hkey(key) in self.dict def __delitem__(self, key): del self.dict[_hkey(key)] def __getitem__(self, key): return self.dict[_hkey(key)][-1] def __setitem__(self, key, value): self.dict[_hkey(key)] = [str(value)] def append(self, key, value): self.dict.setdefault(_hkey(key), []).append(str(value)) def replace(self, key, value): self.dict[_hkey(key)] = [str(value)] def getall(self, key): return self.dict.get(_hkey(key)) or [] def get(self, key, default=None, index=-1): return MultiDict.get(self, _hkey(key), default, index) def filter(self, names): for name in [_hkey(n) for n in names]: if name in self.dict: del self.dict[name] class WSGIHeaderDict(DictMixin): """ This dict-like class wraps a WSGI environ dict and provides convenient access to HTTP_* fields. Keys and values are native strings (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI environment contains non-native string values, these are de- or encoded using a lossless 'latin1' character set. The API will remain stable even on changes to the relevant PEPs. Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-native strings.) """ #: List of keys that do not have a ``HTTP_`` prefix. cgikeys = ('CONTENT_TYPE', 'CONTENT_LENGTH') def __init__(self, environ): self.environ = environ def _ekey(self, key): """ Translate header field name to CGI/WSGI environ key. """ key = key.replace('-','_').upper() if key in self.cgikeys: return key return 'HTTP_' + key def raw(self, key, default=None): """ Return the header value as is (may be bytes or unicode). """ return self.environ.get(self._ekey(key), default) def __getitem__(self, key): return tonat(self.environ[self._ekey(key)], 'latin1') def __setitem__(self, key, value): raise TypeError("%s is read-only." % self.__class__) def __delitem__(self, key): raise TypeError("%s is read-only." % self.__class__) def __iter__(self): for key in self.environ: if key[:5] == 'HTTP_': yield _hkey(key[5:]) elif key in self.cgikeys: yield _hkey(key) def keys(self): return [x for x in self] def __len__(self): return len(self.keys()) def __contains__(self, key): return self._ekey(key) in self.environ class ConfigDict(dict): """ A dict-like configuration storage with additional support for namespaces, validators, meta-data, on_change listeners and more. """ __slots__ = ('_meta', '_on_change') def __init__(self): self._meta = {} self._on_change = lambda name, value: None def load_config(self, filename): """ Load values from an ``*.ini`` style config file. If the config file contains sections, their names are used as namespaces for the values within. The two special sections ``DEFAULT`` and ``bottle`` refer to the root namespace (no prefix). """ conf = ConfigParser() conf.read(filename) for section in conf.sections(): for key, value in conf.items(section): if section not in ('DEFAULT', 'bottle'): key = section + '.' + key self[key] = value return self def load_dict(self, source, namespace=''): """ Load values from a dictionary structure. Nesting can be used to represent namespaces. >>> c = ConfigDict() >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) {'some.namespace.key': 'value'} """ for key, value in source.items(): if isinstance(key, str): nskey = (namespace + '.' + key).strip('.') if isinstance(value, dict): self.load_dict(value, namespace=nskey) else: self[nskey] = value else: raise TypeError('Key has type %r (not a string)' % type(key)) return self def update(self, *a, **ka): """ If the first parameter is a string, all keys are prefixed with this namespace. Apart from that it works just as the usual dict.update(). Example: ``update('some.namespace', key='value')`` """ prefix = '' if a and isinstance(a[0], str): prefix = a[0].strip('.') + '.' a = a[1:] for key, value in dict(*a, **ka).items(): self[prefix+key] = value def setdefault(self, key, value): if key not in self: self[key] = value def __setitem__(self, key, value): if not isinstance(key, str): raise TypeError('Key has type %r (not a string)' % type(key)) value = self.meta_get(key, 'filter', lambda x: x)(value) if key in self and self[key] is value: return self._on_change(key, value) dict.__setitem__(self, key, value) def __delitem__(self, key): self._on_change(key, None) dict.__delitem__(self, key) def meta_get(self, key, metafield, default=None): """ Return the value of a meta field for a key. """ return self._meta.get(key, {}).get(metafield, default) def meta_set(self, key, metafield, value): """ Set the meta field for a key to a new value. This triggers the on-change handler for existing keys. """ self._meta.setdefault(key, {})[metafield] = value if key in self: self[key] = self[key] def meta_list(self, key): """ Return an iterable of meta field names defined for a key. """ return self._meta.get(key, {}).keys() class AppStack(list): """ A stack-like list. Calling it returns the head of the stack. """ def __call__(self): """ Return the current default application. """ return self[-1] def push(self, value=None): """ Add a new :class:`Bottle` instance to the stack """ if not isinstance(value, Bottle): value = Bottle() self.append(value) return value class WSGIFileWrapper(object): def __init__(self, fp, buffer_size=1024*64): self.fp, self.buffer_size = fp, buffer_size for attr in ('fileno', 'close', 'read', 'readlines', 'tell', 'seek'): if hasattr(fp, attr): setattr(self, attr, getattr(fp, attr)) def __iter__(self): buff, read = self.buffer_size, self.read while True: part = read(buff) if not part: return yield part class _closeiter(object): """ This only exists to be able to attach a .close method to iterators that do not support attribute assignment (most of itertools). """ def __init__(self, iterator, close=None): self.iterator = iterator self.close_callbacks = makelist(close) def __iter__(self): return iter(self.iterator) def close(self): for func in self.close_callbacks: func() class ResourceManager(object): """ This class manages a list of search paths and helps to find and open application-bound resources (files). :param base: default value for :meth:`add_path` calls. :param opener: callable used to open resources. :param cachemode: controls which lookups are cached. One of 'all', 'found' or 'none'. """ def __init__(self, base='./', opener=open, cachemode='all'): self.opener = opener self.base = base self.cachemode = cachemode #: A list of search paths. See :meth:`add_path` for details. self.path = [] #: A cache for resolved paths. ``res.cache.clear()`` clears the cache. self.cache = {} def add_path(self, path, base=None, index=None, create=False): """ Add a new path to the list of search paths. Return False if the path does not exist. :param path: The new search path. Relative paths are turned into an absolute and normalized form. If the path looks like a file (not ending in `/`), the filename is stripped off. :param base: Path used to absolutize relative search paths. Defaults to :attr:`base` which defaults to ``os.getcwd()``. :param index: Position within the list of search paths. Defaults to last index (appends to the list). The `base` parameter makes it easy to reference files installed along with a python module or package:: res.add_path('./resources/', __file__) """ base = os.path.abspath(os.path.dirname(base or self.base)) path = os.path.abspath(os.path.join(base, os.path.dirname(path))) path += os.sep if path in self.path: self.path.remove(path) if create and not os.path.isdir(path): os.makedirs(path) if index is None: self.path.append(path) else: self.path.insert(index, path) self.cache.clear() return os.path.exists(path) def __iter__(self): """ Iterate over all existing files in all registered paths. """ search = self.path[:] while search: path = search.pop() if not os.path.isdir(path): continue for name in os.listdir(path): full = os.path.join(path, name) if os.path.isdir(full): search.append(full) else: yield full def lookup(self, name): """ Search for a resource and return an absolute file path, or `None`. The :attr:`path` list is searched in order. The first match is returend. Symlinks are followed. The result is cached to speed up future lookups. """ if name not in self.cache or DEBUG: for path in self.path: fpath = os.path.join(path, name) if os.path.isfile(fpath): if self.cachemode in ('all', 'found'): self.cache[name] = fpath return fpath if self.cachemode == 'all': self.cache[name] = None return self.cache[name] def open(self, name, mode='r', *args, **kwargs): """ Find a resource and return a file object, or raise IOError. """ fname = self.lookup(name) if not fname: raise IOError("Resource %r not found." % name) return self.opener(fname, mode=mode, *args, **kwargs) class FileUpload(object): def __init__(self, fileobj, name, filename, headers=None): """ Wrapper for file uploads. """ #: Open file(-like) object (BytesIO buffer or temporary file) self.file = fileobj #: Name of the upload form field self.name = name #: Raw filename as sent by the client (may contain unsafe characters) self.raw_filename = filename #: A :class:`HeaderDict` with additional headers (e.g. content-type) self.headers = HeaderDict(headers) if headers else HeaderDict() content_type = HeaderProperty('Content-Type') content_length = HeaderProperty('Content-Length', reader=int, default=-1) @cached_property def filename(self): """ Name of the file on the client file system, but normalized to ensure file system compatibility. An empty filename is returned as 'empty'. Only ASCII letters, digits, dashes, underscores and dots are allowed in the final filename. Accents are removed, if possible. Whitespace is replaced by a single dash. Leading or tailing dots or dashes are removed. The filename is limited to 255 characters. """ fname = self.raw_filename if not isinstance(fname, unicode): fname = fname.decode('utf8', 'ignore') fname = normalize('NFKD', fname).encode('ASCII', 'ignore').decode('ASCII') fname = os.path.basename(fname.replace('\\', os.path.sep)) fname = re.sub(r'[^a-zA-Z0-9-_.\s]', '', fname).strip() fname = re.sub(r'[-\s]+', '-', fname).strip('.-') return fname[:255] or 'empty' def _copy_file(self, fp, chunk_size=2**16): read, write, offset = self.file.read, fp.write, self.file.tell() while 1: buf = read(chunk_size) if not buf: break write(buf) self.file.seek(offset) def save(self, destination, overwrite=False, chunk_size=2**16): """ Save file to disk or copy its content to an open file(-like) object. If *destination* is a directory, :attr:`filename` is added to the path. Existing files are not overwritten by default (IOError). :param destination: File path, directory or file(-like) object. :param overwrite: If True, replace existing files. (default: False) :param chunk_size: Bytes to read at a time. (default: 64kb) """ if isinstance(destination, basestring): # Except file-likes here if os.path.isdir(destination): destination = os.path.join(destination, self.filename) if not overwrite and os.path.exists(destination): raise IOError('File exists.') with open(destination, 'wb') as fp: self._copy_file(fp, chunk_size) else: self._copy_file(destination, chunk_size) ############################################################################### # Application Helper ########################################################### ############################################################################### def abort(code=500, text='Unknown Error.'): """ Aborts execution and causes a HTTP error. """ raise HTTPError(code, text) def redirect(url, code=None): """ Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version. """ if not code: code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302 res = response.copy(cls=HTTPResponse) res.status = code res.body = "" res.set_header('Location', urljoin(request.url, url)) raise res def _file_iter_range(fp, offset, bytes, maxread=1024*1024): """ Yield chunks from a range in a file. No chunk is bigger than maxread.""" fp.seek(offset) while bytes > 0: part = fp.read(min(bytes, maxread)) if not part: break bytes -= len(part) yield part def static_file(filename, root, mimetype='auto', download=False, charset='UTF-8'): """ Open a file in a safe way and return :exc:`HTTPResponse` with status code 200, 305, 403 or 404. The ``Content-Type``, ``Content-Encoding``, ``Content-Length`` and ``Last-Modified`` headers are set if possible. Special support for ``If-Modified-Since``, ``Range`` and ``HEAD`` requests. :param filename: Name or path of the file to send. :param root: Root path for file lookups. Should be an absolute directory path. :param mimetype: Defines the content-type header (default: guess from file extension) :param download: If True, ask the browser to open a `Save as...` dialog instead of opening the file with the associated program. You can specify a custom filename as a string. If not specified, the original filename is used (default: False). :param charset: The charset to use for files with a ``text/*`` mime-type. (default: UTF-8) """ root = os.path.abspath(root) + os.sep filename = os.path.abspath(os.path.join(root, filename.strip('/\\'))) headers = dict() if not filename.startswith(root): return HTTPError(403, "Access denied.") if not os.path.exists(filename) or not os.path.isfile(filename): return HTTPError(404, "File does not exist.") if not os.access(filename, os.R_OK): return HTTPError(403, "You do not have permission to access this file.") if mimetype == 'auto': mimetype, encoding = mimetypes.guess_type(filename) if encoding: headers['Content-Encoding'] = encoding if mimetype: if mimetype[:5] == 'text/' and charset and 'charset' not in mimetype: mimetype += '; charset=%s' % charset headers['Content-Type'] = mimetype if download: download = os.path.basename(filename if download == True else download) headers['Content-Disposition'] = 'attachment; filename="%s"' % download stats = os.stat(filename) headers['Content-Length'] = clen = stats.st_size lm = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(stats.st_mtime)) headers['Last-Modified'] = lm ims = request.environ.get('HTTP_IF_MODIFIED_SINCE') if ims: ims = parse_date(ims.split(";")[0].strip()) if ims is not None and ims >= int(stats.st_mtime): headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) return HTTPResponse(status=304, **headers) body = '' if request.method == 'HEAD' else open(filename, 'rb') headers["Accept-Ranges"] = "bytes" ranges = request.environ.get('HTTP_RANGE') if 'HTTP_RANGE' in request.environ: ranges = list(parse_range_header(request.environ['HTTP_RANGE'], clen)) if not ranges: return HTTPError(416, "Requested Range Not Satisfiable") offset, end = ranges[0] headers["Content-Range"] = "bytes %d-%d/%d" % (offset, end-1, clen) headers["Content-Length"] = str(end-offset) if body: body = _file_iter_range(body, offset, end-offset) return HTTPResponse(body, status=206, **headers) return HTTPResponse(body, **headers) ############################################################################### # HTTP Utilities and MISC (TODO) ############################################### ############################################################################### def debug(mode=True): """ Change the debug level. There is only one debug level supported at the moment.""" global DEBUG if mode: warnings.simplefilter('default') DEBUG = bool(mode) def http_date(value): if isinstance(value, (datedate, datetime)): value = value.utctimetuple() elif isinstance(value, (int, float)): value = time.gmtime(value) if not isinstance(value, basestring): value = time.strftime("%a, %d %b %Y %H:%M:%S GMT", value) return value def parse_date(ims): """ Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. """ try: ts = email.utils.parsedate_tz(ims) return time.mktime(ts[:8] + (0,)) - (ts[9] or 0) - time.timezone except (TypeError, ValueError, IndexError, OverflowError): return None def parse_auth(header): """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" try: method, data = header.split(None, 1) if method.lower() == 'basic': user, pwd = touni(base64.b64decode(tob(data))).split(':',1) return user, pwd except (KeyError, ValueError): return None def parse_range_header(header, maxlen=0): """ Yield (start, end) ranges parsed from a HTTP Range header. Skip unsatisfiable ranges. The end index is non-inclusive.""" if not header or header[:6] != 'bytes=': return ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r] for start, end in ranges: try: if not start: # bytes=-100 -> last 100 bytes start, end = max(0, maxlen-int(end)), maxlen elif not end: # bytes=100- -> all but the first 99 bytes start, end = int(start), maxlen else: # bytes=100-200 -> bytes 100-200 (inclusive) start, end = int(start), min(int(end)+1, maxlen) if 0 <= start < end <= maxlen: yield start, end except ValueError: pass def _parse_qsl(qs): r = [] for pair in qs.replace(';','&').split('&'): if not pair: continue nv = pair.split('=', 1) if len(nv) != 2: nv.append('') key = urlunquote(nv[0].replace('+', ' ')) value = urlunquote(nv[1].replace('+', ' ')) r.append((key, value)) return r def _lscmp(a, b): """ Compares two strings in a cryptographically safe way: Runtime is not affected by length of common prefix. """ return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b) def cookie_encode(data, key): """ Encode and sign a pickle-able object. Return a (byte) string """ msg = base64.b64encode(pickle.dumps(data, -1)) sig = base64.b64encode(hmac.new(tob(key), msg).digest()) return tob('!') + sig + tob('?') + msg def cookie_decode(data, key): """ Verify and decode an encoded string. Return an object or None.""" data = tob(data) if cookie_is_encoded(data): sig, msg = data.split(tob('?'), 1) if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg).digest())): return pickle.loads(base64.b64decode(msg)) return None def cookie_is_encoded(data): """ Return True if the argument looks like a encoded cookie.""" return bool(data.startswith(tob('!')) and tob('?') in data) def html_escape(string): """ Escape HTML special characters ``&<>`` and quotes ``'"``. """ return string.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')\ .replace('"','&quot;').replace("'",'&#039;') def html_quote(string): """ Escape and quote a string to be used as an HTTP attribute.""" return '"%s"' % html_escape(string).replace('\n','&#10;')\ .replace('\r','&#13;').replace('\t','&#9;') def yieldroutes(func): """ Return a generator for routes that match the signature (name, args) of the func parameter. This may yield more than one route if the function takes optional keyword arguments. The output is best described by example:: a() -> '/a' b(x, y) -> '/b/<x>/<y>' c(x, y=5) -> '/c/<x>' and '/c/<x>/<y>' d(x=5, y=6) -> '/d' and '/d/<x>' and '/d/<x>/<y>' """ path = '/' + func.__name__.replace('__','/').lstrip('/') spec = getargspec(func) argc = len(spec[0]) - len(spec[3] or []) path += ('/<%s>' * argc) % tuple(spec[0][:argc]) yield path for arg in spec[0][argc:]: path += '/<%s>' % arg yield path def path_shift(script_name, path_info, shift=1): """ Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. :return: The modified paths. :param script_name: The SCRIPT_NAME path. :param script_name: The PATH_INFO path. :param shift: The number of path fragments to shift. May be negative to change the shift direction. (default: 1) """ if shift == 0: return script_name, path_info pathlist = path_info.strip('/').split('/') scriptlist = script_name.strip('/').split('/') if pathlist and pathlist[0] == '': pathlist = [] if scriptlist and scriptlist[0] == '': scriptlist = [] if 0 < shift <= len(pathlist): moved = pathlist[:shift] scriptlist = scriptlist + moved pathlist = pathlist[shift:] elif 0 > shift >= -len(scriptlist): moved = scriptlist[shift:] pathlist = moved + pathlist scriptlist = scriptlist[:shift] else: empty = 'SCRIPT_NAME' if shift < 0 else 'PATH_INFO' raise AssertionError("Cannot shift. Nothing left from %s" % empty) new_script_name = '/' + '/'.join(scriptlist) new_path_info = '/' + '/'.join(pathlist) if path_info.endswith('/') and pathlist: new_path_info += '/' return new_script_name, new_path_info def auth_basic(check, realm="private", text="Access denied"): """ Callback decorator to require HTTP auth (basic). TODO: Add route(check_auth=...) parameter. """ def decorator(func): @functools.wraps(func) def wrapper(*a, **ka): user, password = request.auth or (None, None) if user is None or not check(user, password): err = HTTPError(401, text) err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm) return err return func(*a, **ka) return wrapper return decorator # Shortcuts for common Bottle methods. # They all refer to the current default application. def make_default_app_wrapper(name): """ Return a callable that relays calls to the current default app. """ @functools.wraps(getattr(Bottle, name)) def wrapper(*a, **ka): return getattr(app(), name)(*a, **ka) return wrapper route = make_default_app_wrapper('route') get = make_default_app_wrapper('get') post = make_default_app_wrapper('post') put = make_default_app_wrapper('put') delete = make_default_app_wrapper('delete') patch = make_default_app_wrapper('patch') error = make_default_app_wrapper('error') mount = make_default_app_wrapper('mount') hook = make_default_app_wrapper('hook') install = make_default_app_wrapper('install') uninstall = make_default_app_wrapper('uninstall') url = make_default_app_wrapper('get_url') ############################################################################### # Server Adapter ############################################################### ############################################################################### class ServerAdapter(object): quiet = False def __init__(self, host='127.0.0.1', port=8080, **options): self.options = options self.host = host self.port = int(port) def run(self, handler): # pragma: no cover pass def __repr__(self): args = ', '.join(['%s=%s'%(k,repr(v)) for k, v in self.options.items()]) return "%s(%s)" % (self.__class__.__name__, args) class CGIServer(ServerAdapter): quiet = True def run(self, handler): # pragma: no cover from wsgiref.handlers import CGIHandler def fixed_environ(environ, start_response): environ.setdefault('PATH_INFO', '') return handler(environ, start_response) CGIHandler().run(fixed_environ) class FlupFCGIServer(ServerAdapter): def run(self, handler): # pragma: no cover import flup.server.fcgi self.options.setdefault('bindAddress', (self.host, self.port)) flup.server.fcgi.WSGIServer(handler, **self.options).run() class WSGIRefServer(ServerAdapter): def run(self, app): # pragma: no cover from wsgiref.simple_server import make_server from wsgiref.simple_server import WSGIRequestHandler, WSGIServer import socket class FixedHandler(WSGIRequestHandler): def address_string(self): # Prevent reverse DNS lookups please. return self.client_address[0] def log_request(*args, **kw): if not self.quiet: return WSGIRequestHandler.log_request(*args, **kw) handler_cls = self.options.get('handler_class', FixedHandler) server_cls = self.options.get('server_class', WSGIServer) if ':' in self.host: # Fix wsgiref for IPv6 addresses. if getattr(server_cls, 'address_family') == socket.AF_INET: class server_cls(server_cls): address_family = socket.AF_INET6 self.srv = make_server(self.host, self.port, app, server_cls, handler_cls) self.port = self.srv.server_port # update port actual port (0 means random) try: self.srv.serve_forever() except KeyboardInterrupt: self.srv.server_close() # Prevent ResourceWarning: unclosed socket raise class CherryPyServer(ServerAdapter): def run(self, handler): # pragma: no cover from cherrypy import wsgiserver self.options['bind_addr'] = (self.host, self.port) self.options['wsgi_app'] = handler certfile = self.options.get('certfile') if certfile: del self.options['certfile'] keyfile = self.options.get('keyfile') if keyfile: del self.options['keyfile'] server = wsgiserver.CherryPyWSGIServer(**self.options) if certfile: server.ssl_certificate = certfile if keyfile: server.ssl_private_key = keyfile try: server.start() finally: server.stop() class WaitressServer(ServerAdapter): def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port) class PasteServer(ServerAdapter): def run(self, handler): # pragma: no cover from paste import httpserver from paste.translogger import TransLogger handler = TransLogger(handler, setup_console_handler=(not self.quiet)) httpserver.serve(handler, host=self.host, port=str(self.port), **self.options) class MeinheldServer(ServerAdapter): def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler) class FapwsServer(ServerAdapter): """ Extremely fast webserver using libev. See http://www.fapws.org/ """ def run(self, handler): # pragma: no cover import fapws._evwsgi as evwsgi from fapws import base, config port = self.port if float(config.SERVER_IDENT[-2:]) > 0.4: # fapws3 silently changed its API in 0.5 port = str(port) evwsgi.start(self.host, port) # fapws3 never releases the GIL. Complain upstream. I tried. No luck. if 'BOTTLE_CHILD' in os.environ and not self.quiet: _stderr("WARNING: Auto-reloading does not work with Fapws3.\n") _stderr(" (Fapws3 breaks python thread support)\n") evwsgi.set_base_module(base) def app(environ, start_response): environ['wsgi.multiprocess'] = False return handler(environ, start_response) evwsgi.wsgi_cb(('', app)) evwsgi.run() class TornadoServer(ServerAdapter): """ The super hyped asynchronous server by facebook. Untested. """ def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port,address=self.host) tornado.ioloop.IOLoop.instance().start() class AppEngineServer(ServerAdapter): """ Adapter for Google App Engine. """ quiet = True def run(self, handler): from google.appengine.ext.webapp import util # A main() function in the handler script enables 'App Caching'. # Lets makes sure it is there. This _really_ improves performance. module = sys.modules.get('__main__') if module and not hasattr(module, 'main'): module.main = lambda: util.run_wsgi_app(handler) util.run_wsgi_app(handler) class TwistedServer(ServerAdapter): """ Untested. """ def run(self, handler): from twisted.web import server, wsgi from twisted.python.threadpool import ThreadPool from twisted.internet import reactor thread_pool = ThreadPool() thread_pool.start() reactor.addSystemEventTrigger('after', 'shutdown', thread_pool.stop) factory = server.Site(wsgi.WSGIResource(reactor, thread_pool, handler)) reactor.listenTCP(self.port, factory, interface=self.host) if not reactor.running: reactor.run() class DieselServer(ServerAdapter): """ Untested. """ def run(self, handler): from diesel.protocols.wsgi import WSGIApplication app = WSGIApplication(handler, port=self.port) app.run() class GeventServer(ServerAdapter): """ Untested. Options: * `fast` (default: False) uses libevent's http server, but has some issues: No streaming, no pipelining, no SSL. * See gevent.wsgi.WSGIServer() documentation for more options. """ def run(self, handler): from gevent import wsgi, pywsgi, local if not isinstance(threading.local(), local.local): msg = "Bottle requires gevent.monkey.patch_all() (before import)" raise RuntimeError(msg) if not self.options.pop('fast', None): wsgi = pywsgi self.options['log'] = None if self.quiet else 'default' address = (self.host, self.port) server = wsgi.WSGIServer(address, handler, **self.options) if 'BOTTLE_CHILD' in os.environ: import signal signal.signal(signal.SIGINT, lambda s, f: server.stop()) server.serve_forever() class GeventSocketIOServer(ServerAdapter): def run(self,handler): from socketio import server address = (self.host, self.port) server.SocketIOServer(address, handler, **self.options).serve_forever() class GunicornServer(ServerAdapter): """ Untested. See http://gunicorn.org/configure.html for options. """ def run(self, handler): from gunicorn.app.base import Application config = {'bind': "%s:%d" % (self.host, int(self.port))} config.update(self.options) class GunicornApplication(Application): def init(self, parser, opts, args): return config def load(self): return handler GunicornApplication().run() class EventletServer(ServerAdapter): """ Untested. Options: * `backlog` adjust the eventlet backlog parameter which is the maximum number of queued connections. Should be at least 1; the maximum value is system-dependent. * `family`: (default is 2) socket family, optional. See socket documentation for available families. """ def run(self, handler): from eventlet import wsgi, listen, patcher if not patcher.is_monkey_patched(os): msg = "Bottle requires eventlet.monkey_patch() (before import)" raise RuntimeError(msg) socket_args = {} for arg in ('backlog', 'family'): try: socket_args[arg] = self.options.pop(arg) except KeyError: pass address = (self.host, self.port) try: wsgi.server(listen(address, **socket_args), handler, log_output=(not self.quiet)) except TypeError: # Fallback, if we have old version of eventlet wsgi.server(listen(address), handler) class RocketServer(ServerAdapter): """ Untested. """ def run(self, handler): from rocket import Rocket server = Rocket((self.host, self.port), 'wsgi', { 'wsgi_app' : handler }) server.start() class BjoernServer(ServerAdapter): """ Fast server written in C: https://github.com/jonashaag/bjoern """ def run(self, handler): from bjoern import run run(handler, self.host, self.port) class AutoServer(ServerAdapter): """ Untested. """ adapters = [WaitressServer, PasteServer, TwistedServer, CherryPyServer, WSGIRefServer] def run(self, handler): for sa in self.adapters: try: return sa(self.host, self.port, **self.options).run(handler) except ImportError: pass server_names = { 'cgi': CGIServer, 'flup': FlupFCGIServer, 'wsgiref': WSGIRefServer, 'waitress': WaitressServer, 'cherrypy': CherryPyServer, 'paste': PasteServer, 'fapws3': FapwsServer, 'tornado': TornadoServer, 'gae': AppEngineServer, 'twisted': TwistedServer, 'diesel': DieselServer, 'meinheld': MeinheldServer, 'gunicorn': GunicornServer, 'eventlet': EventletServer, 'gevent': GeventServer, 'geventSocketIO':GeventSocketIOServer, 'rocket': RocketServer, 'bjoern' : BjoernServer, 'auto': AutoServer, } ############################################################################### # Application Control ########################################################## ############################################################################### def load(target, **namespace): """ Import a module or fetch an object from a module. * ``package.module`` returns `module` as a module object. * ``pack.mod:name`` returns the module variable `name` from `pack.mod`. * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result. The last form accepts not only function calls, but any type of expression. Keyword arguments passed to this function are available as local variables. Example: ``import_string('re:compile(x)', x='[a-z]')`` """ module, target = target.split(":", 1) if ':' in target else (target, None) if module not in sys.modules: __import__(module) if not target: return sys.modules[module] if target.isalnum(): return getattr(sys.modules[module], target) package_name = module.split('.')[0] namespace[package_name] = sys.modules[package_name] return eval('%s.%s' % (module, target), namespace) def load_app(target): """ Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See :func:`load` for the target parameter. """ global NORUN; NORUN, nr_old = True, NORUN tmp = default_app.push() # Create a new "default application" try: rv = load(target) # Import the target module return rv if callable(rv) else tmp finally: default_app.remove(tmp) # Remove the temporary added default application NORUN = nr_old _debug = debug def run(app=None, server='wsgiref', host='127.0.0.1', port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, **kargs): """ Start a server instance. This method blocks until the server terminates. :param app: WSGI application or target string supported by :func:`load_app`. (default: :func:`default_app`) :param server: Server adapter to use. See :data:`server_names` keys for valid names or pass a :class:`ServerAdapter` subclass. (default: `wsgiref`) :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces including the external one. (default: 127.0.0.1) :param port: Server port to bind to. Values below 1024 require root privileges. (default: 8080) :param reloader: Start auto-reloading server? (default: False) :param interval: Auto-reloader interval in seconds (default: 1) :param quiet: Suppress output to stdout and stderr? (default: False) :param options: Options passed to the server adapter. """ if NORUN: return if reloader and not os.environ.get('BOTTLE_CHILD'): lockfile = None try: fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock') os.close(fd) # We only need this file to exist. We never write to it while os.path.exists(lockfile): args = [sys.executable] + sys.argv environ = os.environ.copy() environ['BOTTLE_CHILD'] = 'true' environ['BOTTLE_LOCKFILE'] = lockfile p = subprocess.Popen(args, env=environ) while p.poll() is None: # Busy wait... os.utime(lockfile, None) # I am alive! time.sleep(interval) if p.poll() != 3: if os.path.exists(lockfile): os.unlink(lockfile) sys.exit(p.poll()) except KeyboardInterrupt: pass finally: if os.path.exists(lockfile): os.unlink(lockfile) return try: if debug is not None: _debug(debug) app = app or default_app() if isinstance(app, basestring): app = load_app(app) if not callable(app): raise ValueError("Application is not callable: %r" % app) for plugin in plugins or []: if isinstance(plugin, basestring): plugin = load(plugin) app.install(plugin) if server in server_names: server = server_names.get(server) if isinstance(server, basestring): server = load(server) if isinstance(server, type): server = server(host=host, port=port, **kargs) if not isinstance(server, ServerAdapter): raise ValueError("Unknown or unsupported server: %r" % server) server.quiet = server.quiet or quiet if not server.quiet: _stderr("Bottle v%s server starting up (using %s)...\n" % (__version__, repr(server))) _stderr("Listening on http://%s:%d/\n" % (server.host, server.port)) _stderr("Hit Ctrl-C to quit.\n\n") if reloader: lockfile = os.environ.get('BOTTLE_LOCKFILE') bgcheck = FileCheckerThread(lockfile, interval) with bgcheck: server.run(app) if bgcheck.status == 'reload': sys.exit(3) else: server.run(app) except KeyboardInterrupt: pass except (SystemExit, MemoryError): raise except: if not reloader: raise if not getattr(server, 'quiet', quiet): print_exc() time.sleep(interval) sys.exit(3) class FileCheckerThread(threading.Thread): """ Interrupt main-thread as soon as a changed module file is detected, the lockfile gets deleted or gets to old. """ def __init__(self, lockfile, interval): threading.Thread.__init__(self) self.daemon = True self.lockfile, self.interval = lockfile, interval #: Is one of 'reload', 'error' or 'exit' self.status = None def run(self): exists = os.path.exists mtime = lambda p: os.stat(p).st_mtime files = dict() for module in list(sys.modules.values()): path = getattr(module, '__file__', '') if path[-4:] in ('.pyo', '.pyc'): path = path[:-1] if path and exists(path): files[path] = mtime(path) while not self.status: if not exists(self.lockfile)\ or mtime(self.lockfile) < time.time() - self.interval - 5: self.status = 'error' thread.interrupt_main() for path, lmtime in list(files.items()): if not exists(path) or mtime(path) > lmtime: self.status = 'reload' thread.interrupt_main() break time.sleep(self.interval) def __enter__(self): self.start() def __exit__(self, exc_type, *_): if not self.status: self.status = 'exit' # silent exit self.join() return exc_type is not None and issubclass(exc_type, KeyboardInterrupt) ############################################################################### # Template Adapters ############################################################ ############################################################################### class TemplateError(HTTPError): def __init__(self, message): HTTPError.__init__(self, 500, message) class BaseTemplate(object): """ Base class and minimal API for template adapters """ extensions = ['tpl','html','thtml','stpl'] settings = {} #used in prepare() defaults = {} #used in render() def __init__(self, source=None, name=None, lookup=None, encoding='utf8', **settings): """ Create a new template. If the source parameter (str or buffer) is missing, the name argument is used to guess a template filename. Subclasses can assume that self.source and/or self.filename are set. Both are strings. The lookup, encoding and settings parameters are stored as instance variables. The lookup parameter stores a list containing directory paths. The encoding parameter should be used to decode byte strings or files. The settings parameter contains a dict for engine-specific settings. """ self.name = name self.source = source.read() if hasattr(source, 'read') else source self.filename = source.filename if hasattr(source, 'filename') else None self.lookup = [os.path.abspath(x) for x in lookup] if lookup else [] self.encoding = encoding self.settings = self.settings.copy() # Copy from class variable self.settings.update(settings) # Apply if not self.source and self.name: self.filename = self.search(self.name, self.lookup) if not self.filename: raise TemplateError('Template %s not found.' % repr(name)) if not self.source and not self.filename: raise TemplateError('No template specified.') self.prepare(**self.settings) @classmethod def search(cls, name, lookup=None): """ Search name in all directories specified in lookup. First without, then with common extensions. Return first hit. """ if not lookup: depr('The template lookup path list should not be empty.', True) #0.12 lookup = ['.'] if os.path.isabs(name) and os.path.isfile(name): depr('Absolute template path names are deprecated.', True) #0.12 return os.path.abspath(name) for spath in lookup: spath = os.path.abspath(spath) + os.sep fname = os.path.abspath(os.path.join(spath, name)) if not fname.startswith(spath): continue if os.path.isfile(fname): return fname for ext in cls.extensions: if os.path.isfile('%s.%s' % (fname, ext)): return '%s.%s' % (fname, ext) @classmethod def global_config(cls, key, *args): """ This reads or sets the global settings stored in class.settings. """ if args: cls.settings = cls.settings.copy() # Make settings local to class cls.settings[key] = args[0] else: return cls.settings[key] def prepare(self, **options): """ Run preparations (parsing, caching, ...). It should be possible to call this again to refresh a template or to update settings. """ raise NotImplementedError def render(self, *args, **kwargs): """ Render the template with the specified local variables and return a single byte or unicode string. If it is a byte string, the encoding must match self.encoding. This method must be thread-safe! Local variables may be provided in dictionaries (args) or directly, as keywords (kwargs). """ raise NotImplementedError class MakoTemplate(BaseTemplate): def prepare(self, **options): from mako.template import Template from mako.lookup import TemplateLookup options.update({'input_encoding':self.encoding}) options.setdefault('format_exceptions', bool(DEBUG)) lookup = TemplateLookup(directories=self.lookup, **options) if self.source: self.tpl = Template(self.source, lookup=lookup, **options) else: self.tpl = Template(uri=self.name, filename=self.filename, lookup=lookup, **options) def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) _defaults = self.defaults.copy() _defaults.update(kwargs) return self.tpl.render(**_defaults) class CheetahTemplate(BaseTemplate): def prepare(self, **options): from Cheetah.Template import Template self.context = threading.local() self.context.vars = {} options['searchList'] = [self.context.vars] if self.source: self.tpl = Template(source=self.source, **options) else: self.tpl = Template(file=self.filename, **options) def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) self.context.vars.update(self.defaults) self.context.vars.update(kwargs) out = str(self.tpl) self.context.vars.clear() return out class Jinja2Template(BaseTemplate): def prepare(self, filters=None, tests=None, globals={}, **kwargs): from jinja2 import Environment, FunctionLoader self.env = Environment(loader=FunctionLoader(self.loader), **kwargs) if filters: self.env.filters.update(filters) if tests: self.env.tests.update(tests) if globals: self.env.globals.update(globals) if self.source: self.tpl = self.env.from_string(self.source) else: self.tpl = self.env.get_template(self.filename) def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) _defaults = self.defaults.copy() _defaults.update(kwargs) return self.tpl.render(**_defaults) def loader(self, name): fname = self.search(name, self.lookup) if not fname: return with open(fname, "rb") as f: return f.read().decode(self.encoding) class SimpleTemplate(BaseTemplate): def prepare(self, escape_func=html_escape, noescape=False, syntax=None, **ka): self.cache = {} enc = self.encoding self._str = lambda x: touni(x, enc) self._escape = lambda x: escape_func(touni(x, enc)) self.syntax = syntax if noescape: self._str, self._escape = self._escape, self._str @cached_property def co(self): return compile(self.code, self.filename or '<string>', 'exec') @cached_property def code(self): source = self.source if not source: with open(self.filename, 'rb') as f: source = f.read() try: source, encoding = touni(source), 'utf8' except UnicodeError: depr('Template encodings other than utf8 are no longer supported.') #0.11 source, encoding = touni(source, 'latin1'), 'latin1' parser = StplParser(source, encoding=encoding, syntax=self.syntax) code = parser.translate() self.encoding = parser.encoding return code def _rebase(self, _env, _name=None, **kwargs): _env['_rebase'] = (_name, kwargs) def _include(self, _env, _name=None, **kwargs): env = _env.copy() env.update(kwargs) if _name not in self.cache: self.cache[_name] = self.__class__(name=_name, lookup=self.lookup) return self.cache[_name].execute(env['_stdout'], env) def execute(self, _stdout, kwargs): env = self.defaults.copy() env.update(kwargs) env.update({'_stdout': _stdout, '_printlist': _stdout.extend, 'include': functools.partial(self._include, env), 'rebase': functools.partial(self._rebase, env), '_rebase': None, '_str': self._str, '_escape': self._escape, 'get': env.get, 'setdefault': env.setdefault, 'defined': env.__contains__ }) eval(self.co, env) if env.get('_rebase'): subtpl, rargs = env.pop('_rebase') rargs['base'] = ''.join(_stdout) #copy stdout del _stdout[:] # clear stdout return self._include(env, subtpl, **rargs) return env def render(self, *args, **kwargs): """ Render the template using keyword arguments as local variables. """ env = {}; stdout = [] for dictarg in args: env.update(dictarg) env.update(kwargs) self.execute(stdout, env) return ''.join(stdout) class StplSyntaxError(TemplateError): pass class StplParser(object): """ Parser for stpl templates. """ _re_cache = {} #: Cache for compiled re patterns # This huge pile of voodoo magic splits python code into 8 different tokens. # 1: All kinds of python strings (trust me, it works) _re_tok = '((?m)[urbURB]?(?:\'\'(?!\')|""(?!")|\'{6}|"{6}' \ '|\'(?:[^\\\\\']|\\\\.)+?\'|"(?:[^\\\\"]|\\\\.)+?"' \ '|\'{3}(?:[^\\\\]|\\\\.|\\n)+?\'{3}' \ '|"{3}(?:[^\\\\]|\\\\.|\\n)+?"{3}))' _re_inl = _re_tok.replace('|\\n','') # We re-use this string pattern later # 2: Comments (until end of line, but not the newline itself) _re_tok += '|(#.*)' # 3,4: Keywords that start or continue a python block (only start of line) _re_tok += '|^([ \\t]*(?:if|for|while|with|try|def|class)\\b)' \ '|^([ \\t]*(?:elif|else|except|finally)\\b)' # 5: Our special 'end' keyword (but only if it stands alone) _re_tok += '|((?:^|;)[ \\t]*end[ \\t]*(?=(?:%(block_close)s[ \\t]*)?\\r?$|;|#))' # 6: A customizable end-of-code-block template token (only end of line) _re_tok += '|(%(block_close)s[ \\t]*(?=$))' # 7: And finally, a single newline. The 8th token is 'everything else' _re_tok += '|(\\r?\\n)' # Match the start tokens of code areas in a template _re_split = '(?m)^[ \t]*(\\\\?)((%(line_start)s)|(%(block_start)s))' # Match inline statements (may contain python strings) _re_inl = '%%(inline_start)s((?:%s|[^\'"\n]+?)*?)%%(inline_end)s' % _re_inl default_syntax = '<% %> % {{ }}' def __init__(self, source, syntax=None, encoding='utf8'): self.source, self.encoding = touni(source, encoding), encoding self.set_syntax(syntax or self.default_syntax) self.code_buffer, self.text_buffer = [], [] self.lineno, self.offset = 1, 0 self.indent, self.indent_mod = 0, 0 def get_syntax(self): """ Tokens as a space separated string (default: <% %> % {{ }}) """ return self._syntax def set_syntax(self, syntax): self._syntax = syntax self._tokens = syntax.split() if not syntax in self._re_cache: names = 'block_start block_close line_start inline_start inline_end' etokens = map(re.escape, self._tokens) pattern_vars = dict(zip(names.split(), etokens)) patterns = (self._re_split, self._re_tok, self._re_inl) patterns = [re.compile(p%pattern_vars) for p in patterns] self._re_cache[syntax] = patterns self.re_split, self.re_tok, self.re_inl = self._re_cache[syntax] syntax = property(get_syntax, set_syntax) def translate(self): if self.offset: raise RuntimeError('Parser is a one time instance.') while True: m = self.re_split.search(self.source[self.offset:]) if m: text = self.source[self.offset:self.offset+m.start()] self.text_buffer.append(text) offs = self.offset self.offset += m.end() if m.group(1): # Escape syntax line, sep, _ = self.source[self.offset:].partition('\n') self.text_buffer.append(self.source[offs+m.start():offs+m.start(1)]+m.group(2)+line+sep) self.offset += len(line+sep) continue self.flush_text() self.read_code(multiline=bool(m.group(4))) else: break self.text_buffer.append(self.source[self.offset:]) self.flush_text() return ''.join(self.code_buffer) def read_code(self, multiline): code_line, comment = '', '' while True: m = self.re_tok.search(self.source[self.offset:]) if not m: code_line += self.source[self.offset:] self.offset = len(self.source) self.write_code(code_line.strip(), comment) return code_line += self.source[self.offset:self.offset+m.start()] self.offset += m.end() _str, _com, _blk1, _blk2, _end, _cend, _nl = m.groups() if code_line and (_blk1 or _blk2): # a if b else c code_line += _blk1 or _blk2 continue if _str: # Python string code_line += _str elif _com: # Python comment (up to EOL) comment = _com if multiline and _com.strip().endswith(self._tokens[1]): multiline = False # Allow end-of-block in comments elif _blk1: # Start-block keyword (if/for/while/def/try/...) code_line, self.indent_mod = _blk1, -1 self.indent += 1 elif _blk2: # Continue-block keyword (else/elif/except/...) code_line, self.indent_mod = _blk2, -1 elif _end: # The non-standard 'end'-keyword (ends a block) self.indent -= 1 elif _cend: # The end-code-block template token (usually '%>') if multiline: multiline = False else: code_line += _cend else: # \n self.write_code(code_line.strip(), comment) self.lineno += 1 code_line, comment, self.indent_mod = '', '', 0 if not multiline: break def flush_text(self): text = ''.join(self.text_buffer) del self.text_buffer[:] if not text: return parts, pos, nl = [], 0, '\\\n'+' '*self.indent for m in self.re_inl.finditer(text): prefix, pos = text[pos:m.start()], m.end() if prefix: parts.append(nl.join(map(repr, prefix.splitlines(True)))) if prefix.endswith('\n'): parts[-1] += nl parts.append(self.process_inline(m.group(1).strip())) if pos < len(text): prefix = text[pos:] lines = prefix.splitlines(True) if lines[-1].endswith('\\\\\n'): lines[-1] = lines[-1][:-3] elif lines[-1].endswith('\\\\\r\n'): lines[-1] = lines[-1][:-4] parts.append(nl.join(map(repr, lines))) code = '_printlist((%s,))' % ', '.join(parts) self.lineno += code.count('\n')+1 self.write_code(code) @staticmethod def process_inline(chunk): if chunk[0] == '!': return '_str(%s)' % chunk[1:] return '_escape(%s)' % chunk def write_code(self, line, comment=''): code = ' ' * (self.indent+self.indent_mod) code += line.lstrip() + comment + '\n' self.code_buffer.append(code) def template(*args, **kwargs): """ Get a rendered template as a string iterator. You can use a name, a filename or a template string as first parameter. Template rendering arguments can be passed as dictionaries or directly (as keyword arguments). """ tpl = args[0] if args else None adapter = kwargs.pop('template_adapter', SimpleTemplate) lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) tplid = (id(lookup), tpl) if tplid not in TEMPLATES or DEBUG: settings = kwargs.pop('template_settings', {}) if isinstance(tpl, adapter): TEMPLATES[tplid] = tpl if settings: TEMPLATES[tplid].prepare(**settings) elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl: TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings) else: TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings) if not TEMPLATES[tplid]: abort(500, 'Template (%s) not found' % tpl) for dictarg in args[1:]: kwargs.update(dictarg) return TEMPLATES[tplid].render(kwargs) mako_template = functools.partial(template, template_adapter=MakoTemplate) cheetah_template = functools.partial(template, template_adapter=CheetahTemplate) jinja2_template = functools.partial(template, template_adapter=Jinja2Template) def view(tpl_name, **defaults): """ Decorator: renders a template for a handler. The handler can control its behavior like that: - return a dict of template vars to fill out the template - return something other than a dict and the view decorator will not process the template, but return the handler result as is. This includes returning a HTTPResponse(dict) to get, for instance, JSON with autojson or other castfilters. """ def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) if isinstance(result, (dict, DictMixin)): tplvars = defaults.copy() tplvars.update(result) return template(tpl_name, **tplvars) elif result is None: return template(tpl_name, defaults) return result return wrapper return decorator mako_view = functools.partial(view, template_adapter=MakoTemplate) cheetah_view = functools.partial(view, template_adapter=CheetahTemplate) jinja2_view = functools.partial(view, template_adapter=Jinja2Template) ############################################################################### # Constants and Globals ######################################################## ############################################################################### TEMPLATE_PATH = ['./', './views/'] TEMPLATES = {} DEBUG = False NORUN = False # If set, run() does nothing. Used by load_app() #: A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found') HTTP_CODES = httplib.responses HTTP_CODES[418] = "I'm a teapot" # RFC 2324 HTTP_CODES[428] = "Precondition Required" HTTP_CODES[429] = "Too Many Requests" HTTP_CODES[431] = "Request Header Fields Too Large" HTTP_CODES[511] = "Network Authentication Required" _HTTP_STATUS_LINES = dict((k, '%d %s'%(k,v)) for (k,v) in HTTP_CODES.items()) #: The default template used for error pages. Override with @error() ERROR_PAGE_TEMPLATE = """ %%try: %%from %s import DEBUG, request <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> <head> <title>Error: {{e.status}}</title> <style type="text/css"> html {background-color: #eee; font-family: sans-serif;} body {background-color: #fff; border: 1px solid #ddd; padding: 15px; margin: 15px;} pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;} </style> </head> <body> <h1>Error: {{e.status}}</h1> <p>Sorry, the requested URL <tt>{{repr(request.url)}}</tt> caused an error:</p> <pre>{{e.body}}</pre> %%if DEBUG and e.exception: <h2>Exception:</h2> <pre>{{repr(e.exception)}}</pre> %%end %%if DEBUG and e.traceback: <h2>Traceback:</h2> <pre>{{e.traceback}}</pre> %%end </body> </html> %%except ImportError: <b>ImportError:</b> Could not generate the error page. Please add bottle to the import path. %%end """ % __name__ #: A thread-safe instance of :class:`LocalRequest`. If accessed from within a #: request callback, this instance always refers to the *current* request #: (even on a multithreaded server). request = LocalRequest() #: A thread-safe instance of :class:`LocalResponse`. It is used to change the #: HTTP response for the *current* request. response = LocalResponse() #: A thread-safe namespace. Not used by Bottle. local = threading.local() # Initialize app stack (create first empty Bottle app) # BC: 0.6.4 and needed for run() app = default_app = AppStack() app.push() #: A virtual package that redirects import statements. #: Example: ``import bottle.ext.sqlite`` actually imports `bottle_sqlite`. ext = _ImportRedirect('bottle.ext' if __name__ == '__main__' else __name__+".ext", 'bottle_%s').module if __name__ == '__main__': opt, args, parser = _cmd_options, _cmd_args, _cmd_parser if opt.version: _stdout('Bottle %s\n'%__version__) sys.exit(0) if not args: parser.print_help() _stderr('\nError: No application entry point specified.\n') sys.exit(1) sys.path.insert(0, '.') sys.modules.setdefault('bottle', sys.modules['__main__']) host, port = (opt.bind or 'localhost'), 8080 if ':' in host and host.rfind(']') < host.rfind(':'): host, port = host.rsplit(':', 1) host = host.strip('[]') run(args[0], host=host, port=int(port), server=opt.server, reloader=opt.reload, plugins=opt.plugin, debug=opt.debug) # THE END
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 202, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 624, 202, 199, 14026, 1118, 365, 282, 7377, 436, 3486, 9967, 13, 4857, 367, 7425, 3330, 13103, 14, 2779, 202, 199, 1997, 1192, 1056, 7634, 316, 334, 5407, 744, 9, 543, 1166, 2725, 2291, 12, 7009, 12, 202, 199, 65, 6137, 13, 262, 3101, 7146, 436, 1503, 12552, 367, 5002, 10919, 17135, 9279, 15, 2856, 13, 1000, 436, 202, 199, 1160, 28156, 446, 1006, 315, 282, 2849, 570, 436, 543, 949, 5124, 1163, 2419, 314, 202, 199, 4718, 9739, 11243, 14, 2999, 199, 12054, 1606, 436, 3794, 26, 1455, 921, 31245, 647, 14, 1308, 15, 2999, 199, 7384, 334, 67, 9, 6927, 12, 16794, 6067, 869, 1697, 75, 5282, 14, 202, 199, 3761, 26, 10697, 334, 3239, 5113, 367, 2436, 9, 202, 199, 624, 2999, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 2999, 199, 363, 2502, 363, 275, 283, 10570, 6067, 869, 1697, 75, 5282, 7, 202, 199, 363, 1023, 363, 275, 283, 16, 14, 969, 13, 2374, 7, 202, 199, 363, 1682, 363, 275, 283, 13965, 7, 2999, 199, 3, 710, 23386, 436, 21819, 1654, 1503, 12552, 1929, 370, 3371, 2005, 4621, 2544, 202, 199, 3, 2985, 787, 8439, 14, 961, 365, 10842, 781, 2198, 314, 28279, 2633, 2348, 1325, 202, 199, 3, 2429, 3062, 2945, 202, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 687, 8691, 492, 13491, 1128, 485, 1760, 63, 2087, 275, 13491, 8, 3807, 628, 3807, 26, 450, 6595, 359, 1419, 61, 2559, 14, 578, 26, 571, 531, 1128, 485, 2992, 275, 485, 1760, 63, 2087, 14, 525, 63, 1422, 1128, 485, 2992, 6739, 1023, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 2384, 1015, 1329, 2685, 1128, 485, 2992, 6096, 66, 401, 4320, 3409, 401, 8214, 628, 12368, 401, 1720, 628, 3409, 2838, 370, 16271, 4564, 1608, 2685, 1128, 485, 2992, 6096, 83, 401, 4320, 1000, 401, 849, 534, 6508, 1121, 297, 1720, 628, 1180, 23578, 465, 4865, 2685, 1128, 485, 2992, 6096, 80, 401, 4320, 2718, 401, 1595, 628, 740, 401, 1720, 628, 3174, 4722, 3589, 15, 83, 2685, 1128, 485, 2992, 6739, 1757, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 928, 1654, 315, 3105, 818, 2685, 1128, 485, 2992, 6739, 9233, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 2495, 13, 9233, 641, 570, 4493, 2685, 1128, 485, 1760, 63, 1419, 12, 485, 1760, 63, 589, 275, 485, 1760, 63, 2087, 14, 1122, 63, 589, 342, 1128, 340, 485, 1760, 63, 1419, 14, 1000, 26, 1039, 340, 485, 1760, 63, 1419, 14, 1000, 14, 2460, 360, 303, 782, 735, 1675, 492, 23386, 14, 20372, 27, 23386, 14, 20372, 14, 2068, 63, 452, 342, 1039, 916, 485, 1760, 63, 1419, 14, 1000, 14, 2460, 360, 1430, 2723, 735, 1675, 492, 21819, 27, 21819, 14, 20372, 63, 2068, 342, 2999, 199, 646, 1300, 772, 12, 16004, 12, 3031, 14, 1208, 12, 9143, 12, 20330, 12, 1742, 12, 7975, 12, 13290, 4202, 1039, 747, 12, 295, 12, 3873, 12, 984, 12, 5549, 12, 5796, 12, 900, 12, 3598, 2999, 199, 504, 2197, 492, 1434, 465, 1434, 602, 12, 2197, 12, 6871, 202, 199, 504, 5549, 492, 21791, 1173, 202, 199, 504, 5190, 492, 1475, 63, 2804, 12, 870, 63, 2804, 202, 199, 504, 6485, 492, 664, 15644, 202, 199, 504, 23128, 492, 7666, 8065, 199, 893, 26, 687, 13804, 492, 16864, 465, 2022, 63, 4180, 12, 14404, 465, 2022, 63, 76, 795, 202, 199, 2590, 3545, 26, 327, 11942, 26, 949, 8486, 1128, 862, 26, 687, 2022, 492, 16864, 465, 2022, 63, 4180, 12, 14404, 465, 2022, 63, 76, 795, 1128, 871, 3545, 26, 1039, 862, 26, 687, 1639, 14, 1208, 14, 4129, 1001, 492, 16864, 465, 2022, 63, 4180, 12, 14404, 465, 2022, 63, 76, 795, 1039, 871, 3545, 26, 1675, 347, 2022, 63, 4180, 8, 576, 304, 2628, 746, 3545, 480, 6243, 2291, 5074, 2018, 499, 14, 22, 503, 13804, 2685, 1675, 2022, 63, 76, 795, 275, 2022, 63, 4180, 1223, 8065, 199, 3, 2136, 3063, 862, 370, 5325, 499, 14, 21, 15, 18, 14, 22, 15, 19, 14, 17, 15, 19, 14, 18, 315, 863, 2159, 66, 5462, 14, 202, 199, 3, 2779, 282, 262, 1133, 7268, 1325, 652, 5419, 1396, 428, 21342, 367, 314, 15634, 14, 2999, 199, 647, 257, 275, 984, 14, 1023, 63, 815, 202, 199, 647, 19, 75, 275, 1134, 2356, 334, 19, 12, 378, 12, 378, 9, 202, 199, 647, 821, 275, 1134, 665, 221, 334, 18, 12, 1227, 12, 378, 9, 202, 199, 647, 2192, 275, 334, 19, 12, 413, 12, 378, 9, 2695, 1134, 665, 334, 19, 12, 499, 12, 378, 9, 2999, 199, 3, 9361, 11659, 367, 314, 4124, 298, 305, 2, 4252, 315, 1134, 19, 75, 14, 202, 199, 318, 485, 69, 837, 372, 984, 14, 2804, 63, 815, 3430, 17, 61, 2999, 199, 3, 9361, 11659, 367, 314, 298, 1361, 365, 282, 4252, 15, 1593, 2, 2018, 499, 15, 19, 487, 3701, 391, 202, 199, 3, 436, 282, 9567, 367, 3413, 63, 6508, 334, 3911, 73, 3021, 3839, 15, 1508, 2225, 2879, 9, 202, 199, 893, 26, 1128, 485, 2703, 12, 485, 3083, 275, 984, 14, 2703, 14, 952, 12, 984, 14, 3083, 14, 952, 202, 199, 2590, 5925, 26, 1128, 485, 2703, 275, 2400, 671, 26, 984, 14, 2703, 14, 952, 8, 88, 9, 1128, 485, 3083, 275, 2400, 671, 26, 984, 14, 3083, 14, 952, 8, 88, 9, 2999, 199, 3, 491, 16673, 402, 26678, 436, 6762, 15109, 14, 202, 199, 692, 1134, 19, 75, 26, 1128, 492, 1455, 14, 1258, 465, 8809, 1128, 492, 485, 2671, 465, 2462, 1128, 687, 4011, 14, 1122, 492, 20818, 12, 11740, 2889, 465, 20503, 8862, 2889, 1128, 687, 4011, 14, 1122, 492, 16511, 12, 6313, 465, 1166, 3513, 12, 14342, 465, 1166, 12240, 1128, 1166, 12240, 275, 9143, 14, 6672, 8, 633, 12240, 12, 2644, 534, 10378, 17, 358, 1128, 687, 1455, 14, 7792, 492, 5870, 7810, 1128, 687, 5055, 492, 29396, 465, 7448, 4256, 1128, 492, 5927, 1128, 687, 5890, 492, 11808, 1128, 687, 21230, 492, 14196, 1128, 7116 ]
[ 2647, 15, 1393, 15, 1813, 2366, 202, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 624, 202, 199, 14026, 1118, 365, 282, 7377, 436, 3486, 9967, 13, 4857, 367, 7425, 3330, 13103, 14, 2779, 202, 199, 1997, 1192, 1056, 7634, 316, 334, 5407, 744, 9, 543, 1166, 2725, 2291, 12, 7009, 12, 202, 199, 65, 6137, 13, 262, 3101, 7146, 436, 1503, 12552, 367, 5002, 10919, 17135, 9279, 15, 2856, 13, 1000, 436, 202, 199, 1160, 28156, 446, 1006, 315, 282, 2849, 570, 436, 543, 949, 5124, 1163, 2419, 314, 202, 199, 4718, 9739, 11243, 14, 2999, 199, 12054, 1606, 436, 3794, 26, 1455, 921, 31245, 647, 14, 1308, 15, 2999, 199, 7384, 334, 67, 9, 6927, 12, 16794, 6067, 869, 1697, 75, 5282, 14, 202, 199, 3761, 26, 10697, 334, 3239, 5113, 367, 2436, 9, 202, 199, 624, 2999, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 2999, 199, 363, 2502, 363, 275, 283, 10570, 6067, 869, 1697, 75, 5282, 7, 202, 199, 363, 1023, 363, 275, 283, 16, 14, 969, 13, 2374, 7, 202, 199, 363, 1682, 363, 275, 283, 13965, 7, 2999, 199, 3, 710, 23386, 436, 21819, 1654, 1503, 12552, 1929, 370, 3371, 2005, 4621, 2544, 202, 199, 3, 2985, 787, 8439, 14, 961, 365, 10842, 781, 2198, 314, 28279, 2633, 2348, 1325, 202, 199, 3, 2429, 3062, 2945, 202, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 687, 8691, 492, 13491, 1128, 485, 1760, 63, 2087, 275, 13491, 8, 3807, 628, 3807, 26, 450, 6595, 359, 1419, 61, 2559, 14, 578, 26, 571, 531, 1128, 485, 2992, 275, 485, 1760, 63, 2087, 14, 525, 63, 1422, 1128, 485, 2992, 6739, 1023, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 2384, 1015, 1329, 2685, 1128, 485, 2992, 6096, 66, 401, 4320, 3409, 401, 8214, 628, 12368, 401, 1720, 628, 3409, 2838, 370, 16271, 4564, 1608, 2685, 1128, 485, 2992, 6096, 83, 401, 4320, 1000, 401, 849, 534, 6508, 1121, 297, 1720, 628, 1180, 23578, 465, 4865, 2685, 1128, 485, 2992, 6096, 80, 401, 4320, 2718, 401, 1595, 628, 740, 401, 1720, 628, 3174, 4722, 3589, 15, 83, 2685, 1128, 485, 2992, 6739, 1757, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 928, 1654, 315, 3105, 818, 2685, 1128, 485, 2992, 6739, 9233, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 2495, 13, 9233, 641, 570, 4493, 2685, 1128, 485, 1760, 63, 1419, 12, 485, 1760, 63, 589, 275, 485, 1760, 63, 2087, 14, 1122, 63, 589, 342, 1128, 340, 485, 1760, 63, 1419, 14, 1000, 26, 1039, 340, 485, 1760, 63, 1419, 14, 1000, 14, 2460, 360, 303, 782, 735, 1675, 492, 23386, 14, 20372, 27, 23386, 14, 20372, 14, 2068, 63, 452, 342, 1039, 916, 485, 1760, 63, 1419, 14, 1000, 14, 2460, 360, 1430, 2723, 735, 1675, 492, 21819, 27, 21819, 14, 20372, 63, 2068, 342, 2999, 199, 646, 1300, 772, 12, 16004, 12, 3031, 14, 1208, 12, 9143, 12, 20330, 12, 1742, 12, 7975, 12, 13290, 4202, 1039, 747, 12, 295, 12, 3873, 12, 984, 12, 5549, 12, 5796, 12, 900, 12, 3598, 2999, 199, 504, 2197, 492, 1434, 465, 1434, 602, 12, 2197, 12, 6871, 202, 199, 504, 5549, 492, 21791, 1173, 202, 199, 504, 5190, 492, 1475, 63, 2804, 12, 870, 63, 2804, 202, 199, 504, 6485, 492, 664, 15644, 202, 199, 504, 23128, 492, 7666, 8065, 199, 893, 26, 687, 13804, 492, 16864, 465, 2022, 63, 4180, 12, 14404, 465, 2022, 63, 76, 795, 202, 199, 2590, 3545, 26, 327, 11942, 26, 949, 8486, 1128, 862, 26, 687, 2022, 492, 16864, 465, 2022, 63, 4180, 12, 14404, 465, 2022, 63, 76, 795, 1128, 871, 3545, 26, 1039, 862, 26, 687, 1639, 14, 1208, 14, 4129, 1001, 492, 16864, 465, 2022, 63, 4180, 12, 14404, 465, 2022, 63, 76, 795, 1039, 871, 3545, 26, 1675, 347, 2022, 63, 4180, 8, 576, 304, 2628, 746, 3545, 480, 6243, 2291, 5074, 2018, 499, 14, 22, 503, 13804, 2685, 1675, 2022, 63, 76, 795, 275, 2022, 63, 4180, 1223, 8065, 199, 3, 2136, 3063, 862, 370, 5325, 499, 14, 21, 15, 18, 14, 22, 15, 19, 14, 17, 15, 19, 14, 18, 315, 863, 2159, 66, 5462, 14, 202, 199, 3, 2779, 282, 262, 1133, 7268, 1325, 652, 5419, 1396, 428, 21342, 367, 314, 15634, 14, 2999, 199, 647, 257, 275, 984, 14, 1023, 63, 815, 202, 199, 647, 19, 75, 275, 1134, 2356, 334, 19, 12, 378, 12, 378, 9, 202, 199, 647, 821, 275, 1134, 665, 221, 334, 18, 12, 1227, 12, 378, 9, 202, 199, 647, 2192, 275, 334, 19, 12, 413, 12, 378, 9, 2695, 1134, 665, 334, 19, 12, 499, 12, 378, 9, 2999, 199, 3, 9361, 11659, 367, 314, 4124, 298, 305, 2, 4252, 315, 1134, 19, 75, 14, 202, 199, 318, 485, 69, 837, 372, 984, 14, 2804, 63, 815, 3430, 17, 61, 2999, 199, 3, 9361, 11659, 367, 314, 298, 1361, 365, 282, 4252, 15, 1593, 2, 2018, 499, 15, 19, 487, 3701, 391, 202, 199, 3, 436, 282, 9567, 367, 3413, 63, 6508, 334, 3911, 73, 3021, 3839, 15, 1508, 2225, 2879, 9, 202, 199, 893, 26, 1128, 485, 2703, 12, 485, 3083, 275, 984, 14, 2703, 14, 952, 12, 984, 14, 3083, 14, 952, 202, 199, 2590, 5925, 26, 1128, 485, 2703, 275, 2400, 671, 26, 984, 14, 2703, 14, 952, 8, 88, 9, 1128, 485, 3083, 275, 2400, 671, 26, 984, 14, 3083, 14, 952, 8, 88, 9, 2999, 199, 3, 491, 16673, 402, 26678, 436, 6762, 15109, 14, 202, 199, 692, 1134, 19, 75, 26, 1128, 492, 1455, 14, 1258, 465, 8809, 1128, 492, 485, 2671, 465, 2462, 1128, 687, 4011, 14, 1122, 492, 20818, 12, 11740, 2889, 465, 20503, 8862, 2889, 1128, 687, 4011, 14, 1122, 492, 16511, 12, 6313, 465, 1166, 3513, 12, 14342, 465, 1166, 12240, 1128, 1166, 12240, 275, 9143, 14, 6672, 8, 633, 12240, 12, 2644, 534, 10378, 17, 358, 1128, 687, 1455, 14, 7792, 492, 5870, 7810, 1128, 687, 5055, 492, 29396, 465, 7448, 4256, 1128, 492, 5927, 1128, 687, 5890, 492, 11808, 1128, 687, 21230, 492, 14196, 1128, 7116, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Anoopsmohan/logbook
logbook/_termcolors.py
24
1174
# -*- coding: utf-8 -*- """ logbook._termcolors ~~~~~~~~~~~~~~~~~~~ Provides terminal color mappings. :copyright: (c) 2010 by Armin Ronacher, Georg Brandl. :license: BSD, see LICENSE for more details. """ esc = "\x1b[" codes = {} codes[""] = "" codes["reset"] = esc + "39;49;00m" dark_colors = ["black", "darkred", "darkgreen", "brown", "darkblue", "purple", "teal", "lightgray"] light_colors = ["darkgray", "red", "green", "yellow", "blue", "fuchsia", "turquoise", "white"] x = 30 for d, l in zip(dark_colors, light_colors): codes[d] = esc + "%im" % x codes[l] = esc + "%i;01m" % x x += 1 del d, l, x codes["darkteal"] = codes["turquoise"] codes["darkyellow"] = codes["brown"] codes["fuscia"] = codes["fuchsia"] def _str_to_type(obj, strtype): """Helper for ansiformat and colorize""" if isinstance(obj, type(strtype)): return obj return obj.encode('ascii') def colorize(color_key, text): """Returns an ANSI formatted text with the given color.""" return _str_to_type(codes[color_key], text) + text + \ _str_to_type(codes["reset"], text)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 943, 2706, 423, 5125, 7120, 272, 18294, 23597, 339, 21552, 11167, 3164, 13546, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 1952, 827, 32472, 19728, 12, 5346, 1308, 699, 3759, 76, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 19303, 275, 1867, 88, 17, 66, 905, 199, 199, 6021, 275, 1052, 199, 6021, 59, 341, 61, 3515, 275, 3087, 199, 6021, 905, 3958, 937, 258, 275, 14683, 435, 298, 1355, 27, 1887, 27, 383, 77, 2, 199, 199, 13625, 63, 7120, 221, 275, 2097, 8399, 401, 298, 13625, 581, 401, 298, 13625, 7731, 401, 298, 27133, 401, 298, 13625, 6304, 401, 355, 298, 6653, 11045, 401, 298, 266, 279, 401, 298, 4040, 12150, 937, 199, 4040, 63, 7120, 275, 2097, 13625, 12150, 401, 298, 581, 401, 298, 7731, 401, 298, 14514, 401, 298, 6304, 401, 355, 298, 70, 2133, 10971, 401, 298, 16218, 14209, 572, 401, 298, 7510, 937, 199, 199, 88, 275, 4233, 199, 509, 366, 12, 634, 315, 3482, 8, 13625, 63, 7120, 12, 10540, 63, 7120, 304, 272, 9479, 59, 68, 61, 275, 14683, 435, 2071, 1017, 2, 450, 671, 272, 9479, 59, 76, 61, 275, 14683, 435, 2071, 73, 27, 614, 77, 2, 450, 671, 272, 671, 847, 413, 199, 199, 2264, 366, 12, 634, 12, 671, 199, 199, 6021, 905, 13625, 266, 279, 937, 257, 275, 9479, 905, 16218, 14209, 572, 937, 199, 6021, 905, 13625, 14514, 937, 275, 9479, 905, 27133, 937, 199, 6021, 905, 31958, 16521, 937, 258, 275, 9479, 905, 70, 2133, 10971, 937, 421, 199, 318, 485, 495, 63, 475, 63, 466, 8, 1113, 12, 620, 466, 304, 272, 408, 4433, 367, 376, 338, 908, 436, 31019, 624, 272, 340, 1228, 8, 1113, 12, 730, 8, 495, 466, 2298, 267, 372, 1559, 272, 372, 1559, 14, 2143, 360, 4371, 358, 421, 199, 318, 31019, 8, 2326, 63, 498, 12, 1318, 304, 272, 408, 3407, 376, 25600, 7871, 1318, 543, 314, 1627, 3164, 1041, 272, 372, 485, 495, 63, 475, 63, 466, 8, 6021, 59, 2326, 63, 498, 467, 1318, 9, 435, 1318, 435, 971, 1779, 485, 495, 63, 475, 63, 466, 8, 6021, 905, 3958, 2255, 1318, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 943, 2706, 423, 5125, 7120, 272, 18294, 23597, 339, 21552, 11167, 3164, 13546, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 1952, 827, 32472, 19728, 12, 5346, 1308, 699, 3759, 76, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 19303, 275, 1867, 88, 17, 66, 905, 199, 199, 6021, 275, 1052, 199, 6021, 59, 341, 61, 3515, 275, 3087, 199, 6021, 905, 3958, 937, 258, 275, 14683, 435, 298, 1355, 27, 1887, 27, 383, 77, 2, 199, 199, 13625, 63, 7120, 221, 275, 2097, 8399, 401, 298, 13625, 581, 401, 298, 13625, 7731, 401, 298, 27133, 401, 298, 13625, 6304, 401, 355, 298, 6653, 11045, 401, 298, 266, 279, 401, 298, 4040, 12150, 937, 199, 4040, 63, 7120, 275, 2097, 13625, 12150, 401, 298, 581, 401, 298, 7731, 401, 298, 14514, 401, 298, 6304, 401, 355, 298, 70, 2133, 10971, 401, 298, 16218, 14209, 572, 401, 298, 7510, 937, 199, 199, 88, 275, 4233, 199, 509, 366, 12, 634, 315, 3482, 8, 13625, 63, 7120, 12, 10540, 63, 7120, 304, 272, 9479, 59, 68, 61, 275, 14683, 435, 2071, 1017, 2, 450, 671, 272, 9479, 59, 76, 61, 275, 14683, 435, 2071, 73, 27, 614, 77, 2, 450, 671, 272, 671, 847, 413, 199, 199, 2264, 366, 12, 634, 12, 671, 199, 199, 6021, 905, 13625, 266, 279, 937, 257, 275, 9479, 905, 16218, 14209, 572, 937, 199, 6021, 905, 13625, 14514, 937, 275, 9479, 905, 27133, 937, 199, 6021, 905, 31958, 16521, 937, 258, 275, 9479, 905, 70, 2133, 10971, 937, 421, 199, 318, 485, 495, 63, 475, 63, 466, 8, 1113, 12, 620, 466, 304, 272, 408, 4433, 367, 376, 338, 908, 436, 31019, 624, 272, 340, 1228, 8, 1113, 12, 730, 8, 495, 466, 2298, 267, 372, 1559, 272, 372, 1559, 14, 2143, 360, 4371, 358, 421, 199, 318, 31019, 8, 2326, 63, 498, 12, 1318, 304, 272, 408, 3407, 376, 25600, 7871, 1318, 543, 314, 1627, 3164, 1041, 272, 372, 485, 495, 63, 475, 63, 466, 8, 6021, 59, 2326, 63, 498, 467, 1318, 9, 435, 1318, 435, 971, 1779, 485, 495, 63, 475, 63, 466, 8, 6021, 905, 3958, 2255, 1318, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
rgeleta/odoo
addons/warning/__openerp__.py
261
1603
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Warning Messages and Alerts', 'version': '1.0', 'category': 'Tools', 'description': """ Module to trigger warnings in OpenERP objects. ============================================== Warning messages can be displayed for objects like sale order, purchase order, picking and invoice. The message is triggered by the form's onchange event. """, 'author': 'OpenERP SA', 'depends': ['base', 'sale_stock', 'purchase'], 'data': ['warning_view.xml'], 'demo': [], 'installable': True, 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 3849, 27377, 436, 437, 16676, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 11654, 297, 272, 283, 1802, 356, 408, 199, 2377, 370, 6804, 3598, 315, 7653, 2251, 14, 199, 2486, 17224, 199, 199, 3849, 3788, 883, 506, 9080, 367, 2251, 2839, 13590, 1865, 12, 15932, 1865, 12, 199, 11463, 436, 8485, 14, 710, 1245, 365, 15572, 701, 314, 1824, 1159, 20258, 1566, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 1095, 297, 283, 8515, 63, 6088, 297, 283, 9533, 995, 272, 283, 576, 356, 788, 3764, 63, 1345, 14, 1652, 995, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 3849, 27377, 436, 437, 16676, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 11654, 297, 272, 283, 1802, 356, 408, 199, 2377, 370, 6804, 3598, 315, 7653, 2251, 14, 199, 2486, 17224, 199, 199, 3849, 3788, 883, 506, 9080, 367, 2251, 2839, 13590, 1865, 12, 15932, 1865, 12, 199, 11463, 436, 8485, 14, 710, 1245, 365, 15572, 701, 314, 1824, 1159, 20258, 1566, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 1095, 297, 283, 8515, 63, 6088, 297, 283, 9533, 995, 272, 283, 576, 356, 788, 3764, 63, 1345, 14, 1652, 995, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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ripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
802
2710
# Core.py - Python extension for perf trace, core functions # # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com> # # This software may be distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. from collections import defaultdict def autodict(): return defaultdict(autodict) flag_fields = autodict() symbolic_fields = autodict() def define_flag_field(event_name, field_name, delim): flag_fields[event_name][field_name]['delim'] = delim def define_flag_value(event_name, field_name, value, field_str): flag_fields[event_name][field_name]['values'][value] = field_str def define_symbolic_field(event_name, field_name): # nothing to do, really pass def define_symbolic_value(event_name, field_name, value, field_str): symbolic_fields[event_name][field_name]['values'][value] = field_str def flag_str(event_name, field_name, value): string = "" if flag_fields[event_name][field_name]: print_delim = 0 keys = flag_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string += flag_fields[event_name][field_name]['values'][idx] break if idx and (value & idx) == idx: if print_delim and flag_fields[event_name][field_name]['delim']: string += " " + flag_fields[event_name][field_name]['delim'] + " " string += flag_fields[event_name][field_name]['values'][idx] print_delim = 1 value &= ~idx return string def symbol_str(event_name, field_name, value): string = "" if symbolic_fields[event_name][field_name]: keys = symbolic_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string = symbolic_fields[event_name][field_name]['values'][idx] break if (value == idx): string = symbolic_fields[event_name][field_name]['values'][idx] break return string trace_flags = { 0x00: "NONE", \ 0x01: "IRQS_OFF", \ 0x02: "IRQS_NOSUPPORT", \ 0x04: "NEED_RESCHED", \ 0x08: "HARDIRQ", \ 0x10: "SOFTIRQ" } def trace_flag_str(value): string = "" print_delim = 0 keys = trace_flags.keys() for idx in keys: if not value and not idx: string += "NONE" break if idx and (value & idx) == idx: if print_delim: string += " | "; string += trace_flags[idx] print_delim = 1 value &= ~idx return string
gpl-2.0
[ 3, 11672, 14, 647, 446, 2018, 3329, 367, 8582, 3307, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 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 ]
[ 11672, 14, 647, 446, 2018, 3329, 367, 8582, 3307, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 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, 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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 2013, Matt Hite <mhite@hotmail.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/>. ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: bigip_pool_member short_description: Manages F5 BIG-IP LTM pool members description: - Manages F5 BIG-IP LTM pool members via iControl SOAP API version_added: 1.4 author: - Matt Hite (@mhite) - Tim Rupp (@caphrim007) notes: - Requires BIG-IP software version >= 11 - F5 developed module 'bigsuds' required (see http://devcentral.f5.com) - Best run as a local_action in your playbook - Supersedes bigip_pool for managing pool members requirements: - bigsuds options: state: description: - Pool member state required: true default: present choices: - present - absent session_state: description: - Set new session availability status for pool member version_added: 2.0 required: false default: null choices: - enabled - disabled monitor_state: description: - Set monitor availability status for pool member version_added: 2.0 required: false default: null choices: - enabled - disabled pool: description: - Pool name. This pool must exist. required: true partition: description: - Partition required: false default: 'Common' host: description: - Pool member IP required: true aliases: - address - name port: description: - Pool member port required: true connection_limit: description: - Pool member connection limit. Setting this to 0 disables the limit. required: false default: null description: description: - Pool member description required: false default: null rate_limit: description: - Pool member rate limit (connections-per-second). Setting this to 0 disables the limit. required: false default: null ratio: description: - Pool member ratio weight. Valid values range from 1 through 100. New pool members -- unless overridden with this value -- default to 1. required: false default: null preserve_node: description: - When state is absent and the pool member is no longer referenced in other pools, the default behavior removes the unused node o bject. Setting this to 'yes' disables this behavior. required: false default: 'no' choices: - yes - no version_added: 2.1 priority_group: description: - Sets priority group for a pool member. required: false default: null version_added: 2.4 extends_documentation_fragment: f5 ''' EXAMPLES = ''' - name: Add pool member bigip_pool_member: server: "lb.mydomain.com" user: "admin" password: "secret" state: "present" pool: "my-pool" partition: "Common" host: "{{ ansible_default_ipv4['address'] }}" port: 80 description: "web server" connection_limit: 100 rate_limit: 50 ratio: 2 delegate_to: localhost - name: Modify pool member ratio and description bigip_pool_member: server: "lb.mydomain.com" user: "admin" password: "secret" state: "present" pool: "my-pool" partition: "Common" host: "{{ ansible_default_ipv4['address'] }}" port: 80 ratio: 1 description: "nginx server" delegate_to: localhost - name: Remove pool member from pool bigip_pool_member: server: "lb.mydomain.com" user: "admin" password: "secret" state: "absent" pool: "my-pool" partition: "Common" host: "{{ ansible_default_ipv4['address'] }}" port: 80 delegate_to: localhost # The BIG-IP GUI doesn't map directly to the API calls for "Pool -> # Members -> State". The following states map to API monitor # and session states. # # Enabled (all traffic allowed): # monitor_state=enabled, session_state=enabled # Disabled (only persistent or active connections allowed): # monitor_state=enabled, session_state=disabled # Forced offline (only active connections allowed): # monitor_state=disabled, session_state=disabled # # See https://devcentral.f5.com/questions/icontrol-equivalent-call-for-b-node-down - name: Force pool member offline bigip_pool_member: server: "lb.mydomain.com" user: "admin" password: "secret" state: "present" session_state: "disabled" monitor_state: "disabled" pool: "my-pool" partition: "Common" host: "{{ ansible_default_ipv4['address'] }}" port: 80 delegate_to: localhost ''' def pool_exists(api, pool): # hack to determine if pool exists result = False try: api.LocalLB.Pool.get_object_status(pool_names=[pool]) result = True except bigsuds.OperationFailed as e: if "was not found" in str(e): result = False else: # genuine exception raise return result def member_exists(api, pool, address, port): # hack to determine if member exists result = False try: members = [{'address': address, 'port': port}] api.LocalLB.Pool.get_member_object_status(pool_names=[pool], members=[members]) result = True except bigsuds.OperationFailed as e: if "was not found" in str(e): result = False else: # genuine exception raise return result def delete_node_address(api, address): result = False try: api.LocalLB.NodeAddressV2.delete_node_address(nodes=[address]) result = True except bigsuds.OperationFailed as e: if "is referenced by a member of pool" in str(e): result = False else: # genuine exception raise return result def remove_pool_member(api, pool, address, port): members = [{'address': address, 'port': port}] api.LocalLB.Pool.remove_member_v2( pool_names=[pool], members=[members] ) def add_pool_member(api, pool, address, port): members = [{'address': address, 'port': port}] api.LocalLB.Pool.add_member_v2( pool_names=[pool], members=[members] ) def get_connection_limit(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_connection_limit( pool_names=[pool], members=[members] )[0][0] return result def set_connection_limit(api, pool, address, port, limit): members = [{'address': address, 'port': port}] api.LocalLB.Pool.set_member_connection_limit( pool_names=[pool], members=[members], limits=[[limit]] ) def get_description(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_description( pool_names=[pool], members=[members] )[0][0] return result def set_description(api, pool, address, port, description): members = [{'address': address, 'port': port}] api.LocalLB.Pool.set_member_description( pool_names=[pool], members=[members], descriptions=[[description]] ) def get_rate_limit(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_rate_limit( pool_names=[pool], members=[members] )[0][0] return result def set_rate_limit(api, pool, address, port, limit): members = [{'address': address, 'port': port}] api.LocalLB.Pool.set_member_rate_limit( pool_names=[pool], members=[members], limits=[[limit]] ) def get_ratio(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_ratio( pool_names=[pool], members=[members] )[0][0] return result def set_ratio(api, pool, address, port, ratio): members = [{'address': address, 'port': port}] api.LocalLB.Pool.set_member_ratio( pool_names=[pool], members=[members], ratios=[[ratio]] ) def get_priority_group(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_priority( pool_names=[pool], members=[members] )[0][0] return result def set_priority_group(api, pool, address, port, priority_group): members = [{'address': address, 'port': port}] api.LocalLB.Pool.set_member_priority( pool_names=[pool], members=[members], priorities=[[priority_group]] ) def set_member_session_enabled_state(api, pool, address, port, session_state): members = [{'address': address, 'port': port}] session_state = ["STATE_%s" % session_state.strip().upper()] api.LocalLB.Pool.set_member_session_enabled_state( pool_names=[pool], members=[members], session_states=[session_state] ) def get_member_session_status(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_session_status( pool_names=[pool], members=[members] )[0][0] result = result.split("SESSION_STATUS_")[-1].lower() return result def set_member_monitor_state(api, pool, address, port, monitor_state): members = [{'address': address, 'port': port}] monitor_state = ["STATE_%s" % monitor_state.strip().upper()] api.LocalLB.Pool.set_member_monitor_state( pool_names=[pool], members=[members], monitor_states=[monitor_state] ) def get_member_monitor_status(api, pool, address, port): members = [{'address': address, 'port': port}] result = api.LocalLB.Pool.get_member_monitor_status( pool_names=[pool], members=[members] )[0][0] result = result.split("MONITOR_STATUS_")[-1].lower() return result def main(): argument_spec = f5_argument_spec() meta_args = dict( session_state=dict(type='str', choices=['enabled', 'disabled']), monitor_state=dict(type='str', choices=['enabled', 'disabled']), pool=dict(type='str', required=True), host=dict(type='str', required=True, aliases=['address', 'name']), port=dict(type='int', required=True), connection_limit=dict(type='int'), description=dict(type='str'), rate_limit=dict(type='int'), ratio=dict(type='int'), preserve_node=dict(type='bool', default=False), priority_group=dict(type='int') ) argument_spec.update(meta_args) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True ) if module.params['validate_certs']: import ssl if not hasattr(ssl, 'SSLContext'): module.fail_json( msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task' ) server = module.params['server'] server_port = module.params['server_port'] user = module.params['user'] password = module.params['password'] state = module.params['state'] partition = module.params['partition'] validate_certs = module.params['validate_certs'] session_state = module.params['session_state'] monitor_state = module.params['monitor_state'] pool = fq_name(partition, module.params['pool']) connection_limit = module.params['connection_limit'] description = module.params['description'] rate_limit = module.params['rate_limit'] ratio = module.params['ratio'] priority_group = module.params['priority_group'] host = module.params['host'] address = fq_name(partition, host) port = module.params['port'] preserve_node = module.params['preserve_node'] if (host and port is None) or (port is not None and not host): module.fail_json(msg="both host and port must be supplied") if 0 > port or port > 65535: module.fail_json(msg="valid ports must be in range 0 - 65535") try: api = bigip_api(server, user, password, validate_certs, port=server_port) if not pool_exists(api, pool): module.fail_json(msg="pool %s does not exist" % pool) result = {'changed': False} # default if state == 'absent': if member_exists(api, pool, address, port): if not module.check_mode: remove_pool_member(api, pool, address, port) if preserve_node: result = {'changed': True} else: deleted = delete_node_address(api, address) result = {'changed': True, 'deleted': deleted} else: result = {'changed': True} elif state == 'present': if not member_exists(api, pool, address, port): if not module.check_mode: add_pool_member(api, pool, address, port) if connection_limit is not None: set_connection_limit(api, pool, address, port, connection_limit) if description is not None: set_description(api, pool, address, port, description) if rate_limit is not None: set_rate_limit(api, pool, address, port, rate_limit) if ratio is not None: set_ratio(api, pool, address, port, ratio) if session_state is not None: set_member_session_enabled_state(api, pool, address, port, session_state) if monitor_state is not None: set_member_monitor_state(api, pool, address, port, monitor_state) if priority_group is not None: set_priority_group(api, pool, address, port, priority_group) result = {'changed': True} else: # pool member exists -- potentially modify attributes if connection_limit is not None and connection_limit != get_connection_limit(api, pool, address, port): if not module.check_mode: set_connection_limit(api, pool, address, port, connection_limit) result = {'changed': True} if description is not None and description != get_description(api, pool, address, port): if not module.check_mode: set_description(api, pool, address, port, description) result = {'changed': True} if rate_limit is not None and rate_limit != get_rate_limit(api, pool, address, port): if not module.check_mode: set_rate_limit(api, pool, address, port, rate_limit) result = {'changed': True} if ratio is not None and ratio != get_ratio(api, pool, address, port): if not module.check_mode: set_ratio(api, pool, address, port, ratio) result = {'changed': True} if session_state is not None: session_status = get_member_session_status(api, pool, address, port) if session_state == 'enabled' and session_status == 'forced_disabled': if not module.check_mode: set_member_session_enabled_state(api, pool, address, port, session_state) result = {'changed': True} elif session_state == 'disabled' and session_status != 'forced_disabled': if not module.check_mode: set_member_session_enabled_state(api, pool, address, port, session_state) result = {'changed': True} if monitor_state is not None: monitor_status = get_member_monitor_status(api, pool, address, port) if monitor_state == 'enabled' and monitor_status == 'forced_down': if not module.check_mode: set_member_monitor_state(api, pool, address, port, monitor_state) result = {'changed': True} elif monitor_state == 'disabled' and monitor_status != 'forced_down': if not module.check_mode: set_member_monitor_state(api, pool, address, port, monitor_state) result = {'changed': True} if priority_group is not None and priority_group != get_priority_group(api, pool, address, port): if not module.check_mode: set_priority_group(api, pool, address, port, priority_group) result = {'changed': True} except Exception as e: module.fail_json(msg="received exception: %s" % e) module.exit_json(**result) from ansible.module_utils.basic import * from ansible.module_utils.f5_utils import * 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, 334, 67, 9, 6171, 12, 31653, 869, 1175, 665, 17077, 1175, 32, 8885, 1198, 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, 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, 27281, 63, 2293, 63, 1114, 199, 3612, 63, 1802, 26, 21612, 481, 21, 16524, 13, 1772, 491, 20690, 4203, 7556, 199, 1802, 26, 523, 446, 21612, 481, 21, 16524, 13, 1772, 491, 20690, 4203, 7556, 4799, 284, 3717, 26805, 3261, 199, 1023, 63, 3270, 26, 413, 14, 20, 199, 2502, 26, 523, 446, 31653, 869, 1175, 8593, 17077, 1175, 9, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 199, 5983, 26, 523, 446, 15127, 16524, 13, 1772, 2032, 1015, 2356, 4119, 523, 446, 481, 21, 477, 27813, 859, 283, 4492, 458, 14577, 7, 1415, 334, 3239, 1455, 921, 2374, 16067, 14, 70, 21, 14, 957, 9, 523, 446, 699, 597, 1255, 465, 282, 2257, 63, 1287, 315, 2195, 15695, 523, 446, 17897, 261, 3424, 27281, 63, 2293, 367, 28453, 4203, 7556, 199, 7538, 26, 523, 446, 12111, 458, 14577, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1174, 272, 1415, 26, 2549, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 523, 2351, 63, 929, 26, 272, 1369, 26, 489, 446, 2494, 892, 2351, 14962, 2004, 367, 4203, 3653, 272, 1015, 63, 3270, 26, 499, 14, 16, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 3415, 26, 489, 446, 5223, 489, 446, 6980, 523, 8372, 63, 929, 26, 272, 1369, 26, 489, 446, 2494, 8372, 14962, 2004, 367, 4203, 3653, 272, 1015, 63, 3270, 26, 499, 14, 16, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 3415, 26, 489, 446, 5223, 489, 446, 6980, 523, 4203, 26, 272, 1369, 26, 489, 446, 15553, 536, 14, 961, 4203, 1471, 2187, 14, 272, 1415, 26, 2549, 523, 6484, 26, 272, 1369, 26, 489, 446, 27353, 272, 1415, 26, 3055, 272, 849, 26, 283, 7844, 7, 523, 1591, 26, 272, 1369, 26, 489, 446, 15553, 3653, 3531, 272, 1415, 26, 2549, 272, 5481, 26, 489, 446, 2287, 489, 446, 536, 523, 1844, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1844, 272, 1415, 26, 2549, 523, 1950, 63, 3097, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1950, 2304, 14, 13510, 642, 370, 378, 28421, 314, 2304, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1369, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1369, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 6634, 63, 3097, 26, 272, 1369, 26, 489, 446, 15553, 3653, 6634, 2304, 334, 7995, 13, 529, 13, 4375, 680, 13510, 642, 370, 378, 267, 28421, 314, 2304, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 10463, 26, 272, 1369, 26, 489, 446, 15553, 3653, 10463, 5401, 14, 4821, 1338, 1425, 687, 413, 4012, 2948, 14, 267, 7053, 4203, 7556, 1553, 7444, 10087, 543, 642, 574, 1553, 849, 267, 370, 413, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 11211, 63, 932, 26, 272, 1369, 26, 489, 446, 3979, 1174, 365, 9552, 436, 314, 4203, 3653, 365, 949, 8088, 11812, 267, 315, 1163, 20092, 12, 314, 849, 5953, 14185, 314, 9563, 1031, 267, 312, 330, 963, 14, 13510, 642, 370, 283, 5066, 7, 28421, 642, 5953, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 889, 7, 272, 3415, 26, 489, 446, 9456, 489, 446, 949, 272, 1015, 63, 3270, 26, 499, 14, 17, 523, 7464, 63, 923, 26, 272, 1369, 26, 489, 446, 10729, 7464, 1572, 367, 282, 4203, 3653, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 499, 14, 20, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2654, 4203, 3653, 523, 27281, 63, 2293, 63, 1114, 26, 489, 1654, 26, 298, 6374, 14, 30945, 14, 957, 2, 489, 922, 26, 298, 2113, 2, 489, 2505, 26, 298, 4731, 2, 489, 1174, 26, 298, 1881, 2, 489, 4203, 26, 298, 1662, 13, 2293, 2, 489, 6484, 26, 298, 7844, 2, 489, 1591, 26, 7370, 3242, 63, 885, 63, 4774, 20, 459, 1562, 418, 7820, 489, 1844, 26, 5939, 489, 1369, 26, 298, 2520, 1654, 2, 489, 1950, 63, 3097, 26, 2948, 489, 6634, 63, 3097, 26, 5238, 489, 10463, 26, 499, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 22520, 4203, 3653, 10463, 436, 1369, 523, 27281, 63, 2293, 63, 1114, 26, 489, 1654, 26, 298, 6374, 14, 30945, 14, 957, 2, 489, 922, 26, 298, 2113, 2, 489, 2505, 26, 298, 4731, 2, 489, 1174, 26, 298, 1881, 2, 489, 4203, 26, 298, 1662, 13, 2293, 2, 489, 6484, 26, 298, 7844, 2, 489, 1591, 26, 7370, 3242, 63, 885, 63, 4774, 20, 459, 1562, 418, 7820, 489, 1844, 26, 5939, 489, 10463, 26, 413, 489, 1369, 26, 298, 25826, 1654, 2 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 6171, 12, 31653, 869, 1175, 665, 17077, 1175, 32, 8885, 1198, 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, 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, 27281, 63, 2293, 63, 1114, 199, 3612, 63, 1802, 26, 21612, 481, 21, 16524, 13, 1772, 491, 20690, 4203, 7556, 199, 1802, 26, 523, 446, 21612, 481, 21, 16524, 13, 1772, 491, 20690, 4203, 7556, 4799, 284, 3717, 26805, 3261, 199, 1023, 63, 3270, 26, 413, 14, 20, 199, 2502, 26, 523, 446, 31653, 869, 1175, 8593, 17077, 1175, 9, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 199, 5983, 26, 523, 446, 15127, 16524, 13, 1772, 2032, 1015, 2356, 4119, 523, 446, 481, 21, 477, 27813, 859, 283, 4492, 458, 14577, 7, 1415, 334, 3239, 1455, 921, 2374, 16067, 14, 70, 21, 14, 957, 9, 523, 446, 699, 597, 1255, 465, 282, 2257, 63, 1287, 315, 2195, 15695, 523, 446, 17897, 261, 3424, 27281, 63, 2293, 367, 28453, 4203, 7556, 199, 7538, 26, 523, 446, 12111, 458, 14577, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1174, 272, 1415, 26, 2549, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 523, 2351, 63, 929, 26, 272, 1369, 26, 489, 446, 2494, 892, 2351, 14962, 2004, 367, 4203, 3653, 272, 1015, 63, 3270, 26, 499, 14, 16, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 3415, 26, 489, 446, 5223, 489, 446, 6980, 523, 8372, 63, 929, 26, 272, 1369, 26, 489, 446, 2494, 8372, 14962, 2004, 367, 4203, 3653, 272, 1015, 63, 3270, 26, 499, 14, 16, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 3415, 26, 489, 446, 5223, 489, 446, 6980, 523, 4203, 26, 272, 1369, 26, 489, 446, 15553, 536, 14, 961, 4203, 1471, 2187, 14, 272, 1415, 26, 2549, 523, 6484, 26, 272, 1369, 26, 489, 446, 27353, 272, 1415, 26, 3055, 272, 849, 26, 283, 7844, 7, 523, 1591, 26, 272, 1369, 26, 489, 446, 15553, 3653, 3531, 272, 1415, 26, 2549, 272, 5481, 26, 489, 446, 2287, 489, 446, 536, 523, 1844, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1844, 272, 1415, 26, 2549, 523, 1950, 63, 3097, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1950, 2304, 14, 13510, 642, 370, 378, 28421, 314, 2304, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1369, 26, 272, 1369, 26, 489, 446, 15553, 3653, 1369, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 6634, 63, 3097, 26, 272, 1369, 26, 489, 446, 15553, 3653, 6634, 2304, 334, 7995, 13, 529, 13, 4375, 680, 13510, 642, 370, 378, 267, 28421, 314, 2304, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 10463, 26, 272, 1369, 26, 489, 446, 15553, 3653, 10463, 5401, 14, 4821, 1338, 1425, 687, 413, 4012, 2948, 14, 267, 7053, 4203, 7556, 1553, 7444, 10087, 543, 642, 574, 1553, 849, 267, 370, 413, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 11211, 63, 932, 26, 272, 1369, 26, 489, 446, 3979, 1174, 365, 9552, 436, 314, 4203, 3653, 365, 949, 8088, 11812, 267, 315, 1163, 20092, 12, 314, 849, 5953, 14185, 314, 9563, 1031, 267, 312, 330, 963, 14, 13510, 642, 370, 283, 5066, 7, 28421, 642, 5953, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 889, 7, 272, 3415, 26, 489, 446, 9456, 489, 446, 949, 272, 1015, 63, 3270, 26, 499, 14, 17, 523, 7464, 63, 923, 26, 272, 1369, 26, 489, 446, 10729, 7464, 1572, 367, 282, 4203, 3653, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 499, 14, 20, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2654, 4203, 3653, 523, 27281, 63, 2293, 63, 1114, 26, 489, 1654, 26, 298, 6374, 14, 30945, 14, 957, 2, 489, 922, 26, 298, 2113, 2, 489, 2505, 26, 298, 4731, 2, 489, 1174, 26, 298, 1881, 2, 489, 4203, 26, 298, 1662, 13, 2293, 2, 489, 6484, 26, 298, 7844, 2, 489, 1591, 26, 7370, 3242, 63, 885, 63, 4774, 20, 459, 1562, 418, 7820, 489, 1844, 26, 5939, 489, 1369, 26, 298, 2520, 1654, 2, 489, 1950, 63, 3097, 26, 2948, 489, 6634, 63, 3097, 26, 5238, 489, 10463, 26, 499, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 22520, 4203, 3653, 10463, 436, 1369, 523, 27281, 63, 2293, 63, 1114, 26, 489, 1654, 26, 298, 6374, 14, 30945, 14, 957, 2, 489, 922, 26, 298, 2113, 2, 489, 2505, 26, 298, 4731, 2, 489, 1174, 26, 298, 1881, 2, 489, 4203, 26, 298, 1662, 13, 2293, 2, 489, 6484, 26, 298, 7844, 2, 489, 1591, 26, 7370, 3242, 63, 885, 63, 4774, 20, 459, 1562, 418, 7820, 489, 1844, 26, 5939, 489, 10463, 26, 413, 489, 1369, 26, 298, 25826, 1654, 2, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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inspection.py
15
1236
# -*- encoding: utf-8 -*- ############################################################################## # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## from openerp import models, fields, api class QcInspection(models.Model): _inherit = 'qc.inspection' @api.multi def _prepare_inspection_lines(self, test, force_fill=False): res = super(QcInspection, self)._prepare_inspection_lines( test, force_fill=force_fill) if test.sample: num_samples = test.sample.get_samples_number(self.qty) if num_samples: i = 1 new_data = [] while i <= num_samples: for line_tuple in res: line = line_tuple[2].copy() line['sample_number'] = i new_data.append((0, 0, line)) i += 1 return new_data return res class QcInspectionLine(models.Model): _inherit = 'qc.inspection.line' _order = 'sample_number, id' sample_number = fields.Integer( string='# sample', readonly=True)
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 2104, 4248, 436, 4190, 949, 7724, 12, 1937, 636, 11267, 4343, 647, 570, 315, 1738, 2082, 199, 4605, 199, 199, 504, 5166, 492, 1709, 12, 1504, 12, 2986, 421, 199, 533, 1413, 67, 13962, 10303, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 283, 21882, 14, 25098, 7, 339, 768, 1246, 14, 3029, 272, 347, 485, 6726, 63, 25098, 63, 1278, 8, 277, 12, 511, 12, 3542, 63, 4498, 29, 797, 304, 267, 522, 275, 1613, 8, 49, 67, 13962, 10303, 12, 291, 10445, 6726, 63, 25098, 63, 1278, 8, 288, 511, 12, 3542, 63, 4498, 29, 3990, 63, 4498, 9, 267, 340, 511, 14, 3271, 26, 288, 1967, 63, 3356, 275, 511, 14, 3271, 14, 362, 63, 3356, 63, 1955, 8, 277, 14, 5643, 9, 288, 340, 1967, 63, 3356, 26, 355, 284, 275, 413, 355, 892, 63, 576, 275, 942, 355, 1830, 284, 2695, 1967, 63, 3356, 26, 490, 367, 1004, 63, 2960, 315, 522, 26, 717, 1004, 275, 1004, 63, 2960, 59, 18, 1055, 1574, 342, 717, 1004, 459, 3271, 63, 1955, 418, 275, 284, 717, 892, 63, 576, 14, 740, 1332, 16, 12, 378, 12, 1004, 430, 490, 284, 847, 413, 355, 372, 892, 63, 576, 267, 372, 522, 421, 199, 533, 1413, 67, 13962, 10303, 3049, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 283, 21882, 14, 25098, 14, 604, 7, 272, 485, 1648, 275, 283, 3271, 63, 1955, 12, 1305, 7, 339, 2690, 63, 1955, 275, 1504, 14, 2674, 8, 267, 1059, 26431, 2690, 297, 6863, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 2104, 4248, 436, 4190, 949, 7724, 12, 1937, 636, 11267, 4343, 647, 570, 315, 1738, 2082, 199, 4605, 199, 199, 504, 5166, 492, 1709, 12, 1504, 12, 2986, 421, 199, 533, 1413, 67, 13962, 10303, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 283, 21882, 14, 25098, 7, 339, 768, 1246, 14, 3029, 272, 347, 485, 6726, 63, 25098, 63, 1278, 8, 277, 12, 511, 12, 3542, 63, 4498, 29, 797, 304, 267, 522, 275, 1613, 8, 49, 67, 13962, 10303, 12, 291, 10445, 6726, 63, 25098, 63, 1278, 8, 288, 511, 12, 3542, 63, 4498, 29, 3990, 63, 4498, 9, 267, 340, 511, 14, 3271, 26, 288, 1967, 63, 3356, 275, 511, 14, 3271, 14, 362, 63, 3356, 63, 1955, 8, 277, 14, 5643, 9, 288, 340, 1967, 63, 3356, 26, 355, 284, 275, 413, 355, 892, 63, 576, 275, 942, 355, 1830, 284, 2695, 1967, 63, 3356, 26, 490, 367, 1004, 63, 2960, 315, 522, 26, 717, 1004, 275, 1004, 63, 2960, 59, 18, 1055, 1574, 342, 717, 1004, 459, 3271, 63, 1955, 418, 275, 284, 717, 892, 63, 576, 14, 740, 1332, 16, 12, 378, 12, 1004, 430, 490, 284, 847, 413, 355, 372, 892, 63, 576, 267, 372, 522, 421, 199, 533, 1413, 67, 13962, 10303, 3049, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 283, 21882, 14, 25098, 14, 604, 7, 272, 485, 1648, 275, 283, 3271, 63, 1955, 12, 1305, 7, 339, 2690, 63, 1955, 275, 1504, 14, 2674, 8, 267, 1059, 26431, 2690, 297, 6863, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]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 0 ]
appsembler/mayan_appsembler
apps/history/api.py
2
2011
from __future__ import absolute_import import pickle import json from django.db import transaction from django.core import serializers from django.shortcuts import get_object_or_404 from django.db import models from django.db.utils import DatabaseError from .models import HistoryType, History from .runtime_data import history_types_dict @transaction.commit_on_success def register_history_type(history_type_dict): namespace = history_type_dict['namespace'] name = history_type_dict['name'] try: history_type_obj, created = HistoryType.objects.get_or_create( namespace=namespace, name=name) history_type_obj.save() except DatabaseError: # Special case for syncdb transaction.rollback() # Runtime history_types_dict.setdefault(namespace, {}) history_types_dict[namespace][name] = { 'label': history_type_dict['label'], 'summary': history_type_dict.get('summary', u''), 'details': history_type_dict.get('details', u''), 'expressions': history_type_dict.get('expressions', {}), } def create_history(history_type_dict, source_object=None, data=None): history_type = get_object_or_404(HistoryType, namespace=history_type_dict['namespace'], name=history_type_dict['name']) new_history = History(history_type=history_type) if source_object: new_history.content_object = source_object if data: new_dict = {} for key, value in data.items(): new_dict[key] = {} if isinstance(value, models.Model): new_dict[key]['value'] = serializers.serialize('json', [value]) elif isinstance(value, models.query.QuerySet): new_dict[key]['value'] = serializers.serialize('json', value) else: new_dict[key]['value'] = json.dumps(value) new_dict[key]['type'] = pickle.dumps(type(value)) new_history.dictionary = json.dumps(new_dict) new_history.save()
gpl-3.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 5927, 199, 646, 2022, 199, 199, 504, 1639, 14, 697, 492, 6008, 199, 504, 1639, 14, 1018, 492, 12506, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 1208, 492, 27728, 199, 199, 504, 1275, 992, 492, 27829, 804, 12, 27829, 199, 504, 1275, 7726, 63, 576, 492, 7994, 63, 1313, 63, 807, 421, 199, 32, 5945, 14, 3543, 63, 265, 63, 3742, 199, 318, 2274, 63, 5570, 63, 466, 8, 5570, 63, 466, 63, 807, 304, 272, 3231, 275, 7994, 63, 466, 63, 807, 459, 3251, 418, 272, 536, 275, 7994, 63, 466, 63, 807, 459, 354, 418, 339, 862, 26, 267, 7994, 63, 466, 63, 1113, 12, 2737, 275, 27829, 804, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 3231, 29, 3251, 12, 536, 29, 354, 9, 267, 7994, 63, 466, 63, 1113, 14, 2117, 342, 272, 871, 27728, 26, 267, 327, 12568, 1930, 367, 7604, 697, 267, 6008, 14, 10437, 342, 5493, 327, 19103, 272, 7994, 63, 1313, 63, 807, 14, 5486, 8, 3251, 12, 5009, 272, 7994, 63, 1313, 63, 807, 59, 3251, 1527, 354, 61, 275, 469, 267, 283, 1302, 356, 7994, 63, 466, 63, 807, 459, 1302, 995, 267, 283, 4705, 356, 7994, 63, 466, 63, 807, 14, 362, 360, 4705, 297, 399, 7, 659, 267, 283, 5087, 356, 7994, 63, 466, 63, 807, 14, 362, 360, 5087, 297, 399, 7, 659, 267, 283, 15264, 356, 7994, 63, 466, 63, 807, 14, 362, 360, 15264, 297, 8613, 272, 789, 421, 199, 318, 1218, 63, 5570, 8, 5570, 63, 466, 63, 807, 12, 1350, 63, 785, 29, 403, 12, 666, 29, 403, 304, 272, 7994, 63, 466, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 12114, 804, 12, 3231, 29, 5570, 63, 466, 63, 807, 459, 3251, 995, 536, 29, 5570, 63, 466, 63, 807, 459, 354, 1105, 272, 892, 63, 5570, 275, 27829, 8, 5570, 63, 466, 29, 5570, 63, 466, 9, 272, 340, 1350, 63, 785, 26, 267, 892, 63, 5570, 14, 1317, 63, 785, 275, 1350, 63, 785, 272, 340, 666, 26, 267, 892, 63, 807, 275, 1052, 267, 367, 790, 12, 574, 315, 666, 14, 1744, 837, 288, 892, 63, 807, 59, 498, 61, 275, 1052, 288, 340, 1228, 8, 585, 12, 1709, 14, 1685, 304, 355, 892, 63, 807, 59, 498, 2733, 585, 418, 275, 12506, 14, 3549, 360, 1001, 297, 359, 585, 566, 288, 916, 1228, 8, 585, 12, 1709, 14, 1131, 14, 13689, 304, 355, 892, 63, 807, 59, 498, 2733, 585, 418, 275, 12506, 14, 3549, 360, 1001, 297, 574, 9, 288, 587, 26, 355, 892, 63, 807, 59, 498, 2733, 585, 418, 275, 2022, 14, 4180, 8, 585, 9, 288, 892, 63, 807, 59, 498, 2733, 466, 418, 275, 5927, 14, 4180, 8, 466, 8, 585, 430, 398, 892, 63, 5570, 14, 9086, 275, 2022, 14, 4180, 8, 1222, 63, 807, 9, 272, 892, 63, 5570, 14, 2117, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 5927, 199, 646, 2022, 199, 199, 504, 1639, 14, 697, 492, 6008, 199, 504, 1639, 14, 1018, 492, 12506, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 1208, 492, 27728, 199, 199, 504, 1275, 992, 492, 27829, 804, 12, 27829, 199, 504, 1275, 7726, 63, 576, 492, 7994, 63, 1313, 63, 807, 421, 199, 32, 5945, 14, 3543, 63, 265, 63, 3742, 199, 318, 2274, 63, 5570, 63, 466, 8, 5570, 63, 466, 63, 807, 304, 272, 3231, 275, 7994, 63, 466, 63, 807, 459, 3251, 418, 272, 536, 275, 7994, 63, 466, 63, 807, 459, 354, 418, 339, 862, 26, 267, 7994, 63, 466, 63, 1113, 12, 2737, 275, 27829, 804, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 3231, 29, 3251, 12, 536, 29, 354, 9, 267, 7994, 63, 466, 63, 1113, 14, 2117, 342, 272, 871, 27728, 26, 267, 327, 12568, 1930, 367, 7604, 697, 267, 6008, 14, 10437, 342, 5493, 327, 19103, 272, 7994, 63, 1313, 63, 807, 14, 5486, 8, 3251, 12, 5009, 272, 7994, 63, 1313, 63, 807, 59, 3251, 1527, 354, 61, 275, 469, 267, 283, 1302, 356, 7994, 63, 466, 63, 807, 459, 1302, 995, 267, 283, 4705, 356, 7994, 63, 466, 63, 807, 14, 362, 360, 4705, 297, 399, 7, 659, 267, 283, 5087, 356, 7994, 63, 466, 63, 807, 14, 362, 360, 5087, 297, 399, 7, 659, 267, 283, 15264, 356, 7994, 63, 466, 63, 807, 14, 362, 360, 15264, 297, 8613, 272, 789, 421, 199, 318, 1218, 63, 5570, 8, 5570, 63, 466, 63, 807, 12, 1350, 63, 785, 29, 403, 12, 666, 29, 403, 304, 272, 7994, 63, 466, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 12114, 804, 12, 3231, 29, 5570, 63, 466, 63, 807, 459, 3251, 995, 536, 29, 5570, 63, 466, 63, 807, 459, 354, 1105, 272, 892, 63, 5570, 275, 27829, 8, 5570, 63, 466, 29, 5570, 63, 466, 9, 272, 340, 1350, 63, 785, 26, 267, 892, 63, 5570, 14, 1317, 63, 785, 275, 1350, 63, 785, 272, 340, 666, 26, 267, 892, 63, 807, 275, 1052, 267, 367, 790, 12, 574, 315, 666, 14, 1744, 837, 288, 892, 63, 807, 59, 498, 61, 275, 1052, 288, 340, 1228, 8, 585, 12, 1709, 14, 1685, 304, 355, 892, 63, 807, 59, 498, 2733, 585, 418, 275, 12506, 14, 3549, 360, 1001, 297, 359, 585, 566, 288, 916, 1228, 8, 585, 12, 1709, 14, 1131, 14, 13689, 304, 355, 892, 63, 807, 59, 498, 2733, 585, 418, 275, 12506, 14, 3549, 360, 1001, 297, 574, 9, 288, 587, 26, 355, 892, 63, 807, 59, 498, 2733, 585, 418, 275, 2022, 14, 4180, 8, 585, 9, 288, 892, 63, 807, 59, 498, 2733, 466, 418, 275, 5927, 14, 4180, 8, 466, 8, 585, 430, 398, 892, 63, 5570, 14, 9086, 275, 2022, 14, 4180, 8, 1222, 63, 807, 9, 272, 892, 63, 5570, 14, 2117, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'core'} DOCUMENTATION = r''' --- module: win_dns_client version_added: "2.3" short_description: Configures DNS lookup on Windows hosts description: - The C(win_dns_client) module configures the DNS client on Windows network adapters. options: adapter_names: description: - Adapter name or list of adapter names for which to manage DNS settings ('*' is supported as a wildcard value). The adapter name used is the connection caption in the Network Control Panel or via C(Get-NetAdapter), eg C(Local Area Connection). required: yes ipv4_addresses: description: - Single or ordered list of DNS server IPv4 addresses to configure for lookup. An empty list will configure the adapter to use the DHCP-assigned values on connections where DHCP is enabled, or disable DNS lookup on statically-configured connections. required: yes notes: - When setting an empty list of DNS server addresses on an adapter with DHCP enabled, a change will always be registered, since it is not possible to detect the difference between a DHCP-sourced server value and one that is statically set. author: - Matt Davis (@nitzmahone) ''' EXAMPLES = r''' - name: Set a single address on the adapter named Ethernet win_dns_client: adapter_names: Ethernet ipv4_addresses: 192.168.34.5 - name: Set multiple lookup addresses on all visible adapters (usually physical adapters that are in the Up state), with debug logging to a file win_dns_client: adapter_names: '*' ipv4_addresses: - 192.168.34.5 - 192.168.34.6 log_path: C:\dns_log.txt - name: Configure all adapters whose names begin with Ethernet to use DHCP-assigned DNS values win_dns_client: adapter_names: 'Ethernet*' ipv4_addresses: [] ''' RETURN = ''' '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 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, 1018, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 5797, 63, 1258, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 4094, 1482, 10237, 4237, 641, 5417, 7057, 199, 1802, 26, 523, 446, 710, 445, 8, 2676, 63, 5797, 63, 1258, 9, 859, 1101, 1482, 314, 10237, 1890, 641, 5417, 2784, 1503, 12552, 14, 199, 1419, 26, 523, 12146, 63, 1247, 26, 272, 1369, 26, 489, 446, 4431, 4185, 536, 503, 769, 402, 12146, 1561, 367, 1314, 370, 9635, 10237, 2202, 661, 10223, 365, 3748, 465, 282, 16792, 574, 680, 267, 710, 12146, 536, 1202, 365, 314, 1950, 19038, 315, 314, 7220, 8612, 510, 4822, 503, 4799, 445, 8, 1002, 13, 2480, 10200, 395, 11837, 445, 8, 5339, 26280, 8113, 680, 272, 1415, 26, 9456, 523, 3278, 20, 63, 7423, 26, 272, 1369, 26, 489, 446, 13050, 503, 7741, 769, 402, 10237, 1654, 6509, 20, 7149, 370, 7908, 367, 4237, 14, 1626, 2701, 769, 911, 7908, 314, 12146, 370, 675, 314, 267, 26821, 13, 12941, 1338, 641, 6947, 2382, 26821, 365, 5223, 12, 503, 3507, 10237, 4237, 641, 2955, 1183, 13, 11786, 6947, 14, 272, 1415, 26, 9456, 199, 5983, 26, 523, 446, 3979, 4260, 376, 2701, 769, 402, 10237, 1654, 7149, 641, 376, 12146, 543, 26821, 5223, 12, 282, 1570, 911, 3544, 506, 7264, 12, 3967, 652, 365, 440, 3962, 370, 272, 9696, 314, 8865, 3382, 282, 26821, 13, 1365, 68, 1654, 574, 436, 1373, 626, 365, 2955, 1183, 663, 14, 199, 2502, 26, 199, 13, 31653, 577, 1214, 374, 8593, 78, 23751, 391, 72, 368, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2494, 282, 2849, 2287, 641, 314, 12146, 4310, 26125, 523, 4747, 63, 5797, 63, 1258, 26, 272, 12146, 63, 1247, 26, 26125, 272, 3278, 20, 63, 7423, 26, 13567, 14, 6568, 14, 1082, 14, 21, 199, 199, 13, 536, 26, 2494, 3663, 4237, 7149, 641, 1006, 8917, 1503, 12552, 334, 25118, 14095, 1503, 12552, 626, 787, 315, 314, 4949, 1174, 395, 543, 3105, 2050, 370, 282, 570, 523, 4747, 63, 5797, 63, 1258, 26, 272, 12146, 63, 1247, 26, 13626, 272, 3278, 20, 63, 7423, 26, 272, 446, 13567, 14, 6568, 14, 1082, 14, 21, 272, 446, 13567, 14, 6568, 14, 1082, 14, 22, 272, 943, 63, 515, 26, 445, 3427, 5797, 63, 793, 14, 2424, 199, 199, 13, 536, 26, 15453, 1006, 1503, 12552, 7447, 1561, 5386, 543, 26125, 370, 675, 26821, 13, 12941, 10237, 1338, 523, 4747, 63, 5797, 63, 1258, 26, 272, 12146, 63, 1247, 26, 283, 22056, 10223, 272, 3278, 20, 63, 7423, 26, 942, 199, 2344, 199, 199, 9677, 275, 1449, 199, 199, 2344, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 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, 1018, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 5797, 63, 1258, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 4094, 1482, 10237, 4237, 641, 5417, 7057, 199, 1802, 26, 523, 446, 710, 445, 8, 2676, 63, 5797, 63, 1258, 9, 859, 1101, 1482, 314, 10237, 1890, 641, 5417, 2784, 1503, 12552, 14, 199, 1419, 26, 523, 12146, 63, 1247, 26, 272, 1369, 26, 489, 446, 4431, 4185, 536, 503, 769, 402, 12146, 1561, 367, 1314, 370, 9635, 10237, 2202, 661, 10223, 365, 3748, 465, 282, 16792, 574, 680, 267, 710, 12146, 536, 1202, 365, 314, 1950, 19038, 315, 314, 7220, 8612, 510, 4822, 503, 4799, 445, 8, 1002, 13, 2480, 10200, 395, 11837, 445, 8, 5339, 26280, 8113, 680, 272, 1415, 26, 9456, 523, 3278, 20, 63, 7423, 26, 272, 1369, 26, 489, 446, 13050, 503, 7741, 769, 402, 10237, 1654, 6509, 20, 7149, 370, 7908, 367, 4237, 14, 1626, 2701, 769, 911, 7908, 314, 12146, 370, 675, 314, 267, 26821, 13, 12941, 1338, 641, 6947, 2382, 26821, 365, 5223, 12, 503, 3507, 10237, 4237, 641, 2955, 1183, 13, 11786, 6947, 14, 272, 1415, 26, 9456, 199, 5983, 26, 523, 446, 3979, 4260, 376, 2701, 769, 402, 10237, 1654, 7149, 641, 376, 12146, 543, 26821, 5223, 12, 282, 1570, 911, 3544, 506, 7264, 12, 3967, 652, 365, 440, 3962, 370, 272, 9696, 314, 8865, 3382, 282, 26821, 13, 1365, 68, 1654, 574, 436, 1373, 626, 365, 2955, 1183, 663, 14, 199, 2502, 26, 199, 13, 31653, 577, 1214, 374, 8593, 78, 23751, 391, 72, 368, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2494, 282, 2849, 2287, 641, 314, 12146, 4310, 26125, 523, 4747, 63, 5797, 63, 1258, 26, 272, 12146, 63, 1247, 26, 26125, 272, 3278, 20, 63, 7423, 26, 13567, 14, 6568, 14, 1082, 14, 21, 199, 199, 13, 536, 26, 2494, 3663, 4237, 7149, 641, 1006, 8917, 1503, 12552, 334, 25118, 14095, 1503, 12552, 626, 787, 315, 314, 4949, 1174, 395, 543, 3105, 2050, 370, 282, 570, 523, 4747, 63, 5797, 63, 1258, 26, 272, 12146, 63, 1247, 26, 13626, 272, 3278, 20, 63, 7423, 26, 272, 446, 13567, 14, 6568, 14, 1082, 14, 21, 272, 446, 13567, 14, 6568, 14, 1082, 14, 22, 272, 943, 63, 515, 26, 445, 3427, 5797, 63, 793, 14, 2424, 199, 199, 13, 536, 26, 15453, 1006, 1503, 12552, 7447, 1561, 5386, 543, 26125, 370, 675, 26821, 13, 12941, 10237, 1338, 523, 4747, 63, 5797, 63, 1258, 26, 272, 12146, 63, 1247, 26, 283, 22056, 10223, 272, 3278, 20, 63, 7423, 26, 942, 199, 2344, 199, 199, 9677, 275, 1449, 199, 199, 2344, 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, 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 ]
ifduyue/sentry
src/sentry/models/user.py
1
10584
""" sentry.models.user ~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from __future__ import absolute_import import logging import warnings from bitfield import BitField from django.contrib.auth.models import AbstractBaseUser, UserManager from django.core.urlresolvers import reverse from django.db import IntegrityError, models, transaction from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from sentry.db.models import BaseManager, BaseModel, BoundedAutoField from sentry.models import LostPasswordHash from sentry.utils.http import absolute_uri audit_logger = logging.getLogger('sentry.audit.user') class UserManager(BaseManager, UserManager): pass class User(BaseModel, AbstractBaseUser): __core__ = True id = BoundedAutoField(primary_key=True) username = models.CharField(_('username'), max_length=128, unique=True) # this column is called first_name for legacy reasons, but it is the entire # display name name = models.CharField(_('name'), max_length=200, blank=True, db_column='first_name') email = models.EmailField(_('email address'), blank=True) is_staff = models.BooleanField( _('staff status'), default=False, help_text=_('Designates whether the user can log into this admin ' 'site.') ) is_active = models.BooleanField( _('active'), default=True, help_text=_( 'Designates whether this user should be treated as ' 'active. Unselect this instead of deleting accounts.' ) ) is_superuser = models.BooleanField( _('superuser status'), default=False, help_text=_( 'Designates that this user has all permissions without ' 'explicitly assigning them.' ) ) is_managed = models.BooleanField( _('managed'), default=False, help_text=_( 'Designates whether this user should be treated as ' 'managed. Select this to disallow the user from ' 'modifying their account (username, password, etc).' ) ) is_sentry_app = models.NullBooleanField( _('is sentry app'), null=True, default=None, help_text=_( 'Designates whether this user is the entity used for Permissions' 'on behalf of a Sentry App. Cannot login or use Sentry like a' 'normal User would.' ) ) is_password_expired = models.BooleanField( _('password expired'), default=False, help_text=_( 'If set to true then the user needs to change the ' 'password on next sign in.' ) ) last_password_change = models.DateTimeField( _('date of last password change'), null=True, help_text=_('The date the password was changed last.') ) flags = BitField( flags=( ( 'newsletter_consent_prompt', 'Do we need to ask this user for newsletter consent?' ), ), default=0, null=True, ) session_nonce = models.CharField(max_length=12, null=True) date_joined = models.DateTimeField(_('date joined'), default=timezone.now) last_active = models.DateTimeField(_('last active'), default=timezone.now, null=True) objects = UserManager(cache_fields=['pk']) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['email'] class Meta: app_label = 'sentry' db_table = 'auth_user' verbose_name = _('user') verbose_name_plural = _('users') def delete(self): if self.username == 'sentry': raise Exception('You cannot delete the "sentry" user as it is required by Sentry.') avatar = self.avatar.first() if avatar: avatar.delete() return super(User, self).delete() def save(self, *args, **kwargs): if not self.username: self.username = self.email return super(User, self).save(*args, **kwargs) def has_perm(self, perm_name): warnings.warn('User.has_perm is deprecated', DeprecationWarning) return self.is_superuser def has_module_perms(self, app_label): warnings.warn('User.has_module_perms is deprecated', DeprecationWarning) return self.is_superuser def get_unverified_emails(self): return self.emails.filter(is_verified=False) def get_verified_emails(self): return self.emails.filter(is_verified=True) def has_unverified_emails(self): return self.get_unverified_emails().exists() def get_label(self): return self.email or self.username or self.id def get_display_name(self): return self.name or self.email or self.username def get_full_name(self): return self.name def get_short_name(self): return self.username def get_salutation_name(self): name = self.name or self.username.split('@', 1)[0].split('.', 1)[0] first_name = name.split(' ', 1)[0] return first_name.capitalize() def get_avatar_type(self): avatar = self.avatar.first() if avatar: return avatar.get_avatar_type_display() return 'letter_avatar' def send_confirm_email_singular(self, email, is_new_user=False): from sentry import options from sentry.utils.email import MessageBuilder if not email.hash_is_valid(): email.set_hash() email.save() context = { 'user': self, 'url': absolute_uri( reverse('sentry-account-confirm-email', args=[self.id, email.validation_hash]) ), 'confirm_email': email.email, 'is_new_user': is_new_user, } msg = MessageBuilder( subject='%sConfirm Email' % (options.get('mail.subject-prefix'), ), template='sentry/emails/confirm_email.txt', html_template='sentry/emails/confirm_email.html', type='user.confirm_email', context=context, ) msg.send_async([email.email]) def send_confirm_emails(self, is_new_user=False): email_list = self.get_unverified_emails() for email in email_list: self.send_confirm_email_singular(email, is_new_user) def merge_to(from_user, to_user): # TODO: we could discover relations automatically and make this useful from sentry import roles from sentry.models import ( Activity, AuditLogEntry, AuthIdentity, Authenticator, GroupAssignee, GroupBookmark, GroupSeen, GroupShare, GroupSubscription, OrganizationMember, OrganizationMemberTeam, UserAvatar, UserEmail, UserOption, ) audit_logger.info( 'user.merge', extra={ 'from_user_id': from_user.id, 'to_user_id': to_user.id, } ) for obj in OrganizationMember.objects.filter(user=from_user): try: with transaction.atomic(): obj.update(user=to_user) except IntegrityError: pass # identify the highest priority membership to_member = OrganizationMember.objects.get( organization=obj.organization_id, user=to_user, ) if roles.get(obj.role).priority > roles.get(to_member.role).priority: to_member.update(role=obj.role) for team in obj.teams.all(): try: with transaction.atomic(): OrganizationMemberTeam.objects.create( organizationmember=to_member, team=team, ) except IntegrityError: pass model_list = ( Authenticator, GroupAssignee, GroupBookmark, GroupSeen, GroupShare, GroupSubscription, UserAvatar, UserEmail, UserOption, ) for model in model_list: for obj in model.objects.filter(user=from_user): try: with transaction.atomic(): obj.update(user=to_user) except IntegrityError: pass Activity.objects.filter( user=from_user, ).update(user=to_user) AuditLogEntry.objects.filter( actor=from_user, ).update(actor=to_user) AuditLogEntry.objects.filter( target_user=from_user, ).update(target_user=to_user) # remove any duplicate identities that exist on the current user that # might conflict w/ the new users existing SSO AuthIdentity.objects.filter( user=from_user, auth_provider__organization__in=AuthIdentity.objects.filter( user=to_user, ).values('auth_provider__organization') ).delete() AuthIdentity.objects.filter( user=from_user, ).update(user=to_user) def set_password(self, raw_password): super(User, self).set_password(raw_password) self.last_password_change = timezone.now() self.is_password_expired = False def refresh_session_nonce(self, request=None): from django.utils.crypto import get_random_string self.session_nonce = get_random_string(12) if request is not None: request.session['_nonce'] = self.session_nonce def get_orgs(self): from sentry.models import (Organization, OrganizationMember, OrganizationStatus) return Organization.objects.filter( status=OrganizationStatus.VISIBLE, id__in=OrganizationMember.objects.filter( user=self, ).values('organization'), ) def get_orgs_require_2fa(self): from sentry.models import (Organization, OrganizationStatus) return Organization.objects.filter( flags=models.F('flags').bitor(Organization.flags.require_2fa), status=OrganizationStatus.VISIBLE, member_set__user=self, ) def clear_lost_passwords(self): LostPasswordHash.objects.filter(user=self).delete() # HACK(dcramer): last_login needs nullable for Django 1.8 User._meta.get_field('last_login').null = True
bsd-3-clause
[ 624, 199, 3870, 14, 992, 14, 751, 199, 9753, 1714, 199, 199, 26, 7307, 26, 334, 67, 9, 7129, 13, 7280, 701, 314, 428, 2373, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 199, 26, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 3598, 199, 199, 504, 4546, 698, 492, 10199, 792, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 11836, 1563, 1899, 12, 2876, 2988, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 492, 26864, 12, 1709, 12, 6008, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 26230, 14, 697, 14, 992, 492, 3523, 2988, 12, 3523, 1685, 12, 5088, 4585, 4378, 199, 504, 26230, 14, 992, 492, 491, 941, 6139, 3476, 199, 504, 26230, 14, 1208, 14, 1014, 492, 3679, 63, 2302, 199, 199, 14274, 63, 2921, 275, 2050, 14, 5572, 360, 3870, 14, 14274, 14, 751, 358, 421, 199, 533, 2876, 2988, 8, 1563, 2988, 12, 2876, 2988, 304, 272, 986, 421, 199, 533, 2876, 8, 27687, 12, 11836, 1563, 1899, 304, 272, 636, 1018, 363, 275, 715, 339, 1305, 275, 5088, 4585, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 3434, 275, 1709, 14, 2183, 6723, 2473, 659, 1390, 63, 1267, 29, 3933, 12, 3747, 29, 549, 9, 272, 327, 642, 2763, 365, 2797, 1642, 63, 354, 367, 12139, 14872, 12, 1325, 652, 365, 314, 8039, 272, 327, 2929, 536, 272, 536, 275, 1709, 14, 2183, 6723, 354, 659, 1390, 63, 1267, 29, 1840, 12, 4596, 29, 549, 12, 1592, 63, 2301, 534, 2246, 63, 354, 358, 272, 3031, 275, 1709, 14, 16577, 6723, 2123, 2287, 659, 4596, 29, 549, 9, 272, 365, 63, 7018, 275, 1709, 14, 5036, 8, 267, 4018, 7018, 2004, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 12397, 20924, 2335, 3775, 314, 922, 883, 943, 1901, 642, 4628, 283, 490, 283, 2124, 2659, 272, 776, 272, 365, 63, 2682, 275, 1709, 14, 5036, 8, 267, 4018, 2682, 659, 267, 849, 29, 549, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 3775, 642, 922, 1077, 506, 10184, 465, 283, 288, 283, 2682, 14, 1910, 2416, 642, 3140, 402, 13794, 12639, 3530, 267, 776, 272, 776, 272, 365, 63, 11434, 275, 1709, 14, 5036, 8, 267, 4018, 11434, 2004, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 626, 642, 922, 965, 1006, 3443, 1928, 283, 288, 283, 10306, 590, 26694, 3062, 3530, 267, 776, 272, 776, 272, 365, 63, 11122, 275, 1709, 14, 5036, 8, 267, 4018, 11122, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 3775, 642, 922, 1077, 506, 10184, 465, 283, 288, 283, 11122, 14, 9496, 642, 370, 2153, 3306, 314, 922, 687, 283, 288, 283, 8951, 316, 3932, 2933, 334, 2473, 12, 2505, 12, 5423, 28823, 267, 776, 272, 776, 272, 365, 63, 3870, 63, 571, 275, 1709, 14, 29068, 8, 267, 4018, 374, 26230, 1145, 659, 267, 2973, 29, 549, 12, 267, 849, 29, 403, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 3775, 642, 922, 365, 314, 4642, 1202, 367, 28260, 7, 288, 283, 265, 506, 10220, 402, 282, 428, 2373, 4693, 14, 18435, 4676, 503, 675, 428, 2373, 2839, 282, 7, 288, 283, 3302, 2876, 3955, 3530, 267, 776, 272, 776, 272, 365, 63, 2060, 63, 16340, 275, 1709, 14, 5036, 8, 267, 4018, 2060, 14721, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 17441, 288, 283, 3917, 663, 370, 2549, 2066, 314, 922, 4839, 370, 1570, 314, 283, 288, 283, 2060, 641, 2163, 2070, 315, 3530, 267, 776, 272, 776, 272, 2061, 63, 2060, 63, 1461, 275, 1709, 14, 4626, 8, 267, 4018, 602, 402, 2061, 2505, 1570, 659, 267, 2973, 29, 549, 12, 267, 1720, 63, 505, 12397, 1918, 1434, 314, 2505, 1990, 2896, 2061, 2659, 272, 776, 339, 3285, 275, 10199, 792, 8, 267, 3285, 2687, 288, 334, 355, 283, 13224, 9269, 63, 388, 1150, 63, 7650, 297, 355, 283, 2585, 781, 1929, 370, 7198, 642, 922, 367, 19497, 9269, 406, 1150, 14069, 288, 2318, 267, 2318, 267, 849, 29, 16, 12, 267, 2973, 29, 549, 12, 272, 776, 339, 2351, 63, 10667, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 713, 12, 2973, 29, 549, 9, 339, 1434, 63, 11806, 275, 1709, 14, 4626, 6723, 602, 16538, 659, 849, 29, 7145, 14, 2131, 9, 272, 2061, 63, 2682, 275, 1709, 14, 4626, 6723, 2019, 4702, 659, 849, 29, 7145, 14, 2131, 12, 2973, 29, 549, 9, 339, 2251, 275, 2876, 2988, 8, 1637, 63, 955, 2968, 2051, 1105, 339, 13044, 2339, 63, 8609, 275, 283, 2473, 7, 272, 25090, 63, 12767, 275, 788, 2123, 418, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 3870, 7, 267, 1592, 63, 1224, 275, 283, 1178, 63, 751, 7, 267, 3376, 63, 354, 275, 4018, 751, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 3707, 358, 339, 347, 3145, 8, 277, 304, 267, 340, 291, 14, 2473, 508, 283, 3870, 356, 288, 746, 2186, 360, 5556, 3913, 3145, 314, 298, 3870, 2, 922, 465, 652, 365, 1415, 701, 428, 2373, 2659, 267, 20913, 275, 291, 14, 14584, 14, 2246, 342, 267, 340, 20913, 26, 288, 20913, 14, 1807, 342, 267, 372, 1613, 8, 1899, 12, 291, 680, 1807, 342, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 14, 2473, 26, 288, 291, 14, 2473, 275, 291, 14, 2123, 267, 372, 1613, 8, 1899, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 965, 63, 8220, 8, 277, 12, 10869, 63, 354, 304, 267, 3598, 14, 4050, 360, 1899, 14, 1989, 63, 8220, 365, 5906, 297, 13413, 9, 267, 372, 291, 14, 374, 63, 11434, 339, 347, 965, 63, 578, 63, 12068, 8, 277, 12, 1145, 63, 1302, 304, 267, 3598, 14, 4050, 360, 1899, 14, 1989, 63, 578, 63, 12068 ]
[ 199, 3870, 14, 992, 14, 751, 199, 9753, 1714, 199, 199, 26, 7307, 26, 334, 67, 9, 7129, 13, 7280, 701, 314, 428, 2373, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 199, 26, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 3598, 199, 199, 504, 4546, 698, 492, 10199, 792, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 11836, 1563, 1899, 12, 2876, 2988, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 492, 26864, 12, 1709, 12, 6008, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 26230, 14, 697, 14, 992, 492, 3523, 2988, 12, 3523, 1685, 12, 5088, 4585, 4378, 199, 504, 26230, 14, 992, 492, 491, 941, 6139, 3476, 199, 504, 26230, 14, 1208, 14, 1014, 492, 3679, 63, 2302, 199, 199, 14274, 63, 2921, 275, 2050, 14, 5572, 360, 3870, 14, 14274, 14, 751, 358, 421, 199, 533, 2876, 2988, 8, 1563, 2988, 12, 2876, 2988, 304, 272, 986, 421, 199, 533, 2876, 8, 27687, 12, 11836, 1563, 1899, 304, 272, 636, 1018, 363, 275, 715, 339, 1305, 275, 5088, 4585, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 3434, 275, 1709, 14, 2183, 6723, 2473, 659, 1390, 63, 1267, 29, 3933, 12, 3747, 29, 549, 9, 272, 327, 642, 2763, 365, 2797, 1642, 63, 354, 367, 12139, 14872, 12, 1325, 652, 365, 314, 8039, 272, 327, 2929, 536, 272, 536, 275, 1709, 14, 2183, 6723, 354, 659, 1390, 63, 1267, 29, 1840, 12, 4596, 29, 549, 12, 1592, 63, 2301, 534, 2246, 63, 354, 358, 272, 3031, 275, 1709, 14, 16577, 6723, 2123, 2287, 659, 4596, 29, 549, 9, 272, 365, 63, 7018, 275, 1709, 14, 5036, 8, 267, 4018, 7018, 2004, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 12397, 20924, 2335, 3775, 314, 922, 883, 943, 1901, 642, 4628, 283, 490, 283, 2124, 2659, 272, 776, 272, 365, 63, 2682, 275, 1709, 14, 5036, 8, 267, 4018, 2682, 659, 267, 849, 29, 549, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 3775, 642, 922, 1077, 506, 10184, 465, 283, 288, 283, 2682, 14, 1910, 2416, 642, 3140, 402, 13794, 12639, 3530, 267, 776, 272, 776, 272, 365, 63, 11434, 275, 1709, 14, 5036, 8, 267, 4018, 11434, 2004, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 626, 642, 922, 965, 1006, 3443, 1928, 283, 288, 283, 10306, 590, 26694, 3062, 3530, 267, 776, 272, 776, 272, 365, 63, 11122, 275, 1709, 14, 5036, 8, 267, 4018, 11122, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 3775, 642, 922, 1077, 506, 10184, 465, 283, 288, 283, 11122, 14, 9496, 642, 370, 2153, 3306, 314, 922, 687, 283, 288, 283, 8951, 316, 3932, 2933, 334, 2473, 12, 2505, 12, 5423, 28823, 267, 776, 272, 776, 272, 365, 63, 3870, 63, 571, 275, 1709, 14, 29068, 8, 267, 4018, 374, 26230, 1145, 659, 267, 2973, 29, 549, 12, 267, 849, 29, 403, 12, 267, 1720, 63, 505, 17441, 288, 283, 20924, 2335, 3775, 642, 922, 365, 314, 4642, 1202, 367, 28260, 7, 288, 283, 265, 506, 10220, 402, 282, 428, 2373, 4693, 14, 18435, 4676, 503, 675, 428, 2373, 2839, 282, 7, 288, 283, 3302, 2876, 3955, 3530, 267, 776, 272, 776, 272, 365, 63, 2060, 63, 16340, 275, 1709, 14, 5036, 8, 267, 4018, 2060, 14721, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 17441, 288, 283, 3917, 663, 370, 2549, 2066, 314, 922, 4839, 370, 1570, 314, 283, 288, 283, 2060, 641, 2163, 2070, 315, 3530, 267, 776, 272, 776, 272, 2061, 63, 2060, 63, 1461, 275, 1709, 14, 4626, 8, 267, 4018, 602, 402, 2061, 2505, 1570, 659, 267, 2973, 29, 549, 12, 267, 1720, 63, 505, 12397, 1918, 1434, 314, 2505, 1990, 2896, 2061, 2659, 272, 776, 339, 3285, 275, 10199, 792, 8, 267, 3285, 2687, 288, 334, 355, 283, 13224, 9269, 63, 388, 1150, 63, 7650, 297, 355, 283, 2585, 781, 1929, 370, 7198, 642, 922, 367, 19497, 9269, 406, 1150, 14069, 288, 2318, 267, 2318, 267, 849, 29, 16, 12, 267, 2973, 29, 549, 12, 272, 776, 339, 2351, 63, 10667, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 713, 12, 2973, 29, 549, 9, 339, 1434, 63, 11806, 275, 1709, 14, 4626, 6723, 602, 16538, 659, 849, 29, 7145, 14, 2131, 9, 272, 2061, 63, 2682, 275, 1709, 14, 4626, 6723, 2019, 4702, 659, 849, 29, 7145, 14, 2131, 12, 2973, 29, 549, 9, 339, 2251, 275, 2876, 2988, 8, 1637, 63, 955, 2968, 2051, 1105, 339, 13044, 2339, 63, 8609, 275, 283, 2473, 7, 272, 25090, 63, 12767, 275, 788, 2123, 418, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 3870, 7, 267, 1592, 63, 1224, 275, 283, 1178, 63, 751, 7, 267, 3376, 63, 354, 275, 4018, 751, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 3707, 358, 339, 347, 3145, 8, 277, 304, 267, 340, 291, 14, 2473, 508, 283, 3870, 356, 288, 746, 2186, 360, 5556, 3913, 3145, 314, 298, 3870, 2, 922, 465, 652, 365, 1415, 701, 428, 2373, 2659, 267, 20913, 275, 291, 14, 14584, 14, 2246, 342, 267, 340, 20913, 26, 288, 20913, 14, 1807, 342, 267, 372, 1613, 8, 1899, 12, 291, 680, 1807, 342, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 14, 2473, 26, 288, 291, 14, 2473, 275, 291, 14, 2123, 267, 372, 1613, 8, 1899, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 965, 63, 8220, 8, 277, 12, 10869, 63, 354, 304, 267, 3598, 14, 4050, 360, 1899, 14, 1989, 63, 8220, 365, 5906, 297, 13413, 9, 267, 372, 291, 14, 374, 63, 11434, 339, 347, 965, 63, 578, 63, 12068, 8, 277, 12, 1145, 63, 1302, 304, 267, 3598, 14, 4050, 360, 1899, 14, 1989, 63, 578, 63, 12068, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, current_app class DebugToolbar(object): # default config settings config = { 'DEBUG_TB_INTERCEPT_REDIRECTS': True, 'DEBUG_TB_PANELS': ( 'flask_debugtoolbar.panels.versions.VersionDebugPanel', 'flask_debugtoolbar.panels.timer.TimerDebugPanel', 'flask_debugtoolbar.panels.headers.HeaderDebugPanel', 'flask_debugtoolbar.panels.request_vars.RequestVarsDebugPanel', 'flask_debugtoolbar.panels.template.TemplateDebugPanel', 'flask_debugtoolbar.panels.sqlalchemy.SQLAlchemyDebugPanel', 'flask_debugtoolbar.panels.logger.LoggingPanel', 'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel', ) } panel_classes = [] def __init__(self, request, jinja_env): self.jinja_env = jinja_env self.request = request self.panels = [] self.template_context = { 'static_path': url_for('_debug_toolbar.static', filename='') } self.create_panels() @classmethod def load_panels(cls, app): cls.config.update(app.config) for panel_path in cls.config['DEBUG_TB_PANELS']: dot = panel_path.rindex('.') panel_module, panel_classname = panel_path[:dot], panel_path[dot+1:] try: mod = __import__(panel_module, {}, {}, ['']) except ImportError, e: app.logger.warning('Disabled %s due to ImportError: %s', panel_classname, e) continue panel_class = getattr(mod, panel_classname) cls.panel_classes.append(panel_class) def create_panels(self): """ Populate debug panels """ activated = self.request.cookies.get('fldt_active', '') activated = urllib.unquote(activated).split(';') for panel_class in self.panel_classes: panel_instance = panel_class( context=self.template_context, jinja_env=self.jinja_env) if panel_instance.dom_id() in activated: panel_instance.is_active = True self.panels.append(panel_instance) def render_toolbar(self): context = self.template_context.copy() context.update({'panels': self.panels}) template = self.jinja_env.get_template('base.html') return template.render(**context)
mit
[ 646, 4011, 199, 199, 504, 7209, 492, 1166, 63, 509, 12, 1453, 63, 571, 4388, 199, 533, 14245, 29630, 8, 785, 304, 339, 327, 849, 1101, 2202, 272, 1101, 275, 469, 267, 283, 5287, 63, 20098, 63, 3843, 7177, 63, 19747, 51, 356, 715, 12, 267, 283, 5287, 63, 20098, 63, 26685, 2901, 51, 356, 334, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 6234, 14, 3353, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 7414, 14, 7929, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 2139, 14, 2567, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 1069, 63, 2936, 14, 2017, 16270, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 1160, 14, 4231, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 14536, 14, 4657, 12800, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 2921, 14, 14054, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 20132, 14, 5736, 82, 7084, 10185, 297, 267, 776, 272, 789, 339, 12748, 63, 2888, 275, 942, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 10321, 63, 1813, 304, 267, 291, 14, 12264, 63, 1813, 275, 10321, 63, 1813, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 31929, 275, 942, 398, 291, 14, 1160, 63, 1100, 275, 469, 288, 283, 1986, 63, 515, 356, 1166, 63, 509, 6412, 1757, 63, 13951, 14, 1986, 297, 1788, 13275, 267, 789, 398, 291, 14, 981, 63, 31929, 342, 339, 768, 3744, 272, 347, 2248, 63, 31929, 8, 1886, 12, 1145, 304, 267, 843, 14, 888, 14, 873, 8, 571, 14, 888, 9, 398, 367, 12748, 63, 515, 315, 843, 14, 888, 459, 5287, 63, 20098, 63, 26685, 2901, 51, 2565, 288, 6308, 275, 12748, 63, 515, 14, 26187, 7563, 288, 12748, 63, 578, 12, 12748, 63, 19851, 275, 12748, 63, 515, 1491, 3287, 467, 12748, 63, 515, 59, 3287, 11, 17, 2938, 953, 862, 26, 355, 3413, 275, 636, 646, 721, 7885, 63, 578, 12, 5479, 5479, 788, 1105, 288, 871, 3545, 12, 325, 26, 355, 1145, 14, 2921, 14, 3764, 360, 15049, 450, 83, 7037, 370, 3545, 26, 450, 83, 297, 12748, 63, 19851, 12, 325, 9, 355, 1980, 288, 12748, 63, 533, 275, 2519, 8, 1494, 12, 12748, 63, 19851, 9, 288, 843, 14, 7885, 63, 2888, 14, 740, 8, 7885, 63, 533, 9, 339, 347, 1218, 63, 31929, 8, 277, 304, 267, 408, 267, 31731, 3105, 12748, 83, 267, 408, 267, 22225, 275, 291, 14, 1069, 14, 7792, 14, 362, 360, 17511, 84, 63, 2682, 297, 4074, 267, 22225, 275, 4011, 14, 12240, 8, 18218, 680, 1294, 26468, 398, 367, 12748, 63, 533, 315, 291, 14, 7885, 63, 2888, 26, 288, 12748, 63, 842, 275, 12748, 63, 533, 8, 355, 1067, 29, 277, 14, 1160, 63, 1100, 12, 355, 10321, 63, 1813, 29, 277, 14, 12264, 63, 1813, 9, 953, 340, 12748, 63, 842, 14, 4556, 63, 344, 342, 315, 22225, 26, 355, 12748, 63, 842, 14, 374, 63, 2682, 275, 715, 288, 291, 14, 31929, 14, 740, 8, 7885, 63, 842, 9, 339, 347, 3795, 63, 13951, 8, 277, 304, 267, 1067, 275, 291, 14, 1160, 63, 1100, 14, 1574, 342, 267, 1067, 14, 873, 3252, 31929, 356, 291, 14, 31929, 1552, 398, 1978, 275, 291, 14, 12264, 63, 1813, 14, 362, 63, 1160, 360, 1095, 14, 1360, 358, 267, 372, 1978, 14, 3352, 3682, 1100, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4011, 199, 199, 504, 7209, 492, 1166, 63, 509, 12, 1453, 63, 571, 4388, 199, 533, 14245, 29630, 8, 785, 304, 339, 327, 849, 1101, 2202, 272, 1101, 275, 469, 267, 283, 5287, 63, 20098, 63, 3843, 7177, 63, 19747, 51, 356, 715, 12, 267, 283, 5287, 63, 20098, 63, 26685, 2901, 51, 356, 334, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 6234, 14, 3353, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 7414, 14, 7929, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 2139, 14, 2567, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 1069, 63, 2936, 14, 2017, 16270, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 1160, 14, 4231, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 14536, 14, 4657, 12800, 7084, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 2921, 14, 14054, 10185, 297, 288, 283, 15720, 63, 1757, 13951, 14, 31929, 14, 20132, 14, 5736, 82, 7084, 10185, 297, 267, 776, 272, 789, 339, 12748, 63, 2888, 275, 942, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 10321, 63, 1813, 304, 267, 291, 14, 12264, 63, 1813, 275, 10321, 63, 1813, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 31929, 275, 942, 398, 291, 14, 1160, 63, 1100, 275, 469, 288, 283, 1986, 63, 515, 356, 1166, 63, 509, 6412, 1757, 63, 13951, 14, 1986, 297, 1788, 13275, 267, 789, 398, 291, 14, 981, 63, 31929, 342, 339, 768, 3744, 272, 347, 2248, 63, 31929, 8, 1886, 12, 1145, 304, 267, 843, 14, 888, 14, 873, 8, 571, 14, 888, 9, 398, 367, 12748, 63, 515, 315, 843, 14, 888, 459, 5287, 63, 20098, 63, 26685, 2901, 51, 2565, 288, 6308, 275, 12748, 63, 515, 14, 26187, 7563, 288, 12748, 63, 578, 12, 12748, 63, 19851, 275, 12748, 63, 515, 1491, 3287, 467, 12748, 63, 515, 59, 3287, 11, 17, 2938, 953, 862, 26, 355, 3413, 275, 636, 646, 721, 7885, 63, 578, 12, 5479, 5479, 788, 1105, 288, 871, 3545, 12, 325, 26, 355, 1145, 14, 2921, 14, 3764, 360, 15049, 450, 83, 7037, 370, 3545, 26, 450, 83, 297, 12748, 63, 19851, 12, 325, 9, 355, 1980, 288, 12748, 63, 533, 275, 2519, 8, 1494, 12, 12748, 63, 19851, 9, 288, 843, 14, 7885, 63, 2888, 14, 740, 8, 7885, 63, 533, 9, 339, 347, 1218, 63, 31929, 8, 277, 304, 267, 408, 267, 31731, 3105, 12748, 83, 267, 408, 267, 22225, 275, 291, 14, 1069, 14, 7792, 14, 362, 360, 17511, 84, 63, 2682, 297, 4074, 267, 22225, 275, 4011, 14, 12240, 8, 18218, 680, 1294, 26468, 398, 367, 12748, 63, 533, 315, 291, 14, 7885, 63, 2888, 26, 288, 12748, 63, 842, 275, 12748, 63, 533, 8, 355, 1067, 29, 277, 14, 1160, 63, 1100, 12, 355, 10321, 63, 1813, 29, 277, 14, 12264, 63, 1813, 9, 953, 340, 12748, 63, 842, 14, 4556, 63, 344, 342, 315, 22225, 26, 355, 12748, 63, 842, 14, 374, 63, 2682, 275, 715, 288, 291, 14, 31929, 14, 740, 8, 7885, 63, 842, 9, 339, 347, 3795, 63, 13951, 8, 277, 304, 267, 1067, 275, 291, 14, 1160, 63, 1100, 14, 1574, 342, 267, 1067, 14, 873, 3252, 31929, 356, 291, 14, 31929, 1552, 398, 1978, 275, 291, 14, 12264, 63, 1813, 14, 362, 63, 1160, 360, 1095, 14, 1360, 358, 267, 372, 1978, 14, 3352, 3682, 1100, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
gnieboer/tensorflow
tensorflow/contrib/keras/python/keras/backend.py
12
103391
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # pylint: disable=protected-access # pylint: disable=redefined-outer-name # pylint: disable=redefined-builtin """Keras backend API. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import json import os import warnings import numpy as np from tensorflow.core.protobuf import config_pb2 from tensorflow.python.client import session as session_module from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes as dtypes_module from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.ops import array_ops from tensorflow.python.ops import clip_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import ctc_ops as ctc from tensorflow.python.ops import functional_ops from tensorflow.python.ops import gradients as gradients_module from tensorflow.python.ops import image_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import logging_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn from tensorflow.python.ops import random_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.ops import state_ops from tensorflow.python.ops import tensor_array_grad # pylint: disable=unused-import from tensorflow.python.ops import tensor_array_ops from tensorflow.python.ops import variables as variables_module from tensorflow.python.training import moving_averages py_all = all py_sum = sum # INTERNAL UTILS # This is the default internal TF session used by Keras. # It can be set manually via `set_session(sess)`. _SESSION = None # This dictionary holds a mapping {graph: learning_phase}. # A learning phase is a bool tensor used to run Keras models in # either train mode (learning_phase == 1) or test mode (learning_phase == 0). _GRAPH_LEARNING_PHASES = {} # This dictionary holds a mapping {graph: UID_DICT}. # each UID_DICT is a dictionary mapping name prefixes to a current index, # used for generatic graph-specific string UIDs # for various names (e.g. layer names). _GRAPH_UID_DICTS = {} # This boolean flag can be set to True to leave variable initialization # up to the user. # Change its value via `manual_variable_initialization(value)`. _MANUAL_VAR_INIT = False # The type of float to use throughout a session. _FLOATX = 'float32' # Epsilon fuzz factor used throughout the codebase. _EPSILON = 10e-8 # Default image data format, one of "channels_last", "channels_first". _IMAGE_DATA_FORMAT = 'channels_last' def backend(): """Publicly accessible method for determining the current backend. Only exists for API compatibily with multi-backend Keras. Returns: The string "tensorflow". """ return 'tensorflow' def epsilon(): """Returns the value of the fuzz factor used in numeric expressions. Returns: A float. Example: ```python >>> keras.backend.epsilon() 1e-08 ``` """ return _EPSILON def set_epsilon(value): """Sets the value of the fuzz factor used in numeric expressions. Arguments: value: float. New value of epsilon. Example: ```python >>> from keras import backend as K >>> K.epsilon() 1e-08 >>> K.set_epsilon(1e-05) >>> K.epsilon() 1e-05 ``` """ global _EPSILON _EPSILON = value def floatx(): """Returns the default float type, as a string. E.g. 'float16', 'float32', 'float64'. Returns: String, the current default float type. Example: ```python >>> keras.backend.floatx() 'float32' ``` """ return _FLOATX def set_floatx(value): """Sets the default float type. Arguments: value: String; 'float16', 'float32', or 'float64'. Example: ```python >>> from keras import backend as K >>> K.floatx() 'float32' >>> K.set_floatx('float16') >>> K.floatx() 'float16' ``` Raises: ValueError: In case of invalid value. """ global _FLOATX if value not in {'float16', 'float32', 'float64'}: raise ValueError('Unknown floatx type: ' + str(value)) _FLOATX = str(value) def cast_to_floatx(x): """Cast a Numpy array to the default Keras float type. Arguments: x: Numpy array. Returns: The same Numpy array, cast to its new type. Example: ```python >>> from keras import backend as K >>> K.floatx() 'float32' >>> arr = numpy.array([1.0, 2.0], dtype='float64') >>> arr.dtype dtype('float64') >>> new_arr = K.cast_to_floatx(arr) >>> new_arr array([ 1., 2.], dtype=float32) >>> new_arr.dtype dtype('float32') ``` """ return np.asarray(x, dtype=_FLOATX) def image_data_format(): """Returns the default image data format convention. Returns: A string, either `'channels_first'` or `'channels_last'` Example: ```python >>> keras.backend.image_data_format() 'channels_first' ``` """ return _IMAGE_DATA_FORMAT def set_image_data_format(data_format): """Sets the value of the image data format convention. Arguments: data_format: string. `'channels_first'` or `'channels_last'`. Example: ```python >>> from keras import backend as K >>> K.image_data_format() 'channels_first' >>> K.set_image_data_format('channels_last') >>> K.image_data_format() 'channels_last' ``` Raises: ValueError: In case of invalid `data_format` value. """ global _IMAGE_DATA_FORMAT if data_format not in {'channels_last', 'channels_first'}: raise ValueError('Unknown data_format:', data_format) _IMAGE_DATA_FORMAT = str(data_format) def get_uid(prefix=''): """Associates a string prefix with an integer counter in a TensorFlow graph. Arguments: prefix: String prefix to index. Returns: Unique integer ID. Example: ``` >>> get_uid('dense') 1 >>> get_uid('dense') 2 ``` """ layer_name_uids_collection = ops.get_collection('LAYER_NAME_UIDS') if not layer_name_uids_collection: layer_name_uids = {} ops.add_to_collection('LAYER_NAME_UIDS', layer_name_uids) else: layer_name_uids = layer_name_uids_collection[0] if prefix not in layer_name_uids: layer_name_uids[prefix] = 1 else: layer_name_uids[prefix] += 1 return layer_name_uids[prefix] def reset_uids(): layer_name_uids_collection = ops.get_collection_ref('LAYER_NAME_UIDS') if layer_name_uids_collection: layer_name_uids_collection.pop() def clear_session(): """Destroys the current TF graph and creates a new one. Useful to avoid clutter from old models / layers. """ global _SESSION global _GRAPH_LEARNING_PHASES # pylint: disable=global-variable-not-assigned ops.reset_default_graph() reset_uids() _SESSION = None phase = array_ops.placeholder(dtype='bool', name='keras_learning_phase') _GRAPH_LEARNING_PHASES = {} _GRAPH_LEARNING_PHASES[ops.get_default_graph()] = phase def manual_variable_initialization(value): """Sets the manual variable initialization flag. This boolean flag determines whether variables should be initialized as they are instantiated (default), or if the user should handle the initialization (e.g. via `tf.initialize_all_variables()`). Arguments: value: Python boolean. """ global _MANUAL_VAR_INIT _MANUAL_VAR_INIT = value def learning_phase(): """Returns the learning phase flag. The learning phase flag is a bool tensor (0 = test, 1 = train) to be passed as input to any Keras function that uses a different behavior at train time and test time. Returns: Learning phase (scalar integer tensor or Python integer). """ graph = ops.get_default_graph() if graph not in _GRAPH_LEARNING_PHASES: phase = array_ops.placeholder(dtype='bool', name='keras_learning_phase') _GRAPH_LEARNING_PHASES[graph] = phase return _GRAPH_LEARNING_PHASES[graph] def set_learning_phase(value): """Sets the learning phase to a fixed value. Arguments: value: Learning phase value, either 0 or 1 (integers). Raises: ValueError: if `value` is neither `0` nor `1`. """ global _GRAPH_LEARNING_PHASES # pylint: disable=global-variable-not-assigned if value not in {0, 1}: raise ValueError('Expected learning phase to be ' '0 or 1.') _GRAPH_LEARNING_PHASES[ops.get_default_graph()] = value def get_session(): """Returns the TF session to be used by the backend. If a default TensorFlow session is available, we will return it. Else, we will return the global Keras session. If no global Keras session exists at this point: we will create a new global session. Note that you can manually set the global session via `K.set_session(sess)`. Returns: A TensorFlow session. """ global _SESSION if ops.get_default_session() is not None: session = ops.get_default_session() else: if _SESSION is None: if not os.environ.get('OMP_NUM_THREADS'): config = config_pb2.ConfigProto(allow_soft_placement=True) else: num_thread = int(os.environ.get('OMP_NUM_THREADS')) config = config_pb2.ConfigProto( intra_op_parallelism_threads=num_thread, allow_soft_placement=True) _SESSION = session_module.Session(config=config) session = _SESSION if not _MANUAL_VAR_INIT: with session.graph.as_default(): _initialize_variables() return session def set_session(session): """Sets the global TensorFlow session. Arguments: session: A TF Session. """ global _SESSION _SESSION = session # VARIABLE MANIPULATION def _convert_string_dtype(dtype): if dtype == 'float16': return dtypes_module.float16 if dtype == 'float32': return dtypes_module.float32 elif dtype == 'float64': return dtypes_module.float64 elif dtype == 'int16': return dtypes_module.int16 elif dtype == 'int32': return dtypes_module.int32 elif dtype == 'int64': return dtypes_module.int64 elif dtype == 'uint8': return dtypes_module.int8 elif dtype == 'uint16': return dtypes_module.uint16 else: raise ValueError('Unsupported dtype:', dtype) def _to_tensor(x, dtype): x = ops.convert_to_tensor(x) if x.dtype != dtype: x = math_ops.cast(x, dtype) return x def is_sparse(tensor): """Returns whether a tensor is a sparse tensor. Arguments: tensor: A tensor instance. Returns: A boolean. Example: ```python >>> from keras import backend as K >>> a = K.placeholder((2, 2), sparse=False) >>> print(K.is_sparse(a)) False >>> b = K.placeholder((2, 2), sparse=True) >>> print(K.is_sparse(b)) True ``` """ return isinstance(tensor, sparse_tensor.SparseTensor) def to_dense(tensor): """Converts a sparse tensor into a dense tensor and returns it. Arguments: tensor: A tensor instance (potentially sparse). Returns: A dense tensor. Examples: ```python >>> from keras import backend as K >>> b = K.placeholder((2, 2), sparse=True) >>> print(K.is_sparse(b)) True >>> c = K.to_dense(b) >>> print(K.is_sparse(c)) False ``` """ if is_sparse(tensor): return sparse_ops.sparse_tensor_to_dense(tensor) else: return tensor name_scope = ops.name_scope def variable(value, dtype=None, name=None): """Instantiates a variable and returns it. Arguments: value: Numpy array, initial value of the tensor. dtype: Tensor type. name: Optional name string for the tensor. Returns: A variable instance (with Keras metadata included). Examples: ```python >>> from keras import backend as K >>> val = np.array([[1, 2], [3, 4]]) >>> kvar = K.variable(value=val, dtype='float64', name='example_var') >>> K.dtype(kvar) 'float64' >>> print(kvar) example_var >>> kvar.eval() array([[ 1., 2.], [ 3., 4.]]) ``` """ if dtype is None: dtype = floatx() if hasattr(value, 'tocoo'): sparse_coo = value.tocoo() indices = np.concatenate((np.expand_dims(sparse_coo.row, 1), np.expand_dims( sparse_coo.col, 1)), 1) v = sparse_tensor.SparseTensor( indices=indices, values=sparse_coo.data, dense_shape=sparse_coo.shape) v._uses_learning_phase = False return v v = variables_module.Variable( value, dtype=_convert_string_dtype(dtype), name=name) v._uses_learning_phase = False return v def _initialize_variables(): """Utility to initialize uninitialized variables on the fly. """ variables = variables_module.global_variables() uninitialized_variables = [] for v in variables: if not hasattr(v, '_keras_initialized') or not v._keras_initialized: uninitialized_variables.append(v) v._keras_initialized = True if uninitialized_variables: sess = get_session() sess.run(variables_module.variables_initializer(uninitialized_variables)) def constant(value, dtype=None, shape=None, name=None): if dtype is None: dtype = floatx() return constant_op.constant(value, dtype=dtype, shape=shape, name=name) def placeholder(shape=None, ndim=None, dtype=None, sparse=False, name=None): """Instantiates a placeholder tensor and returns it. Arguments: shape: Shape of the placeholder (integer tuple, may include `None` entries). ndim: Number of axes of the tensor. At least one of {`shape`, `ndim`} must be specified. If both are specified, `shape` is used. dtype: Placeholder type. sparse: Boolean, whether the placeholder should have a sparse type. name: Optional name string for the placeholder. Returns: Tensor instance (with Keras metadata included). Examples: ```python >>> from keras import backend as K >>> input_ph = K.placeholder(shape=(2, 4, 5)) >>> input_ph <tf.Tensor 'Placeholder_4:0' shape=(2, 4, 5) dtype=float32> ``` """ if dtype is None: dtype = floatx() if not shape: if ndim: shape = tuple([None for _ in range(ndim)]) if sparse: x = array_ops.sparse_placeholder(dtype, shape=shape, name=name) else: x = array_ops.placeholder(dtype, shape=shape, name=name) x._uses_learning_phase = False return x def shape(x): """Returns the symbolic shape of a tensor or variable. Arguments: x: A tensor or variable. Returns: A symbolic shape (which is itself a tensor). Examples: ``` # TensorFlow example >>> from keras import backend as K >>> tf_session = K.get_session() >>> val = np.array([[1, 2], [3, 4]]) >>> kvar = K.variable(value=val) >>> input = keras.backend.placeholder(shape=(2, 4, 5)) >>> K.shape(kvar) <tf.Tensor 'Shape_8:0' shape=(2,) dtype=int32> >>> K.shape(input) <tf.Tensor 'Shape_9:0' shape=(3,) dtype=int32> # To get integer shape (Instead, you can use K.int_shape(x)) >>> K.shape(kvar).eval(session=tf_session) array([2, 2], dtype=int32) >>> K.shape(input).eval(session=tf_session) array([2, 4, 5], dtype=int32) ``` """ return array_ops.shape(x) def int_shape(x): """Returns the shape tensor or variable as a tuple of int or None entries. Arguments: x: Tensor or variable. Returns: A tuple of integers (or None entries). Examples: ```python >>> from keras import backend as K >>> input = K.placeholder(shape=(2, 4, 5)) >>> K.int_shape(input) (2, 4, 5) >>> val = np.array([[1, 2], [3, 4]]) >>> kvar = K.variable(value=val) >>> K.int_shape(kvar) (2, 2) ``` """ shape = x.get_shape() try: return tuple([i.__int__() for i in shape]) except ValueError: return None def ndim(x): """Returns the number of axes in a tensor, as an integer. Arguments: x: Tensor or variable. Returns: Integer (scalar), number of axes. Examples: ```python >>> from keras import backend as K >>> input = K.placeholder(shape=(2, 4, 5)) >>> val = np.array([[1, 2], [3, 4]]) >>> kvar = K.variable(value=val) >>> K.ndim(input) 3 >>> K.ndim(kvar) 2 ``` """ dims = x.get_shape()._dims if dims is not None: return len(dims) return None def dtype(x): """Returns the dtype of a Keras tensor or variable, as a string. Arguments: x: Tensor or variable. Returns: String, dtype of `x`. Examples: ```python >>> from keras import backend as K >>> K.dtype(K.placeholder(shape=(2,4,5))) 'float32' >>> K.dtype(K.placeholder(shape=(2,4,5), dtype='float32')) 'float32' >>> K.dtype(K.placeholder(shape=(2,4,5), dtype='float64')) 'float64' # Keras variable >>> kvar = K.variable(np.array([[1, 2], [3, 4]])) >>> K.dtype(kvar) 'float32_ref' >>> kvar = K.variable(np.array([[1, 2], [3, 4]]), dtype='float32') >>> K.dtype(kvar) 'float32_ref' ``` """ return x.dtype.name def eval(x): """Evaluates the value of a variable. Arguments: x: A variable. Returns: A Numpy array. Examples: ```python >>> from keras import backend as K >>> kvar = K.variable(np.array([[1, 2], [3, 4]]), dtype='float32') >>> K.eval(kvar) array([[ 1., 2.], [ 3., 4.]], dtype=float32) ``` """ return to_dense(x).eval(session=get_session()) def zeros(shape, dtype=None, name=None): """Instantiates an all-zeros variable and returns it. Arguments: shape: Tuple of integers, shape of returned Keras variable dtype: String, data type of returned Keras variable name: String, name of returned Keras variable Returns: A variable (including Keras metadata), filled with `0.0`. Example: ```python >>> from keras import backend as K >>> kvar = K.zeros((3,4)) >>> K.eval(kvar) array([[ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.]], dtype=float32) ``` """ if dtype is None: dtype = floatx() shape = tuple(map(int, shape)) tf_dtype = _convert_string_dtype(dtype) return variable( init_ops.constant_initializer(0., dtype=tf_dtype)(shape), dtype, name) def ones(shape, dtype=None, name=None): """Instantiates an all-ones tensor variable and returns it. Arguments: shape: Tuple of integers, shape of returned Keras variable. dtype: String, data type of returned Keras variable. name: String, name of returned Keras variable. Returns: A Keras variable, filled with `1.0`. Example: ```python >>> from keras import backend as K >>> kvar = K.ones((3,4)) >>> K.eval(kvar) array([[ 1., 1., 1., 1.], [ 1., 1., 1., 1.], [ 1., 1., 1., 1.]], dtype=float32) ``` """ if dtype is None: dtype = floatx() shape = tuple(map(int, shape)) tf_dtype = _convert_string_dtype(dtype) return variable( init_ops.constant_initializer(1., dtype=tf_dtype)(shape), dtype, name) def eye(size, dtype=None, name=None): """Instantiate an identity matrix and returns it. Arguments: size: Integer, number of rows/columns. dtype: String, data type of returned Keras variable. name: String, name of returned Keras variable. Returns: A Keras variable, an identity matrix. Example: ```python >>> from keras import backend as K >>> kvar = K.eye(3) >>> K.eval(kvar) array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]], dtype=float32) ``` """ return variable(np.eye(size), dtype, name) def zeros_like(x, dtype=None, name=None): """Instantiates an all-zeros variable of the same shape as another tensor. Arguments: x: Keras variable or Keras tensor. dtype: String, dtype of returned Keras variable. None uses the dtype of x. name: String, name for the variable to create. Returns: A Keras variable with the shape of x filled with zeros. Example: ```python >>> from keras import backend as K >>> kvar = K.variable(np.random.random((2,3))) >>> kvar_zeros = K.zeros_like(kvar) >>> K.eval(kvar_zeros) array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) ``` """ return array_ops.zeros_like(x, dtype=dtype, name=name) def ones_like(x, dtype=None, name=None): """Instantiates an all-ones variable of the same shape as another tensor. Arguments: x: Keras variable or tensor. dtype: String, dtype of returned Keras variable. None uses the dtype of x. name: String, name for the variable to create. Returns: A Keras variable with the shape of x filled with ones. Example: ```python >>> from keras import backend as K >>> kvar = K.variable(np.random.random((2,3))) >>> kvar_ones = K.ones_like(kvar) >>> K.eval(kvar_ones) array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) ``` """ return array_ops.ones_like(x, dtype=dtype, name=name) def random_uniform_variable(shape, low, high, dtype=None, name=None, seed=None): """Instantiates a variable with values drawn from a uniform distribution. Arguments: shape: Tuple of integers, shape of returned Keras variable. low: Float, lower boundary of the output interval. high: Float, upper boundary of the output interval. dtype: String, dtype of returned Keras variable. name: String, name of returned Keras variable. seed: Integer, random seed. Returns: A Keras variable, filled with drawn samples. Example: ```python # TensorFlow example >>> kvar = K.random_uniform_variable((2,3), 0, 1) >>> kvar <tensorflow.python.ops.variables.Variable object at 0x10ab40b10> >>> K.eval(kvar) array([[ 0.10940075, 0.10047495, 0.476143 ], [ 0.66137183, 0.00869417, 0.89220798]], dtype=float32) ``` """ if dtype is None: dtype = floatx() shape = tuple(map(int, shape)) tf_dtype = _convert_string_dtype(dtype) if seed is None: # ensure that randomness is conditioned by the Numpy RNG seed = np.random.randint(10e8) value = init_ops.random_uniform_initializer( low, high, dtype=tf_dtype, seed=seed)(shape) return variable(value, dtype=dtype, name=name) def random_normal_variable(shape, mean, scale, dtype=None, name=None, seed=None): """Instantiates a variable with values drawn from a normal distribution. Arguments: shape: Tuple of integers, shape of returned Keras variable. mean: Float, mean of the normal distribution. scale: Float, standard deviation of the normal distribution. dtype: String, dtype of returned Keras variable. name: String, name of returned Keras variable. seed: Integer, random seed. Returns: A Keras variable, filled with drawn samples. Example: ```python # TensorFlow example >>> kvar = K.random_normal_variable((2,3), 0, 1) >>> kvar <tensorflow.python.ops.variables.Variable object at 0x10ab12dd0> >>> K.eval(kvar) array([[ 1.19591331, 0.68685907, -0.63814116], [ 0.92629528, 0.28055015, 1.70484698]], dtype=float32) ``` """ if dtype is None: dtype = floatx() shape = tuple(map(int, shape)) tf_dtype = _convert_string_dtype(dtype) if seed is None: # ensure that randomness is conditioned by the Numpy RNG seed = np.random.randint(10e8) value = init_ops.random_normal_initializer( mean, scale, dtype=tf_dtype, seed=seed)(shape) return variable(value, dtype=dtype, name=name) def count_params(x): """Returns the number of scalars in a Keras variable. Arguments: x: Keras variable. Returns: Integer, the number of scalars in `x`. Example: ```python >>> kvar = K.zeros((2,3)) >>> K.count_params(kvar) 6 >>> K.eval(kvar) array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) ``` """ shape = x.get_shape() return np.prod([shape[i]._value for i in range(len(shape))]) def cast(x, dtype): """Casts a tensor to a different dtype and returns it. You can cast a Keras variable but it still returns a Keras tensor. Arguments: x: Keras tensor (or variable). dtype: String, either (`'float16'`, `'float32'`, or `'float64'`). Returns: Keras tensor with dtype `dtype`. Example: ```python >>> from keras import backend as K >>> input = K.placeholder((2, 3), dtype='float32') >>> input <tf.Tensor 'Placeholder_2:0' shape=(2, 3) dtype=float32> # It doesn't work in-place as below. >>> K.cast(input, dtype='float16') <tf.Tensor 'Cast_1:0' shape=(2, 3) dtype=float16> >>> input <tf.Tensor 'Placeholder_2:0' shape=(2, 3) dtype=float32> # you need to assign it. >>> input = K.cast(input, dtype='float16') >>> input <tf.Tensor 'Cast_2:0' shape=(2, 3) dtype=float16> ``` """ return math_ops.cast(x, dtype) # UPDATES OPS def update(x, new_x): return state_ops.assign(x, new_x) def update_add(x, increment): return state_ops.assign_add(x, increment) def update_sub(x, decrement): return state_ops.assign_sub(x, decrement) def moving_average_update(x, value, momentum): return moving_averages.assign_moving_average( x, value, momentum, zero_debias=False) # LINEAR ALGEBRA def dot(x, y): """Multiplies 2 tensors (and/or variables) and returns a *tensor*. When attempting to multiply a nD tensor with a nD tensor, it reproduces the Theano behavior. (e.g. `(2, 3) * (4, 3, 5) -> (2, 4, 5)`) Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A tensor, dot product of `x` and `y`. Examples: ```python # dot product between tensors >>> x = K.placeholder(shape=(2, 3)) >>> y = K.placeholder(shape=(3, 4)) >>> xy = K.dot(x, y) >>> xy <tf.Tensor 'MatMul_9:0' shape=(2, 4) dtype=float32> ``` ```python # dot product between tensors >>> x = K.placeholder(shape=(32, 28, 3)) >>> y = K.placeholder(shape=(3, 4)) >>> xy = K.dot(x, y) >>> xy <tf.Tensor 'MatMul_9:0' shape=(32, 28, 4) dtype=float32> ``` ```python # Theano-like behavior example >>> x = K.random_uniform_variable(shape=(2, 3), low=0, high=1) >>> y = K.ones((4, 3, 5)) >>> xy = K.dot(x, y) >>> K.int_shape(xy) (2, 4, 5) ``` """ if ndim(x) is not None and (ndim(x) > 2 or ndim(y) > 2): x_shape = [] for i, s in zip(int_shape(x), array_ops.unstack(array_ops.shape(x))): if i is not None: x_shape.append(i) else: x_shape.append(s) x_shape = tuple(x_shape) y_shape = [] for i, s in zip(int_shape(y), array_ops.unstack(array_ops.shape(y))): if i is not None: y_shape.append(i) else: y_shape.append(s) y_shape = tuple(y_shape) y_permute_dim = list(range(ndim(y))) y_permute_dim = [y_permute_dim.pop(-2)] + y_permute_dim xt = array_ops.reshape(x, [-1, x_shape[-1]]) yt = array_ops.reshape( array_ops.transpose(y, perm=y_permute_dim), [y_shape[-2], -1]) return array_ops.reshape( math_ops.matmul(xt, yt), x_shape[:-1] + y_shape[:-2] + y_shape[-1:]) if is_sparse(x): out = sparse_ops.sparse_tensor_dense_matmul(x, y) else: out = math_ops.matmul(x, y) return out def batch_dot(x, y, axes=None): """Batchwise dot product. `batch_dot` is used to compute dot product of `x` and `y` when `x` and `y` are data in batch, i.e. in a shape of `(batch_size, :)`. `batch_dot` results in a tensor or variable with less dimensions than the input. If the number of dimensions is reduced to 1, we use `expand_dims` to make sure that ndim is at least 2. Arguments: x: Keras tensor or variable with `ndim >= 2`. y: Keras tensor or variable with `ndim >= 2`. axes: list of (or single) int with target dimensions. The lengths of `axes[0]` and `axes[1]` should be the same. Returns: A tensor with shape equal to the concatenation of `x`'s shape (less the dimension that was summed over) and `y`'s shape (less the batch dimension and the dimension that was summed over). If the final rank is 1, we reshape it to `(batch_size, 1)`. Examples: Assume `x = [[1, 2], [3, 4]]` and `y = [[5, 6], [7, 8]]` `batch_dot(x, y, axes=1) = [[17, 53]]` which is the main diagonal of `x.dot(y.T)`, although we never have to calculate the off-diagonal elements. Shape inference: Let `x`'s shape be `(100, 20)` and `y`'s shape be `(100, 30, 20)`. If `axes` is (1, 2), to find the output shape of resultant tensor, loop through each dimension in `x`'s shape and `y`'s shape: * `x.shape[0]` : 100 : append to output shape * `x.shape[1]` : 20 : do not append to output shape, dimension 1 of `x` has been summed over. (`dot_axes[0]` = 1) * `y.shape[0]` : 100 : do not append to output shape, always ignore first dimension of `y` * `y.shape[1]` : 30 : append to output shape * `y.shape[2]` : 20 : do not append to output shape, dimension 2 of `y` has been summed over. (`dot_axes[1]` = 2) `output_shape` = `(100, 30)` ```python >>> x_batch = K.ones(shape=(32, 20, 1)) >>> y_batch = K.ones(shape=(32, 30, 20)) >>> xy_batch_dot = K.batch_dot(x_batch, y_batch, axes=[1, 2]) >>> K.int_shape(xy_batch_dot) (32, 1, 30) ``` """ if isinstance(axes, int): axes = (axes, axes) if ndim(x) == 2 and ndim(y) == 2: if axes[0] == axes[1]: out = math_ops.reduce_sum(math_ops.multiply(x, y), axes[0]) else: out = math_ops.reduce_sum( math_ops.multiply(array_ops.transpose(x, [1, 0]), y), axes[1]) else: if axes is not None: adj_x = None if axes[0] == ndim(x) - 1 else True adj_y = True if axes[1] == ndim(y) - 1 else None else: adj_x = None adj_y = None out = math_ops.matmul(x, y, adjoint_a=adj_x, adjoint_b=adj_y) if ndim(out) == 1: out = expand_dims(out, 1) return out def transpose(x): """Transposes a tensor and returns it. Arguments: x: Tensor or variable. Returns: A tensor. Examples: ```python >>> var = K.variable([[1, 2, 3], [4, 5, 6]]) >>> K.eval(var) array([[ 1., 2., 3.], [ 4., 5., 6.]], dtype=float32) >>> var_transposed = K.transpose(var) >>> K.eval(var_transposed) array([[ 1., 4.], [ 2., 5.], [ 3., 6.]], dtype=float32) ``` ```python >>> input = K.placeholder((2, 3)) >>> input <tf.Tensor 'Placeholder_11:0' shape=(2, 3) dtype=float32> >>> input_transposed = K.transpose(input) >>> input_transposed <tf.Tensor 'transpose_4:0' shape=(3, 2) dtype=float32> ``` """ return array_ops.transpose(x) def gather(reference, indices): """Retrieves the elements of indices `indices` in the tensor `reference`. Arguments: reference: A tensor. indices: An integer tensor of indices. Returns: A tensor of same type as `reference`. """ return array_ops.gather(reference, indices) # ELEMENT-WISE OPERATIONS def _normalize_axis(axis, ndim): """Converts negative axes to positive values. Arguments: axis: Integer axis (possibly negative). ndim: Rank of the tensor considered. Returns: Positive integer axis. """ if isinstance(axis, tuple): axis = list(axis) if isinstance(axis, list): for i, a in enumerate(axis): if a is not None and a < 0: axis[i] = a % ndim else: if axis is not None and axis < 0: axis %= ndim return axis def max(x, axis=None, keepdims=False): """Maximum value in a tensor. Arguments: x: A tensor or variable. axis: An integer, the axis to find maximum values. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1. If `keepdims` is `True`, the reduced dimension is retained with length 1. Returns: A tensor with maximum values of `x`. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.reduce_max(x, reduction_indices=axis, keep_dims=keepdims) def min(x, axis=None, keepdims=False): """Minimum value in a tensor. Arguments: x: A tensor or variable. axis: An integer, the axis to find minimum values. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1. If `keepdims` is `True`, the reduced dimension is retained with length 1. Returns: A tensor with miminum values of `x`. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.reduce_min(x, reduction_indices=axis, keep_dims=keepdims) def sum(x, axis=None, keepdims=False): """Sum of the values in a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: An integer, the axis to sum over. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1. If `keepdims` is `True`, the reduced dimension is retained with length 1. Returns: A tensor with sum of `x`. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.reduce_sum(x, reduction_indices=axis, keep_dims=keepdims) def prod(x, axis=None, keepdims=False): """Multiplies the values in a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: An integer, the axis to compute the product. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1. If `keepdims` is `True`, the reduced dimension is retained with length 1. Returns: A tensor with the product of elements of `x`. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.reduce_prod(x, reduction_indices=axis, keep_dims=keepdims) def cumsum(x, axis=0): """Cumulative sum of the values in a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: An integer, the axis to compute the sum. Returns: A tensor of the cumulative sum of values of `x` along `axis`. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.cumsum(x, axis=axis) def cumprod(x, axis=0): """Cumulative product of the values in a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: An integer, the axis to compute the product. Returns: A tensor of the cumulative product of values of `x` along `axis`. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.cumprod(x, axis=axis) def var(x, axis=None, keepdims=False): """Variance of a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: An integer, the axis to compute the variance. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1. If `keepdims` is `True`, the reduced dimension is retained with length 1. Returns: A tensor with the variance of elements of `x`. """ axis = _normalize_axis(axis, ndim(x)) if x.dtype.base_dtype == dtypes_module.bool: x = math_ops.cast(x, floatx()) m = math_ops.reduce_mean(x, reduction_indices=axis, keep_dims=True) devs_squared = math_ops.square(x - m) return math_ops.reduce_mean( devs_squared, reduction_indices=axis, keep_dims=keepdims) def std(x, axis=None, keepdims=False): """Standard deviation of a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: An integer, the axis to compute the standard deviation. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1. If `keepdims` is `True`, the reduced dimension is retained with length 1. Returns: A tensor with the standard deviation of elements of `x`. """ return math_ops.sqrt(var(x, axis=axis, keepdims=keepdims)) def mean(x, axis=None, keepdims=False): """Mean of a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: A list of integer. Axes to compute the mean. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1 for each entry in `axis`. If `keep_dims` is `True`, the reduced dimensions are retained with length 1. Returns: A tensor with the mean of elements of `x`. """ axis = _normalize_axis(axis, ndim(x)) if x.dtype.base_dtype == dtypes_module.bool: x = math_ops.cast(x, floatx()) return math_ops.reduce_mean(x, reduction_indices=axis, keep_dims=keepdims) def any(x, axis=None, keepdims=False): """Bitwise reduction (logical OR). Arguments: x: Tensor or variable. axis: axis along which to perform the reduction. keepdims: whether the drop or broadcast the reduction axes. Returns: A uint8 tensor (0s and 1s). """ axis = _normalize_axis(axis, ndim(x)) x = math_ops.cast(x, dtypes_module.bool) return math_ops.reduce_any(x, reduction_indices=axis, keep_dims=keepdims) def all(x, axis=None, keepdims=False): """Bitwise reduction (logical AND). Arguments: x: Tensor or variable. axis: axis along which to perform the reduction. keepdims: whether the drop or broadcast the reduction axes. Returns: A uint8 tensor (0s and 1s). """ axis = _normalize_axis(axis, ndim(x)) x = math_ops.cast(x, dtypes_module.bool) return math_ops.reduce_all(x, reduction_indices=axis, keep_dims=keepdims) def argmax(x, axis=-1): """Returns the index of the maximum value along an axis. Arguments: x: Tensor or variable. axis: axis along which to perform the reduction. Returns: A tensor. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.argmax(x, axis) def argmin(x, axis=-1): """Returns the index of the minimum value along an axis. Arguments: x: Tensor or variable. axis: axis along which to perform the reduction. Returns: A tensor. """ axis = _normalize_axis(axis, ndim(x)) return math_ops.argmin(x, axis) def square(x): """Element-wise square. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.square(x) def abs(x): """Element-wise absolute value. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.abs(x) def sqrt(x): """Element-wise square root. Arguments: x: Tensor or variable. Returns: A tensor. """ zero = _to_tensor(0., x.dtype.base_dtype) inf = _to_tensor(np.inf, x.dtype.base_dtype) x = clip_ops.clip_by_value(x, zero, inf) return math_ops.sqrt(x) def exp(x): """Element-wise exponential. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.exp(x) def log(x): """Element-wise log. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.log(x) def round(x): """Element-wise rounding to the closest integer. In case of tie, the rounding mode used is "half to even". Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.round(x) def sign(x): """Element-wise sign. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.sign(x) def pow(x, a): """Element-wise exponentiation. Arguments: x: Tensor or variable. a: Python integer. Returns: A tensor. """ return math_ops.pow(x, a) def clip(x, min_value, max_value): """Element-wise value clipping. Arguments: x: Tensor or variable. min_value: Python float or integer. max_value: Python float or integer. Returns: A tensor. """ if max_value is not None and max_value < min_value: max_value = min_value if max_value is None: max_value = np.inf min_value = _to_tensor(min_value, x.dtype.base_dtype) max_value = _to_tensor(max_value, x.dtype.base_dtype) return clip_ops.clip_by_value(x, min_value, max_value) def equal(x, y): """Element-wise equality between two tensors. Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A bool tensor. """ return math_ops.equal(x, y) def not_equal(x, y): """Element-wise inequality between two tensors. Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A bool tensor. """ return math_ops.not_equal(x, y) def greater(x, y): """Element-wise truth value of (x > y). Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A bool tensor. """ return math_ops.greater(x, y) def greater_equal(x, y): """Element-wise truth value of (x >= y). Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A bool tensor. """ return math_ops.greater_equal(x, y) def less(x, y): """Element-wise truth value of (x < y). Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A bool tensor. """ return math_ops.less(x, y) def less_equal(x, y): """Element-wise truth value of (x <= y). Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A bool tensor. """ return math_ops.less_equal(x, y) def maximum(x, y): """Element-wise maximum of two tensors. Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A tensor. """ return math_ops.maximum(x, y) def minimum(x, y): """Element-wise minimum of two tensors. Arguments: x: Tensor or variable. y: Tensor or variable. Returns: A tensor. """ return math_ops.minimum(x, y) def sin(x): """Computes sin of x element-wise. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.sin(x) def cos(x): """Computes cos of x element-wise. Arguments: x: Tensor or variable. Returns: A tensor. """ return math_ops.cos(x) def normalize_batch_in_training(x, gamma, beta, reduction_axes, epsilon=1e-3): """Computes mean and std for batch then apply batch_normalization on batch. Arguments: x: Input tensor or variable. gamma: Tensor by which to scale the input. beta: Tensor with which to center the input. reduction_axes: iterable of integers, axes over which to normalize. epsilon: Fuzz factor. Returns: A tuple length of 3, `(normalized_tensor, mean, variance)`. """ mean, var = nn.moments( x, reduction_axes, shift=None, name=None, keep_dims=False) if sorted(reduction_axes) == list(range(ndim(x)))[:-1]: normed = nn.batch_normalization(x, mean, var, beta, gamma, epsilon) else: # need broadcasting target_shape = [] for axis in range(ndim(x)): if axis in reduction_axes: target_shape.append(1) else: target_shape.append(array_ops.shape(x)[axis]) target_shape = array_ops.stack(target_shape) broadcast_mean = array_ops.reshape(mean, target_shape) broadcast_var = array_ops.reshape(var, target_shape) if gamma is None: broadcast_gamma = None else: broadcast_gamma = array_ops.reshape(gamma, target_shape) if beta is None: broadcast_beta = None else: broadcast_beta = array_ops.reshape(beta, target_shape) normed = nn.batch_normalization(x, broadcast_mean, broadcast_var, broadcast_beta, broadcast_gamma, epsilon) return normed, mean, var def batch_normalization(x, mean, var, beta, gamma, epsilon=1e-3): """Applies batch normalization on x given mean, var, beta and gamma. I.e. returns: `output = (x - mean) / (sqrt(var) + epsilon) * gamma + beta` Arguments: x: Input tensor or variable. mean: Mean of batch. var: Variance of batch. beta: Tensor with which to center the input. gamma: Tensor by which to scale the input. epsilon: Fuzz factor. Returns: A tensor. """ return nn.batch_normalization(x, mean, var, beta, gamma, epsilon) # SHAPE OPERATIONS def concatenate(tensors, axis=-1): """Concatenates a list of tensors alongside the specified axis. Arguments: tensors: list of tensors to concatenate. axis: concatenation axis. Returns: A tensor. """ if axis < 0: rank = ndim(tensors[0]) if rank: axis %= rank else: axis = 0 if py_all([is_sparse(x) for x in tensors]): return sparse_ops.sparse_concat(axis, tensors) else: return array_ops.concat([to_dense(x) for x in tensors], axis) def reshape(x, shape): """Reshapes a tensor to the specified shape. Arguments: x: Tensor or variable. shape: Target shape tuple. Returns: A tensor. """ return array_ops.reshape(x, shape) def permute_dimensions(x, pattern): """Permutes axes in a tensor. Arguments: x: Tensor or variable. pattern: A tuple of dimension indices, e.g. `(0, 2, 1)`. Returns: A tensor. """ return array_ops.transpose(x, perm=pattern) def resize_images(x, height_factor, width_factor, data_format): """Resizes the images contained in a 4D tensor. Arguments: x: Tensor or variable to resize. height_factor: Positive integer. width_factor: Positive integer. data_format: One of `"channels_first"`, `"channels_last"`. Returns: A tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format == 'channels_first': original_shape = int_shape(x) new_shape = array_ops.shape(x)[2:] new_shape *= constant_op.constant( np.array([height_factor, width_factor]).astype('int32')) x = permute_dimensions(x, [0, 2, 3, 1]) x = image_ops.resize_nearest_neighbor(x, new_shape) x = permute_dimensions(x, [0, 3, 1, 2]) x.set_shape((None, None, original_shape[2] * height_factor if original_shape[2] is not None else None, original_shape[3] * width_factor if original_shape[3] is not None else None)) return x elif data_format == 'channels_last': original_shape = int_shape(x) new_shape = array_ops.shape(x)[1:3] new_shape *= constant_op.constant( np.array([height_factor, width_factor]).astype('int32')) x = image_ops.resize_nearest_neighbor(x, new_shape) x.set_shape((None, original_shape[1] * height_factor if original_shape[1] is not None else None, original_shape[2] * width_factor if original_shape[2] is not None else None, None)) return x else: raise ValueError('Invalid data_format:', data_format) def resize_volumes(x, depth_factor, height_factor, width_factor, data_format): """Resizes the volume contained in a 5D tensor. Arguments: x: Tensor or variable to resize. depth_factor: Positive integer. height_factor: Positive integer. width_factor: Positive integer. data_format: One of `"channels_first"`, `"channels_last"`. Returns: A tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format == 'channels_first': output = repeat_elements(x, depth_factor, axis=2) output = repeat_elements(output, height_factor, axis=3) output = repeat_elements(output, width_factor, axis=4) return output elif data_format == 'channels_last': output = repeat_elements(x, depth_factor, axis=1) output = repeat_elements(output, height_factor, axis=2) output = repeat_elements(output, width_factor, axis=3) return output else: raise ValueError('Invalid data_format:', data_format) def repeat_elements(x, rep, axis): """Repeats the elements of a tensor along an axis, like `np.repeat`. If `x` has shape `(s1, s2, s3)` and `axis` is `1`, the output will have shape `(s1, s2 * rep, s3)`. Arguments: x: Tensor or variable. rep: Python integer, number of times to repeat. axis: Axis along which to repeat. Raises: ValueError: In case `x.shape[axis]` is undefined. Returns: A tensor. """ x_shape = x.get_shape().as_list() if x_shape[axis] is None: raise ValueError('Axis ' + str(axis) + ' of input tensor ' 'should have a defined dimension, but is None. ' 'Full tensor shape: ' + str(tuple(x_shape)) + '. ' 'Typically you need to pass a fully-defined ' '`input_shape` argument to your first layer.') # slices along the repeat axis splits = array_ops.split(value=x, num_or_size_splits=x_shape[axis], axis=axis) # repeat each slice the given number of reps x_rep = [s for s in splits for _ in range(rep)] return concatenate(x_rep, axis) def repeat(x, n): """Repeats a 2D tensor. if `x` has shape (samples, dim) and `n` is `2`, the output will have shape `(samples, 2, dim)`. Arguments: x: Tensor or variable. n: Python integer, number of times to repeat. Returns: A tensor. """ assert ndim(x) == 2 x = array_ops.expand_dims(x, 1) pattern = array_ops.stack([1, n, 1]) return array_ops.tile(x, pattern) def arange(start, stop=None, step=1, dtype='int32'): """Creates a 1D tensor containing a sequence of integers. The function arguments use the same convention as Theano's arange: if only one argument is provided, it is in fact the "stop" argument. The default type of the returned tensor is `'int32'` to match TensorFlow's default. Arguments: start: Start value. stop: Stop value. step: Difference between two successive values. dtype: Integer dtype to use. Returns: An integer tensor. """ # Match the behavior of numpy and Theano by returning an empty seqence. if stop is None and start < 0: start = 0 result = math_ops.range(start, limit=stop, delta=step, name='arange') if dtype != 'int32': result = cast(result, dtype) return result def tile(x, n): """Creates a tensor by tiling `x` by `n`. Arguments: x: A tensor or variable n: A list of integer. The length must be the same as the number of dimensions in `x`. Returns: A tiled tensor. """ if isinstance(n, int): n = [n] return array_ops.tile(x, n) def flatten(x): """Flatten a tensor. Arguments: x: A tensor or variable. Returns: A tensor, reshaped into 1-D """ return array_ops.reshape(x, [-1]) def batch_flatten(x): """Turn a nD tensor into a 2D tensor with same 0th dimension. In other words, it flattens each data samples of a batch. Arguments: x: A tensor or variable. Returns: A tensor. """ x = array_ops.reshape(x, array_ops.stack([-1, prod(shape(x)[1:])])) return x def expand_dims(x, axis=-1): """Adds a 1-sized dimension at index "dim". Arguments: x: A tensor or variable. axis: Position where to add a new axis. Returns: A tensor with expended dimensions. """ return array_ops.expand_dims(x, axis) def squeeze(x, axis): """Removes a 1-dimension from the tensor at index "axis". Arguments: x: A tensor or variable. axis: Axis to drop. Returns: A tensor with the same data as `x` but reduced dimensions. """ return array_ops.squeeze(x, [axis]) def temporal_padding(x, padding=(1, 1)): """Pads the middle dimension of a 3D tensor. Arguments: x: Tensor or variable. padding: Tuple of 2 integers, how many zeros to add at the start and end of dim 1. Returns: A padded 3D tensor. """ assert len(padding) == 2 pattern = [[0, 0], [padding[0], padding[1]], [0, 0]] return array_ops.pad(x, pattern) def spatial_2d_padding(x, padding=((1, 1), (1, 1)), data_format=None): """Pads the 2nd and 3rd dimensions of a 4D tensor. Arguments: x: Tensor or variable. padding: Tuple of 2 tuples, padding pattern. data_format: One of `channels_last` or `channels_first`. Returns: A padded 4D tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ assert len(padding) == 2 assert len(padding[0]) == 2 assert len(padding[1]) == 2 if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) if data_format == 'channels_first': pattern = [[0, 0], [0, 0], list(padding[0]), list(padding[1])] else: pattern = [[0, 0], list(padding[0]), list(padding[1]), [0, 0]] return array_ops.pad(x, pattern) def spatial_3d_padding(x, padding=((1, 1), (1, 1), (1, 1)), data_format=None): """Pads 5D tensor with zeros along the depth, height, width dimensions. Pads these dimensions with respectively "padding[0]", "padding[1]" and "padding[2]" zeros left and right. For 'channels_last' data_format, the 2nd, 3rd and 4th dimension will be padded. For 'channels_first' data_format, the 3rd, 4th and 5th dimension will be padded. Arguments: x: Tensor or variable. padding: Tuple of 3 tuples, padding pattern. data_format: One of `channels_last` or `channels_first`. Returns: A padded 5D tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ assert len(padding) == 3 assert len(padding[0]) == 2 assert len(padding[1]) == 2 assert len(padding[2]) == 2 if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) if data_format == 'channels_first': pattern = [[0, 0], [0, 0], [padding[0][0], padding[0][1]], [padding[1][0], padding[1][1]], [padding[2][0], padding[2][1]]] else: pattern = [[0, 0], [padding[0][0], padding[0][1]], [padding[1][0], padding[1][1]], [padding[2][0], padding[2][1]], [0, 0]] return array_ops.pad(x, pattern) def stack(x, axis=0): """Stacks a list of rank `R` tensors into a rank `R+1` tensor. Arguments: x: List of tensors. axis: Axis along which to perform stacking. Returns: A tensor. """ return array_ops.stack(x, axis=axis) def one_hot(indices, num_classes): """Computes the one-hot representation of an integer tensor. Arguments: indices: nD integer tensor of shape `(batch_size, dim1, dim2, ... dim(n-1))` num_classes: Integer, number of classes to consider. Returns: (n + 1)D one hot representation of the input with shape `(batch_size, dim1, dim2, ... dim(n-1), num_classes)` Returns: The one-hot tensor. """ return array_ops.one_hot(indices, depth=num_classes, axis=-1) def reverse(x, axes): """Reverse a tensor along the specified axes. Arguments: x: Tensor to reverse. axes: Integer or iterable of integers. Axes to reverse. Returns: A tensor. """ if isinstance(axes, int): axes = [axes] return array_ops.reverse(x, axes) # VALUE MANIPULATION def get_value(x): """Returns the value of a variable. Arguments: x: input variable. Returns: A Numpy array. """ return x.eval(session=get_session()) def batch_get_value(tensors): """Returns the value of more than one tensor variable. Arguments: tensors: list of ops to run. Returns: A list of Numpy arrays. """ if tensors: return get_session().run(tensors) else: return [] def set_value(x, value): """Sets the value of a variable, from a Numpy array. Arguments: x: Tensor to set to a new value. value: Value to set the tensor to, as a Numpy array (of the same shape). """ value = np.asarray(value) tf_dtype = _convert_string_dtype(x.dtype.name.split('_')[0]) if hasattr(x, '_assign_placeholder'): assign_placeholder = x._assign_placeholder assign_op = x._assign_op else: assign_placeholder = array_ops.placeholder(tf_dtype, shape=value.shape) assign_op = x.assign(assign_placeholder) x._assign_placeholder = assign_placeholder x._assign_op = assign_op get_session().run(assign_op, feed_dict={assign_placeholder: value}) def batch_set_value(tuples): """Sets the values of many tensor variables at once. Arguments: tuples: a list of tuples `(tensor, value)`. `value` should be a Numpy array. """ if tuples: assign_ops = [] feed_dict = {} for x, value in tuples: value = np.asarray(value) tf_dtype = _convert_string_dtype(x.dtype.name.split('_')[0]) if hasattr(x, '_assign_placeholder'): assign_placeholder = x._assign_placeholder assign_op = x._assign_op else: assign_placeholder = array_ops.placeholder(tf_dtype, shape=value.shape) assign_op = x.assign(assign_placeholder) x._assign_placeholder = assign_placeholder x._assign_op = assign_op assign_ops.append(assign_op) feed_dict[assign_placeholder] = value get_session().run(assign_ops, feed_dict=feed_dict) def print_tensor(x, message=''): """Prints `message` and the tensor value when evaluated. Arguments: x: Tensor to print. message: Message to print jointly with the tensor. Returns: The same tensor `x`, unchanged. """ return logging_ops.Print(x, [x], message) # GRAPH MANIPULATION class Function(object): """Runs a computation graph. Arguments: inputs: Feed placeholders to the computation graph. outputs: Output tensors to fetch. updates: Additional update ops to be run at function call. """ def __init__(self, inputs, outputs, updates=None): updates = updates or [] if not isinstance(inputs, (list, tuple)): raise TypeError('`inputs` to a TensorFlow backend function ' 'should be a list or tuple.') if not isinstance(outputs, (list, tuple)): raise TypeError('`outputs` of a TensorFlow backend function ' 'should be a list or tuple.') if not isinstance(updates, (list, tuple)): raise TypeError('`updates` in a TensorFlow backend function ' 'should be a list or tuple.') self.inputs = list(inputs) self.outputs = list(outputs) with ops.control_dependencies(self.outputs): updates_ops = [] for update in updates: if isinstance(update, tuple): p, new_p = update updates_ops.append(state_ops.assign(p, new_p)) else: # assumed already an op updates_ops.append(update) self.updates_op = control_flow_ops.group(*updates_ops) def __call__(self, inputs): if not isinstance(inputs, (list, tuple)): raise TypeError('`inputs` should be a list or tuple.') feed_dict = {} for tensor, value in zip(self.inputs, inputs): if is_sparse(tensor): sparse_coo = value.tocoo() indices = np.concatenate((np.expand_dims(sparse_coo.row, 1), np.expand_dims(sparse_coo.col, 1)), 1) value = (indices, sparse_coo.data, sparse_coo.shape) feed_dict[tensor] = value session = get_session() updated = session.run(self.outputs + [self.updates_op], feed_dict=feed_dict) return updated[:len(self.outputs)] def function(inputs, outputs, updates=None, **kwargs): """Instantiates a Keras function. Arguments: inputs: List of placeholder tensors. outputs: List of output tensors. updates: List of update ops. **kwargs: Not used with TensorFlow. Returns: Output values as Numpy arrays. """ if kwargs: msg = [ 'Expected no kwargs, you passed %s' % len(kwargs), 'kwargs passed to function are ignored with Tensorflow backend' ] warnings.warn('\n'.join(msg)) return Function(inputs, outputs, updates=updates) def gradients(loss, variables): """Returns the gradients of `variables` w.r.t. `loss`. Arguments: loss: Scalar tensor to minimize. variables: List of variables. Returns: A gradients tensor. """ return gradients_module.gradients( loss, variables, colocate_gradients_with_ops=True) def stop_gradient(variables): """Returns `variables` but with zero gradient w.r.t. every other variable. Arguments: variables: List of variables. Returns: The same list of variables. """ return array_ops.stop_gradient(variables) # CONTROL FLOW def rnn(step_function, inputs, initial_states, go_backwards=False, mask=None, constants=None, unroll=False): """Iterates over the time dimension of a tensor. Arguments: step_function: RNN step function. Parameters; input; tensor with shape `(samples, ...)` (no time dimension), representing input for the batch of samples at a certain time step. states; list of tensors. Returns; output; tensor with shape `(samples, output_dim)` (no time dimension). new_states; list of tensors, same length and shapes as 'states'. The first state in the list must be the output tensor at the previous timestep. inputs: tensor of temporal data of shape `(samples, time, ...)` (at least 3D). initial_states: tensor with shape (samples, output_dim) (no time dimension), containing the initial values for the states used in the step function. go_backwards: boolean. If True, do the iteration over the time dimension in reverse order and return the reversed sequence. mask: binary tensor with shape `(samples, time, 1)`, with a zero for every element that is masked. constants: a list of constant values passed at each step. unroll: whether to unroll the RNN or to use a symbolic loop (`while_loop` or `scan` depending on backend). Returns: A tuple, `(last_output, outputs, new_states)`. last_output: the latest output of the rnn, of shape `(samples, ...)` outputs: tensor with shape `(samples, time, ...)` where each entry `outputs[s, t]` is the output of the step function at time `t` for sample `s`. new_states: list of tensors, latest states returned by the step function, of shape `(samples, ...)`. Raises: ValueError: if input dimension is less than 3. ValueError: if `unroll` is `True` but input timestep is not a fixed number. ValueError: if `mask` is provided (not `None`) but states is not provided (`len(states)` == 0). """ ndim = len(inputs.get_shape()) if ndim < 3: raise ValueError('Input should be at least 3D.') axes = [1, 0] + list(range(2, ndim)) inputs = array_ops.transpose(inputs, (axes)) if mask is not None: if mask.dtype != dtypes_module.bool: mask = math_ops.cast(mask, dtypes_module.bool) if len(mask.get_shape()) == ndim - 1: mask = expand_dims(mask) mask = array_ops.transpose(mask, axes) if constants is None: constants = [] if unroll: if not inputs.get_shape()[0]: raise ValueError('Unrolling requires a ' 'fixed number of timesteps.') states = initial_states successive_states = [] successive_outputs = [] input_list = array_ops.unstack(inputs) if go_backwards: input_list.reverse() if mask is not None: mask_list = array_ops.unstack(mask) if go_backwards: mask_list.reverse() for inp, mask_t in zip(input_list, mask_list): output, new_states = step_function(inp, states + constants) # tf.where needs its condition tensor # to be the same shape as its two # result tensors, but in our case # the condition (mask) tensor is # (nsamples, 1), and A and B are (nsamples, ndimensions). # So we need to # broadcast the mask to match the shape of A and B. # That's what the tile call does, # it just repeats the mask along its second dimension # n times. tiled_mask_t = array_ops.tile(mask_t, array_ops.stack( [1, array_ops.shape(output)[1]])) if not successive_outputs: prev_output = zeros_like(output) else: prev_output = successive_outputs[-1] output = array_ops.where(tiled_mask_t, output, prev_output) return_states = [] for state, new_state in zip(states, new_states): # (see earlier comment for tile explanation) tiled_mask_t = array_ops.tile(mask_t, array_ops.stack( [1, array_ops.shape(new_state)[1]])) return_states.append(array_ops.where(tiled_mask_t, new_state, state)) states = return_states successive_outputs.append(output) successive_states.append(states) last_output = successive_outputs[-1] new_states = successive_states[-1] outputs = array_ops.stack(successive_outputs) else: for inp in input_list: output, states = step_function(inp, states + constants) successive_outputs.append(output) successive_states.append(states) last_output = successive_outputs[-1] new_states = successive_states[-1] outputs = array_ops.stack(successive_outputs) else: if go_backwards: inputs = reverse(inputs, 0) states = tuple(initial_states) time_steps = array_ops.shape(inputs)[0] outputs, _ = step_function(inputs[0], initial_states + constants) output_ta = tensor_array_ops.TensorArray( dtype=outputs.dtype, size=time_steps, tensor_array_name='output_ta') input_ta = tensor_array_ops.TensorArray( dtype=inputs.dtype, size=time_steps, tensor_array_name='input_ta') input_ta = input_ta.unstack(inputs) time = constant_op.constant(0, dtype='int32', name='time') if mask is not None: if not states: raise ValueError('No initial states provided! ' 'When using masking in an RNN, you should ' 'provide initial states ' '(and your step function should return ' 'as its first state at time `t` ' 'the output at time `t-1`).') if go_backwards: mask = reverse(mask, 0) mask_ta = tensor_array_ops.TensorArray( dtype=dtypes_module.bool, size=time_steps, tensor_array_name='mask_ta') mask_ta = mask_ta.unstack(mask) def _step(time, output_ta_t, *states): """RNN step function. Arguments: time: Current timestep value. output_ta_t: TensorArray. *states: List of states. Returns: Tuple: `(time + 1,output_ta_t) + tuple(new_states)` """ current_input = input_ta.read(time) mask_t = mask_ta.read(time) output, new_states = step_function(current_input, tuple(states) + tuple(constants)) for state, new_state in zip(states, new_states): new_state.set_shape(state.get_shape()) tiled_mask_t = array_ops.tile(mask_t, array_ops.stack( [1, array_ops.shape(output)[1]])) output = array_ops.where(tiled_mask_t, output, states[0]) new_states = [ array_ops.where(tiled_mask_t, new_states[i], states[i]) for i in range(len(states)) ] output_ta_t = output_ta_t.write(time, output) return (time + 1, output_ta_t) + tuple(new_states) else: def _step(time, output_ta_t, *states): """RNN step function. Arguments: time: Current timestep value. output_ta_t: TensorArray. *states: List of states. Returns: Tuple: `(time + 1,output_ta_t) + tuple(new_states)` """ current_input = input_ta.read(time) output, new_states = step_function(current_input, tuple(states) + tuple(constants)) for state, new_state in zip(states, new_states): new_state.set_shape(state.get_shape()) output_ta_t = output_ta_t.write(time, output) return (time + 1, output_ta_t) + tuple(new_states) final_outputs = control_flow_ops.while_loop( cond=lambda time, *_: time < time_steps, body=_step, loop_vars=(time, output_ta) + states, parallel_iterations=32, swap_memory=True) last_time = final_outputs[0] output_ta = final_outputs[1] new_states = final_outputs[2:] outputs = output_ta.stack() last_output = output_ta.read(last_time - 1) axes = [1, 0] + list(range(2, len(outputs.get_shape()))) outputs = array_ops.transpose(outputs, axes) return last_output, outputs, new_states def switch(condition, then_expression, else_expression): """Switches between two operations depending on a scalar value. Note that both `then_expression` and `else_expression` should be symbolic tensors of the *same shape*. Arguments: condition: scalar tensor (`int` or `bool`). then_expression: either a tensor, or a callable that returns a tensor. else_expression: either a tensor, or a callable that returns a tensor. Returns: The selected tensor. """ if condition.dtype != dtypes_module.bool: condition = math_ops.cast(condition, 'bool') if not callable(then_expression): def then_expression_fn(): return then_expression else: then_expression_fn = then_expression if not callable(else_expression): def else_expression_fn(): return else_expression else: else_expression_fn = else_expression x = control_flow_ops.cond(condition, then_expression_fn, else_expression_fn) return x def in_train_phase(x, alt, training=None): """Selects `x` in train phase, and `alt` otherwise. Note that `alt` should have the *same shape* as `x`. Arguments: x: What to return in train phase (tensor or callable that returns a tensor). alt: What to return otherwise (tensor or callable that returns a tensor). training: Optional scalar tensor (or Python boolean, or Python integer) specifing the learning phase. Returns: Either `x` or `alt` based on the `training` flag. the `training` flag defaults to `K.learning_phase()`. """ if training is None: training = learning_phase() uses_learning_phase = True else: uses_learning_phase = False if training is 1 or training is True: if callable(x): return x() else: return x elif training is 0 or training is False: if callable(alt): return alt() else: return alt # else: assume learning phase is a placeholder tensor. x = switch(training, x, alt) if uses_learning_phase: x._uses_learning_phase = True return x def in_test_phase(x, alt, training=None): """Selects `x` in test phase, and `alt` otherwise. Note that `alt` should have the *same shape* as `x`. Arguments: x: What to return in test phase (tensor or callable that returns a tensor). alt: What to return otherwise (tensor or callable that returns a tensor). training: Optional scalar tensor (or Python boolean, or Python integer) specifing the learning phase. Returns: Either `x` or `alt` based on `K.learning_phase`. """ return in_train_phase(alt, x, training=training) # NN OPERATIONS def relu(x, alpha=0., max_value=None): """Rectified linear unit. With default values, it returns element-wise `max(x, 0)`. Arguments: x: A tensor or variable. alpha: A scalar, slope of negative section (default=`0.`). max_value: Saturation threshold. Returns: A tensor. """ if alpha != 0.: negative_part = nn.relu(-x) x = nn.relu(x) if max_value is not None: max_value = _to_tensor(max_value, x.dtype.base_dtype) zero = _to_tensor(0., x.dtype.base_dtype) x = clip_ops.clip_by_value(x, zero, max_value) if alpha != 0.: alpha = _to_tensor(alpha, x.dtype.base_dtype) x -= alpha * negative_part return x def elu(x, alpha=1.): """Exponential linear unit. Arguments: x: A tenor or variable to compute the activation function for. alpha: A scalar, slope of positive section. Returns: A tensor. """ res = nn.elu(x) if alpha == 1: return res else: return array_ops.where(x > 0, res, alpha * res) def softmax(x): """Softmax of a tensor. Arguments: x: A tensor or variable. Returns: A tensor. """ return nn.softmax(x) def softplus(x): """Softplus of a tensor. Arguments: x: A tensor or variable. Returns: A tensor. """ return nn.softplus(x) def softsign(x): """Softsign of a tensor. Arguments: x: A tensor or variable. Returns: A tensor. """ return nn.softsign(x) def categorical_crossentropy(output, target, from_logits=False): """Categorical crossentropy between an output tensor and a target tensor. Arguments: output: A tensor resulting from a softmax (unless `from_logits` is True, in which case `output` is expected to be the logits). target: A tensor of the same shape as `output`. from_logits: Boolean, whether `output` is the result of a softmax, or is a tensor of logits. Returns: Output tensor. """ # Note: nn.softmax_cross_entropy_with_logits # expects logits, Keras expects probabilities. if not from_logits: # scale preds so that the class probas of each sample sum to 1 output /= math_ops.reduce_sum( output, reduction_indices=len(output.get_shape()) - 1, keep_dims=True) # manual computation of crossentropy epsilon = _to_tensor(_EPSILON, output.dtype.base_dtype) output = clip_ops.clip_by_value(output, epsilon, 1. - epsilon) return -math_ops.reduce_sum( target * math_ops.log(output), reduction_indices=len(output.get_shape()) - 1) else: return nn.softmax_cross_entropy_with_logits(labels=target, logits=output) def sparse_categorical_crossentropy(output, target, from_logits=False): """Categorical crossentropy with integer targets. Arguments: output: A tensor resulting from a softmax (unless `from_logits` is True, in which case `output` is expected to be the logits). target: An integer tensor. from_logits: Boolean, whether `output` is the result of a softmax, or is a tensor of logits. Returns: Output tensor. """ # Note: nn.softmax_cross_entropy_with_logits # expects logits, Keras expects probabilities. if not from_logits: epsilon = _to_tensor(_EPSILON, output.dtype.base_dtype) output = clip_ops.clip_by_value(output, epsilon, 1 - epsilon) output = math_ops.log(output) output_shape = output.get_shape() targets = cast(flatten(target), 'int64') logits = array_ops.reshape(output, [-1, int(output_shape[-1])]) res = nn.sparse_softmax_cross_entropy_with_logits( labels=targets, logits=logits) if len(output_shape) == 3: # if our output includes timesteps we need to reshape return array_ops.reshape(res, array_ops.shape(output)[:-1]) else: return res def binary_crossentropy(output, target, from_logits=False): """Binary crossentropy between an output tensor and a target tensor. Arguments: output: A tensor. target: A tensor with the same shape as `output`. from_logits: Whether `output` is expected to be a logits tensor. By default, we consider that `output` encodes a probability distribution. Returns: A tensor. """ # Note: nn.softmax_cross_entropy_with_logits # expects logits, Keras expects probabilities. if not from_logits: # transform back to logits epsilon = _to_tensor(_EPSILON, output.dtype.base_dtype) output = clip_ops.clip_by_value(output, epsilon, 1 - epsilon) output = math_ops.log(output / (1 - output)) return nn.sigmoid_cross_entropy_with_logits(labels=target, logits=output) def sigmoid(x): """Element-wise sigmoid. Arguments: x: A tensor or variable. Returns: A tensor. """ return nn.sigmoid(x) def hard_sigmoid(x): """Segment-wise linear approximation of sigmoid. Faster than sigmoid. Returns `0.` if `x < -2.5`, `1.` if `x > 2.5`. In `-2.5 <= x <= 2.5`, returns `0.2 * x + 0.5`. Arguments: x: A tensor or variable. Returns: A tensor. """ x = (0.2 * x) + 0.5 zero = _to_tensor(0., x.dtype.base_dtype) one = _to_tensor(1., x.dtype.base_dtype) x = clip_ops.clip_by_value(x, zero, one) return x def tanh(x): """Element-wise tanh. Arguments: x: A tensor or variable. Returns: A tensor. """ return nn.tanh(x) def dropout(x, level, noise_shape=None, seed=None): """Sets entries in `x` to zero at random, while scaling the entire tensor. Arguments: x: tensor level: fraction of the entries in the tensor that will be set to 0. noise_shape: shape for randomly generated keep/drop flags, must be broadcastable to the shape of `x` seed: random seed to ensure determinism. Returns: A tensor. """ retain_prob = 1. - level if seed is None: seed = np.random.randint(10e6) # the dummy 1. works around a TF bug # (float32_ref vs. float32 incomptability) return nn.dropout(x * 1., retain_prob, noise_shape, seed=seed) def l2_normalize(x, axis): """Normalizes a tensor wrt the L2 norm alongside the specified axis. Arguments: x: Tensor or variable. axis: axis along which to perform normalization. Returns: A tensor. """ if axis < 0: axis %= len(x.get_shape()) return nn.l2_normalize(x, dim=axis) def in_top_k(predictions, targets, k): """Returns whether the `targets` are in the top `k` `predictions`. Arguments: predictions: A tensor of shape `(batch_size, classes)` and type `float32`. targets: A 1D tensor of length `batch_size` and type `int32` or `int64`. k: An `int`, number of top elements to consider. Returns: A 1D tensor of length `batch_size` and type `bool`. `output[i]` is `True` if `predictions[i, targets[i]]` is within top-`k` values of `predictions[i]`. """ return nn.in_top_k(predictions, targets, k) # CONVOLUTIONS def _preprocess_deconv_output_shape(x, shape, data_format): if data_format == 'channels_first': shape = (shape[0], shape[2], shape[3], shape[1]) if shape[0] is None: shape = (array_ops.shape(x)[0],) + tuple(shape[1:]) shape = array_ops.stack(list(shape)) return shape def _preprocess_conv2d_input(x, data_format): if dtype(x) == 'float64': x = math_ops.cast(x, 'float32') if data_format == 'channels_first': # TF uses the last dimension as channel dimension, # instead of the 2nd one. # TH input shape: (samples, input_depth, rows, cols) # TF input shape: (samples, rows, cols, input_depth) x = array_ops.transpose(x, (0, 2, 3, 1)) return x def _preprocess_conv3d_input(x, data_format): if dtype(x) == 'float64': x = math_ops.cast(x, 'float32') if data_format == 'channels_first': x = array_ops.transpose(x, (0, 2, 3, 4, 1)) return x def _preprocess_conv2d_kernel(kernel, data_format): if dtype(kernel) == 'float64': kernel = math_ops.cast(kernel, 'float32') if data_format == 'channels_first': kernel = array_ops.transpose(kernel, (2, 3, 1, 0)) return kernel def _preprocess_conv3d_kernel(kernel, data_format): if dtype(kernel) == 'float64': kernel = math_ops.cast(kernel, 'float32') if data_format == 'channels_first': kernel = array_ops.transpose(kernel, (2, 3, 4, 1, 0)) return kernel def _preprocess_padding(padding): if padding == 'same': padding = 'SAME' elif padding == 'valid': padding = 'VALID' else: raise ValueError('Invalid border mode:', padding) return padding def _postprocess_conv2d_output(x, data_format): if data_format == 'channels_first': x = array_ops.transpose(x, (0, 3, 1, 2)) if floatx() == 'float64': x = math_ops.cast(x, 'float64') return x def _postprocess_conv3d_output(x, data_format): if data_format == 'channels_first': x = array_ops.transpose(x, (0, 4, 1, 2, 3)) if floatx() == 'float64': x = math_ops.cast(x, 'float64') return x def conv1d(x, kernel, strides=1, padding='valid', data_format=None, dilation_rate=1): """1D convolution. Arguments: x: Tensor or variable. kernel: kernel tensor. strides: stride integer. padding: string, `"same"`, `"causal"` or `"valid"`. data_format: string, one of "channels_last", "channels_first". dilation_rate: integer dilate rate. Returns: A tensor, result of 1D convolution. """ kernel_shape = kernel.get_shape().as_list() if padding == 'causal': # causal (dilated) convolution: left_pad = dilation_rate * (kernel_shape[0] - 1) x = temporal_padding(x, (left_pad, 0)) padding = 'valid' padding = _preprocess_padding(padding) if data_format == 'channels_last': tf_data_format = 'NWC' else: tf_data_format = 'NCW' x = nn.convolution( input=x, filter=kernel, dilation_rate=(dilation_rate,), strides=(strides,), padding=padding, data_format=tf_data_format) return x def conv2d(x, kernel, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1)): """2D convolution. Arguments: x: Tensor or variable. kernel: kernel tensor. strides: strides tuple. padding: string, `"same"` or `"valid"`. data_format: `"channels_last"` or `"channels_first"`. Whether to use Theano or TensorFlow data format for inputs/kernels/ouputs. dilation_rate: tuple of 2 integers. Returns: A tensor, result of 2D convolution. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) # With 4d inputs, nn.convolution only supports # data_format NHWC, so we transpose the inputs # in case we are in data_format channels_first. x = _preprocess_conv2d_input(x, data_format) padding = _preprocess_padding(padding) x = nn.convolution( input=x, filter=kernel, dilation_rate=dilation_rate, strides=strides, padding=padding, data_format='NHWC') return _postprocess_conv2d_output(x, data_format) def conv2d_transpose(x, kernel, output_shape, strides=(1, 1), padding='valid', data_format=None): """2D deconvolution (i.e. transposed convolution). Arguments: x: Tensor or variable. kernel: kernel tensor. output_shape: 1D int tensor for the output shape. strides: strides tuple. padding: string, `"same"` or `"valid"`. data_format: `"channels_last"` or `"channels_first"`. Whether to use Theano or TensorFlow data format for inputs/kernels/ouputs. Returns: A tensor, result of transposed 2D convolution. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) if isinstance(output_shape, (tuple, list)): output_shape = array_ops.stack(output_shape) x = _preprocess_conv2d_input(x, data_format) output_shape = _preprocess_deconv_output_shape(x, output_shape, data_format) padding = _preprocess_padding(padding) strides = (1,) + strides + (1,) x = nn.conv2d_transpose(x, kernel, output_shape, strides, padding=padding) x = _postprocess_conv2d_output(x, data_format) return x def separable_conv2d(x, depthwise_kernel, pointwise_kernel, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1)): """2D convolution with separable filters. Arguments: x: input tensor depthwise_kernel: convolution kernel for the depthwise convolution. pointwise_kernel: kernel for the 1x1 convolution. strides: strides tuple (length 2). padding: padding mode, "valid" or "same". data_format: data format, "channels_first" or "channels_last". dilation_rate: tuple of integers, dilation rates for the separable convolution. Returns: Output tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) x = _preprocess_conv2d_input(x, data_format) padding = _preprocess_padding(padding) strides = (1,) + strides + (1,) x = nn.separable_conv2d( x, depthwise_kernel, pointwise_kernel, strides=strides, padding=padding, rate=dilation_rate) return _postprocess_conv2d_output(x, data_format) def conv3d(x, kernel, strides=(1, 1, 1), padding='valid', data_format=None, dilation_rate=(1, 1, 1)): """3D convolution. Arguments: x: Tensor or variable. kernel: kernel tensor. strides: strides tuple. padding: string, `"same"` or `"valid"`. data_format: `"channels_last"` or `"channels_first"`. Whether to use Theano or TensorFlow data format for inputs/kernels/ouputs. dilation_rate: tuple of 3 integers. Returns: A tensor, result of 3D convolution. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) # With 5d inputs, nn.convolution only supports # data_format NDHWC, so we transpose the inputs # in case we are in data_format channels_first. x = _preprocess_conv3d_input(x, data_format) padding = _preprocess_padding(padding) x = nn.convolution( input=x, filter=kernel, dilation_rate=dilation_rate, strides=strides, padding=padding, data_format='NDHWC') return _postprocess_conv3d_output(x, data_format) def pool2d(x, pool_size, strides=(1, 1), padding='valid', data_format=None, pool_mode='max'): """2D Pooling. Arguments: x: Tensor or variable. pool_size: tuple of 2 integers. strides: tuple of 2 integers. padding: one of `"valid"`, `"same"`. data_format: one of `"channels_first"`, `"channels_last"`. pool_mode: one of `"max"`, `"avg"`. Returns: A tensor, result of 2D pooling. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. ValueError: if `pool_mode` is neither `max` or `avg`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) padding = _preprocess_padding(padding) strides = (1,) + strides + (1,) pool_size = (1,) + pool_size + (1,) x = _preprocess_conv2d_input(x, data_format) if pool_mode == 'max': x = nn.max_pool(x, pool_size, strides, padding=padding) elif pool_mode == 'avg': x = nn.avg_pool(x, pool_size, strides, padding=padding) else: raise ValueError('Invalid pooling mode:', pool_mode) return _postprocess_conv2d_output(x, data_format) def pool3d(x, pool_size, strides=(1, 1, 1), padding='valid', data_format=None, pool_mode='max'): """3D Pooling. Arguments: x: Tensor or variable. pool_size: tuple of 3 integers. strides: tuple of 3 integers. padding: one of `"valid"`, `"same"`. data_format: one of `"channels_first"`, `"channels_last"`. pool_mode: one of `"max"`, `"avg"`. Returns: A tensor, result of 3D pooling. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. ValueError: if `pool_mode` is neither `max` or `avg`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) padding = _preprocess_padding(padding) strides = (1,) + strides + (1,) pool_size = (1,) + pool_size + (1,) x = _preprocess_conv3d_input(x, data_format) if pool_mode == 'max': x = nn.max_pool3d(x, pool_size, strides, padding=padding) elif pool_mode == 'avg': x = nn.avg_pool3d(x, pool_size, strides, padding=padding) else: raise ValueError('Invalid pooling mode:', pool_mode) return _postprocess_conv3d_output(x, data_format) def bias_add(x, bias, data_format=None): """Adds a bias vector to a tensor. Arguments: x: Tensor or variable. bias: Bias tensor to add. data_format: Data format for 3D, 4D or 5D tensors: one of "channels_first", "channels_last". Returns: Output tensor. Raises: ValueError: In case of invalid `data_format` argument. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) if ndim(x) == 5: if data_format == 'channels_first': x += reshape(bias, (1, int_shape(bias)[0], 1, 1, 1)) elif data_format == 'channels_last': x += reshape(bias, (1, 1, 1, 1, int_shape(bias)[0])) elif ndim(x) == 4: if data_format == 'channels_first': # No support yet for NCHW in bias_add. x += reshape(bias, (1, int_shape(bias)[0], 1, 1)) elif data_format == 'channels_last': x = nn.bias_add(x, bias, data_format='NHWC') elif ndim(x) == 3: if data_format == 'channels_first': x += reshape(bias, (1, int_shape(bias)[0], 1)) elif data_format == 'channels_last': x += reshape(bias, (1, 1, int_shape(bias)[0])) else: x = nn.bias_add(x, bias) return x # RANDOMNESS def random_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None): """Returns a tensor with normal distribution of values. Arguments: shape: A tuple of integers, the shape of tensor to create. mean: A float, mean of the normal distribution to draw samples. stddev: A float, standard deviation of the normal distribution to draw samples. dtype: String, dtype of returned tensor. seed: Integer, random seed. Returns: A tensor. """ if dtype is None: dtype = floatx() if seed is None: seed = np.random.randint(10e6) return random_ops.random_normal( shape, mean=mean, stddev=stddev, dtype=dtype, seed=seed) def random_uniform(shape, minval=0.0, maxval=1.0, dtype=None, seed=None): """Returns a tensor with uniform distribution of values. Arguments: shape: A tuple of integers, the shape of tensor to create. minval: A float, lower boundary of the uniform distribution to draw samples. maxval: A float, upper boundary of the uniform distribution to draw samples. dtype: String, dtype of returned tensor. seed: Integer, random seed. Returns: A tensor. """ if dtype is None: dtype = floatx() if seed is None: seed = np.random.randint(10e6) return random_ops.random_uniform( shape, minval=minval, maxval=maxval, dtype=dtype, seed=seed) def random_binomial(shape, p=0.0, dtype=None, seed=None): """Returns a tensor with random binomial distribution of values. Arguments: shape: A tuple of integers, the shape of tensor to create. p: A float, `0. <= p <= 1`, probability of binomial distribution. dtype: String, dtype of returned tensor. seed: Integer, random seed. Returns: A tensor. """ if dtype is None: dtype = floatx() if seed is None: seed = np.random.randint(10e6) return array_ops.where( random_ops.random_uniform(shape, dtype=dtype, seed=seed) <= p, array_ops.ones(shape, dtype=dtype), array_ops.zeros(shape, dtype=dtype)) def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None): """Returns a tensor with truncated random normal distribution of values. The generated values follow a normal distribution with specified mean and standard deviation, except that values whose magnitude is more than two standard deviations from the mean are dropped and re-picked. Arguments: shape: A tuple of integers, the shape of tensor to create. mean: Mean of the values. stddev: Standard deviation of the values. dtype: String, dtype of returned tensor. seed: Integer, random seed. Returns: A tensor. """ if dtype is None: dtype = floatx() if seed is None: seed = np.random.randint(10e6) return random_ops.truncated_normal( shape, mean, stddev, dtype=dtype, seed=seed) # CTC # tensorflow has a native implemenation, but it uses sparse tensors # and therefore requires a wrapper for Keras. The functions below convert # dense to sparse tensors and also wraps up the beam search code that is # in tensorflow's CTC implementation def ctc_label_dense_to_sparse(labels, label_lengths): """Converts CTC labels from dense to sparse. Arguments: labels: dense CTC labels. label_lengths: length of the labels. Returns: A sparse tensor representation of the lablels. """ label_shape = array_ops.shape(labels) num_batches_tns = array_ops.stack([label_shape[0]]) max_num_labels_tns = array_ops.stack([label_shape[1]]) def range_less_than(_, current_input): return array_ops.expand_dims( math_ops.range(label_shape[1]), 0) < array_ops.fill( max_num_labels_tns, current_input) init = math_ops.cast( array_ops.fill([1, label_shape[1]], 0), dtypes_module.bool) dense_mask = functional_ops.scan( range_less_than, label_lengths, initializer=init, parallel_iterations=1) dense_mask = dense_mask[:, 0, :] label_array = array_ops.reshape( array_ops.tile(math_ops.range(0, label_shape[1]), num_batches_tns), label_shape) label_ind = array_ops.boolean_mask(label_array, dense_mask) batch_array = array_ops.transpose( array_ops.reshape( array_ops.tile(math_ops.range(0, label_shape[0]), max_num_labels_tns), reverse(label_shape, 0))) batch_ind = array_ops.boolean_mask(batch_array, dense_mask) indices = array_ops.transpose( array_ops.reshape(concatenate([batch_ind, label_ind], axis=0), [2, -1])) vals_sparse = array_ops.gather_nd(labels, indices) return sparse_tensor.SparseTensor( math_ops.to_int64(indices), vals_sparse, math_ops.to_int64(label_shape)) def ctc_batch_cost(y_true, y_pred, input_length, label_length): """Runs CTC loss algorithm on each batch element. Arguments: y_true: tensor `(samples, max_string_length)` containing the truth labels. y_pred: tensor `(samples, time_steps, num_categories)` containing the prediction, or output of the softmax. input_length: tensor `(samples, 1)` containing the sequence length for each batch item in `y_pred`. label_length: tensor `(samples, 1)` containing the sequence length for each batch item in `y_true`. Returns: Tensor with shape (samples,1) containing the CTC loss of each element. """ label_length = math_ops.to_int32(array_ops.squeeze(label_length)) input_length = math_ops.to_int32(array_ops.squeeze(input_length)) sparse_labels = math_ops.to_int32( ctc_label_dense_to_sparse(y_true, label_length)) y_pred = math_ops.log(array_ops.transpose(y_pred, perm=[1, 0, 2]) + 1e-8) return array_ops.expand_dims( ctc.ctc_loss( inputs=y_pred, labels=sparse_labels, sequence_length=input_length), 1) def ctc_decode(y_pred, input_length, greedy=True, beam_width=100, top_paths=1): """Decodes the output of a softmax. Can use either greedy search (also known as best path) or a constrained dictionary search. Arguments: y_pred: tensor `(samples, time_steps, num_categories)` containing the prediction, or output of the softmax. input_length: tensor `(samples, )` containing the sequence length for each batch item in `y_pred`. greedy: perform much faster best-path search if `true`. This does not use a dictionary. beam_width: if `greedy` is `false`: a beam search decoder will be used with a beam of this width. top_paths: if `greedy` is `false`, how many of the most probable paths will be returned. Returns: Tuple: List: if `greedy` is `true`, returns a list of one element that contains the decoded sequence. If `false`, returns the `top_paths` most probable decoded sequences. Important: blank labels are returned as `-1`. Tensor `(top_paths, )` that contains the log probability of each decoded sequence. """ y_pred = math_ops.log(array_ops.transpose(y_pred, perm=[1, 0, 2]) + 1e-8) input_length = math_ops.to_int32(input_length) if greedy: (decoded, log_prob) = ctc.ctc_greedy_decoder( inputs=y_pred, sequence_length=input_length) else: (decoded, log_prob) = ctc.ctc_beam_search_decoder( inputs=y_pred, sequence_length=input_length, beam_width=beam_width, top_paths=top_paths) decoded_dense = [ sparse_ops.sparse_to_dense( st.indices, st.dense_shape, st.values, default_value=-1) for st in decoded ] return (decoded_dense, log_prob) # HIGH ORDER FUNCTIONS def map_fn(fn, elems, name=None, dtype=None): """Map the function fn over the elements elems and return the outputs. Arguments: fn: Callable that will be called upon each element in elems elems: tensor name: A string name for the map node in the graph dtype: Output data type. Returns: Tensor with dtype `dtype`. """ return functional_ops.map_fn(fn, elems, name=name, dtype=dtype) def foldl(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from left to right. Arguments: fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[0]` in case of None) name: A string name for the foldl node in the graph Returns: Tensor with same type and shape as `initializer`. """ return functional_ops.foldl(fn, elems, initializer=initializer, name=name) def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. Arguments: fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph Returns: Same type and shape as initializer """ return functional_ops.foldr(fn, elems, initializer=initializer, name=name) # Load Keras default configuration from config file if present. _keras_base_dir = os.path.expanduser('~') _keras_dir = os.path.join(_keras_base_dir, '.keras') _config_path = os.path.expanduser(os.path.join(_keras_dir, 'keras.json')) if os.path.exists(_config_path): try: _config = json.load(open(_config_path)) except ValueError: _config = {} _floatx = _config.get('floatx', floatx()) assert _floatx in {'float16', 'float32', 'float64'} _epsilon = _config.get('epsilon', epsilon()) assert isinstance(_epsilon, float) _image_data_format = _config.get('image_data_format', image_data_format()) assert _image_data_format in {'channels_last', 'channels_first'} set_floatx(_floatx) set_epsilon(_epsilon) set_image_data_format(_image_data_format) # Save config file. if not os.path.exists(_keras_dir): try: os.makedirs(_keras_dir) except OSError: # Except permission denied and potential race conditions # in multi-threaded environments. pass if not os.path.exists(_config_path): _config = { 'floatx': floatx(), 'epsilon': epsilon(), 'backend': 'tensorflow', 'image_data_format': image_data_format() } try: with open(_config_path, 'w') as f: f.write(json.dumps(_config, indent=4)) except IOError: # Except permission denied. pass
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 3, 4287, 26, 3507, 29, 27913, 13, 7837, 13, 354, 199, 3, 4287, 26, 3507, 29, 27913, 13, 5351, 199, 624, 43, 30037, 4865, 3261, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 465, 2351, 63, 578, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 465, 6674, 63, 578, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11353, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 286, 3641, 63, 1483, 465, 286, 3641, 199, 504, 3228, 14, 1548, 14, 1483, 492, 22380, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 465, 12661, 63, 578, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1834, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2050, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5178, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1174, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2345, 63, 1144, 63, 6017, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2345, 63, 1144, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 465, 2860, 63, 578, 199, 504, 3228, 14, 1548, 14, 7588, 492, 12876, 63, 8536, 83, 421, 199, 647, 63, 452, 275, 1006, 199, 647, 63, 1838, 275, 3089, 199, 199, 3, 1621, 17071, 738, 52, 1193, 51, 199, 199, 3, 961, 365, 314, 849, 5007, 21721, 2351, 1202, 701, 1804, 30037, 14, 199, 3, 2779, 883, 506, 663, 10250, 4799, 658, 409, 63, 1730, 8, 5480, 20414, 199, 63, 12763, 275, 488, 199, 199, 3, 961, 2600, 15164, 282, 4412, 469, 2180, 26, 9328, 63, 6971, 5565, 199, 3, 437, 9328, 7669, 365, 282, 2155, 2345, 1202, 370, 1255, 1804, 30037, 1709, 315, 199, 3, 1902, 3560, 818, 334, 10546, 63, 6971, 508, 413, 9, 503, 511, 818, 334, 10546, 63, 6971, 508, 378, 680, 199, 63, 25302, 63, 906, 689, 6024, 63, 9791, 21983, 275, 1052, 199, 199, 3, 961, 2600, 15164, 282, 4412, 469, 2180, 26, 20746, 63, 12511, 5565, 199, 3, 1924, 20746, 63, 12511, 365, 282, 2600, 4412, 536, 13158, 370, 282, 1453, 1478, 12, 199, 3, 1202, 367, 1519, 65, 764, 3343, 13, 6100, 1059, 738, 12818, 199, 3, 367, 7750, 1561, 334, 69, 14, 71, 14, 4045, 1561, 680, 199, 63, 25302, 63, 6685, 63, 12511, 51, 275, 1052, 199, 199, 3, 961, 5046, 3305, 883, 506, 663, 370, 715, 370, 10137, 1750, 11097, 199, 3, 1536, 370, 314, 922, 14, 199, 3, 7743, 2399, 574, 4799, 658, 9285, 63, 1975, 63, 27876, 8, 585, 20414, 199, 63, 6588, 13841, 63, 5568, 63, 8727, 275, 756, 199, 199, 3, 710, 730, 402, 2069, 370, 675, 23088, 282, 2351, 14, 199, 63, 11783, 56, 275, 283, 1609, 708, 7, 199, 199, 3, 27255, 8746, 15632, 4348, 6535, 1202, 23088, 314, 1233, 1095, 14, 199, 63, 37, 20725, 275, 1616, 69, 13, 24, 199, 199, 3, 3758, 1834, 666, 1475, 12, 1373, 402, 298, 6324, 63, 2019, 401, 298, 6324, 63, 2246, 1674, 199, 63, 9438, 63, 3998, 63, 4807, 275, 283, 6324, 63, 2019, 7, 421, 199, 318, 4865, 837, 523, 408, 18060, 317, 429, 89, 17909, 1083, 367, 26638, 314, 1453, 4865, 14, 819, 5972, 3495, 367, 3261, 1013, 2159, 66, 3444, 543, 3510, 13, 4620, 1804, 30037, 14, 819, 1803, 26, 489, 710, 1059, 298, 16008, 1674, 523, 408, 523, 372, 283, 16008, 7, 421, 199, 318, 14030, 837, 523, 408, 3407, 314, 574, 402, 314, 15632, 4348, 6535, 1202, 315, 8950, 8455, 14, 819, 1803, 26, 489, 437, 2069, 14, 819, 5679, 26, 523, 10841, 1548, 489, 1306, 11708, 14, 4620, 14, 15761, 342, 489, 413, 69, 13, 2036, 523, 10841, 523, 408, 523, 372, 485, 37, 20725, 421, 199, 318, 663, 63, 15761, 8, 585, 304, 523, 408, 9899, 314, 574, 402, 314, 15632, 4348, 6535, 1202, 315, 8950, 8455, 14, 819, 7628, 26, 489, 574, 26, 2069, 14, 7053, 574, 402, 14030, 14, 819, 5679, 26, 523, 10841, 1548, 489, 1306, 687, 11708, 492, 4865, 465, 1804, 489, 1306, 1804, 14, 15761, 342, 489, 413, 69, 13, 2036, 489, 1306, 1804, 14, 409, 63, 15761, 8, 17, 69, 13, 1717, 9, 489, 1306, 1804, 14, 15761, 342, 489, 413, 69, 13, 1717, 523, 10841, 523 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 3, 4287, 26, 3507, 29, 27913, 13, 7837, 13, 354, 199, 3, 4287, 26, 3507, 29, 27913, 13, 5351, 199, 624, 43, 30037, 4865, 3261, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 465, 2351, 63, 578, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 465, 6674, 63, 578, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11353, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 286, 3641, 63, 1483, 465, 286, 3641, 199, 504, 3228, 14, 1548, 14, 1483, 492, 22380, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 465, 12661, 63, 578, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1834, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2050, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5178, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1174, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2345, 63, 1144, 63, 6017, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2345, 63, 1144, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 465, 2860, 63, 578, 199, 504, 3228, 14, 1548, 14, 7588, 492, 12876, 63, 8536, 83, 421, 199, 647, 63, 452, 275, 1006, 199, 647, 63, 1838, 275, 3089, 199, 199, 3, 1621, 17071, 738, 52, 1193, 51, 199, 199, 3, 961, 365, 314, 849, 5007, 21721, 2351, 1202, 701, 1804, 30037, 14, 199, 3, 2779, 883, 506, 663, 10250, 4799, 658, 409, 63, 1730, 8, 5480, 20414, 199, 63, 12763, 275, 488, 199, 199, 3, 961, 2600, 15164, 282, 4412, 469, 2180, 26, 9328, 63, 6971, 5565, 199, 3, 437, 9328, 7669, 365, 282, 2155, 2345, 1202, 370, 1255, 1804, 30037, 1709, 315, 199, 3, 1902, 3560, 818, 334, 10546, 63, 6971, 508, 413, 9, 503, 511, 818, 334, 10546, 63, 6971, 508, 378, 680, 199, 63, 25302, 63, 906, 689, 6024, 63, 9791, 21983, 275, 1052, 199, 199, 3, 961, 2600, 15164, 282, 4412, 469, 2180, 26, 20746, 63, 12511, 5565, 199, 3, 1924, 20746, 63, 12511, 365, 282, 2600, 4412, 536, 13158, 370, 282, 1453, 1478, 12, 199, 3, 1202, 367, 1519, 65, 764, 3343, 13, 6100, 1059, 738, 12818, 199, 3, 367, 7750, 1561, 334, 69, 14, 71, 14, 4045, 1561, 680, 199, 63, 25302, 63, 6685, 63, 12511, 51, 275, 1052, 199, 199, 3, 961, 5046, 3305, 883, 506, 663, 370, 715, 370, 10137, 1750, 11097, 199, 3, 1536, 370, 314, 922, 14, 199, 3, 7743, 2399, 574, 4799, 658, 9285, 63, 1975, 63, 27876, 8, 585, 20414, 199, 63, 6588, 13841, 63, 5568, 63, 8727, 275, 756, 199, 199, 3, 710, 730, 402, 2069, 370, 675, 23088, 282, 2351, 14, 199, 63, 11783, 56, 275, 283, 1609, 708, 7, 199, 199, 3, 27255, 8746, 15632, 4348, 6535, 1202, 23088, 314, 1233, 1095, 14, 199, 63, 37, 20725, 275, 1616, 69, 13, 24, 199, 199, 3, 3758, 1834, 666, 1475, 12, 1373, 402, 298, 6324, 63, 2019, 401, 298, 6324, 63, 2246, 1674, 199, 63, 9438, 63, 3998, 63, 4807, 275, 283, 6324, 63, 2019, 7, 421, 199, 318, 4865, 837, 523, 408, 18060, 317, 429, 89, 17909, 1083, 367, 26638, 314, 1453, 4865, 14, 819, 5972, 3495, 367, 3261, 1013, 2159, 66, 3444, 543, 3510, 13, 4620, 1804, 30037, 14, 819, 1803, 26, 489, 710, 1059, 298, 16008, 1674, 523, 408, 523, 372, 283, 16008, 7, 421, 199, 318, 14030, 837, 523, 408, 3407, 314, 574, 402, 314, 15632, 4348, 6535, 1202, 315, 8950, 8455, 14, 819, 1803, 26, 489, 437, 2069, 14, 819, 5679, 26, 523, 10841, 1548, 489, 1306, 11708, 14, 4620, 14, 15761, 342, 489, 413, 69, 13, 2036, 523, 10841, 523, 408, 523, 372, 485, 37, 20725, 421, 199, 318, 663, 63, 15761, 8, 585, 304, 523, 408, 9899, 314, 574, 402, 314, 15632, 4348, 6535, 1202, 315, 8950, 8455, 14, 819, 7628, 26, 489, 574, 26, 2069, 14, 7053, 574, 402, 14030, 14, 819, 5679, 26, 523, 10841, 1548, 489, 1306, 687, 11708, 492, 4865, 465, 1804, 489, 1306, 1804, 14, 15761, 342, 489, 413, 69, 13, 2036, 489, 1306, 1804, 14, 409, 63, 15761, 8, 17, 69, 13, 1717, 9, 489, 1306, 1804, 14, 15761, 342, 489, 413, 69, 13, 1717, 523, 10841, 523, 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 ]
jelly/calibre
src/calibre/gui2/dbus_export/tray.py
1
7237
#!/usr/bin/env python2 # vim:fileencoding=utf-8 from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>' # Implement the StatusNotifierItem spec for creating a system tray icon in # modern linux desktop environments. See # http://www.notmart.org/misc/statusnotifieritem/index.html#introduction # This is not an actual standard, but is apparently used by GNOME, KDE and # Unity, which makes it necessary enough to implement. import os import dbus from PyQt5.Qt import ( QApplication, QObject, pyqtSignal, Qt, QPoint, QRect, QMenu, QSystemTrayIcon) from calibre.gui2.dbus_export.menu import DBusMenu from calibre.gui2.dbus_export.utils import icon_cache from calibre.utils.dbus_service import ( Object, method as dbus_method, BusName, dbus_property, signal as dbus_signal) _sni_count = 0 class StatusNotifierItem(QObject): IFACE = 'org.kde.StatusNotifierItem' activated = pyqtSignal(object) show_menu = pyqtSignal(int, int) def __init__(self, **kw): global _sni_count QObject.__init__(self, parent=kw.get('parent')) self.context_menu = None self.is_visible = True self.tool_tip = '' self._icon = QApplication.instance().windowIcon() self.show_menu.connect(self._show_menu, type=Qt.QueuedConnection) _sni_count += 1 kw['num'] = _sni_count self.dbus_api = StatusNotifierItemAPI(self, **kw) def _show_menu(self, x, y): m = self.contextMenu() if m is not None: m.exec_(QPoint(x, y)) def isVisible(self): return self.is_visible def setVisible(self, visible): if self.is_visible != visible: self.is_visible = visible self.dbus_api.NewStatus(self.dbus_api.Status) def show(self): self.setVisible(True) def hide(self): self.setVisible(False) def toggle(self): self.setVisible(not self.isVisible()) def contextMenu(self): return self.context_menu def setContextMenu(self, menu): self.context_menu = menu self.dbus_api.publish_new_menu() def geometry(self): return QRect() def toolTip(self): return self.tool_tip def setToolTip(self, val): self.tool_tip = val or '' self.dbus_api.NewToolTip() def setIcon(self, icon): self._icon = icon self.dbus_api.NewIcon() def icon(self): return self._icon @classmethod def supportsMessages(cls): return False def emit_activated(self): self.activated.emit(QSystemTrayIcon.Trigger) _status_item_menu_count = 0 class StatusNotifierItemAPI(Object): 'See http://www.notmart.org/misc/statusnotifieritem/statusnotifieritem.html' IFACE = 'org.kde.StatusNotifierItem' def __init__(self, notifier, **kw): global _status_item_menu_count self.notifier = notifier bus = kw.get('bus') if bus is None: bus = kw['bus'] = dbus.SessionBus() self.name = '%s-%s-%s' % (self.IFACE, os.getpid(), kw.get('num', 1)) self.dbus_name = BusName(self.name, bus=bus, do_not_queue=True) self.app_id = kw.get('app_id') or QApplication.instance().applicationName() or 'unknown_application' self.category = kw.get('category') or 'ApplicationStatus' self.title = kw.get('title') or self.app_id Object.__init__(self, bus, '/' + self.IFACE.split('.')[-1]) _status_item_menu_count += 1 self.dbus_menu = DBusMenu('/StatusItemMenu/%d' % _status_item_menu_count, bus=bus, parent=kw.get('parent')) def publish_new_menu(self): menu = self.notifier.contextMenu() if menu is None: menu = QMenu() if len(menu.actions()) == 0: menu.addAction(self.notifier.icon(), _('Show/hide %s') % self.title, self.notifier.emit_activated) # The menu must have at least one entry, namely the show/hide entry. # This is necessary as Canonical in their infinite wisdom decided to # force all tray icons to show their popup menus when clicked. self.dbus_menu.publish_new_menu(menu) @dbus_property(IFACE, signature='s') def IconName(self): return icon_cache().name_for_icon(self.notifier.icon()) @dbus_property(IFACE, signature='s') def IconThemePath(self): return icon_cache().icon_theme_path @dbus_property(IFACE, signature='a(iiay)') def IconPixmap(self): return dbus.Array(signature='(iiay)') @dbus_property(IFACE, signature='s') def OverlayIconName(self): return '' @dbus_property(IFACE, signature='(sa(iiay)ss)') def ToolTip(self): # This is ignored on Unity, Canonical believes in user interfaces # that are so functionality free that they dont need tooltips return self.IconName, self.IconPixmap, self.Title, self.notifier.toolTip() @dbus_property(IFACE, signature='a(iiay)') def OverlayIconPixmap(self): return dbus.Array(signature='(iiay)') @dbus_property(IFACE, signature='s') def AttentionIconName(self): return '' @dbus_property(IFACE, signature='a(iiay)') def AttentionIconPixmap(self): return dbus.Array(signature='(iiay)') @dbus_property(IFACE, signature='s') def Category(self): return self.category @dbus_property(IFACE, signature='s') def Id(self): return self.app_id @dbus_property(IFACE, signature='s') def Title(self): return self.title @dbus_property(IFACE, signature='s') def Status(self): return 'Active' if self.notifier.isVisible() else 'Passive' @dbus_property(IFACE, signature='o') def Menu(self): return dbus.ObjectPath(self.dbus_menu.object_path) @dbus_property(IFACE, signature='i') def WindowId(self): return 0 @dbus_method(IFACE, in_signature='ii', out_signature='') def ContextMenu(self, x, y): self.notifier.show_menu.emit(x, y) @dbus_method(IFACE, in_signature='ii', out_signature='') def Activate(self, x, y): self.notifier.activated.emit(QSystemTrayIcon.Trigger) @dbus_method(IFACE, in_signature='u', out_signature='') def XAyatanaSecondaryActivate(self, timestamp): # This is called when the user middle clicks the icon in Unity self.notifier.activated.emit(QSystemTrayIcon.MiddleClick) @dbus_method(IFACE, in_signature='ii', out_signature='') def SecondaryActivate(self, x, y): self.notifier.activated.emit(QSystemTrayIcon.MiddleClick) @dbus_method(IFACE, in_signature='is', out_signature='') def Scroll(self, delta, orientation): pass @dbus_signal(IFACE, '') def NewTitle(self): pass @dbus_signal(IFACE, '') def NewIcon(self): pass @dbus_signal(IFACE, '') def NewAttentionIcon(self): pass @dbus_signal(IFACE, '') def NewOverlayIcon(self): pass @dbus_signal(IFACE, '') def NewToolTip(self): pass @dbus_signal(IFACE, 's') def NewStatus(self, status): pass
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 1624, 13, 24, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7280, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 737, 20817, 5017, 1939, 31876, 14, 846, 3524, 199, 199, 3, 22467, 314, 9795, 26884, 2081, 3158, 367, 6425, 282, 2656, 307, 803, 7016, 315, 199, 3, 818, 11641, 18369, 19763, 22196, 14, 1666, 199, 3, 1455, 921, 1544, 14, 1397, 77, 580, 14, 1308, 15, 9923, 15, 1205, 18031, 1053, 15, 1080, 14, 1360, 3, 18206, 5199, 199, 3, 961, 365, 440, 376, 3503, 4465, 12, 1325, 365, 27241, 590, 1202, 701, 598, 2826, 3635, 12, 1804, 1093, 436, 199, 3, 1910, 1209, 12, 1314, 7704, 652, 5784, 8321, 370, 5669, 14, 199, 199, 646, 747, 199, 199, 646, 21140, 199, 504, 14084, 21, 14, 4238, 492, 334, 272, 29469, 12, 1413, 1692, 12, 27149, 11274, 12, 3959, 12, 1413, 3428, 12, 1413, 8252, 12, 1413, 5977, 12, 1413, 3989, 52, 803, 8954, 9, 199, 199, 504, 19238, 14, 5885, 18, 14, 17066, 63, 3790, 14, 4470, 492, 6249, 527, 5977, 199, 504, 19238, 14, 5885, 18, 14, 17066, 63, 3790, 14, 1208, 492, 7016, 63, 1637, 199, 504, 19238, 14, 1208, 14, 17066, 63, 1364, 492, 334, 272, 6935, 12, 1083, 465, 21140, 63, 765, 12, 18573, 985, 12, 21140, 63, 1829, 12, 4673, 465, 21140, 63, 4653, 9, 199, 199, 63, 5167, 73, 63, 835, 275, 378, 421, 199, 533, 9795, 26884, 2081, 8, 32260, 304, 339, 8036, 4121, 275, 283, 1308, 14, 29461, 14, 3694, 26884, 2081, 7, 272, 22225, 275, 27149, 11274, 8, 785, 9, 272, 2498, 63, 4470, 275, 27149, 11274, 8, 442, 12, 1109, 9, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 2288, 485, 5167, 73, 63, 835, 267, 1413, 1692, 855, 826, 721, 277, 12, 1676, 29, 829, 14, 362, 360, 1708, 1333, 267, 291, 14, 1100, 63, 4470, 275, 488, 267, 291, 14, 374, 63, 6604, 275, 715, 267, 291, 14, 3557, 63, 8996, 275, 2125, 267, 291, 423, 4677, 275, 29469, 14, 842, 1252, 3806, 8954, 342, 267, 291, 14, 2384, 63, 4470, 14, 2242, 8, 277, 423, 2384, 63, 4470, 12, 730, 29, 4238, 14, 3737, 68, 3225, 9, 267, 485, 5167, 73, 63, 835, 847, 413, 267, 4775, 459, 1507, 418, 275, 485, 5167, 73, 63, 835, 267, 291, 14, 17066, 63, 1246, 275, 9795, 26884, 2081, 3735, 8, 277, 12, 1011, 829, 9, 339, 347, 485, 2384, 63, 4470, 8, 277, 12, 671, 12, 612, 304, 267, 333, 275, 291, 14, 1100, 5977, 342, 267, 340, 333, 365, 440, 488, 26, 288, 333, 14, 1628, 2531, 49, 3428, 8, 88, 12, 612, 430, 339, 347, 365, 14917, 8, 277, 304, 267, 372, 291, 14, 374, 63, 6604, 339, 347, 663, 14917, 8, 277, 12, 8917, 304, 267, 340, 291, 14, 374, 63, 6604, 1137, 8917, 26, 288, 291, 14, 374, 63, 6604, 275, 8917, 288, 291, 14, 17066, 63, 1246, 14, 4665, 3694, 8, 277, 14, 17066, 63, 1246, 14, 3694, 9, 339, 347, 2498, 8, 277, 304, 267, 291, 14, 32232, 8, 549, 9, 339, 347, 13714, 8, 277, 304, 267, 291, 14, 32232, 8, 797, 9, 339, 347, 19420, 8, 277, 304, 267, 291, 14, 32232, 8, 1397, 291, 14, 374, 14917, 1012, 339, 347, 1067, 5977, 8, 277, 304, 267, 372, 291, 14, 1100, 63, 4470, 339, 347, 663, 2998, 5977, 8, 277, 12, 6269, 304, 267, 291, 14, 1100, 63, 4470, 275, 6269, 267, 291, 14, 17066, 63, 1246, 14, 4763, 63, 1222, 63, 4470, 342, 339, 347, 3400, 8, 277, 304, 267, 372, 1413, 8252, 342, 339, 347, 4744, 15915, 8, 277, 304, 267, 372, 291, 14, 3557, 63, 8996, 339, 347, 663, 21784, 8, 277, 12, 1139, 304, 267, 291, 14, 3557, 63, 8996, 275, 1139, 503, 2125, 267, 291, 14, 17066, 63, 1246, 14, 4665, 21784, 342, 339, 347, 663, 8954, 8, 277, 12, 7016, 304, 267, 291, 423, 4677, 275, 7016, 267, 291, 14, 17066, 63, 1246, 14, 4665, 8954, 342, 339, 347, 7016, 8, 277, 304, 267, 372, 291, 423, 4677, 339, 768, 3744, 272, 347, 5171, 14508, 8, 1886, 304, 267, 372, 756, 339, 347, 8689, 63, 18218, 8, 277, 304, 267, 291, 14, 18218, 14, 8159, 8, 49, 3989, 52, 803, 8954, 14, 16276, 9, 199, 199, 63, 1205, 63, 1053, 63, 4470, 63, 835, 275, 378, 421, 199, 533, 9795, 26884, 2081, 3735, 8, 1692, 304, 339, 283, 9295, 1455, 921, 1544, 14, 1397, 77, 580, 14, 1308, 15, 9923, 15, 1205, 18031, 1053, 15, 1205, 18031, 1053, 14, 1360, 7, 339, 8036, 4121, 275, 283, 1308, 14, 29461, 14, 3694, 26884, 2081, 7, 339, 347, 636, 826, 721, 277, 12, 30154, 12, 1011, 829, 304, 267, 2288, 485, 1205, 63, 1053, 63, 4470, 63, 835, 267, 291, 14, 18031, 275, 30154, 267, 10414, 275, 4775, 14, 362, 360, 5610, 358, 267, 340, 10414, 365, 488, 26, 288, 10414, 275, 4775, 459, 5610, 418, 275, 21140, 14, 4434, 12106, 342, 267, 291, 14, 354, 275, 1543, 83, 3295, 83, 3295, 83, 7, 450, 334, 277, 14, 4656, 4121, 12, 747, 14, 17829, 1062, 4775, 14, 362, 360, 1507, 297, 413, 430, 267, 291, 14, 17066, 63, 354, 275, 18573, 985, 8, 277, 14, 354, 12, 10414, 29, 5610, 12, 886, 63, 1397, 63, 1825, 29, 549, 9, 267, 291, 14, 571, 63, 344, 275, 4775, 14, 362, 360, 571, 63, 344, 358, 503, 29469, 14, 842, 1252, 3578, 985, 342, 503, 283, 5187, 63, 3578, 7, 267, 291, 14, 3710, 275, 4775, 14, 362, 360, 3710, 358, 503, 283, 5039, 3694, 7, 267, 291, 14, 1213, 275, 4775, 14, 362, 360, 1213, 358, 503, 291, 14, 571, 63, 344, 267, 6935, 855, 826, 721, 277, 12, 10414, 12, 7324, 435, 291, 14, 4656, 4121, 14, 1294, 29084, 17, 566, 267, 485, 1205, 63, 1053, 63, 4470, 63, 835 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 1624, 13, 24, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7280, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 737, 20817, 5017, 1939, 31876, 14, 846, 3524, 199, 199, 3, 22467, 314, 9795, 26884, 2081, 3158, 367, 6425, 282, 2656, 307, 803, 7016, 315, 199, 3, 818, 11641, 18369, 19763, 22196, 14, 1666, 199, 3, 1455, 921, 1544, 14, 1397, 77, 580, 14, 1308, 15, 9923, 15, 1205, 18031, 1053, 15, 1080, 14, 1360, 3, 18206, 5199, 199, 3, 961, 365, 440, 376, 3503, 4465, 12, 1325, 365, 27241, 590, 1202, 701, 598, 2826, 3635, 12, 1804, 1093, 436, 199, 3, 1910, 1209, 12, 1314, 7704, 652, 5784, 8321, 370, 5669, 14, 199, 199, 646, 747, 199, 199, 646, 21140, 199, 504, 14084, 21, 14, 4238, 492, 334, 272, 29469, 12, 1413, 1692, 12, 27149, 11274, 12, 3959, 12, 1413, 3428, 12, 1413, 8252, 12, 1413, 5977, 12, 1413, 3989, 52, 803, 8954, 9, 199, 199, 504, 19238, 14, 5885, 18, 14, 17066, 63, 3790, 14, 4470, 492, 6249, 527, 5977, 199, 504, 19238, 14, 5885, 18, 14, 17066, 63, 3790, 14, 1208, 492, 7016, 63, 1637, 199, 504, 19238, 14, 1208, 14, 17066, 63, 1364, 492, 334, 272, 6935, 12, 1083, 465, 21140, 63, 765, 12, 18573, 985, 12, 21140, 63, 1829, 12, 4673, 465, 21140, 63, 4653, 9, 199, 199, 63, 5167, 73, 63, 835, 275, 378, 421, 199, 533, 9795, 26884, 2081, 8, 32260, 304, 339, 8036, 4121, 275, 283, 1308, 14, 29461, 14, 3694, 26884, 2081, 7, 272, 22225, 275, 27149, 11274, 8, 785, 9, 272, 2498, 63, 4470, 275, 27149, 11274, 8, 442, 12, 1109, 9, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 2288, 485, 5167, 73, 63, 835, 267, 1413, 1692, 855, 826, 721, 277, 12, 1676, 29, 829, 14, 362, 360, 1708, 1333, 267, 291, 14, 1100, 63, 4470, 275, 488, 267, 291, 14, 374, 63, 6604, 275, 715, 267, 291, 14, 3557, 63, 8996, 275, 2125, 267, 291, 423, 4677, 275, 29469, 14, 842, 1252, 3806, 8954, 342, 267, 291, 14, 2384, 63, 4470, 14, 2242, 8, 277, 423, 2384, 63, 4470, 12, 730, 29, 4238, 14, 3737, 68, 3225, 9, 267, 485, 5167, 73, 63, 835, 847, 413, 267, 4775, 459, 1507, 418, 275, 485, 5167, 73, 63, 835, 267, 291, 14, 17066, 63, 1246, 275, 9795, 26884, 2081, 3735, 8, 277, 12, 1011, 829, 9, 339, 347, 485, 2384, 63, 4470, 8, 277, 12, 671, 12, 612, 304, 267, 333, 275, 291, 14, 1100, 5977, 342, 267, 340, 333, 365, 440, 488, 26, 288, 333, 14, 1628, 2531, 49, 3428, 8, 88, 12, 612, 430, 339, 347, 365, 14917, 8, 277, 304, 267, 372, 291, 14, 374, 63, 6604, 339, 347, 663, 14917, 8, 277, 12, 8917, 304, 267, 340, 291, 14, 374, 63, 6604, 1137, 8917, 26, 288, 291, 14, 374, 63, 6604, 275, 8917, 288, 291, 14, 17066, 63, 1246, 14, 4665, 3694, 8, 277, 14, 17066, 63, 1246, 14, 3694, 9, 339, 347, 2498, 8, 277, 304, 267, 291, 14, 32232, 8, 549, 9, 339, 347, 13714, 8, 277, 304, 267, 291, 14, 32232, 8, 797, 9, 339, 347, 19420, 8, 277, 304, 267, 291, 14, 32232, 8, 1397, 291, 14, 374, 14917, 1012, 339, 347, 1067, 5977, 8, 277, 304, 267, 372, 291, 14, 1100, 63, 4470, 339, 347, 663, 2998, 5977, 8, 277, 12, 6269, 304, 267, 291, 14, 1100, 63, 4470, 275, 6269, 267, 291, 14, 17066, 63, 1246, 14, 4763, 63, 1222, 63, 4470, 342, 339, 347, 3400, 8, 277, 304, 267, 372, 1413, 8252, 342, 339, 347, 4744, 15915, 8, 277, 304, 267, 372, 291, 14, 3557, 63, 8996, 339, 347, 663, 21784, 8, 277, 12, 1139, 304, 267, 291, 14, 3557, 63, 8996, 275, 1139, 503, 2125, 267, 291, 14, 17066, 63, 1246, 14, 4665, 21784, 342, 339, 347, 663, 8954, 8, 277, 12, 7016, 304, 267, 291, 423, 4677, 275, 7016, 267, 291, 14, 17066, 63, 1246, 14, 4665, 8954, 342, 339, 347, 7016, 8, 277, 304, 267, 372, 291, 423, 4677, 339, 768, 3744, 272, 347, 5171, 14508, 8, 1886, 304, 267, 372, 756, 339, 347, 8689, 63, 18218, 8, 277, 304, 267, 291, 14, 18218, 14, 8159, 8, 49, 3989, 52, 803, 8954, 14, 16276, 9, 199, 199, 63, 1205, 63, 1053, 63, 4470, 63, 835, 275, 378, 421, 199, 533, 9795, 26884, 2081, 3735, 8, 1692, 304, 339, 283, 9295, 1455, 921, 1544, 14, 1397, 77, 580, 14, 1308, 15, 9923, 15, 1205, 18031, 1053, 15, 1205, 18031, 1053, 14, 1360, 7, 339, 8036, 4121, 275, 283, 1308, 14, 29461, 14, 3694, 26884, 2081, 7, 339, 347, 636, 826, 721, 277, 12, 30154, 12, 1011, 829, 304, 267, 2288, 485, 1205, 63, 1053, 63, 4470, 63, 835, 267, 291, 14, 18031, 275, 30154, 267, 10414, 275, 4775, 14, 362, 360, 5610, 358, 267, 340, 10414, 365, 488, 26, 288, 10414, 275, 4775, 459, 5610, 418, 275, 21140, 14, 4434, 12106, 342, 267, 291, 14, 354, 275, 1543, 83, 3295, 83, 3295, 83, 7, 450, 334, 277, 14, 4656, 4121, 12, 747, 14, 17829, 1062, 4775, 14, 362, 360, 1507, 297, 413, 430, 267, 291, 14, 17066, 63, 354, 275, 18573, 985, 8, 277, 14, 354, 12, 10414, 29, 5610, 12, 886, 63, 1397, 63, 1825, 29, 549, 9, 267, 291, 14, 571, 63, 344, 275, 4775, 14, 362, 360, 571, 63, 344, 358, 503, 29469, 14, 842, 1252, 3578, 985, 342, 503, 283, 5187, 63, 3578, 7, 267, 291, 14, 3710, 275,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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 ]
southpawtech/TACTIC-DEV
src/pyasm/deprecated/flash/biz.py
6
5658
########################################################### # # Copyright (c) 2005, Southpaw Technology # All Rights Reserved # # PROPRIETARY INFORMATION. This software is proprietary to # Southpaw Technology, and is not to be reproduced, transmitted, # or disclosed in any way without written permission. # # # __all__ = ['FlashSObject', 'FlashFunpack', 'FlashDesignPack', 'FlashShot', 'FlashAsset', 'FlashLayer', 'FlashShotInstance', 'FlashMapping', 'FlashTask', 'NatPause', 'FinalWave', 'FlashEpisodeInstance'] from pyasm.common import Config from pyasm.search import * from pyasm.prod.biz import * from pyasm.biz import Task, Pipeline class FlashMapping(SObjectMapping): '''Defines all the production assets''' def __init__(my): my.mapping = {} my.mapping['prod/sequence'] = "prod/episode" my.mapping['prod/asset'] = "flash/asset" my.mapping['prod/shot'] = "flash/shot" my.mapping['prod/layer'] = "flash/layer" my.mapping['prod/script'] = "flash/script" my.mapping['prod/storyboard'] = "flash/storyboard" my.mapping['prod/shot_instance'] = "flash/shot_instance" my.mapping['prod/sequence_instance'] = "flash/episode_instance" class FlashSObject(SObject): '''All episodic flash animations are organized by episode''' def get_icon_context(my, context=None): return "publish" def get_pipeline(my): return Pipeline.get_by_code(my.get_value('pipeline')) def is_general_asset(my): if my.has_value('asset_type') and \ my.get_value("asset_type") in ["general", 'image']: return True if not my.has_value('asset_library'): return False return False class FlashFunpack(SObject): SEARCH_TYPE = "flash/funpack" class FlashDesignPack(SObject): SEARCH_TYPE = "flash/design_pack" class FlashShot(Shot): SEARCH_TYPE = "flash/shot" def get_foreign_key(my): return "shot_code" def get_code(my): return my.get_value("code") def get_all_instances(my): return FlashInstance.get_all_by_shot(my) def get_icon_context(my, context=None): return "publish" def is_general_asset(my): return False def create(code, episode_code, description): shot = SObjectFactory.create( FlashShot.SEARCH_TYPE ) shot.set_value("code",code) shot.set_value("episode_code", episode_code) shot.set_value("description",description) shot.commit() return shot create = staticmethod(create) class FlashAsset(FlashSObject): SEARCH_TYPE = "flash/asset" def get_code(my): return my.get_value("code") def get_asset_type(my): return my.get_value("asset_type") def get_asset_type_obj(my): search = Search("prod/asset_type") search.add_filter("code", my.get_asset_type() ) return search.get_sobject() def get_asset_library(my): return my.get_value("asset_library") def get_asset_library_obj(my): search = Search("prod/asset_library") search.add_filter("code", my.get_asset_library() ) return search.get_sobject() class FlashShotInstance(FlashSObject): SEARCH_TYPE = "flash/shot_instance" class FlashEpisodeInstance(FlashSObject): SEARCH_TYPE = "flash/episode_instance" class FlashLayer(FlashSObject): SEARCH_TYPE = "flash/layer" def get_foreign_key(my): return "layer_id" def get_frame_range(my): shot = my.get_shot() return shot.get_frame_range() def get_shot(my): return FlashShot.get_by_code( my.get_value("shot_code") ) def get( shot_code, layer_name): search = Search("flash/layer") search.add_filter("shot_code", shot_code) search.add_filter("name", layer_name) return search.get_sobject() get = staticmethod(get) def get_description(my): return "%s %s" %(my.get_value("shot_code"), my.get_value("name")) class FlashTask(Task): SEARCH_TYPE = "flash/task" class NatPause(SObject): SEARCH_TYPE = "flash/nat_pause" def create(cls, episode_code, title=''): '''create with an episode code''' asset = SObjectFactory.create( cls.SEARCH_TYPE ) asset.set_value("episode_code", episode_code) if title: asset.set_value("title", title) asset.commit() return asset create = classmethod(create) def get_by_episode_code(episode_code): search = Search(NatPause.SEARCH_TYPE) search.add_filter("episode_code", episode_code) return search.get_sobject() get_by_episode_code = staticmethod(get_by_episode_code) def get_update_description(my): code = my.get_value('episode_code') title = my.get_search_type_obj().get_title() description = "Updated %s: episode [%s]" % (title, code) return description class FinalWave(SObject): SEARCH_TYPE = "flash/final_wave" def create(cls, episode_code, line, title=''): '''create with an episode code, line''' asset = SObjectFactory.create( cls.SEARCH_TYPE ) asset.set_value("episode_code", episode_code) asset.set_value("line", line) if title: asset.set_value("title", title) asset.commit() return asset create = classmethod(create) def get(episode_code, line): search = Search(FinalWave.SEARCH_TYPE) search.add_filter("episode_code", episode_code) search.add_filter("line", line) return search.get_sobject() get = staticmethod(get)
epl-1.0
[ 26207, 5680, 199, 3, 199, 3, 1898, 334, 67, 9, 11811, 12, 23150, 387, 87, 21580, 199, 3, 9326, 2900, 5924, 5702, 199, 3, 199, 3, 3611, 20076, 775, 4392, 1621, 18623, 14, 221, 961, 2032, 365, 557, 1359, 386, 695, 370, 199, 3, 23150, 387, 87, 21580, 12, 436, 365, 440, 370, 506, 9172, 68, 12, 29818, 12, 199, 3, 503, 4339, 320, 939, 315, 1263, 4340, 1928, 5313, 4983, 14, 199, 3, 199, 3, 199, 3, 199, 199, 363, 452, 363, 275, 788, 29189, 51, 1692, 297, 283, 29189, 38, 5301, 297, 283, 29189, 20924, 2305, 297, 283, 29189, 2662, 357, 297, 283, 29189, 19979, 297, 283, 29189, 5003, 297, 283, 29189, 2662, 357, 3244, 297, 283, 29189, 7674, 297, 283, 29189, 4476, 297, 283, 23604, 30851, 297, 283, 12776, 21393, 297, 283, 29189, 22887, 3244, 418, 199, 199, 504, 1134, 11374, 14, 2330, 492, 4094, 199, 504, 1134, 11374, 14, 1733, 492, 627, 199, 504, 1134, 11374, 14, 8788, 14, 66, 565, 492, 627, 199, 504, 1134, 11374, 14, 66, 565, 492, 8495, 12, 19090, 4388, 199, 533, 11040, 1119, 7674, 8, 51, 1692, 7674, 304, 272, 1449, 23891, 1006, 314, 9920, 17202, 2344, 339, 347, 636, 826, 721, 1662, 304, 267, 3002, 14, 4745, 275, 1052, 267, 3002, 14, 4745, 459, 8788, 15, 4041, 418, 275, 298, 8788, 15, 9544, 2, 267, 3002, 14, 4745, 459, 8788, 15, 6562, 418, 275, 298, 11331, 15, 6562, 2, 267, 3002, 14, 4745, 459, 8788, 15, 2782, 418, 275, 298, 11331, 15, 2782, 2, 267, 3002, 14, 4745, 459, 8788, 15, 1897, 418, 275, 298, 11331, 15, 1897, 2, 267, 3002, 14, 4745, 459, 8788, 15, 1579, 418, 275, 298, 11331, 15, 1579, 2, 267, 3002, 14, 4745, 459, 8788, 15, 17372, 3576, 418, 275, 298, 11331, 15, 17372, 3576, 2, 267, 3002, 14, 4745, 459, 8788, 15, 2782, 63, 842, 418, 275, 298, 11331, 15, 2782, 63, 842, 2, 267, 3002, 14, 4745, 459, 8788, 15, 4041, 63, 842, 418, 275, 298, 11331, 15, 9544, 63, 842, 2, 4388, 199, 533, 11040, 1119, 51, 1692, 8, 51, 1692, 304, 272, 1449, 2422, 5442, 4595, 5000, 14775, 376, 11744, 852, 787, 20765, 1759, 701, 11052, 2344, 339, 347, 664, 63, 4677, 63, 1100, 8, 1662, 12, 1067, 29, 403, 304, 267, 372, 298, 4763, 2, 339, 347, 664, 63, 7379, 8, 1662, 304, 267, 372, 19090, 14, 362, 63, 991, 63, 600, 8, 1662, 14, 362, 63, 585, 360, 7379, 1333, 2378, 347, 365, 63, 10706, 63, 6562, 8, 1662, 304, 398, 340, 3002, 14, 1989, 63, 585, 360, 6562, 63, 466, 358, 436, 221, 971, 288, 3002, 14, 362, 63, 585, 480, 6562, 63, 466, 531, 315, 2097, 10706, 401, 283, 1569, 2565, 355, 372, 715, 398, 340, 440, 3002, 14, 1989, 63, 585, 360, 6562, 63, 4342, 735, 288, 372, 756, 489, 267, 372, 756, 421, 199, 533, 11040, 1119, 38, 5301, 8, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 70, 5301, 2, 199, 199, 533, 11040, 1119, 20924, 2305, 8, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 14748, 63, 1389, 2, 4388, 199, 533, 11040, 1119, 2662, 357, 8, 2662, 357, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 2782, 2, 339, 347, 664, 63, 6846, 63, 498, 8, 1662, 304, 267, 372, 298, 2782, 63, 600, 2, 339, 347, 664, 63, 600, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 600, 531, 339, 347, 664, 63, 452, 63, 5990, 8, 1662, 304, 267, 372, 11040, 1119, 3244, 14, 362, 63, 452, 63, 991, 63, 2782, 8, 1662, 9, 339, 347, 664, 63, 4677, 63, 1100, 8, 1662, 12, 1067, 29, 403, 304, 267, 372, 298, 4763, 2, 339, 347, 365, 63, 10706, 63, 6562, 8, 1662, 304, 267, 372, 756, 339, 347, 1218, 8, 600, 12, 11052, 63, 600, 12, 1369, 304, 267, 1033, 357, 275, 428, 8634, 14, 981, 8, 11040, 1119, 2662, 357, 14, 15962, 63, 2711, 776, 267, 1033, 357, 14, 409, 63, 585, 480, 600, 401, 600, 9, 267, 1033, 357, 14, 409, 63, 585, 480, 9544, 63, 600, 401, 11052, 63, 600, 9, 267, 1033, 357, 14, 409, 63, 585, 480, 1802, 401, 1802, 9, 267, 1033, 357, 14, 3543, 342, 267, 372, 1033, 357, 272, 1218, 275, 12822, 8, 981, 9, 421, 199, 533, 11040, 1119, 19979, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 6562, 2, 2286, 347, 664, 63, 600, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 600, 531, 339, 347, 664, 63, 6562, 63, 466, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 6562, 63, 466, 531, 339, 347, 664, 63, 6562, 63, 466, 63, 1113, 8, 1662, 304, 267, 2754, 275, 8730, 480, 8788, 15, 6562, 63, 466, 531, 267, 2754, 14, 525, 63, 1541, 480, 600, 401, 3002, 14, 362, 63, 6562, 63, 466, 342, 776, 267, 372, 2754, 14, 362, 63, 83, 785, 342, 339, 347, 664, 63, 6562, 63, 4342, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 6562, 63, 4342, 531, 339, 347, 664, 63, 6562, 63, 4342, 63, 1113, 8, 1662, 304, 267, 2754, 275, 8730, 480, 8788, 15, 6562, 63, 4342, 531, 267, 2754, 14, 525, 63, 1541, 480, 600, 401, 3002, 14, 362, 63, 6562, 63, 4342, 342, 776, 267, 372, 2754, 14, 362, 63, 83, 785, 342, 199, 199, 533, 11040, 1119, 2662, 357, 3244, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 2782, 63, 842, 2, 421, 199, 533, 11040, 1119, 22887, 3244, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 9544, 63, 842, 2, 421, 199, 533, 11040, 1119, 5003, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 1897, 2, 339, 347, 664, 63, 6846, 63, 498, 8, 1662, 304, 267, 372, 298, 1897, 63, 344, 2, 339, 347, 664, 63, 1943, 63, 1842, 8, 1662, 304, 267, 1033, 357, 275, 3002, 14, 362, 63, 2782, 342, 267, 372, 1033 ]
[ 5680, 199, 3, 199, 3, 1898, 334, 67, 9, 11811, 12, 23150, 387, 87, 21580, 199, 3, 9326, 2900, 5924, 5702, 199, 3, 199, 3, 3611, 20076, 775, 4392, 1621, 18623, 14, 221, 961, 2032, 365, 557, 1359, 386, 695, 370, 199, 3, 23150, 387, 87, 21580, 12, 436, 365, 440, 370, 506, 9172, 68, 12, 29818, 12, 199, 3, 503, 4339, 320, 939, 315, 1263, 4340, 1928, 5313, 4983, 14, 199, 3, 199, 3, 199, 3, 199, 199, 363, 452, 363, 275, 788, 29189, 51, 1692, 297, 283, 29189, 38, 5301, 297, 283, 29189, 20924, 2305, 297, 283, 29189, 2662, 357, 297, 283, 29189, 19979, 297, 283, 29189, 5003, 297, 283, 29189, 2662, 357, 3244, 297, 283, 29189, 7674, 297, 283, 29189, 4476, 297, 283, 23604, 30851, 297, 283, 12776, 21393, 297, 283, 29189, 22887, 3244, 418, 199, 199, 504, 1134, 11374, 14, 2330, 492, 4094, 199, 504, 1134, 11374, 14, 1733, 492, 627, 199, 504, 1134, 11374, 14, 8788, 14, 66, 565, 492, 627, 199, 504, 1134, 11374, 14, 66, 565, 492, 8495, 12, 19090, 4388, 199, 533, 11040, 1119, 7674, 8, 51, 1692, 7674, 304, 272, 1449, 23891, 1006, 314, 9920, 17202, 2344, 339, 347, 636, 826, 721, 1662, 304, 267, 3002, 14, 4745, 275, 1052, 267, 3002, 14, 4745, 459, 8788, 15, 4041, 418, 275, 298, 8788, 15, 9544, 2, 267, 3002, 14, 4745, 459, 8788, 15, 6562, 418, 275, 298, 11331, 15, 6562, 2, 267, 3002, 14, 4745, 459, 8788, 15, 2782, 418, 275, 298, 11331, 15, 2782, 2, 267, 3002, 14, 4745, 459, 8788, 15, 1897, 418, 275, 298, 11331, 15, 1897, 2, 267, 3002, 14, 4745, 459, 8788, 15, 1579, 418, 275, 298, 11331, 15, 1579, 2, 267, 3002, 14, 4745, 459, 8788, 15, 17372, 3576, 418, 275, 298, 11331, 15, 17372, 3576, 2, 267, 3002, 14, 4745, 459, 8788, 15, 2782, 63, 842, 418, 275, 298, 11331, 15, 2782, 63, 842, 2, 267, 3002, 14, 4745, 459, 8788, 15, 4041, 63, 842, 418, 275, 298, 11331, 15, 9544, 63, 842, 2, 4388, 199, 533, 11040, 1119, 51, 1692, 8, 51, 1692, 304, 272, 1449, 2422, 5442, 4595, 5000, 14775, 376, 11744, 852, 787, 20765, 1759, 701, 11052, 2344, 339, 347, 664, 63, 4677, 63, 1100, 8, 1662, 12, 1067, 29, 403, 304, 267, 372, 298, 4763, 2, 339, 347, 664, 63, 7379, 8, 1662, 304, 267, 372, 19090, 14, 362, 63, 991, 63, 600, 8, 1662, 14, 362, 63, 585, 360, 7379, 1333, 2378, 347, 365, 63, 10706, 63, 6562, 8, 1662, 304, 398, 340, 3002, 14, 1989, 63, 585, 360, 6562, 63, 466, 358, 436, 221, 971, 288, 3002, 14, 362, 63, 585, 480, 6562, 63, 466, 531, 315, 2097, 10706, 401, 283, 1569, 2565, 355, 372, 715, 398, 340, 440, 3002, 14, 1989, 63, 585, 360, 6562, 63, 4342, 735, 288, 372, 756, 489, 267, 372, 756, 421, 199, 533, 11040, 1119, 38, 5301, 8, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 70, 5301, 2, 199, 199, 533, 11040, 1119, 20924, 2305, 8, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 14748, 63, 1389, 2, 4388, 199, 533, 11040, 1119, 2662, 357, 8, 2662, 357, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 2782, 2, 339, 347, 664, 63, 6846, 63, 498, 8, 1662, 304, 267, 372, 298, 2782, 63, 600, 2, 339, 347, 664, 63, 600, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 600, 531, 339, 347, 664, 63, 452, 63, 5990, 8, 1662, 304, 267, 372, 11040, 1119, 3244, 14, 362, 63, 452, 63, 991, 63, 2782, 8, 1662, 9, 339, 347, 664, 63, 4677, 63, 1100, 8, 1662, 12, 1067, 29, 403, 304, 267, 372, 298, 4763, 2, 339, 347, 365, 63, 10706, 63, 6562, 8, 1662, 304, 267, 372, 756, 339, 347, 1218, 8, 600, 12, 11052, 63, 600, 12, 1369, 304, 267, 1033, 357, 275, 428, 8634, 14, 981, 8, 11040, 1119, 2662, 357, 14, 15962, 63, 2711, 776, 267, 1033, 357, 14, 409, 63, 585, 480, 600, 401, 600, 9, 267, 1033, 357, 14, 409, 63, 585, 480, 9544, 63, 600, 401, 11052, 63, 600, 9, 267, 1033, 357, 14, 409, 63, 585, 480, 1802, 401, 1802, 9, 267, 1033, 357, 14, 3543, 342, 267, 372, 1033, 357, 272, 1218, 275, 12822, 8, 981, 9, 421, 199, 533, 11040, 1119, 19979, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 6562, 2, 2286, 347, 664, 63, 600, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 600, 531, 339, 347, 664, 63, 6562, 63, 466, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 6562, 63, 466, 531, 339, 347, 664, 63, 6562, 63, 466, 63, 1113, 8, 1662, 304, 267, 2754, 275, 8730, 480, 8788, 15, 6562, 63, 466, 531, 267, 2754, 14, 525, 63, 1541, 480, 600, 401, 3002, 14, 362, 63, 6562, 63, 466, 342, 776, 267, 372, 2754, 14, 362, 63, 83, 785, 342, 339, 347, 664, 63, 6562, 63, 4342, 8, 1662, 304, 267, 372, 3002, 14, 362, 63, 585, 480, 6562, 63, 4342, 531, 339, 347, 664, 63, 6562, 63, 4342, 63, 1113, 8, 1662, 304, 267, 2754, 275, 8730, 480, 8788, 15, 6562, 63, 4342, 531, 267, 2754, 14, 525, 63, 1541, 480, 600, 401, 3002, 14, 362, 63, 6562, 63, 4342, 342, 776, 267, 372, 2754, 14, 362, 63, 83, 785, 342, 199, 199, 533, 11040, 1119, 2662, 357, 3244, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 2782, 63, 842, 2, 421, 199, 533, 11040, 1119, 22887, 3244, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 9544, 63, 842, 2, 421, 199, 533, 11040, 1119, 5003, 8, 29189, 51, 1692, 304, 272, 5795, 7762, 63, 2711, 275, 298, 11331, 15, 1897, 2, 339, 347, 664, 63, 6846, 63, 498, 8, 1662, 304, 267, 372, 298, 1897, 63, 344, 2, 339, 347, 664, 63, 1943, 63, 1842, 8, 1662, 304, 267, 1033, 357, 275, 3002, 14, 362, 63, 2782, 342, 267, 372, 1033, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
DinoCow/airflow
airflow/providers/hashicorp/hooks/vault.py
6
15586
# 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. """Hook for HashiCorp Vault""" import json from typing import Optional, Tuple import hvac from hvac.exceptions import VaultError from requests import Response from airflow.hooks.base import BaseHook from airflow.providers.hashicorp._internal_client.vault_client import ( # noqa DEFAULT_KUBERNETES_JWT_PATH, DEFAULT_KV_ENGINE_VERSION, _VaultClient, ) class VaultHook(BaseHook): """ Hook to Interact with HashiCorp Vault KeyValue Secret engine. HashiCorp hvac documentation: * https://hvac.readthedocs.io/en/stable/ You connect to the host specified as host in the connection. The login/password from the connection are used as credentials usually and you can specify different authentication parameters via init params or via corresponding extras in the connection. The mount point should be placed as a path in the URL - similarly to Vault's URL schema: This indicates the "path" the secret engine is mounted on. Default id not specified is "secret". Note that this ``mount_point`` is not used for authentication if authentication is done via a different engines. Each engine uses it's own engine-specific authentication mount_point. The extras in the connection are named the same as the parameters ('kv_engine_version', 'auth_type', ...). You can also use gcp_keyfile_dict extra to pass json-formatted dict in case of 'gcp' authentication. The URL schemas supported are "vault", "http" (using http to connect to the vault) or "vaults" and "https" (using https to connect to the vault). Example URL: .. code-block:: vault://user:password@host:port/mount_point?kv_engine_version=1&auth_type=github Login/Password are used as credentials: * approle: password -> secret_id * github: password -> token * token: password -> token * aws_iam: login -> key_id, password -> secret_id * azure: login -> client_id, password -> client_secret * ldap: login -> username, password -> password * userpass: login -> username, password -> password * radius: password -> radius_secret :param vault_conn_id: The id of the connection to use :type vault_conn_id: str :param auth_type: Authentication Type for the Vault. Default is ``token``. Available values are: ('approle', 'github', 'gcp', 'kubernetes', 'ldap', 'token', 'userpass') :type auth_type: str :param auth_mount_point: It can be used to define mount_point for authentication chosen Default depends on the authentication method used. :type auth_mount_point: str :param kv_engine_version: Select the version of the engine to run (``1`` or ``2``). Defaults to version defined in connection or ``2`` if not defined in connection. :type kv_engine_version: int :param role_id: Role ID for Authentication (for ``approle``, ``aws_iam`` auth_types) :type role_id: str :param kubernetes_role: Role for Authentication (for ``kubernetes`` auth_type) :type kubernetes_role: str :param kubernetes_jwt_path: Path for kubernetes jwt token (for ``kubernetes`` auth_type, default: ``/var/run/secrets/kubernetes.io/serviceaccount/token``) :type kubernetes_jwt_path: str :param token_path: path to file containing authentication token to include in requests sent to Vault (for ``token`` and ``github`` auth_type). :type token_path: str :param gcp_key_path: Path to Google Cloud Service Account key file (JSON) (for ``gcp`` auth_type) Mutually exclusive with gcp_keyfile_dict :type gcp_key_path: str :param gcp_scopes: Comma-separated string containing OAuth2 scopes (for ``gcp`` auth_type) :type gcp_scopes: str :param azure_tenant_id: The tenant id for the Azure Active Directory (for ``azure`` auth_type) :type azure_tenant_id: str :param azure_resource: The configured URL for the application registered in Azure Active Directory (for ``azure`` auth_type) :type azure_resource: str :param radius_host: Host for radius (for ``radius`` auth_type) :type radius_host: str :param radius_port: Port for radius (for ``radius`` auth_type) :type radius_port: int """ conn_name_attr = 'vault_conn_id' default_conn_name = 'imap_default' conn_type = 'vault' hook_name = 'Hashicorp Vault' def __init__( # pylint: disable=too-many-arguments self, vault_conn_id: str = default_conn_name, auth_type: Optional[str] = None, auth_mount_point: Optional[str] = None, kv_engine_version: Optional[int] = None, role_id: Optional[str] = None, kubernetes_role: Optional[str] = None, kubernetes_jwt_path: Optional[str] = None, token_path: Optional[str] = None, gcp_key_path: Optional[str] = None, gcp_scopes: Optional[str] = None, azure_tenant_id: Optional[str] = None, azure_resource: Optional[str] = None, radius_host: Optional[str] = None, radius_port: Optional[int] = None, ): super().__init__() self.connection = self.get_connection(vault_conn_id) if not auth_type: auth_type = self.connection.extra_dejson.get('auth_type') or "token" if not auth_mount_point: auth_mount_point = self.connection.extra_dejson.get('auth_mount_point') if not kv_engine_version: conn_version = self.connection.extra_dejson.get("kv_engine_version") try: kv_engine_version = int(conn_version) if conn_version else DEFAULT_KV_ENGINE_VERSION except ValueError: raise VaultError(f"The version is not an int: {conn_version}. ") if auth_type in ["approle", "aws_iam"]: if not role_id: role_id = self.connection.extra_dejson.get('role_id') azure_resource, azure_tenant_id = ( self._get_azure_parameters_from_connection(azure_resource, azure_tenant_id) if auth_type == 'azure' else (None, None) ) gcp_key_path, gcp_keyfile_dict, gcp_scopes = ( self._get_gcp_parameters_from_connection(gcp_key_path, gcp_scopes) if auth_type == 'gcp' else (None, None, None) ) kubernetes_jwt_path, kubernetes_role = ( self._get_kubernetes_parameters_from_connection(kubernetes_jwt_path, kubernetes_role) if auth_type == 'kubernetes' else (None, None) ) radius_host, radius_port = ( self._get_radius_parameters_from_connection(radius_host, radius_port) if auth_type == 'radius' else (None, None) ) if self.connection.conn_type == 'vault': conn_protocol = 'http' elif self.connection.conn_type == 'vaults': conn_protocol = 'https' elif self.connection.conn_type == 'http': conn_protocol = 'http' elif self.connection.conn_type == 'https': conn_protocol = 'https' else: raise VaultError("The url schema must be one of ['http', 'https', 'vault', 'vaults' ]") url = f"{conn_protocol}://{self.connection.host}" if self.connection.port: url += f":{self.connection.port}" # Schema is really path in the Connection definition. This is pretty confusing because of URL schema mount_point = self.connection.schema if self.connection.schema else 'secret' self.vault_client = _VaultClient( url=url, auth_type=auth_type, auth_mount_point=auth_mount_point, mount_point=mount_point, kv_engine_version=kv_engine_version, token=self.connection.password, token_path=token_path, username=self.connection.login, password=self.connection.password, key_id=self.connection.login, secret_id=self.connection.password, role_id=role_id, kubernetes_role=kubernetes_role, kubernetes_jwt_path=kubernetes_jwt_path, gcp_key_path=gcp_key_path, gcp_keyfile_dict=gcp_keyfile_dict, gcp_scopes=gcp_scopes, azure_tenant_id=azure_tenant_id, azure_resource=azure_resource, radius_host=radius_host, radius_secret=self.connection.password, radius_port=radius_port, ) def _get_kubernetes_parameters_from_connection( self, kubernetes_jwt_path: Optional[str], kubernetes_role: Optional[str] ) -> Tuple[str, Optional[str]]: if not kubernetes_jwt_path: kubernetes_jwt_path = self.connection.extra_dejson.get("kubernetes_jwt_path") if not kubernetes_jwt_path: kubernetes_jwt_path = DEFAULT_KUBERNETES_JWT_PATH if not kubernetes_role: kubernetes_role = self.connection.extra_dejson.get("kubernetes_role") return kubernetes_jwt_path, kubernetes_role def _get_gcp_parameters_from_connection( self, gcp_key_path: Optional[str], gcp_scopes: Optional[str], ) -> Tuple[Optional[str], Optional[dict], Optional[str]]: if not gcp_scopes: gcp_scopes = self.connection.extra_dejson.get("gcp_scopes") if not gcp_key_path: gcp_key_path = self.connection.extra_dejson.get("gcp_key_path") string_keyfile_dict = self.connection.extra_dejson.get("gcp_keyfile_dict") gcp_keyfile_dict = json.loads(string_keyfile_dict) if string_keyfile_dict else None return gcp_key_path, gcp_keyfile_dict, gcp_scopes def _get_azure_parameters_from_connection( self, azure_resource: Optional[str], azure_tenant_id: Optional[str] ) -> Tuple[Optional[str], Optional[str]]: if not azure_tenant_id: azure_tenant_id = self.connection.extra_dejson.get("azure_tenant_id") if not azure_resource: azure_resource = self.connection.extra_dejson.get("azure_resource") return azure_resource, azure_tenant_id def _get_radius_parameters_from_connection( self, radius_host: Optional[str], radius_port: Optional[int] ) -> Tuple[Optional[str], Optional[int]]: if not radius_port: radius_port_str = self.connection.extra_dejson.get("radius_port") if radius_port_str: try: radius_port = int(radius_port_str) except ValueError: raise VaultError(f"Radius port was wrong: {radius_port_str}") if not radius_host: radius_host = self.connection.extra_dejson.get("radius_host") return radius_host, radius_port def get_conn(self) -> hvac.Client: """ Retrieves connection to Vault. :rtype: hvac.Client :return: connection used. """ return self.vault_client.client def get_secret(self, secret_path: str, secret_version: Optional[int] = None) -> Optional[dict]: """ Get secret value from the engine. :param secret_path: Path of the secret :type secret_path: str :param secret_version: Optional version of key to read - can only be used in case of version 2 of KV :type secret_version: int See https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v1.html and https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v2.html for details. :param secret_path: Path of the secret :type secret_path: str :rtype: dict :return: secret stored in the vault as a dictionary """ return self.vault_client.get_secret(secret_path=secret_path, secret_version=secret_version) def get_secret_metadata(self, secret_path: str) -> Optional[dict]: """ Reads secret metadata (including versions) from the engine. It is only valid for KV version 2. :param secret_path: Path to read from :type secret_path: str :rtype: dict :return: secret metadata. This is a Dict containing metadata for the secret. See https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v2.html for details. """ return self.vault_client.get_secret_metadata(secret_path=secret_path) def get_secret_including_metadata( self, secret_path: str, secret_version: Optional[int] = None ) -> Optional[dict]: """ Reads secret including metadata. It is only valid for KV version 2. See https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v2.html for details. :param secret_path: Path of the secret :type secret_path: str :param secret_version: Optional version of key to read - can only be used in case of version 2 of KV :type secret_version: int :rtype: dict :return: key info. This is a Dict with "data" mapping keeping secret and "metadata" mapping keeping metadata of the secret. """ return self.vault_client.get_secret_including_metadata( secret_path=secret_path, secret_version=secret_version ) def create_or_update_secret( self, secret_path: str, secret: dict, method: Optional[str] = None, cas: Optional[int] = None ) -> Response: """ Creates or updates secret. :param secret_path: Path to read from :type secret_path: str :param secret: Secret to create or update for the path specified :type secret: dict :param method: Optional parameter to explicitly request a POST (create) or PUT (update) request to the selected kv secret engine. If no argument is provided for this parameter, hvac attempts to intelligently determine which method is appropriate. Only valid for KV engine version 1 :type method: str :param cas: Set the "cas" value to use a Check-And-Set operation. If not set the write will be allowed. If set to 0 a write will only be allowed if the key doesn't exist. If the index is non-zero the write will only be allowed if the key's current version matches the version specified in the cas parameter. Only valid for KV engine version 2. :type cas: int :rtype: requests.Response :return: The response of the create_or_update_secret request. See https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v1.html and https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v2.html for details. """ return self.vault_client.create_or_update_secret( secret_path=secret_path, secret=secret, method=method, cas=cas )
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 8481, 367, 16101, 73, 8380, 80, 812, 558, 624, 199, 646, 2022, 199, 504, 14090, 492, 4879, 12, 11634, 199, 199, 646, 394, 15367, 199, 504, 394, 15367, 14, 3924, 492, 812, 558, 547, 199, 504, 4145, 492, 7232, 199, 199, 504, 16321, 14, 7922, 14, 1095, 492, 3523, 8481, 199, 504, 16321, 14, 9710, 14, 2227, 530, 269, 80, 423, 4672, 63, 1258, 14, 10077, 63, 1258, 492, 334, 221, 327, 8151, 272, 6186, 63, 43, 2533, 540, 7278, 654, 63, 42, 21283, 63, 3243, 12, 272, 6186, 63, 43, 54, 63, 15956, 63, 4612, 12, 272, 485, 20229, 3041, 12, 199, 9, 421, 199, 533, 812, 558, 8481, 8, 1563, 8481, 304, 272, 408, 272, 24837, 370, 8883, 1957, 543, 16101, 73, 8380, 80, 812, 558, 2606, 1110, 23580, 6869, 14, 339, 16101, 73, 8380, 80, 394, 15367, 3794, 26, 2126, 627, 4178, 921, 72, 15367, 14, 25085, 14, 2308, 15, 287, 15, 11989, 15, 339, 2047, 4907, 370, 314, 1591, 2013, 465, 1591, 315, 314, 1950, 14, 710, 4676, 15, 2060, 687, 314, 1950, 272, 787, 1202, 465, 6235, 9987, 436, 1265, 883, 4165, 3365, 6299, 2633, 272, 4799, 4205, 1862, 503, 4799, 5226, 13751, 315, 314, 1950, 14, 339, 710, 10760, 2376, 1077, 506, 15090, 465, 282, 931, 315, 314, 2851, 446, 8545, 590, 370, 812, 558, 1159, 2851, 4177, 26, 272, 961, 9126, 314, 298, 515, 2, 314, 7565, 6869, 365, 27979, 641, 14, 3758, 1305, 440, 2013, 365, 298, 4731, 1674, 272, 3390, 626, 642, 1124, 3956, 63, 1403, 1040, 365, 440, 1202, 367, 6299, 340, 6299, 365, 4224, 4799, 282, 272, 3365, 28156, 14, 7048, 6869, 4440, 652, 1159, 5705, 6869, 13, 6100, 6299, 10760, 63, 1403, 14, 339, 710, 13751, 315, 314, 1950, 787, 4310, 314, 2011, 465, 314, 2633, 661, 11475, 63, 3908, 63, 1023, 297, 283, 1178, 63, 466, 297, 2263, 680, 339, 2047, 883, 2597, 675, 22088, 63, 21856, 63, 807, 2402, 370, 986, 2022, 13, 15317, 1211, 315, 1930, 402, 283, 20622, 7, 6299, 14, 339, 710, 2851, 32536, 3748, 787, 298, 10077, 401, 298, 1014, 2, 334, 4941, 1455, 370, 4907, 370, 314, 12738, 9, 503, 272, 298, 10077, 83, 2, 436, 298, 2859, 2, 334, 4941, 4178, 370, 4907, 370, 314, 12738, 680, 339, 5679, 2851, 26, 339, 2508, 1233, 13, 1457, 447, 398, 12738, 921, 751, 26, 2060, 32, 1102, 26, 719, 15, 3956, 63, 1403, 31, 11475, 63, 3908, 63, 1023, 29, 17, 6, 1178, 63, 466, 29, 5031, 2378, 16430, 15, 6139, 787, 1202, 465, 6235, 26, 398, 627, 4286, 274, 26, 2505, 1035, 7565, 63, 344, 267, 627, 12869, 26, 2505, 1035, 1526, 267, 627, 1526, 26, 2505, 1035, 1526, 267, 627, 11488, 63, 17741, 26, 4676, 1035, 790, 63, 344, 12, 2505, 1035, 7565, 63, 344, 267, 627, 13601, 26, 4676, 1035, 1890, 63, 344, 12, 2505, 1035, 1890, 63, 4731, 267, 627, 13727, 26, 4676, 1035, 3434, 12, 257, 2505, 1035, 2505, 267, 627, 922, 1529, 26, 4676, 1035, 3434, 12, 2505, 1035, 2505, 267, 627, 9362, 26, 2505, 1035, 9362, 63, 4731, 339, 520, 635, 12738, 63, 1631, 63, 344, 26, 710, 1305, 402, 314, 1950, 370, 675, 272, 520, 466, 12738, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 1790, 63, 466, 26, 15995, 2434, 367, 314, 812, 558, 14, 3758, 365, 1124, 1418, 4345, 23840, 1338, 787, 26, 267, 661, 11227, 274, 297, 283, 5031, 297, 283, 20622, 297, 283, 17422, 297, 283, 9642, 297, 283, 1418, 297, 283, 751, 1529, 358, 272, 520, 466, 1790, 63, 466, 26, 620, 272, 520, 635, 1790, 63, 3956, 63, 1403, 26, 2779, 883, 506, 1202, 370, 5627, 10760, 63, 1403, 367, 6299, 12414, 881, 3758, 8350, 641, 314, 6299, 1083, 1202, 14, 272, 520, 466, 1790, 63, 3956, 63, 1403, 26, 620, 272, 520, 635, 16616, 63, 3908, 63, 1023, 26, 9496, 314, 1015, 402, 314, 6869, 370, 1255, 15693, 17, 1040, 503, 1124, 18, 20008, 7827, 370, 881, 1015, 3247, 315, 1950, 503, 1124, 18, 1040, 340, 440, 3247, 315, 1950, 14, 272, 520, 466, 16616, 63, 3908, 63, 1023, 26, 1109, 272, 520, 635, 4719, 63, 344, 26, 18033, 2870, 367, 15995, 334, 509, 1124, 11227, 274, 4542, 1124, 7231, 63, 17741, 1040, 1790, 63, 1313, 9, 272, 520, 466, 4719, 63, 344, 26, 620, 272, 520, 635, 31160, 63, 3756, 26, 18033, 367, 15995, 334, 509, 1124, 17422, 1040, 1790, 63, 466, 9, 272, 520, 466, 31160, 63, 3756, 26, 620, 272, 520, 635, 31160, 63, 30033, 63, 515, 26, 6912, 367, 31160, 1335, 9115, 1526, 334, 509, 1124, 17422, 1040, 1790, 63, 466, 12, 849, 26, 267, 1124, 15, 1391, 15, 1065, 15, 16153, 15, 17422, 14, 2308, 15, 1364, 2048, 15, 1418, 16580, 272, 520, 466, 31160, 63, 30033, 63, 515, 26, 620, 272, 520, 635, 1526, 63, 515, 26, 931, 370, 570, 3035, 6299, 1526, 370, 2387, 315, 4145, 4847, 370, 812, 558, 267, 334, 509, 1124, 1418, 1040, 436, 1124, 5031, 1040, 1790, 63, 466, 680, 272, 520, 466, 1526, 63, 515 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 8481, 367, 16101, 73, 8380, 80, 812, 558, 624, 199, 646, 2022, 199, 504, 14090, 492, 4879, 12, 11634, 199, 199, 646, 394, 15367, 199, 504, 394, 15367, 14, 3924, 492, 812, 558, 547, 199, 504, 4145, 492, 7232, 199, 199, 504, 16321, 14, 7922, 14, 1095, 492, 3523, 8481, 199, 504, 16321, 14, 9710, 14, 2227, 530, 269, 80, 423, 4672, 63, 1258, 14, 10077, 63, 1258, 492, 334, 221, 327, 8151, 272, 6186, 63, 43, 2533, 540, 7278, 654, 63, 42, 21283, 63, 3243, 12, 272, 6186, 63, 43, 54, 63, 15956, 63, 4612, 12, 272, 485, 20229, 3041, 12, 199, 9, 421, 199, 533, 812, 558, 8481, 8, 1563, 8481, 304, 272, 408, 272, 24837, 370, 8883, 1957, 543, 16101, 73, 8380, 80, 812, 558, 2606, 1110, 23580, 6869, 14, 339, 16101, 73, 8380, 80, 394, 15367, 3794, 26, 2126, 627, 4178, 921, 72, 15367, 14, 25085, 14, 2308, 15, 287, 15, 11989, 15, 339, 2047, 4907, 370, 314, 1591, 2013, 465, 1591, 315, 314, 1950, 14, 710, 4676, 15, 2060, 687, 314, 1950, 272, 787, 1202, 465, 6235, 9987, 436, 1265, 883, 4165, 3365, 6299, 2633, 272, 4799, 4205, 1862, 503, 4799, 5226, 13751, 315, 314, 1950, 14, 339, 710, 10760, 2376, 1077, 506, 15090, 465, 282, 931, 315, 314, 2851, 446, 8545, 590, 370, 812, 558, 1159, 2851, 4177, 26, 272, 961, 9126, 314, 298, 515, 2, 314, 7565, 6869, 365, 27979, 641, 14, 3758, 1305, 440, 2013, 365, 298, 4731, 1674, 272, 3390, 626, 642, 1124, 3956, 63, 1403, 1040, 365, 440, 1202, 367, 6299, 340, 6299, 365, 4224, 4799, 282, 272, 3365, 28156, 14, 7048, 6869, 4440, 652, 1159, 5705, 6869, 13, 6100, 6299, 10760, 63, 1403, 14, 339, 710, 13751, 315, 314, 1950, 787, 4310, 314, 2011, 465, 314, 2633, 661, 11475, 63, 3908, 63, 1023, 297, 283, 1178, 63, 466, 297, 2263, 680, 339, 2047, 883, 2597, 675, 22088, 63, 21856, 63, 807, 2402, 370, 986, 2022, 13, 15317, 1211, 315, 1930, 402, 283, 20622, 7, 6299, 14, 339, 710, 2851, 32536, 3748, 787, 298, 10077, 401, 298, 1014, 2, 334, 4941, 1455, 370, 4907, 370, 314, 12738, 9, 503, 272, 298, 10077, 83, 2, 436, 298, 2859, 2, 334, 4941, 4178, 370, 4907, 370, 314, 12738, 680, 339, 5679, 2851, 26, 339, 2508, 1233, 13, 1457, 447, 398, 12738, 921, 751, 26, 2060, 32, 1102, 26, 719, 15, 3956, 63, 1403, 31, 11475, 63, 3908, 63, 1023, 29, 17, 6, 1178, 63, 466, 29, 5031, 2378, 16430, 15, 6139, 787, 1202, 465, 6235, 26, 398, 627, 4286, 274, 26, 2505, 1035, 7565, 63, 344, 267, 627, 12869, 26, 2505, 1035, 1526, 267, 627, 1526, 26, 2505, 1035, 1526, 267, 627, 11488, 63, 17741, 26, 4676, 1035, 790, 63, 344, 12, 2505, 1035, 7565, 63, 344, 267, 627, 13601, 26, 4676, 1035, 1890, 63, 344, 12, 2505, 1035, 1890, 63, 4731, 267, 627, 13727, 26, 4676, 1035, 3434, 12, 257, 2505, 1035, 2505, 267, 627, 922, 1529, 26, 4676, 1035, 3434, 12, 2505, 1035, 2505, 267, 627, 9362, 26, 2505, 1035, 9362, 63, 4731, 339, 520, 635, 12738, 63, 1631, 63, 344, 26, 710, 1305, 402, 314, 1950, 370, 675, 272, 520, 466, 12738, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 1790, 63, 466, 26, 15995, 2434, 367, 314, 812, 558, 14, 3758, 365, 1124, 1418, 4345, 23840, 1338, 787, 26, 267, 661, 11227, 274, 297, 283, 5031, 297, 283, 20622, 297, 283, 17422, 297, 283, 9642, 297, 283, 1418, 297, 283, 751, 1529, 358, 272, 520, 466, 1790, 63, 466, 26, 620, 272, 520, 635, 1790, 63, 3956, 63, 1403, 26, 2779, 883, 506, 1202, 370, 5627, 10760, 63, 1403, 367, 6299, 12414, 881, 3758, 8350, 641, 314, 6299, 1083, 1202, 14, 272, 520, 466, 1790, 63, 3956, 63, 1403, 26, 620, 272, 520, 635, 16616, 63, 3908, 63, 1023, 26, 9496, 314, 1015, 402, 314, 6869, 370, 1255, 15693, 17, 1040, 503, 1124, 18, 20008, 7827, 370, 881, 1015, 3247, 315, 1950, 503, 1124, 18, 1040, 340, 440, 3247, 315, 1950, 14, 272, 520, 466, 16616, 63, 3908, 63, 1023, 26, 1109, 272, 520, 635, 4719, 63, 344, 26, 18033, 2870, 367, 15995, 334, 509, 1124, 11227, 274, 4542, 1124, 7231, 63, 17741, 1040, 1790, 63, 1313, 9, 272, 520, 466, 4719, 63, 344, 26, 620, 272, 520, 635, 31160, 63, 3756, 26, 18033, 367, 15995, 334, 509, 1124, 17422, 1040, 1790, 63, 466, 9, 272, 520, 466, 31160, 63, 3756, 26, 620, 272, 520, 635, 31160, 63, 30033, 63, 515, 26, 6912, 367, 31160, 1335, 9115, 1526, 334, 509, 1124, 17422, 1040, 1790, 63, 466, 12, 849, 26, 267, 1124, 15, 1391, 15, 1065, 15, 16153, 15, 17422, 14, 2308, 15, 1364, 2048, 15, 1418, 16580, 272, 520, 466, 31160, 63, 30033, 63, 515, 26, 620, 272, 520, 635, 1526, 63, 515, 26, 931, 370, 570, 3035, 6299, 1526, 370, 2387, 315, 4145, 4847, 370, 812, 558, 267, 334, 509, 1124, 1418, 1040, 436, 1124, 5031, 1040, 1790, 63, 466, 680, 272, 520, 466, 1526, 63, 515, 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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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 ]
skosukhin/spack
var/spack/repos/builtin/packages/pax-utils/package.py
6
1567
############################################################################## # Copyright (c) 2017, Los Alamos National Security, LLC # Produced at the Los Alamos 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 PaxUtils(AutotoolsPackage): """ELF utils that can check files for security relevant properties""" homepage = "https://wiki.gentoo.org/index.php?title=Project:Hardened/PaX_Utilities" url = "https://dev.gentoo.org/~vapier/dist/pax-utils-1.2.2.tar.xz" version('1.2.2', 'a580468318f0ff42edf4a8cd314cc942')
lgpl-2.1
[ 4605, 199, 3, 1898, 334, 67, 9, 9708, 12, 491, 736, 437, 416, 16908, 20548, 13863, 12, 20376, 199, 3, 2165, 16584, 737, 314, 491, 736, 437, 416, 16908, 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, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 510, 1219, 7535, 8, 23570, 3459, 1446, 8599, 304, 272, 408, 2901, 38, 3778, 626, 883, 1104, 1584, 367, 6391, 12082, 4382, 624, 339, 26586, 275, 298, 2859, 921, 6797, 14, 2268, 7354, 14, 1308, 15, 1080, 14, 8624, 31, 1213, 29, 4761, 26, 18248, 848, 379, 15, 4232, 56, 63, 22905, 2, 272, 1166, 420, 275, 298, 2859, 921, 2374, 14, 2268, 7354, 14, 1308, 22500, 86, 1246, 281, 15, 2686, 15, 25355, 13, 1208, 13, 17, 14, 18, 14, 18, 14, 5369, 14, 19196, 2, 339, 1015, 360, 17, 14, 18, 14, 18, 297, 283, 65, 2010, 966, 2333, 20739, 70, 16, 556, 2260, 27680, 20, 65, 24, 2866, 8988, 2055, 25, 2260, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 67, 9, 9708, 12, 491, 736, 437, 416, 16908, 20548, 13863, 12, 20376, 199, 3, 2165, 16584, 737, 314, 491, 736, 437, 416, 16908, 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, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 510, 1219, 7535, 8, 23570, 3459, 1446, 8599, 304, 272, 408, 2901, 38, 3778, 626, 883, 1104, 1584, 367, 6391, 12082, 4382, 624, 339, 26586, 275, 298, 2859, 921, 6797, 14, 2268, 7354, 14, 1308, 15, 1080, 14, 8624, 31, 1213, 29, 4761, 26, 18248, 848, 379, 15, 4232, 56, 63, 22905, 2, 272, 1166, 420, 275, 298, 2859, 921, 2374, 14, 2268, 7354, 14, 1308, 22500, 86, 1246, 281, 15, 2686, 15, 25355, 13, 1208, 13, 17, 14, 18, 14, 18, 14, 5369, 14, 19196, 2, 339, 1015, 360, 17, 14, 18, 14, 18, 297, 283, 65, 2010, 966, 2333, 20739, 70, 16, 556, 2260, 27680, 20, 65, 24, 2866, 8988, 2055, 25, 2260, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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/requests/packages/chardet/escsm.py
2930
7839
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .constants import eStart, eError, eItsMe HZ_cls = ( 1,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,0,0,0,0, # 20 - 27 0,0,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,0,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,4,0,5,2,0, # 78 - 7f 1,1,1,1,1,1,1,1, # 80 - 87 1,1,1,1,1,1,1,1, # 88 - 8f 1,1,1,1,1,1,1,1, # 90 - 97 1,1,1,1,1,1,1,1, # 98 - 9f 1,1,1,1,1,1,1,1, # a0 - a7 1,1,1,1,1,1,1,1, # a8 - af 1,1,1,1,1,1,1,1, # b0 - b7 1,1,1,1,1,1,1,1, # b8 - bf 1,1,1,1,1,1,1,1, # c0 - c7 1,1,1,1,1,1,1,1, # c8 - cf 1,1,1,1,1,1,1,1, # d0 - d7 1,1,1,1,1,1,1,1, # d8 - df 1,1,1,1,1,1,1,1, # e0 - e7 1,1,1,1,1,1,1,1, # e8 - ef 1,1,1,1,1,1,1,1, # f0 - f7 1,1,1,1,1,1,1,1, # f8 - ff ) HZ_st = ( eStart,eError, 3,eStart,eStart,eStart,eError,eError,# 00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError,# 10-17 5,eError, 6,eError, 5, 5, 4,eError,# 18-1f 4,eError, 4, 4, 4,eError, 4,eError,# 20-27 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart,# 28-2f ) HZCharLenTable = (0, 0, 0, 0, 0, 0) HZSMModel = {'classTable': HZ_cls, 'classFactor': 6, 'stateTable': HZ_st, 'charLenTable': HZCharLenTable, 'name': "HZ-GB-2312"} ISO2022CN_cls = ( 2,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,0,0,0,0, # 20 - 27 0,3,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,4,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 2,2,2,2,2,2,2,2, # 80 - 87 2,2,2,2,2,2,2,2, # 88 - 8f 2,2,2,2,2,2,2,2, # 90 - 97 2,2,2,2,2,2,2,2, # 98 - 9f 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,2, # f8 - ff ) ISO2022CN_st = ( eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07 eStart,eError,eError,eError,eError,eError,eError,eError,# 08-0f eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17 eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError,# 18-1f eError,eError,eError,eItsMe,eError,eError,eError,eError,# 20-27 5, 6,eError,eError,eError,eError,eError,eError,# 28-2f eError,eError,eError,eItsMe,eError,eError,eError,eError,# 30-37 eError,eError,eError,eError,eError,eItsMe,eError,eStart,# 38-3f ) ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0) ISO2022CNSMModel = {'classTable': ISO2022CN_cls, 'classFactor': 9, 'stateTable': ISO2022CN_st, 'charLenTable': ISO2022CNCharLenTable, 'name': "ISO-2022-CN"} ISO2022JP_cls = ( 2,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,2,2, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,7,0,0,0, # 20 - 27 3,0,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 6,0,4,0,8,0,0,0, # 40 - 47 0,9,5,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 2,2,2,2,2,2,2,2, # 80 - 87 2,2,2,2,2,2,2,2, # 88 - 8f 2,2,2,2,2,2,2,2, # 90 - 97 2,2,2,2,2,2,2,2, # 98 - 9f 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,2, # f8 - ff ) ISO2022JP_st = ( eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07 eStart,eStart,eError,eError,eError,eError,eError,eError,# 08-0f eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,# 18-1f eError, 5,eError,eError,eError, 4,eError,eError,# 20-27 eError,eError,eError, 6,eItsMe,eError,eItsMe,eError,# 28-2f eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,# 30-37 eError,eError,eError,eItsMe,eError,eError,eError,eError,# 38-3f eError,eError,eError,eError,eItsMe,eError,eStart,eStart,# 40-47 ) ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ISO2022JPSMModel = {'classTable': ISO2022JP_cls, 'classFactor': 10, 'stateTable': ISO2022JP_st, 'charLenTable': ISO2022JPCharLenTable, 'name': "ISO-2022-JP"} ISO2022KR_cls = ( 2,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,3,0,0,0, # 20 - 27 0,4,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,5,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 2,2,2,2,2,2,2,2, # 80 - 87 2,2,2,2,2,2,2,2, # 88 - 8f 2,2,2,2,2,2,2,2, # 90 - 97 2,2,2,2,2,2,2,2, # 98 - 9f 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,2, # f8 - ff ) ISO2022KR_st = ( eStart, 3,eError,eStart,eStart,eStart,eError,eError,# 00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f eItsMe,eItsMe,eError,eError,eError, 4,eError,eError,# 10-17 eError,eError,eError,eError, 5,eError,eError,eError,# 18-1f eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart,# 20-27 ) ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0) ISO2022KRSMModel = {'classTable': ISO2022KR_cls, 'classFactor': 6, 'stateTable': ISO2022KR_st, 'charLenTable': ISO2022KRCharLenTable, 'name': "ISO-2022-KR"} # flake8: noqa
lgpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 5559, 492, 325, 3162, 12, 19424, 12, 325, 12278, 199, 199, 25955, 63, 1886, 275, 334, 199, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 8733, 446, 24937, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 19363, 446, 378, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 1616, 446, 5557, 199, 16, 12, 16, 12, 16, 12, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6155, 446, 413, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 3388, 446, 8087, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 7294, 446, 499, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 4233, 446, 6877, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10448, 446, 650, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6335, 446, 10954, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 9615, 446, 841, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5238, 446, 12699, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 13713, 446, 959, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5212, 446, 13296, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10851, 446, 1227, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10045, 446, 8375, 199, 16, 12, 16, 12, 16, 12, 20, 12, 16, 12, 21, 12, 18, 12, 16, 12, 221, 327, 14679, 446, 1520, 70, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 5939, 446, 10513, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 10523, 446, 1695, 70, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 9137, 446, 15997, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 16096, 446, 1749, 70, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 16, 446, 282, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 24, 446, 15871, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 16, 446, 330, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 24, 446, 18839, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 16, 446, 286, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 24, 446, 3980, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 16, 446, 366, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 24, 446, 4051, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 16, 446, 325, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 24, 446, 9530, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 289, 16, 446, 289, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 289, 24, 446, 16328, 199, 9, 199, 199, 25955, 63, 270, 275, 334, 199, 11724, 12, 6259, 12, 258, 650, 12, 11724, 12 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 5559, 492, 325, 3162, 12, 19424, 12, 325, 12278, 199, 199, 25955, 63, 1886, 275, 334, 199, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 8733, 446, 24937, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 19363, 446, 378, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 1616, 446, 5557, 199, 16, 12, 16, 12, 16, 12, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6155, 446, 413, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 3388, 446, 8087, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 7294, 446, 499, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 4233, 446, 6877, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10448, 446, 650, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6335, 446, 10954, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 9615, 446, 841, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5238, 446, 12699, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 13713, 446, 959, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5212, 446, 13296, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10851, 446, 1227, 70, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10045, 446, 8375, 199, 16, 12, 16, 12, 16, 12, 20, 12, 16, 12, 21, 12, 18, 12, 16, 12, 221, 327, 14679, 446, 1520, 70, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 5939, 446, 10513, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 10523, 446, 1695, 70, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 9137, 446, 15997, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 16096, 446, 1749, 70, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 16, 446, 282, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 24, 446, 15871, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 16, 446, 330, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 24, 446, 18839, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 16, 446, 286, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 24, 446, 3980, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 16, 446, 366, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 24, 446, 4051, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 16, 446, 325, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 24, 446, 9530, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 289, 16, 446, 289, 23, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 289, 24, 446, 16328, 199, 9, 199, 199, 25955, 63, 270, 275, 334, 199, 11724, 12, 6259, 12, 258, 650, 12, 11724, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
kjiang8/Ardustat
Deprecated_Unsupported/Python_Client/galvanostat_with_connect.py
1
1837
import numpy import ardustat_library_simple as ard import time import subprocess import os import glob import sys ##Guess a serial port port = "" if os.name == "posix": #try os x if len(glob.glob("/dev/tty.u*")) > 0: port = glob.glob("/dev/tty.u*")[0] elif len(glob.glob("/dev/ttyUSB*")) > 0: port = glob.glob("/dev/ttyUSB*")[0] else: print "can't see any ardustats. PEACE." sys.exit() print port #start a serial forwarder p = subprocess.Popen(("python tcp_serial_redirect.py "+port+" 57600").split()) print "waiting" time.sleep(5) print "going" #set parameters read_delay = .5 #second ardustat_id = 21 file_name = "galvanostat_test" ardustat_socket = 7777 debug = False pulse_time = 60*60*10 #Below here no touchy #connect to to ardustat and setup resistance table a = ard.ardustat() a.connect(ardustat_socket) a.debug = debug a.load_resistance_table(ardustat_id) a.ocv() a.groundvalue = 4 a.moveground() time.sleep(.2) a.ocv() #create arrays + a function for logging data times = [] potential = [] current = [] time_start = time.time() cycle = 0 file_name = file_name+"_"+str(int(time_start))+".dat" def appender(reading): if reading['valid']: print reading['cell_ADC'],read['current'] tdiff = str(time.time()-time_start) out = tdiff+","+str(reading['cell_ADC'])+","+str(read['current'])+","+str(cycle)+"\n" open(file_name,"a").write(out) else: print "bad read" #Step through values output = 0 a.ocv() for i in range(0,20): time.sleep(.1) read = a.parsedread() appender(read) start_pulse = time.time() a.galvanostat(-0.001) while (time.time()- start_pulse) < pulse_time: time.sleep(read_delay) read = a.parsedread() appender(read) start_pulse = time.time() a.ocv() while (time.time()- start_pulse) < 600: time.sleep(read_delay) read = a.parsedread() appender(read) p.kill()
bsd-2-clause
[ 646, 2680, 199, 646, 601, 68, 833, 292, 63, 4342, 63, 4129, 465, 601, 68, 199, 646, 900, 199, 199, 646, 3873, 199, 646, 747, 199, 646, 5739, 199, 646, 984, 199, 199, 309, 25541, 282, 3012, 1844, 199, 719, 275, 3087, 199, 692, 747, 14, 354, 508, 298, 9228, 582, 199, 198, 3, 893, 747, 671, 199, 198, 692, 822, 8, 6463, 14, 6463, 4769, 2374, 15, 4707, 14, 85, 10, 2237, 690, 378, 26, 507, 198, 719, 275, 5739, 14, 6463, 4769, 2374, 15, 4707, 14, 85, 10, 9981, 16, 61, 199, 198, 4164, 822, 8, 6463, 14, 6463, 4769, 2374, 15, 4707, 19919, 10, 2237, 690, 378, 26, 507, 198, 719, 275, 5739, 14, 6463, 4769, 2374, 15, 4707, 19919, 10, 9981, 16, 61, 199, 198, 2836, 26, 507, 198, 1361, 298, 2425, 1133, 1937, 1263, 601, 68, 833, 1956, 14, 221, 19599, 4121, 2122, 507, 198, 1274, 14, 2224, 342, 199, 198, 1361, 1844, 8299, 199, 3, 928, 282, 3012, 367, 26829, 199, 80, 275, 3873, 14, 7942, 9313, 1548, 14719, 63, 2171, 63, 4876, 14, 647, 7210, 719, 5207, 959, 2114, 383, 3471, 1294, 1012, 199, 1361, 298, 14093, 2, 199, 521, 14, 4532, 8, 21, 9, 199, 1361, 298, 10947, 2, 199, 199, 3, 409, 2633, 199, 739, 63, 5814, 275, 1275, 21, 327, 4375, 199, 1005, 833, 292, 63, 344, 275, 7829, 199, 493, 63, 354, 275, 298, 27074, 20662, 941, 292, 63, 396, 2, 199, 1005, 833, 292, 63, 3450, 275, 8375, 1138, 199, 1757, 275, 756, 199, 19538, 63, 521, 275, 5212, 10, 2259, 10, 709, 4388, 199, 3, 3655, 674, 2348, 949, 12943, 89, 199, 3, 2242, 370, 370, 601, 68, 833, 292, 436, 3272, 28633, 611, 1817, 199, 65, 275, 601, 68, 14, 1005, 833, 292, 342, 199, 65, 14, 2242, 8, 1005, 833, 292, 63, 3450, 9, 199, 65, 14, 1757, 275, 3105, 199, 65, 14, 912, 63, 20807, 611, 63, 1224, 8, 1005, 833, 292, 63, 344, 9, 199, 65, 14, 679, 86, 342, 199, 65, 14, 3928, 585, 275, 841, 199, 65, 14, 1185, 3928, 342, 199, 521, 14, 4532, 13417, 18, 9, 199, 65, 14, 679, 86, 342, 421, 199, 3, 981, 6572, 435, 282, 805, 367, 2050, 666, 199, 4508, 275, 942, 199, 24668, 275, 942, 199, 1818, 275, 942, 199, 521, 63, 928, 275, 900, 14, 521, 342, 199, 7612, 275, 378, 199, 493, 63, 354, 275, 570, 63, 354, 30056, 7709, 495, 8, 442, 8, 521, 63, 928, 430, 24878, 4616, 2, 199, 318, 1145, 13747, 8, 19332, 304, 199, 198, 692, 7664, 459, 1078, 2565, 507, 198, 1361, 7664, 459, 3890, 63, 1554, 35, 995, 739, 459, 1818, 418, 507, 198, 84, 3028, 275, 620, 8, 521, 14, 521, 22251, 521, 63, 928, 9, 507, 198, 548, 275, 307, 3028, 11, 2266, 11, 495, 8, 19332, 459, 3890, 63, 1554, 35, 1105, 11, 2266, 11, 495, 8, 739, 459, 1818, 1105, 11, 2266, 11, 495, 8, 7612, 6393, 3212, 78, 2, 507, 198, 1490, 8, 493, 63, 354, 4589, 65, 3471, 952, 8, 548, 9, 199, 198, 2836, 26, 507, 198, 1361, 298, 4087, 1586, 2, 421, 199, 3, 7801, 4012, 1338, 199, 1199, 275, 378, 199, 65, 14, 679, 86, 342, 199, 509, 284, 315, 1425, 8, 16, 12, 1165, 304, 199, 198, 521, 14, 4532, 13417, 17, 9, 199, 198, 739, 275, 282, 14, 6751, 739, 342, 199, 198, 5435, 424, 8, 739, 9, 421, 199, 928, 63, 19538, 275, 900, 14, 521, 342, 199, 65, 14, 27074, 20662, 941, 292, 2801, 16, 14, 4587, 9, 199, 6710, 334, 521, 14, 521, 22251, 1343, 63, 19538, 9, 665, 27949, 63, 521, 26, 199, 198, 521, 14, 4532, 8, 739, 63, 5814, 9, 199, 198, 739, 275, 282, 14, 6751, 739, 342, 199, 198, 5435, 424, 8, 739, 9, 1057, 686, 199, 928, 63, 19538, 275, 900, 14, 521, 342, 199, 65, 14, 679, 86, 342, 199, 6710, 334, 521, 14, 521, 22251, 1343, 63, 19538, 9, 665, 11624, 26, 199, 198, 521, 14, 4532, 8, 739, 63, 5814, 9, 199, 198, 739, 275, 282, 14, 6751, 739, 342, 199, 198, 5435, 424, 8, 739, 9, 507, 421, 199, 80, 14, 8997, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 199, 646, 601, 68, 833, 292, 63, 4342, 63, 4129, 465, 601, 68, 199, 646, 900, 199, 199, 646, 3873, 199, 646, 747, 199, 646, 5739, 199, 646, 984, 199, 199, 309, 25541, 282, 3012, 1844, 199, 719, 275, 3087, 199, 692, 747, 14, 354, 508, 298, 9228, 582, 199, 198, 3, 893, 747, 671, 199, 198, 692, 822, 8, 6463, 14, 6463, 4769, 2374, 15, 4707, 14, 85, 10, 2237, 690, 378, 26, 507, 198, 719, 275, 5739, 14, 6463, 4769, 2374, 15, 4707, 14, 85, 10, 9981, 16, 61, 199, 198, 4164, 822, 8, 6463, 14, 6463, 4769, 2374, 15, 4707, 19919, 10, 2237, 690, 378, 26, 507, 198, 719, 275, 5739, 14, 6463, 4769, 2374, 15, 4707, 19919, 10, 9981, 16, 61, 199, 198, 2836, 26, 507, 198, 1361, 298, 2425, 1133, 1937, 1263, 601, 68, 833, 1956, 14, 221, 19599, 4121, 2122, 507, 198, 1274, 14, 2224, 342, 199, 198, 1361, 1844, 8299, 199, 3, 928, 282, 3012, 367, 26829, 199, 80, 275, 3873, 14, 7942, 9313, 1548, 14719, 63, 2171, 63, 4876, 14, 647, 7210, 719, 5207, 959, 2114, 383, 3471, 1294, 1012, 199, 1361, 298, 14093, 2, 199, 521, 14, 4532, 8, 21, 9, 199, 1361, 298, 10947, 2, 199, 199, 3, 409, 2633, 199, 739, 63, 5814, 275, 1275, 21, 327, 4375, 199, 1005, 833, 292, 63, 344, 275, 7829, 199, 493, 63, 354, 275, 298, 27074, 20662, 941, 292, 63, 396, 2, 199, 1005, 833, 292, 63, 3450, 275, 8375, 1138, 199, 1757, 275, 756, 199, 19538, 63, 521, 275, 5212, 10, 2259, 10, 709, 4388, 199, 3, 3655, 674, 2348, 949, 12943, 89, 199, 3, 2242, 370, 370, 601, 68, 833, 292, 436, 3272, 28633, 611, 1817, 199, 65, 275, 601, 68, 14, 1005, 833, 292, 342, 199, 65, 14, 2242, 8, 1005, 833, 292, 63, 3450, 9, 199, 65, 14, 1757, 275, 3105, 199, 65, 14, 912, 63, 20807, 611, 63, 1224, 8, 1005, 833, 292, 63, 344, 9, 199, 65, 14, 679, 86, 342, 199, 65, 14, 3928, 585, 275, 841, 199, 65, 14, 1185, 3928, 342, 199, 521, 14, 4532, 13417, 18, 9, 199, 65, 14, 679, 86, 342, 421, 199, 3, 981, 6572, 435, 282, 805, 367, 2050, 666, 199, 4508, 275, 942, 199, 24668, 275, 942, 199, 1818, 275, 942, 199, 521, 63, 928, 275, 900, 14, 521, 342, 199, 7612, 275, 378, 199, 493, 63, 354, 275, 570, 63, 354, 30056, 7709, 495, 8, 442, 8, 521, 63, 928, 430, 24878, 4616, 2, 199, 318, 1145, 13747, 8, 19332, 304, 199, 198, 692, 7664, 459, 1078, 2565, 507, 198, 1361, 7664, 459, 3890, 63, 1554, 35, 995, 739, 459, 1818, 418, 507, 198, 84, 3028, 275, 620, 8, 521, 14, 521, 22251, 521, 63, 928, 9, 507, 198, 548, 275, 307, 3028, 11, 2266, 11, 495, 8, 19332, 459, 3890, 63, 1554, 35, 1105, 11, 2266, 11, 495, 8, 739, 459, 1818, 1105, 11, 2266, 11, 495, 8, 7612, 6393, 3212, 78, 2, 507, 198, 1490, 8, 493, 63, 354, 4589, 65, 3471, 952, 8, 548, 9, 199, 198, 2836, 26, 507, 198, 1361, 298, 4087, 1586, 2, 421, 199, 3, 7801, 4012, 1338, 199, 1199, 275, 378, 199, 65, 14, 679, 86, 342, 199, 509, 284, 315, 1425, 8, 16, 12, 1165, 304, 199, 198, 521, 14, 4532, 13417, 17, 9, 199, 198, 739, 275, 282, 14, 6751, 739, 342, 199, 198, 5435, 424, 8, 739, 9, 421, 199, 928, 63, 19538, 275, 900, 14, 521, 342, 199, 65, 14, 27074, 20662, 941, 292, 2801, 16, 14, 4587, 9, 199, 6710, 334, 521, 14, 521, 22251, 1343, 63, 19538, 9, 665, 27949, 63, 521, 26, 199, 198, 521, 14, 4532, 8, 739, 63, 5814, 9, 199, 198, 739, 275, 282, 14, 6751, 739, 342, 199, 198, 5435, 424, 8, 739, 9, 1057, 686, 199, 928, 63, 19538, 275, 900, 14, 521, 342, 199, 65, 14, 679, 86, 342, 199, 6710, 334, 521, 14, 521, 22251, 1343, 63, 19538, 9, 665, 11624, 26, 199, 198, 521, 14, 4532, 8, 739, 63, 5814, 9, 199, 198, 739, 275, 282, 14, 6751, 739, 342, 199, 198, 5435, 424, 8, 739, 9, 507, 421, 199, 80, 14, 8997, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ct-23/home-assistant
homeassistant/components/device_tracker/asuswrt.py
3
13419
""" Support for ASUSWRT routers. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/device_tracker.asuswrt/ """ import logging import re import socket import telnetlib from collections import namedtuple import voluptuous as vol from homeassistant.components.device_tracker import ( DOMAIN, PLATFORM_SCHEMA, DeviceScanner) from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['pexpect==4.0.1'] _LOGGER = logging.getLogger(__name__) CONF_MODE = 'mode' CONF_PROTOCOL = 'protocol' CONF_PUB_KEY = 'pub_key' CONF_SSH_KEY = 'ssh_key' DEFAULT_SSH_PORT = 22 SECRET_GROUP = 'Password or SSH Key' PLATFORM_SCHEMA = vol.All( cv.has_at_least_one_key(CONF_PASSWORD, CONF_PUB_KEY, CONF_SSH_KEY), PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Required(CONF_USERNAME): cv.string, vol.Optional(CONF_PROTOCOL, default='ssh'): vol.In(['ssh', 'telnet']), vol.Optional(CONF_MODE, default='router'): vol.In(['router', 'ap']), vol.Optional(CONF_PORT, default=DEFAULT_SSH_PORT): cv.port, vol.Exclusive(CONF_PASSWORD, SECRET_GROUP): cv.string, vol.Exclusive(CONF_SSH_KEY, SECRET_GROUP): cv.isfile, vol.Exclusive(CONF_PUB_KEY, SECRET_GROUP): cv.isfile })) _LEASES_CMD = 'cat /var/lib/misc/dnsmasq.leases' _LEASES_REGEX = re.compile( r'\w+\s' + r'(?P<mac>(([0-9a-f]{2}[:-]){5}([0-9a-f]{2})))\s' + r'(?P<ip>([0-9]{1,3}[\.]){3}[0-9]{1,3})\s' + r'(?P<host>([^\s]+))') # Command to get both 5GHz and 2.4GHz clients _WL_CMD = 'for dev in `nvram get wl_ifnames`; do wl -i $dev assoclist; done' _WL_REGEX = re.compile( r'\w+\s' + r'(?P<mac>(([0-9A-F]{2}[:-]){5}([0-9A-F]{2})))') _IP_NEIGH_CMD = 'ip neigh' _IP_NEIGH_REGEX = re.compile( r'(?P<ip>([0-9]{1,3}[\.]){3}[0-9]{1,3}|' r'([0-9a-fA-F]{1,4}:){1,7}[0-9a-fA-F]{0,4}(:[0-9a-fA-F]{1,4}){1,7})\s' r'\w+\s' r'\w+\s' r'(\w+\s(?P<mac>(([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))))?\s' r'\s?(router)?' r'(?P<status>(\w+))') # pylint: disable=unused-argument def get_scanner(hass, config): """Validate the configuration and return an ASUS-WRT scanner.""" scanner = AsusWrtDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None AsusWrtResult = namedtuple('AsusWrtResult', 'neighbors leases') class AsusWrtDeviceScanner(DeviceScanner): """This class queries a router running ASUSWRT firmware.""" # Eighth attribute needed for mode (AP mode vs router mode) def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config.get(CONF_PASSWORD, '') self.ssh_key = config.get('ssh_key', config.get('pub_key', '')) self.protocol = config[CONF_PROTOCOL] self.mode = config[CONF_MODE] self.port = config[CONF_PORT] if self.protocol == 'ssh': if not (self.ssh_key or self.password): _LOGGER.error("No password or private key specified") self.success_init = False return self.connection = SshConnection(self.host, self.port, self.username, self.password, self.ssh_key, self.mode == "ap") else: if not self.password: _LOGGER.error("No password specified") self.success_init = False return self.connection = TelnetConnection(self.host, self.port, self.username, self.password, self.mode == "ap") self.last_results = {} # Test the router is accessible. data = self.get_asuswrt_data() self.success_init = data is not None def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [client['mac'] for client in self.last_results] def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if not self.last_results: return None for client in self.last_results: if client['mac'] == device: return client['host'] return None def _update_info(self): """Ensure the information from the ASUSWRT router is up to date. Return boolean if scanning successful. """ if not self.success_init: return False _LOGGER.info('Checking Devices') data = self.get_asuswrt_data() if not data: return False active_clients = [client for client in data.values() if client['status'] == 'REACHABLE' or client['status'] == 'DELAY' or client['status'] == 'STALE' or client['status'] == 'IN_ASSOCLIST'] self.last_results = active_clients return True def get_asuswrt_data(self): """Retrieve data from ASUSWRT and return parsed result.""" result = self.connection.get_result() if not result: return {} devices = {} if self.mode == 'ap': for lease in result.leases: match = _WL_REGEX.search(lease.decode('utf-8')) if not match: _LOGGER.warning("Could not parse wl row: %s", lease) continue host = '' devices[match.group('mac').upper()] = { 'host': host, 'status': 'IN_ASSOCLIST', 'ip': '', 'mac': match.group('mac').upper(), } else: for lease in result.leases: if lease.startswith(b'duid '): continue match = _LEASES_REGEX.search(lease.decode('utf-8')) if not match: _LOGGER.warning("Could not parse lease row: %s", lease) continue # For leases where the client doesn't set a hostname, ensure it # is blank and not '*', which breaks entity_id down the line. host = match.group('host') if host == '*': host = '' devices[match.group('mac')] = { 'host': host, 'status': '', 'ip': match.group('ip'), 'mac': match.group('mac').upper(), } for neighbor in result.neighbors: match = _IP_NEIGH_REGEX.search(neighbor.decode('utf-8')) if not match: _LOGGER.warning("Could not parse neighbor row: %s", neighbor) continue if match.group('mac') in devices: devices[match.group('mac')]['status'] = ( match.group('status')) return devices class _Connection: def __init__(self): self._connected = False @property def connected(self): """Return connection state.""" return self._connected def connect(self): """Mark currenct connection state as connected.""" self._connected = True def disconnect(self): """Mark current connection state as disconnected.""" self._connected = False class SshConnection(_Connection): """Maintains an SSH connection to an ASUS-WRT router.""" def __init__(self, host, port, username, password, ssh_key, ap): """Initialize the SSH connection properties.""" super(SshConnection, self).__init__() self._ssh = None self._host = host self._port = port self._username = username self._password = password self._ssh_key = ssh_key self._ap = ap def get_result(self): """Retrieve a single AsusWrtResult through an SSH connection. Connect to the SSH server if not currently connected, otherwise use the existing connection. """ from pexpect import pxssh, exceptions try: if not self.connected: self.connect() if self._ap: neighbors = [''] self._ssh.sendline(_WL_CMD) self._ssh.prompt() leases_result = self._ssh.before.split(b'\n')[1:-1] else: self._ssh.sendline(_IP_NEIGH_CMD) self._ssh.prompt() neighbors = self._ssh.before.split(b'\n')[1:-1] self._ssh.sendline(_LEASES_CMD) self._ssh.prompt() leases_result = self._ssh.before.split(b'\n')[1:-1] return AsusWrtResult(neighbors, leases_result) except exceptions.EOF as err: _LOGGER.error("Connection refused. SSH enabled?") self.disconnect() return None except pxssh.ExceptionPxssh as err: _LOGGER.error("Unexpected SSH error: %s", str(err)) self.disconnect() return None except AssertionError as err: _LOGGER.error("Connection to router unavailable: %s", str(err)) self.disconnect() return None def connect(self): """Connect to the ASUS-WRT SSH server.""" from pexpect import pxssh self._ssh = pxssh.pxssh() if self._ssh_key: self._ssh.login(self._host, self._username, ssh_key=self._ssh_key, port=self._port) else: self._ssh.login(self._host, self._username, password=self._password, port=self._port) super(SshConnection, self).connect() def disconnect(self): \ # pylint: disable=broad-except """Disconnect the current SSH connection.""" try: self._ssh.logout() except Exception: pass finally: self._ssh = None super(SshConnection, self).disconnect() class TelnetConnection(_Connection): """Maintains a Telnet connection to an ASUS-WRT router.""" def __init__(self, host, port, username, password, ap): """Initialize the Telnet connection properties.""" super(TelnetConnection, self).__init__() self._telnet = None self._host = host self._port = port self._username = username self._password = password self._ap = ap self._prompt_string = None def get_result(self): """Retrieve a single AsusWrtResult through a Telnet connection. Connect to the Telnet server if not currently connected, otherwise use the existing connection. """ try: if not self.connected: self.connect() self._telnet.write('{}\n'.format(_IP_NEIGH_CMD).encode('ascii')) neighbors = (self._telnet.read_until(self._prompt_string). split(b'\n')[1:-1]) if self._ap: self._telnet.write('{}\n'.format(_WL_CMD).encode('ascii')) leases_result = (self._telnet.read_until(self._prompt_string). split(b'\n')[1:-1]) else: self._telnet.write('{}\n'.format(_LEASES_CMD).encode('ascii')) leases_result = (self._telnet.read_until(self._prompt_string). split(b'\n')[1:-1]) return AsusWrtResult(neighbors, leases_result) except EOFError: _LOGGER.error("Unexpected response from router") self.disconnect() return None except ConnectionRefusedError: _LOGGER.error("Connection refused by router. Telnet enabled?") self.disconnect() return None except socket.gaierror as exc: _LOGGER.error("Socket exception: %s", exc) self.disconnect() return None except OSError as exc: _LOGGER.error("OSError: %s", exc) self.disconnect() return None def connect(self): """Connect to the ASUS-WRT Telnet server.""" self._telnet = telnetlib.Telnet(self._host) self._telnet.read_until(b'login: ') self._telnet.write((self._username + '\n').encode('ascii')) self._telnet.read_until(b'Password: ') self._telnet.write((self._password + '\n').encode('ascii')) self._prompt_string = self._telnet.read_until(b'#').split(b'\n')[-1] super(TelnetConnection, self).connect() def disconnect(self): \ # pylint: disable=broad-except """Disconnect the current Telnet connection.""" try: self._telnet.write('exit\n'.encode('ascii')) except Exception: pass super(TelnetConnection, self).disconnect()
apache-2.0
[ 624, 199, 11532, 367, 4319, 1668, 6524, 52, 24464, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 1782, 63, 8877, 14, 305, 527, 87, 2591, 15, 199, 624, 199, 646, 2050, 199, 646, 295, 199, 646, 2838, 199, 646, 26519, 773, 199, 504, 5055, 492, 12863, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 1782, 63, 8877, 492, 334, 272, 15265, 12, 21966, 63, 10926, 12, 12272, 20843, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 5449, 12, 6392, 63, 9032, 12, 6392, 63, 11958, 12, 6392, 63, 3657, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 16531, 1764, 389, 20, 14, 16, 14, 17, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 63, 6963, 275, 283, 632, 7, 199, 3103, 63, 9583, 275, 283, 3922, 7, 199, 3103, 63, 13047, 63, 3078, 275, 283, 5645, 63, 498, 7, 199, 3103, 63, 13716, 63, 3078, 275, 283, 5510, 63, 498, 7, 199, 199, 3472, 63, 13716, 63, 3657, 275, 6928, 199, 199, 12961, 63, 7823, 275, 283, 6139, 503, 12027, 2606, 7, 199, 199, 17805, 63, 10926, 275, 5236, 14, 2422, 8, 272, 6277, 14, 1989, 63, 292, 63, 11790, 63, 368, 63, 498, 8, 3103, 63, 9032, 12, 6392, 63, 13047, 63, 3078, 12, 6392, 63, 13716, 63, 3078, 395, 272, 21966, 63, 10926, 14, 2880, 2561, 267, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 11958, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 9583, 12, 849, 534, 5510, 735, 288, 5236, 14, 607, 2941, 5510, 297, 283, 31085, 3815, 267, 5236, 14, 7012, 8, 3103, 63, 6963, 12, 849, 534, 4995, 735, 288, 5236, 14, 607, 2941, 4995, 297, 283, 439, 3815, 267, 5236, 14, 7012, 8, 3103, 63, 3657, 12, 849, 29, 3472, 63, 13716, 63, 3657, 304, 6277, 14, 719, 12, 267, 5236, 14, 26281, 8, 3103, 63, 9032, 12, 5795, 11771, 63, 7823, 304, 6277, 14, 875, 12, 267, 5236, 14, 26281, 8, 3103, 63, 13716, 63, 3078, 12, 5795, 11771, 63, 7823, 304, 6277, 14, 6292, 12, 267, 5236, 14, 26281, 8, 3103, 63, 13047, 63, 3078, 12, 5795, 11771, 63, 7823, 304, 6277, 14, 6292, 272, 23451, 421, 199, 63, 906, 21983, 63, 9744, 275, 283, 3385, 1182, 1391, 15, 773, 15, 9923, 15, 5797, 5892, 81, 14, 1756, 83, 7, 199, 63, 906, 21983, 63, 10710, 275, 295, 14, 2014, 8, 272, 519, 1154, 87, 7896, 83, 7, 435, 272, 519, 10120, 48, 28, 3088, 13661, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 4439, 566, 91, 21, 93, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 1724, 60, 83, 7, 435, 272, 519, 10120, 48, 28, 711, 30, 779, 16, 13, 25, 8194, 17, 12, 19, 22857, 4537, 566, 91, 19, 22857, 16, 13, 25, 8194, 17, 12, 19, 30446, 83, 7, 435, 272, 519, 10120, 48, 28, 1102, 30, 21690, 83, 2807, 28435, 199, 199, 3, 5817, 370, 664, 3865, 959, 39, 13026, 436, 499, 14, 20, 39, 13026, 13431, 199, 63, 55, 44, 63, 9744, 275, 283, 509, 4866, 315, 658, 15969, 5975, 664, 336, 76, 63, 692, 1247, 64, 27, 886, 336, 76, 446, 73, 2672, 2374, 22149, 513, 27, 4224, 7, 199, 63, 55, 44, 63, 10710, 275, 295, 14, 2014, 8, 272, 519, 1154, 87, 7896, 83, 7, 435, 272, 519, 10120, 48, 28, 3088, 13661, 779, 16, 13, 25, 33, 13, 38, 8194, 18, 93, 4439, 566, 91, 21, 93, 779, 16, 13, 25, 33, 13, 38, 8194, 18, 93, 1724, 358, 199, 199, 63, 1772, 63, 6388, 13454, 63, 9744, 275, 283, 711, 1279, 2056, 7, 199, 63, 1772, 63, 6388, 13454, 63, 10710, 275, 295, 14, 2014, 8, 272, 519, 10120, 48, 28, 711, 30, 779, 16, 13, 25, 8194, 17, 12, 19, 22857, 4537, 566, 91, 19, 22857, 16, 13, 25, 8194, 17, 12, 19, 93, 5227, 272, 519, 21731, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 17, 12, 20, 9160, 11224, 17, 12, 23, 22857, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 16, 12, 20, 22999, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 17, 12, 20, 1552, 91, 17, 12, 23, 30446, 83, 7, 272, 519, 1154, 87, 7896, 83, 7, 272, 519, 1154, 87, 7896, 83, 7, 272, 519, 13445, 87, 7896, 83, 2229, 48, 28, 3088, 13661, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 4439, 566, 91, 21, 93, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 7845, 8995, 83, 7, 272, 519, 1154, 83, 31, 8, 4995, 5547, 7, 272, 519, 10120, 48, 28, 1205, 30, 2961, 87, 11, 28435, 421, 199, 3, 4287, 26, 3507, 29, 8618, 13, 2094, 199, 318, 664, 63, 16378, 8, 5387, 12, 1101, 304, 272, 408, 12584, 314, 2897, 436, 372, 376, 4319, 1668, 13, 6524, 52, 19121, 1041, 272, 19121, 275, 3709, 527, 55, 2591, 2510, 20843, 8, 888, 59, 7378, 566, 339, 372, 19121, 340, 19121, 14, 3742, 63, 826, 587, 488, 421, 199, 2822, 527, 55, 2591, 2889, 275, 12863, 360, 2822, 527, 55, 2591, 2889, 297, 283, 11113, 1026, 3274, 358, 421, 199, 533, 3709, 527, 55, 2591, 2510, 20843, 8, 2510, 20843, 304, 272, 408, 2765, 1021, 9212, 282, 6197, 3879, 4319, 1668, 6524, 52, 27969, 1041, 339, 327, 662, 2056, 273, 2225, 4346, 367, 818, 334, 1282, 818, 8118, 6197, 818, 9, 272, 347, 636, 826, 721, 277, 12, 1101, 304, 267, 408, 9345, 314, 19121, 1041, 267, 291, 14, 1102, 275, 1101, 59, 3103, 63, 5449, 61, 267, 291, 14, 2473, 275, 1101, 59, 3103, 63, 11958, 61, 267, 291, 14, 2060, 275, 1101, 14, 362, 8, 3103, 63, 9032, 12, 4074, 267, 291, 14, 5510, 63, 498, 275, 1101, 14, 362, 360, 5510, 63, 498, 297, 1101, 14, 362, 360, 5645, 63 ]
[ 199, 11532, 367, 4319, 1668, 6524, 52, 24464, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 1782, 63, 8877, 14, 305, 527, 87, 2591, 15, 199, 624, 199, 646, 2050, 199, 646, 295, 199, 646, 2838, 199, 646, 26519, 773, 199, 504, 5055, 492, 12863, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 1782, 63, 8877, 492, 334, 272, 15265, 12, 21966, 63, 10926, 12, 12272, 20843, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 5449, 12, 6392, 63, 9032, 12, 6392, 63, 11958, 12, 6392, 63, 3657, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 16531, 1764, 389, 20, 14, 16, 14, 17, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 63, 6963, 275, 283, 632, 7, 199, 3103, 63, 9583, 275, 283, 3922, 7, 199, 3103, 63, 13047, 63, 3078, 275, 283, 5645, 63, 498, 7, 199, 3103, 63, 13716, 63, 3078, 275, 283, 5510, 63, 498, 7, 199, 199, 3472, 63, 13716, 63, 3657, 275, 6928, 199, 199, 12961, 63, 7823, 275, 283, 6139, 503, 12027, 2606, 7, 199, 199, 17805, 63, 10926, 275, 5236, 14, 2422, 8, 272, 6277, 14, 1989, 63, 292, 63, 11790, 63, 368, 63, 498, 8, 3103, 63, 9032, 12, 6392, 63, 13047, 63, 3078, 12, 6392, 63, 13716, 63, 3078, 395, 272, 21966, 63, 10926, 14, 2880, 2561, 267, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 11958, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 9583, 12, 849, 534, 5510, 735, 288, 5236, 14, 607, 2941, 5510, 297, 283, 31085, 3815, 267, 5236, 14, 7012, 8, 3103, 63, 6963, 12, 849, 534, 4995, 735, 288, 5236, 14, 607, 2941, 4995, 297, 283, 439, 3815, 267, 5236, 14, 7012, 8, 3103, 63, 3657, 12, 849, 29, 3472, 63, 13716, 63, 3657, 304, 6277, 14, 719, 12, 267, 5236, 14, 26281, 8, 3103, 63, 9032, 12, 5795, 11771, 63, 7823, 304, 6277, 14, 875, 12, 267, 5236, 14, 26281, 8, 3103, 63, 13716, 63, 3078, 12, 5795, 11771, 63, 7823, 304, 6277, 14, 6292, 12, 267, 5236, 14, 26281, 8, 3103, 63, 13047, 63, 3078, 12, 5795, 11771, 63, 7823, 304, 6277, 14, 6292, 272, 23451, 421, 199, 63, 906, 21983, 63, 9744, 275, 283, 3385, 1182, 1391, 15, 773, 15, 9923, 15, 5797, 5892, 81, 14, 1756, 83, 7, 199, 63, 906, 21983, 63, 10710, 275, 295, 14, 2014, 8, 272, 519, 1154, 87, 7896, 83, 7, 435, 272, 519, 10120, 48, 28, 3088, 13661, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 4439, 566, 91, 21, 93, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 1724, 60, 83, 7, 435, 272, 519, 10120, 48, 28, 711, 30, 779, 16, 13, 25, 8194, 17, 12, 19, 22857, 4537, 566, 91, 19, 22857, 16, 13, 25, 8194, 17, 12, 19, 30446, 83, 7, 435, 272, 519, 10120, 48, 28, 1102, 30, 21690, 83, 2807, 28435, 199, 199, 3, 5817, 370, 664, 3865, 959, 39, 13026, 436, 499, 14, 20, 39, 13026, 13431, 199, 63, 55, 44, 63, 9744, 275, 283, 509, 4866, 315, 658, 15969, 5975, 664, 336, 76, 63, 692, 1247, 64, 27, 886, 336, 76, 446, 73, 2672, 2374, 22149, 513, 27, 4224, 7, 199, 63, 55, 44, 63, 10710, 275, 295, 14, 2014, 8, 272, 519, 1154, 87, 7896, 83, 7, 435, 272, 519, 10120, 48, 28, 3088, 13661, 779, 16, 13, 25, 33, 13, 38, 8194, 18, 93, 4439, 566, 91, 21, 93, 779, 16, 13, 25, 33, 13, 38, 8194, 18, 93, 1724, 358, 199, 199, 63, 1772, 63, 6388, 13454, 63, 9744, 275, 283, 711, 1279, 2056, 7, 199, 63, 1772, 63, 6388, 13454, 63, 10710, 275, 295, 14, 2014, 8, 272, 519, 10120, 48, 28, 711, 30, 779, 16, 13, 25, 8194, 17, 12, 19, 22857, 4537, 566, 91, 19, 22857, 16, 13, 25, 8194, 17, 12, 19, 93, 5227, 272, 519, 21731, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 17, 12, 20, 9160, 11224, 17, 12, 23, 22857, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 16, 12, 20, 22999, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 17, 12, 20, 1552, 91, 17, 12, 23, 30446, 83, 7, 272, 519, 1154, 87, 7896, 83, 7, 272, 519, 1154, 87, 7896, 83, 7, 272, 519, 13445, 87, 7896, 83, 2229, 48, 28, 3088, 13661, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 4439, 566, 91, 21, 93, 779, 16, 13, 25, 65, 13, 70, 8194, 18, 93, 7845, 8995, 83, 7, 272, 519, 1154, 83, 31, 8, 4995, 5547, 7, 272, 519, 10120, 48, 28, 1205, 30, 2961, 87, 11, 28435, 421, 199, 3, 4287, 26, 3507, 29, 8618, 13, 2094, 199, 318, 664, 63, 16378, 8, 5387, 12, 1101, 304, 272, 408, 12584, 314, 2897, 436, 372, 376, 4319, 1668, 13, 6524, 52, 19121, 1041, 272, 19121, 275, 3709, 527, 55, 2591, 2510, 20843, 8, 888, 59, 7378, 566, 339, 372, 19121, 340, 19121, 14, 3742, 63, 826, 587, 488, 421, 199, 2822, 527, 55, 2591, 2889, 275, 12863, 360, 2822, 527, 55, 2591, 2889, 297, 283, 11113, 1026, 3274, 358, 421, 199, 533, 3709, 527, 55, 2591, 2510, 20843, 8, 2510, 20843, 304, 272, 408, 2765, 1021, 9212, 282, 6197, 3879, 4319, 1668, 6524, 52, 27969, 1041, 339, 327, 662, 2056, 273, 2225, 4346, 367, 818, 334, 1282, 818, 8118, 6197, 818, 9, 272, 347, 636, 826, 721, 277, 12, 1101, 304, 267, 408, 9345, 314, 19121, 1041, 267, 291, 14, 1102, 275, 1101, 59, 3103, 63, 5449, 61, 267, 291, 14, 2473, 275, 1101, 59, 3103, 63, 11958, 61, 267, 291, 14, 2060, 275, 1101, 14, 362, 8, 3103, 63, 9032, 12, 4074, 267, 291, 14, 5510, 63, 498, 275, 1101, 14, 362, 360, 5510, 63, 498, 297, 1101, 14, 362, 360, 5645, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
eceglov/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py
119
9519
# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import unittest2 as unittest import json import optparse import random from webkitpy.common.host_mock import MockHost from webkitpy.layout_tests.layout_package import json_results_generator from webkitpy.layout_tests.models import test_expectations from webkitpy.port import test from webkitpy.thirdparty.mock import Mock class JSONGeneratorTest(unittest.TestCase): def setUp(self): self.builder_name = 'DUMMY_BUILDER_NAME' self.build_name = 'DUMMY_BUILD_NAME' self.build_number = 'DUMMY_BUILDER_NUMBER' # For archived results. self._json = None self._num_runs = 0 self._tests_set = set([]) self._test_timings = {} self._failed_count_map = {} self._PASS_count = 0 self._DISABLED_count = 0 self._FLAKY_count = 0 self._FAILS_count = 0 self._fixable_count = 0 def test_strip_json_wrapper(self): json = "['contents']" self.assertEqual(json_results_generator.strip_json_wrapper(json_results_generator._JSON_PREFIX + json + json_results_generator._JSON_SUFFIX), json) self.assertEqual(json_results_generator.strip_json_wrapper(json), json) def _test_json_generation(self, passed_tests_list, failed_tests_list): tests_set = set(passed_tests_list) | set(failed_tests_list) DISABLED_tests = set([t for t in tests_set if t.startswith('DISABLED_')]) FLAKY_tests = set([t for t in tests_set if t.startswith('FLAKY_')]) FAILS_tests = set([t for t in tests_set if t.startswith('FAILS_')]) PASS_tests = tests_set - (DISABLED_tests | FLAKY_tests | FAILS_tests) failed_tests = set(failed_tests_list) - DISABLED_tests failed_count_map = dict([(t, 1) for t in failed_tests]) test_timings = {} i = 0 for test in tests_set: test_timings[test] = float(self._num_runs * 100 + i) i += 1 test_results_map = dict() for test in tests_set: test_results_map[test] = json_results_generator.TestResult(test, failed=(test in failed_tests), elapsed_time=test_timings[test]) host = MockHost() port = Mock() port._filesystem = host.filesystem generator = json_results_generator.JSONResultsGenerator(port, self.builder_name, self.build_name, self.build_number, '', None, # don't fetch past json results archive test_results_map) failed_count_map = dict([(t, 1) for t in failed_tests]) # Test incremental json results incremental_json = generator.get_json() self._verify_json_results( tests_set, test_timings, failed_count_map, len(PASS_tests), len(DISABLED_tests), len(FLAKY_tests), len(DISABLED_tests | failed_tests), incremental_json, 1) # We don't verify the results here, but at least we make sure the code runs without errors. generator.generate_json_output() generator.generate_times_ms_file() def _verify_json_results(self, tests_set, test_timings, failed_count_map, PASS_count, DISABLED_count, FLAKY_count, fixable_count, json, num_runs): # Aliasing to a short name for better access to its constants. JRG = json_results_generator.JSONResultsGenerator self.assertIn(JRG.VERSION_KEY, json) self.assertIn(self.builder_name, json) buildinfo = json[self.builder_name] self.assertIn(JRG.FIXABLE, buildinfo) self.assertIn(JRG.TESTS, buildinfo) self.assertEqual(len(buildinfo[JRG.BUILD_NUMBERS]), num_runs) self.assertEqual(buildinfo[JRG.BUILD_NUMBERS][0], self.build_number) if tests_set or DISABLED_count: fixable = {} for fixable_items in buildinfo[JRG.FIXABLE]: for (type, count) in fixable_items.iteritems(): if type in fixable: fixable[type] = fixable[type] + count else: fixable[type] = count if PASS_count: self.assertEqual(fixable[JRG.PASS_RESULT], PASS_count) else: self.assertTrue(JRG.PASS_RESULT not in fixable or fixable[JRG.PASS_RESULT] == 0) if DISABLED_count: self.assertEqual(fixable[JRG.SKIP_RESULT], DISABLED_count) else: self.assertTrue(JRG.SKIP_RESULT not in fixable or fixable[JRG.SKIP_RESULT] == 0) if FLAKY_count: self.assertEqual(fixable[JRG.FLAKY_RESULT], FLAKY_count) else: self.assertTrue(JRG.FLAKY_RESULT not in fixable or fixable[JRG.FLAKY_RESULT] == 0) if failed_count_map: tests = buildinfo[JRG.TESTS] for test_name in failed_count_map.iterkeys(): test = self._find_test_in_trie(test_name, tests) failed = 0 for result in test[JRG.RESULTS]: if result[1] == JRG.FAIL_RESULT: failed += result[0] self.assertEqual(failed_count_map[test_name], failed) timing_count = 0 for timings in test[JRG.TIMES]: if timings[1] == test_timings[test_name]: timing_count = timings[0] self.assertEqual(1, timing_count) if fixable_count: self.assertEqual(sum(buildinfo[JRG.FIXABLE_COUNT]), fixable_count) def _find_test_in_trie(self, path, trie): nodes = path.split("/") sub_trie = trie for node in nodes: self.assertIn(node, sub_trie) sub_trie = sub_trie[node] return sub_trie def test_json_generation(self): self._test_json_generation([], []) self._test_json_generation(['A1', 'B1'], []) self._test_json_generation([], ['FAILS_A2', 'FAILS_B2']) self._test_json_generation(['DISABLED_A3', 'DISABLED_B3'], []) self._test_json_generation(['A4'], ['B4', 'FAILS_C4']) self._test_json_generation(['DISABLED_C5', 'DISABLED_D5'], ['A5', 'B5']) self._test_json_generation( ['A6', 'B6', 'FAILS_C6', 'DISABLED_E6', 'DISABLED_F6'], ['FAILS_D6']) # Generate JSON with the same test sets. (Both incremental results and # archived results must be updated appropriately.) self._test_json_generation( ['A', 'FLAKY_B', 'DISABLED_C'], ['FAILS_D', 'FLAKY_E']) self._test_json_generation( ['A', 'DISABLED_C', 'FLAKY_E'], ['FLAKY_B', 'FAILS_D']) self._test_json_generation( ['FLAKY_B', 'DISABLED_C', 'FAILS_D'], ['A', 'FLAKY_E']) def test_hierarchical_json_generation(self): # FIXME: Re-work tests to be more comprehensible and comprehensive. self._test_json_generation(['foo/A'], ['foo/B', 'bar/C']) def test_test_timings_trie(self): test_port = test.TestPort(MockHost()) individual_test_timings = [] individual_test_timings.append(json_results_generator.TestResult('foo/bar/baz.html', elapsed_time=1.2)) individual_test_timings.append(json_results_generator.TestResult('bar.html', elapsed_time=0.0001)) trie = json_results_generator.test_timings_trie(test_port, individual_test_timings) expected_trie = { 'bar.html': 0, 'foo': { 'bar': { 'baz.html': 1200, } } } self.assertEqual(json.dumps(trie), json.dumps(expected_trie))
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 2882, 18, 465, 2882, 199, 646, 2022, 199, 646, 8691, 199, 646, 2196, 199, 199, 504, 18007, 14, 2330, 14, 1102, 63, 1805, 492, 4420, 4965, 199, 504, 18007, 14, 4209, 63, 2219, 14, 4209, 63, 2491, 492, 2022, 63, 2604, 63, 4679, 199, 504, 18007, 14, 4209, 63, 2219, 14, 992, 492, 511, 63, 15752, 199, 504, 18007, 14, 719, 492, 511, 199, 504, 18007, 14, 11470, 7522, 14, 1805, 492, 4420, 421, 199, 533, 4840, 7599, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 5649, 63, 354, 275, 283, 26778, 63, 8248, 540, 63, 2339, 7, 267, 291, 14, 1506, 63, 354, 275, 283, 26778, 63, 8248, 63, 2339, 7, 267, 291, 14, 1506, 63, 1955, 275, 283, 26778, 63, 8248, 540, 63, 9190, 7, 398, 327, 2104, 3819, 12905, 2058, 14, 267, 291, 423, 1001, 275, 488, 267, 291, 423, 1507, 63, 10802, 275, 378, 267, 291, 423, 2219, 63, 409, 275, 663, 4157, 267, 291, 423, 396, 63, 27337, 275, 1052, 267, 291, 423, 4892, 63, 835, 63, 1130, 275, 1052, 398, 291, 423, 6909, 63, 835, 275, 378, 267, 291, 423, 16205, 63, 835, 275, 378, 267, 291, 423, 3143, 7872, 57, 63, 835, 275, 378, 267, 291, 423, 8784, 51, 63, 835, 275, 378, 267, 291, 423, 970, 461, 63, 835, 275, 378, 339, 347, 511, 63, 1913, 63, 1001, 63, 5029, 8, 277, 304, 267, 2022, 275, 25280, 4407, 18721, 267, 291, 14, 629, 8, 1001, 63, 2604, 63, 4679, 14, 1913, 63, 1001, 63, 5029, 8, 1001, 63, 2604, 63, 4679, 423, 6243, 63, 6351, 435, 2022, 435, 2022, 63, 2604, 63, 4679, 423, 6243, 63, 12273, 395, 2022, 9, 267, 291, 14, 629, 8, 1001, 63, 2604, 63, 4679, 14, 1913, 63, 1001, 63, 5029, 8, 1001, 395, 2022, 9, 339, 347, 485, 396, 63, 1001, 63, 15043, 8, 277, 12, 3032, 63, 2219, 63, 513, 12, 3405, 63, 2219, 63, 513, 304, 267, 2295, 63, 409, 275, 663, 8, 12070, 63, 2219, 63, 513, 9, 1204, 663, 8, 4892, 63, 2219, 63, 513, 9, 398, 32147, 36, 63, 2219, 275, 663, 779, 84, 367, 307, 315, 2295, 63, 409, 2490, 340, 307, 14, 2460, 360, 16205, 63, 2023, 267, 481, 5837, 32640, 63, 2219, 275, 663, 779, 84, 367, 307, 315, 2295, 63, 409, 2574, 340, 307, 14, 2460, 360, 3143, 7872, 57, 63, 2023, 267, 10341, 51, 63, 2219, 275, 663, 779, 84, 367, 307, 315, 2295, 63, 409, 2574, 340, 307, 14, 2460, 360, 8784, 51, 63, 2023, 267, 21705, 63, 2219, 275, 2295, 63, 409, 446, 334, 16205, 63, 2219, 1204, 481, 5837, 32640, 63, 2219, 1204, 10341, 51, 63, 2219, 9, 398, 3405, 63, 2219, 275, 663, 8, 4892, 63, 2219, 63, 513, 9, 446, 32147, 36, 63, 2219, 267, 3405, 63, 835, 63, 1130, 275, 1211, 7694, 84, 12, 413, 9, 367, 307, 315, 3405, 63, 2219, 566, 398, 511, 63, 27337, 275, 1052, 267, 284, 275, 378, 267, 367, 511, 315, 2295, 63, 409, 26, 288, 511, 63, 27337, 59, 396, 61, 275, 2069, 8, 277, 423, 1507, 63, 10802, 627, 2948, 435, 284, 9, 288, 284, 847, 413, 398, 511, 63, 2604, 63, 1130, 275, 1211, 342, 267, 367, 511, 315, 2295, 63, 409, 26, 288, 511, 63, 2604, 63, 1130, 59, 396, 61, 275, 2022, 63, 2604, 63, 4679, 14, 13120, 8, 396, 12, 355, 3405, 2687, 396, 315, 3405, 63, 2219, 395, 355, 14439, 63, 521, 29, 396, 63, 27337, 59, 396, 566, 398, 1591, 275, 4420, 4965, 342, 267, 1844, 275, 4420, 342, 267, 1844, 423, 11381, 275, 1591, 14, 11381, 267, 4306, 275, 2022, 63, 2604, 63, 4679, 14, 6243, 6579, 7599, 8, 719, 12, 288, 291, 14, 5649, 63, 354, 12, 291, 14, 1506, 63, 354, 12, 291, 14, 1506, 63, 1955, 12, 288, 3260, 288, 488, 12, 257, 327, 2793, 1133, 5267, 13541, 2022, 2058, 6359, 288, 511, 63, 2604, 63, 1130, 9, 398, 3405, 63, 835, 63, 1130, 275, 1211, 7694, 84, 12, 413, 9, 367, 307, 315, 3405, 63, 2219, 566, 398, 327, 1379, 16316, 2022, 2058, 267, 16316, 63, 1001, 275, 4306, 14, 362, 63, 1001, 342, 267 ]
[ 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 2882, 18, 465, 2882, 199, 646, 2022, 199, 646, 8691, 199, 646, 2196, 199, 199, 504, 18007, 14, 2330, 14, 1102, 63, 1805, 492, 4420, 4965, 199, 504, 18007, 14, 4209, 63, 2219, 14, 4209, 63, 2491, 492, 2022, 63, 2604, 63, 4679, 199, 504, 18007, 14, 4209, 63, 2219, 14, 992, 492, 511, 63, 15752, 199, 504, 18007, 14, 719, 492, 511, 199, 504, 18007, 14, 11470, 7522, 14, 1805, 492, 4420, 421, 199, 533, 4840, 7599, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 5649, 63, 354, 275, 283, 26778, 63, 8248, 540, 63, 2339, 7, 267, 291, 14, 1506, 63, 354, 275, 283, 26778, 63, 8248, 63, 2339, 7, 267, 291, 14, 1506, 63, 1955, 275, 283, 26778, 63, 8248, 540, 63, 9190, 7, 398, 327, 2104, 3819, 12905, 2058, 14, 267, 291, 423, 1001, 275, 488, 267, 291, 423, 1507, 63, 10802, 275, 378, 267, 291, 423, 2219, 63, 409, 275, 663, 4157, 267, 291, 423, 396, 63, 27337, 275, 1052, 267, 291, 423, 4892, 63, 835, 63, 1130, 275, 1052, 398, 291, 423, 6909, 63, 835, 275, 378, 267, 291, 423, 16205, 63, 835, 275, 378, 267, 291, 423, 3143, 7872, 57, 63, 835, 275, 378, 267, 291, 423, 8784, 51, 63, 835, 275, 378, 267, 291, 423, 970, 461, 63, 835, 275, 378, 339, 347, 511, 63, 1913, 63, 1001, 63, 5029, 8, 277, 304, 267, 2022, 275, 25280, 4407, 18721, 267, 291, 14, 629, 8, 1001, 63, 2604, 63, 4679, 14, 1913, 63, 1001, 63, 5029, 8, 1001, 63, 2604, 63, 4679, 423, 6243, 63, 6351, 435, 2022, 435, 2022, 63, 2604, 63, 4679, 423, 6243, 63, 12273, 395, 2022, 9, 267, 291, 14, 629, 8, 1001, 63, 2604, 63, 4679, 14, 1913, 63, 1001, 63, 5029, 8, 1001, 395, 2022, 9, 339, 347, 485, 396, 63, 1001, 63, 15043, 8, 277, 12, 3032, 63, 2219, 63, 513, 12, 3405, 63, 2219, 63, 513, 304, 267, 2295, 63, 409, 275, 663, 8, 12070, 63, 2219, 63, 513, 9, 1204, 663, 8, 4892, 63, 2219, 63, 513, 9, 398, 32147, 36, 63, 2219, 275, 663, 779, 84, 367, 307, 315, 2295, 63, 409, 2490, 340, 307, 14, 2460, 360, 16205, 63, 2023, 267, 481, 5837, 32640, 63, 2219, 275, 663, 779, 84, 367, 307, 315, 2295, 63, 409, 2574, 340, 307, 14, 2460, 360, 3143, 7872, 57, 63, 2023, 267, 10341, 51, 63, 2219, 275, 663, 779, 84, 367, 307, 315, 2295, 63, 409, 2574, 340, 307, 14, 2460, 360, 8784, 51, 63, 2023, 267, 21705, 63, 2219, 275, 2295, 63, 409, 446, 334, 16205, 63, 2219, 1204, 481, 5837, 32640, 63, 2219, 1204, 10341, 51, 63, 2219, 9, 398, 3405, 63, 2219, 275, 663, 8, 4892, 63, 2219, 63, 513, 9, 446, 32147, 36, 63, 2219, 267, 3405, 63, 835, 63, 1130, 275, 1211, 7694, 84, 12, 413, 9, 367, 307, 315, 3405, 63, 2219, 566, 398, 511, 63, 27337, 275, 1052, 267, 284, 275, 378, 267, 367, 511, 315, 2295, 63, 409, 26, 288, 511, 63, 27337, 59, 396, 61, 275, 2069, 8, 277, 423, 1507, 63, 10802, 627, 2948, 435, 284, 9, 288, 284, 847, 413, 398, 511, 63, 2604, 63, 1130, 275, 1211, 342, 267, 367, 511, 315, 2295, 63, 409, 26, 288, 511, 63, 2604, 63, 1130, 59, 396, 61, 275, 2022, 63, 2604, 63, 4679, 14, 13120, 8, 396, 12, 355, 3405, 2687, 396, 315, 3405, 63, 2219, 395, 355, 14439, 63, 521, 29, 396, 63, 27337, 59, 396, 566, 398, 1591, 275, 4420, 4965, 342, 267, 1844, 275, 4420, 342, 267, 1844, 423, 11381, 275, 1591, 14, 11381, 267, 4306, 275, 2022, 63, 2604, 63, 4679, 14, 6243, 6579, 7599, 8, 719, 12, 288, 291, 14, 5649, 63, 354, 12, 291, 14, 1506, 63, 354, 12, 291, 14, 1506, 63, 1955, 12, 288, 3260, 288, 488, 12, 257, 327, 2793, 1133, 5267, 13541, 2022, 2058, 6359, 288, 511, 63, 2604, 63, 1130, 9, 398, 3405, 63, 835, 63, 1130, 275, 1211, 7694, 84, 12, 413, 9, 367, 307, 315, 3405, 63, 2219, 566, 398, 327, 1379, 16316, 2022, 2058, 267, 16316, 63, 1001, 275, 4306, 14, 362, 63, 1001, 342, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
pelya/commandergenius
project/jni/python/src/Lib/test/test_collections.py
48
18805
import unittest, doctest from test import test_support from collections import namedtuple import pickle, cPickle, copy from collections import Hashable, Iterable, Iterator from collections import Sized, Container, Callable from collections import Set, MutableSet from collections import Mapping, MutableMapping from collections import Sequence, MutableSequence TestNT = namedtuple('TestNT', 'x y z') # type used for pickle tests class TestNamedTuple(unittest.TestCase): def test_factory(self): Point = namedtuple('Point', 'x y') self.assertEqual(Point.__name__, 'Point') self.assertEqual(Point.__doc__, 'Point(x, y)') self.assertEqual(Point.__slots__, ()) self.assertEqual(Point.__module__, __name__) self.assertEqual(Point.__getitem__, tuple.__getitem__) self.assertEqual(Point._fields, ('x', 'y')) self.assertRaises(ValueError, namedtuple, 'abc%', 'efg ghi') # type has non-alpha char self.assertRaises(ValueError, namedtuple, 'class', 'efg ghi') # type has keyword self.assertRaises(ValueError, namedtuple, '9abc', 'efg ghi') # type starts with digit self.assertRaises(ValueError, namedtuple, 'abc', 'efg g%hi') # field with non-alpha char self.assertRaises(ValueError, namedtuple, 'abc', 'abc class') # field has keyword self.assertRaises(ValueError, namedtuple, 'abc', '8efg 9ghi') # field starts with digit self.assertRaises(ValueError, namedtuple, 'abc', '_efg ghi') # field with leading underscore self.assertRaises(ValueError, namedtuple, 'abc', 'efg efg ghi') # duplicate field namedtuple('Point0', 'x1 y2') # Verify that numbers are allowed in names namedtuple('_', 'a b c') # Test leading underscores in a typename nt = namedtuple('nt', u'the quick brown fox') # check unicode input self.assert_("u'" not in repr(nt._fields)) nt = namedtuple('nt', (u'the', u'quick')) # check unicode input self.assert_("u'" not in repr(nt._fields)) self.assertRaises(TypeError, Point._make, [11]) # catch too few args self.assertRaises(TypeError, Point._make, [11, 22, 33]) # catch too many args def test_instance(self): Point = namedtuple('Point', 'x y') p = Point(11, 22) self.assertEqual(p, Point(x=11, y=22)) self.assertEqual(p, Point(11, y=22)) self.assertEqual(p, Point(y=22, x=11)) self.assertEqual(p, Point(*(11, 22))) self.assertEqual(p, Point(**dict(x=11, y=22))) self.assertRaises(TypeError, Point, 1) # too few args self.assertRaises(TypeError, Point, 1, 2, 3) # too many args self.assertRaises(TypeError, eval, 'Point(XXX=1, y=2)', locals()) # wrong keyword argument self.assertRaises(TypeError, eval, 'Point(x=1)', locals()) # missing keyword argument self.assertEqual(repr(p), 'Point(x=11, y=22)') self.assert_('__dict__' not in dir(p)) # verify instance has no dict self.assert_('__weakref__' not in dir(p)) self.assertEqual(p, Point._make([11, 22])) # test _make classmethod self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method try: p._replace(x=1, error=2) except ValueError: pass else: self._fail('Did not detect an incorrect fieldname') # verify that field string can have commas Point = namedtuple('Point', 'x, y') p = Point(x=11, y=22) self.assertEqual(repr(p), 'Point(x=11, y=22)') # verify that fieldspec can be a non-string sequence Point = namedtuple('Point', ('x', 'y')) p = Point(x=11, y=22) self.assertEqual(repr(p), 'Point(x=11, y=22)') def test_tupleness(self): Point = namedtuple('Point', 'x y') p = Point(11, 22) self.assert_(isinstance(p, tuple)) self.assertEqual(p, (11, 22)) # matches a real tuple self.assertEqual(tuple(p), (11, 22)) # coercable to a real tuple self.assertEqual(list(p), [11, 22]) # coercable to a list self.assertEqual(max(p), 22) # iterable self.assertEqual(max(*p), 22) # star-able x, y = p self.assertEqual(p, (x, y)) # unpacks like a tuple self.assertEqual((p[0], p[1]), (11, 22)) # indexable like a tuple self.assertRaises(IndexError, p.__getitem__, 3) self.assertEqual(p.x, x) self.assertEqual(p.y, y) self.assertRaises(AttributeError, eval, 'p.z', locals()) def test_odd_sizes(self): Zero = namedtuple('Zero', '') self.assertEqual(Zero(), ()) self.assertEqual(Zero._make([]), ()) self.assertEqual(repr(Zero()), 'Zero()') self.assertEqual(Zero()._asdict(), {}) self.assertEqual(Zero()._fields, ()) Dot = namedtuple('Dot', 'd') self.assertEqual(Dot(1), (1,)) self.assertEqual(Dot._make([1]), (1,)) self.assertEqual(Dot(1).d, 1) self.assertEqual(repr(Dot(1)), 'Dot(d=1)') self.assertEqual(Dot(1)._asdict(), {'d':1}) self.assertEqual(Dot(1)._replace(d=999), (999,)) self.assertEqual(Dot(1)._fields, ('d',)) n = 5000 import string, random names = list(set(''.join([random.choice(string.ascii_letters) for j in range(10)]) for i in range(n))) n = len(names) Big = namedtuple('Big', names) b = Big(*range(n)) self.assertEqual(b, tuple(range(n))) self.assertEqual(Big._make(range(n)), tuple(range(n))) for pos, name in enumerate(names): self.assertEqual(getattr(b, name), pos) repr(b) # make sure repr() doesn't blow-up d = b._asdict() d_expected = dict(zip(names, range(n))) self.assertEqual(d, d_expected) b2 = b._replace(**dict([(names[1], 999),(names[-5], 42)])) b2_expected = range(n) b2_expected[1] = 999 b2_expected[-5] = 42 self.assertEqual(b2, tuple(b2_expected)) self.assertEqual(b._fields, tuple(names)) def test_pickle(self): p = TestNT(x=10, y=20, z=30) for module in pickle, cPickle: loads = getattr(module, 'loads') dumps = getattr(module, 'dumps') for protocol in -1, 0, 1, 2: q = loads(dumps(p, protocol)) self.assertEqual(p, q) self.assertEqual(p._fields, q._fields) def test_copy(self): p = TestNT(x=10, y=20, z=30) for copier in copy.copy, copy.deepcopy: q = copier(p) self.assertEqual(p, q) self.assertEqual(p._fields, q._fields) class ABCTestCase(unittest.TestCase): def validate_abstract_methods(self, abc, *names): methodstubs = dict.fromkeys(names, lambda s, *args: 0) # everything should work will all required methods are present C = type('C', (abc,), methodstubs) C() # instantiation should fail if a required method is missing for name in names: stubs = methodstubs.copy() del stubs[name] C = type('C', (abc,), stubs) self.assertRaises(TypeError, C, name) class TestOneTrickPonyABCs(ABCTestCase): def test_Hashable(self): # Check some non-hashables non_samples = [list(), set(), dict()] for x in non_samples: self.failIf(isinstance(x, Hashable), repr(x)) self.failIf(issubclass(type(x), Hashable), repr(type(x))) # Check some hashables samples = [None, int(), float(), complex(), str(), tuple(), frozenset(), int, list, object, type, ] for x in samples: self.failUnless(isinstance(x, Hashable), repr(x)) self.failUnless(issubclass(type(x), Hashable), repr(type(x))) self.assertRaises(TypeError, Hashable) # Check direct subclassing class H(Hashable): def __hash__(self): return super(H, self).__hash__() __eq__ = Hashable.__eq__ # Silence Py3k warning self.assertEqual(hash(H()), 0) self.failIf(issubclass(int, H)) self.validate_abstract_methods(Hashable, '__hash__') def test_Iterable(self): # Check some non-iterables non_samples = [None, 42, 3.14, 1j] for x in non_samples: self.failIf(isinstance(x, Iterable), repr(x)) self.failIf(issubclass(type(x), Iterable), repr(type(x))) # Check some iterables samples = [str(), tuple(), list(), set(), frozenset(), dict(), dict().keys(), dict().items(), dict().values(), (lambda: (yield))(), (x for x in []), ] for x in samples: self.failUnless(isinstance(x, Iterable), repr(x)) self.failUnless(issubclass(type(x), Iterable), repr(type(x))) # Check direct subclassing class I(Iterable): def __iter__(self): return super(I, self).__iter__() self.assertEqual(list(I()), []) self.failIf(issubclass(str, I)) self.validate_abstract_methods(Iterable, '__iter__') def test_Iterator(self): non_samples = [None, 42, 3.14, 1j, "".encode('ascii'), "", (), [], {}, set()] for x in non_samples: self.failIf(isinstance(x, Iterator), repr(x)) self.failIf(issubclass(type(x), Iterator), repr(type(x))) samples = [iter(str()), iter(tuple()), iter(list()), iter(dict()), iter(set()), iter(frozenset()), iter(dict().keys()), iter(dict().items()), iter(dict().values()), (lambda: (yield))(), (x for x in []), ] for x in samples: self.failUnless(isinstance(x, Iterator), repr(x)) self.failUnless(issubclass(type(x), Iterator), repr(type(x))) self.validate_abstract_methods(Iterator, 'next') def test_Sized(self): non_samples = [None, 42, 3.14, 1j, (lambda: (yield))(), (x for x in []), ] for x in non_samples: self.failIf(isinstance(x, Sized), repr(x)) self.failIf(issubclass(type(x), Sized), repr(type(x))) samples = [str(), tuple(), list(), set(), frozenset(), dict(), dict().keys(), dict().items(), dict().values(), ] for x in samples: self.failUnless(isinstance(x, Sized), repr(x)) self.failUnless(issubclass(type(x), Sized), repr(type(x))) self.validate_abstract_methods(Sized, '__len__') def test_Container(self): non_samples = [None, 42, 3.14, 1j, (lambda: (yield))(), (x for x in []), ] for x in non_samples: self.failIf(isinstance(x, Container), repr(x)) self.failIf(issubclass(type(x), Container), repr(type(x))) samples = [str(), tuple(), list(), set(), frozenset(), dict(), dict().keys(), dict().items(), ] for x in samples: self.failUnless(isinstance(x, Container), repr(x)) self.failUnless(issubclass(type(x), Container), repr(type(x))) self.validate_abstract_methods(Container, '__contains__') def test_Callable(self): non_samples = [None, 42, 3.14, 1j, "", "".encode('ascii'), (), [], {}, set(), (lambda: (yield))(), (x for x in []), ] for x in non_samples: self.failIf(isinstance(x, Callable), repr(x)) self.failIf(issubclass(type(x), Callable), repr(type(x))) samples = [lambda: None, type, int, object, len, list.append, [].append, ] for x in samples: self.failUnless(isinstance(x, Callable), repr(x)) self.failUnless(issubclass(type(x), Callable), repr(type(x))) self.validate_abstract_methods(Callable, '__call__') def test_direct_subclassing(self): for B in Hashable, Iterable, Iterator, Sized, Container, Callable: class C(B): pass self.failUnless(issubclass(C, B)) self.failIf(issubclass(int, C)) def test_registration(self): for B in Hashable, Iterable, Iterator, Sized, Container, Callable: class C: __metaclass__ = type __hash__ = None # Make sure it isn't hashable by default self.failIf(issubclass(C, B), B.__name__) B.register(C) self.failUnless(issubclass(C, B)) class WithSet(MutableSet): def __init__(self, it=()): self.data = set(it) def __len__(self): return len(self.data) def __iter__(self): return iter(self.data) def __contains__(self, item): return item in self.data def add(self, item): self.data.add(item) def discard(self, item): self.data.discard(item) class TestCollectionABCs(ABCTestCase): # XXX For now, we only test some virtual inheritance properties. # We should also test the proper behavior of the collection ABCs # as real base classes or mix-in classes. def test_Set(self): for sample in [set, frozenset]: self.failUnless(isinstance(sample(), Set)) self.failUnless(issubclass(sample, Set)) self.validate_abstract_methods(Set, '__contains__', '__iter__', '__len__') def test_hash_Set(self): class OneTwoThreeSet(Set): def __init__(self): self.contents = [1, 2, 3] def __contains__(self, x): return x in self.contents def __len__(self): return len(self.contents) def __iter__(self): return iter(self.contents) def __hash__(self): return self._hash() a, b = OneTwoThreeSet(), OneTwoThreeSet() self.failUnless(hash(a) == hash(b)) def test_MutableSet(self): self.failUnless(isinstance(set(), MutableSet)) self.failUnless(issubclass(set, MutableSet)) self.failIf(isinstance(frozenset(), MutableSet)) self.failIf(issubclass(frozenset, MutableSet)) self.validate_abstract_methods(MutableSet, '__contains__', '__iter__', '__len__', 'add', 'discard') def test_issue_5647(self): # MutableSet.__iand__ mutated the set during iteration s = WithSet('abcd') s &= WithSet('cdef') # This used to fail self.assertEqual(set(s), set('cd')) def test_issue_4920(self): # MutableSet.pop() method did not work class MySet(collections.MutableSet): __slots__=['__s'] def __init__(self,items=None): if items is None: items=[] self.__s=set(items) def __contains__(self,v): return v in self.__s def __iter__(self): return iter(self.__s) def __len__(self): return len(self.__s) def add(self,v): result=v not in self.__s self.__s.add(v) return result def discard(self,v): result=v in self.__s self.__s.discard(v) return result def __repr__(self): return "MySet(%s)" % repr(list(self)) s = MySet([5,43,2,1]) self.assertEqual(s.pop(), 1) def test_Mapping(self): for sample in [dict]: self.failUnless(isinstance(sample(), Mapping)) self.failUnless(issubclass(sample, Mapping)) self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__', '__getitem__') def test_MutableMapping(self): for sample in [dict]: self.failUnless(isinstance(sample(), MutableMapping)) self.failUnless(issubclass(sample, MutableMapping)) self.validate_abstract_methods(MutableMapping, '__contains__', '__iter__', '__len__', '__getitem__', '__setitem__', '__delitem__') def test_Sequence(self): for sample in [tuple, list, str]: self.failUnless(isinstance(sample(), Sequence)) self.failUnless(issubclass(sample, Sequence)) self.failUnless(issubclass(basestring, Sequence)) self.failUnless(isinstance(range(10), Sequence)) self.failUnless(issubclass(xrange, Sequence)) self.failUnless(issubclass(str, Sequence)) self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__', '__getitem__') def test_MutableSequence(self): for sample in [tuple, str]: self.failIf(isinstance(sample(), MutableSequence)) self.failIf(issubclass(sample, MutableSequence)) for sample in [list]: self.failUnless(isinstance(sample(), MutableSequence)) self.failUnless(issubclass(sample, MutableSequence)) self.failIf(issubclass(basestring, MutableSequence)) self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__', '__len__', '__getitem__', '__setitem__', '__delitem__', 'insert') import doctest, collections def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs] test_support.run_unittest(*test_classes) test_support.run_doctest(collections, verbose) if __name__ == "__main__": test_main(verbose=True)
lgpl-2.1
[ 646, 2882, 12, 8868, 199, 504, 511, 492, 511, 63, 4058, 199, 504, 5055, 492, 12863, 199, 646, 5927, 12, 17572, 12, 1331, 199, 504, 5055, 492, 16101, 461, 12, 19937, 12, 25769, 199, 504, 5055, 492, 428, 1759, 12, 15395, 12, 16975, 199, 504, 5055, 492, 2494, 12, 19610, 1084, 199, 504, 5055, 492, 12340, 12, 29396, 199, 504, 5055, 492, 10975, 12, 19610, 5826, 199, 199, 774, 12460, 275, 12863, 360, 774, 12460, 297, 283, 88, 612, 1315, 358, 259, 327, 730, 1202, 367, 5927, 2295, 199, 199, 533, 1379, 7989, 7075, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 3702, 8, 277, 304, 267, 7584, 275, 12863, 360, 3428, 297, 283, 88, 612, 358, 267, 291, 14, 629, 8, 3428, 855, 354, 3108, 283, 3428, 358, 267, 291, 14, 629, 8, 3428, 855, 1301, 3108, 283, 3428, 8, 88, 12, 612, 5942, 267, 291, 14, 629, 8, 3428, 855, 7257, 3108, 14515, 267, 291, 14, 629, 8, 3428, 855, 578, 3108, 636, 354, 3368, 267, 291, 14, 629, 8, 3428, 855, 6095, 3108, 2008, 855, 6095, 3368, 267, 291, 14, 629, 8, 3428, 423, 955, 12, 661, 88, 297, 283, 89, 1333, 398, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 28575, 283, 2829, 71, 486, 5812, 358, 755, 327, 730, 965, 2222, 13, 4468, 1495, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 533, 297, 283, 2829, 71, 486, 5812, 358, 420, 327, 730, 965, 4252, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 25, 3175, 297, 283, 2829, 71, 486, 5812, 358, 755, 327, 730, 9174, 543, 10964, 398, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 2829, 71, 486, 5, 5812, 358, 755, 327, 901, 543, 2222, 13, 4468, 1495, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 3175, 1021, 358, 420, 327, 901, 965, 4252, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 24, 2829, 71, 1749, 3561, 73, 358, 420, 327, 901, 9174, 543, 10964, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 2513, 2829, 71, 486, 5812, 358, 755, 327, 901, 543, 9186, 18888, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 2829, 71, 9530, 71, 486, 5812, 358, 259, 327, 9250, 901, 398, 12863, 360, 3428, 16, 297, 283, 88, 17, 612, 18, 358, 257, 327, 7635, 626, 5579, 787, 4370, 315, 1561, 267, 12863, 20928, 283, 65, 330, 286, 358, 263, 327, 1379, 9186, 23998, 315, 282, 19151, 398, 13377, 275, 12863, 360, 343, 297, 399, 1133, 426, 12530, 330, 18406, 7090, 88, 358, 9668, 327, 1104, 2649, 1324, 267, 291, 14, 479, 14332, 85, 4065, 440, 315, 4700, 8, 343, 423, 955, 430, 267, 13377, 275, 12863, 360, 343, 297, 334, 85, 1133, 426, 297, 399, 7, 13239, 1333, 13235, 327, 1104, 2649, 1324, 267, 291, 14, 479, 14332, 85, 4065, 440, 315, 4700, 8, 343, 423, 955, 430, 398, 291, 14, 1855, 8, 4333, 12, 7584, 423, 1875, 12, 359, 845, 566, 9326, 327, 8579, 4634, 9284, 1249, 267, 291, 14, 1855, 8, 4333, 12, 7584, 423, 1875, 12, 359, 845, 12, 6928, 12, 9404, 566, 3777, 327, 8579, 4634, 5002, 1249, 339, 347, 511, 63, 842, 8, 277, 304, 267, 7584, 275, 12863, 360, 3428, 297, 283, 88, 612, 358, 267, 299, 275, 7584, 8, 845, 12, 6928, 9, 267, 291, 14, 629, 8, 80, 12, 7584, 8, 88, 29, 845, 12, 612, 29, 1081, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 8, 845, 12, 612, 29, 1081, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 8, 89, 29, 1081, 12, 671, 29, 845, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 29316, 845, 12, 6928, 1724, 267, 291, 14, 629, 8, 80, 12, 7584, 3682, 807, 8, 88, 29, 845, 12, 612, 29, 1081, 1724, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 413, 9, 19242, 327, 4634, 9284, 1249, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 413, 12, 499, 12, 650, 9, 12788, 327, 4634, 5002, 1249, 267, 291, 14, 1855, 8, 4333, 12, 3468, 12, 283, 3428, 8, 13933, 29, 17, 12, 612, 29, 18, 3196, 9480, 1012, 257, 327, 6835, 4252, 1423, 267, 291, 14, 1855, 8, 4333, 12, 3468, 12, 283, 3428, 8, 88, 29, 17, 3196, 9480, 1012, 3515, 327, 4124, 4252, 1423, 267, 291, 14, 629, 8, 2722, 8, 80, 395, 283, 3428, 8, 88, 29, 845, 12, 612, 29, 1081, 5942, 267, 291, 14, 479, 63, 10714, 807, 12217, 440, 315, 2935, 8, 80, 430, 19242, 327, 4911, 1256, 965, 949, 1211, 267, 291, 14, 479, 63, 10714, 21330, 12217, 440, 315, 2935, 8, 80, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 423, 1875, 779, 845, 12, 6928, 2459, 14516, 327, 511, 485, 1875, 18990, 267, 291, 14, 629, 8, 80, 423, 955, 12, 661, 88, 297, 283, 89, 1333, 17907, 327, 511, 485, 955, 2225, 267, 291, 14, 629, 8, 80, 423, 1814, 8, 88, 29, 17, 395, 334, 17, 12, 6928, 430, 14516, 327, 511, 485, 1814, 1083, 267, 291, 14, 629, 8, 80, 423, 305, 807, 1062, 1211, 8, 88, 29, 845, 12, 612, 29, 1081, 430, 9326, 327, 511, 485, 305, 807, 1083, 398, 862, 26, 288, 299, 423, 1814, 8, 88, 29, 17, 12, 1125, 29, 18, 9, 267, 871, 1722, 26, 288, 986, 267, 587, 26, 288, 291, 423, 1633, 360, 17366, 440, 9696, 376, 8927, 18887, 358, 398, 327, 4911, 626, 901, 1059, 883, 1172, 24476, 267, 7584, 275, 12863, 360, 3428, 297, 283, 88, 12, 612, 358, 267, 299, 275, 7584, 8, 88, 29, 845, 12, 612, 29, 1081, 9, 267, 291, 14, 629, 8, 2722, 8, 80, 395, 283, 3428, 8, 88, 29, 845, 12, 612, 29, 1081, 5942, 398, 327, 4911, 626, 1504, 733, 883, 506, 282, 2222, 13, 875, 3414, 267, 7584, 275, 12863, 360, 3428, 297, 661, 88, 297, 283, 89, 1333, 267, 299, 275, 7584, 8, 88, 29, 845, 12, 612, 29, 1081, 9, 267, 291, 14, 629, 8, 2722 ]
[ 2882, 12, 8868, 199, 504, 511, 492, 511, 63, 4058, 199, 504, 5055, 492, 12863, 199, 646, 5927, 12, 17572, 12, 1331, 199, 504, 5055, 492, 16101, 461, 12, 19937, 12, 25769, 199, 504, 5055, 492, 428, 1759, 12, 15395, 12, 16975, 199, 504, 5055, 492, 2494, 12, 19610, 1084, 199, 504, 5055, 492, 12340, 12, 29396, 199, 504, 5055, 492, 10975, 12, 19610, 5826, 199, 199, 774, 12460, 275, 12863, 360, 774, 12460, 297, 283, 88, 612, 1315, 358, 259, 327, 730, 1202, 367, 5927, 2295, 199, 199, 533, 1379, 7989, 7075, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 3702, 8, 277, 304, 267, 7584, 275, 12863, 360, 3428, 297, 283, 88, 612, 358, 267, 291, 14, 629, 8, 3428, 855, 354, 3108, 283, 3428, 358, 267, 291, 14, 629, 8, 3428, 855, 1301, 3108, 283, 3428, 8, 88, 12, 612, 5942, 267, 291, 14, 629, 8, 3428, 855, 7257, 3108, 14515, 267, 291, 14, 629, 8, 3428, 855, 578, 3108, 636, 354, 3368, 267, 291, 14, 629, 8, 3428, 855, 6095, 3108, 2008, 855, 6095, 3368, 267, 291, 14, 629, 8, 3428, 423, 955, 12, 661, 88, 297, 283, 89, 1333, 398, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 28575, 283, 2829, 71, 486, 5812, 358, 755, 327, 730, 965, 2222, 13, 4468, 1495, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 533, 297, 283, 2829, 71, 486, 5812, 358, 420, 327, 730, 965, 4252, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 25, 3175, 297, 283, 2829, 71, 486, 5812, 358, 755, 327, 730, 9174, 543, 10964, 398, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 2829, 71, 486, 5, 5812, 358, 755, 327, 901, 543, 2222, 13, 4468, 1495, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 3175, 1021, 358, 420, 327, 901, 965, 4252, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 24, 2829, 71, 1749, 3561, 73, 358, 420, 327, 901, 9174, 543, 10964, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 2513, 2829, 71, 486, 5812, 358, 755, 327, 901, 543, 9186, 18888, 267, 291, 14, 1855, 8, 3393, 12, 12863, 12, 283, 3175, 297, 283, 2829, 71, 9530, 71, 486, 5812, 358, 259, 327, 9250, 901, 398, 12863, 360, 3428, 16, 297, 283, 88, 17, 612, 18, 358, 257, 327, 7635, 626, 5579, 787, 4370, 315, 1561, 267, 12863, 20928, 283, 65, 330, 286, 358, 263, 327, 1379, 9186, 23998, 315, 282, 19151, 398, 13377, 275, 12863, 360, 343, 297, 399, 1133, 426, 12530, 330, 18406, 7090, 88, 358, 9668, 327, 1104, 2649, 1324, 267, 291, 14, 479, 14332, 85, 4065, 440, 315, 4700, 8, 343, 423, 955, 430, 267, 13377, 275, 12863, 360, 343, 297, 334, 85, 1133, 426, 297, 399, 7, 13239, 1333, 13235, 327, 1104, 2649, 1324, 267, 291, 14, 479, 14332, 85, 4065, 440, 315, 4700, 8, 343, 423, 955, 430, 398, 291, 14, 1855, 8, 4333, 12, 7584, 423, 1875, 12, 359, 845, 566, 9326, 327, 8579, 4634, 9284, 1249, 267, 291, 14, 1855, 8, 4333, 12, 7584, 423, 1875, 12, 359, 845, 12, 6928, 12, 9404, 566, 3777, 327, 8579, 4634, 5002, 1249, 339, 347, 511, 63, 842, 8, 277, 304, 267, 7584, 275, 12863, 360, 3428, 297, 283, 88, 612, 358, 267, 299, 275, 7584, 8, 845, 12, 6928, 9, 267, 291, 14, 629, 8, 80, 12, 7584, 8, 88, 29, 845, 12, 612, 29, 1081, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 8, 845, 12, 612, 29, 1081, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 8, 89, 29, 1081, 12, 671, 29, 845, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 29316, 845, 12, 6928, 1724, 267, 291, 14, 629, 8, 80, 12, 7584, 3682, 807, 8, 88, 29, 845, 12, 612, 29, 1081, 1724, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 413, 9, 19242, 327, 4634, 9284, 1249, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 413, 12, 499, 12, 650, 9, 12788, 327, 4634, 5002, 1249, 267, 291, 14, 1855, 8, 4333, 12, 3468, 12, 283, 3428, 8, 13933, 29, 17, 12, 612, 29, 18, 3196, 9480, 1012, 257, 327, 6835, 4252, 1423, 267, 291, 14, 1855, 8, 4333, 12, 3468, 12, 283, 3428, 8, 88, 29, 17, 3196, 9480, 1012, 3515, 327, 4124, 4252, 1423, 267, 291, 14, 629, 8, 2722, 8, 80, 395, 283, 3428, 8, 88, 29, 845, 12, 612, 29, 1081, 5942, 267, 291, 14, 479, 63, 10714, 807, 12217, 440, 315, 2935, 8, 80, 430, 19242, 327, 4911, 1256, 965, 949, 1211, 267, 291, 14, 479, 63, 10714, 21330, 12217, 440, 315, 2935, 8, 80, 430, 267, 291, 14, 629, 8, 80, 12, 7584, 423, 1875, 779, 845, 12, 6928, 2459, 14516, 327, 511, 485, 1875, 18990, 267, 291, 14, 629, 8, 80, 423, 955, 12, 661, 88, 297, 283, 89, 1333, 17907, 327, 511, 485, 955, 2225, 267, 291, 14, 629, 8, 80, 423, 1814, 8, 88, 29, 17, 395, 334, 17, 12, 6928, 430, 14516, 327, 511, 485, 1814, 1083, 267, 291, 14, 629, 8, 80, 423, 305, 807, 1062, 1211, 8, 88, 29, 845, 12, 612, 29, 1081, 430, 9326, 327, 511, 485, 305, 807, 1083, 398, 862, 26, 288, 299, 423, 1814, 8, 88, 29, 17, 12, 1125, 29, 18, 9, 267, 871, 1722, 26, 288, 986, 267, 587, 26, 288, 291, 423, 1633, 360, 17366, 440, 9696, 376, 8927, 18887, 358, 398, 327, 4911, 626, 901, 1059, 883, 1172, 24476, 267, 7584, 275, 12863, 360, 3428, 297, 283, 88, 12, 612, 358, 267, 299, 275, 7584, 8, 88, 29, 845, 12, 612, 29, 1081, 9, 267, 291, 14, 629, 8, 2722, 8, 80, 395, 283, 3428, 8, 88, 29, 845, 12, 612, 29, 1081, 5942, 398, 327, 4911, 626, 1504, 733, 883, 506, 282, 2222, 13, 875, 3414, 267, 7584, 275, 12863, 360, 3428, 297, 661, 88, 297, 283, 89, 1333, 267, 299, 275, 7584, 8, 88, 29, 845, 12, 612, 29, 1081, 9, 267, 291, 14, 629, 8, 2722, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
manhg/tokit
tokit/postgres.py
1
4462
import logging import shortuuid import uuid import momoko import momoko.exceptions import psycopg2 from psycopg2.extras import DictCursor, DictRow, register_uuid import psycopg2.extensions from tornado.gen import coroutine, sleep from tornado.web import HTTPError import tokit logger = tokit.logger class DictLogCursor(DictCursor): def execute(self, sql, args=None): logger.debug('Excute SQL: %s', self.mogrify(sql, args).decode()) return super().execute(sql, args) @tokit.on('init') def pg_init(app): """ Hook to init Postgres momoko driver. dsn config is required, with syntax same as Psycopg2 DSN. Sample env.ini:: [postgres] dsn=dbname=[APP_NAME] size=2 """ env = app.config.env['postgres'] if env.getboolean('log_momoko'): logging.getLogger('momoko').setLevel(logger.getEffectiveLevel()) momoko_opts = dict( dsn=env['dsn'], size=int(env['size']), max_size=int(env['max_size']), auto_shrink=env.getboolean('auto_shrink'), cursor_factory=(DictLogCursor if env.getboolean('log') else DictCursor), # connection_factory=env.get('connection_factory', None), ) register_uuid() app.pg_db = momoko.Pool(**momoko_opts) try: app.pg_db.connect() except momoko.PartiallyConnectedError: logger.error('Cannot connect') class PgMixin: DbIntegrityError = psycopg2.IntegrityError DbError = psycopg2.Error @property def db(self): return self.application.pg_db @coroutine def pg_insert(self, table, fields=None, **data): """ Postgres shorcut to insert data :return int new row's id Example:: user_id = yield self.pg_insert('users', {"username": "foo", "password": "secret"}) """ if fields: data = self.get_request_dict(*fields) else: fields = list(data.keys()) assert len(data) > 0 # check data values = list(data.values()) sql = 'INSERT INTO {} ({}) VALUES ({}) RETURNING id ' \ .format(table, ','.join(fields), ','.join(['%s'] * len(fields)) ) cursor = yield self.pg_query(sql, *values) return cursor.fetchone()[0] @coroutine def pg_getconn(self): try: connection = yield self.db.getconn() return connection except psycopg2.OperationalError: yield self.db.connect() yield sleep(0.5) try: connection = yield self.db.getconn() return connection except: raise HTTPError(503, "Database unavailable") except (momoko.Pool.DatabaseNotAvailable, momoko.exceptions.PartiallyConnectedError): raise HTTPError(503, "Database unavailable") @coroutine def pg_update(self, table, data): id_value = data.pop('id') changes = [field + ' = %s' for field in data.keys()] sql = 'UPDATE {} SET {} WHERE id = %s'.format(table, ','.join(changes)) values = list(data.values()) + [id_value] cursor = yield self.pg_query(sql, *values) return cursor @coroutine def pg_query(self, query, *params): """ Low level execuation """ connection = yield self.pg_getconn() with self.db.manage(connection): cursor = yield connection.execute(query, params) return cursor def pg_serialize(self, row): if not row: return ret = dict(row) if isinstance(row, DictRow) else row return ret @coroutine def pg_select(self, query, *params): """ Query and convert each returned row :return generator """ result = yield self.pg_query(query, *params) return (self.pg_serialize(row) for row in result.fetchall()) @coroutine def pg_one(self, query, *params): result = yield self.pg_query(query, *params) row = result.fetchone() if row: return self.pg_serialize(row) db_insert = pg_insert db_update = pg_update db_query = pg_query db_select = pg_select db_one = pg_one class UidMixin: def pg_serialize(self, row): ret = PgMixin.pg_serialize(self, row) if 'id' in ret: ret['short_id'] = shortuuid.encode(ret['id']) return ret
mit
[ 646, 2050, 199, 646, 3974, 2580, 199, 646, 5377, 199, 199, 646, 1303, 573, 7697, 199, 646, 1303, 573, 7697, 14, 3924, 199, 646, 15492, 18, 199, 504, 15492, 18, 14, 9975, 492, 7448, 8993, 12, 7448, 5810, 12, 2274, 63, 2580, 199, 646, 15492, 18, 14, 5359, 199, 199, 504, 12148, 14, 2268, 492, 1970, 13242, 12, 9435, 199, 504, 12148, 14, 2520, 492, 15050, 199, 646, 370, 6065, 199, 199, 2921, 275, 370, 6065, 14, 2921, 421, 199, 533, 7448, 2445, 8993, 8, 2141, 8993, 304, 339, 347, 5341, 8, 277, 12, 3875, 12, 1249, 29, 403, 304, 267, 2512, 14, 1757, 360, 20702, 938, 5385, 26, 450, 83, 297, 291, 14, 573, 7928, 1399, 8, 3009, 12, 1249, 680, 2708, 1012, 267, 372, 1613, 1252, 2526, 8, 3009, 12, 1249, 9, 421, 199, 32, 475, 6065, 14, 265, 360, 826, 358, 199, 318, 10275, 63, 826, 8, 571, 304, 272, 408, 24837, 370, 4205, 7711, 7266, 1303, 573, 7697, 5253, 14, 272, 366, 5167, 1101, 365, 1415, 12, 543, 6302, 2011, 465, 510, 1786, 11476, 18, 577, 8199, 14, 339, 15227, 2589, 14, 2730, 447, 398, 359, 10675, 61, 267, 366, 5167, 29, 13238, 1524, 7121, 63, 2339, 61, 267, 1568, 29, 18, 272, 408, 272, 2589, 275, 1145, 14, 888, 14, 1813, 459, 10675, 418, 272, 340, 2589, 14, 30356, 360, 793, 63, 573, 573, 7697, 735, 267, 2050, 14, 5572, 360, 573, 573, 7697, 1959, 13548, 8, 2921, 14, 362, 30754, 4670, 1012, 272, 1303, 573, 7697, 63, 3291, 275, 1211, 8, 267, 366, 5167, 29, 1813, 459, 32510, 995, 267, 1568, 29, 442, 8, 1813, 459, 890, 3815, 267, 1390, 63, 890, 29, 442, 8, 1813, 459, 988, 63, 890, 3815, 267, 2599, 63, 23733, 29, 1813, 14, 30356, 360, 2495, 63, 23733, 659, 267, 3920, 63, 3702, 2687, 2141, 2445, 8993, 340, 2589, 14, 30356, 360, 793, 358, 587, 7448, 8993, 395, 267, 327, 1950, 63, 3702, 29, 1813, 14, 362, 360, 2105, 63, 3702, 297, 488, 395, 272, 776, 272, 2274, 63, 2580, 342, 272, 1145, 14, 4198, 63, 697, 275, 1303, 573, 7697, 14, 5453, 3682, 573, 573, 7697, 63, 3291, 9, 272, 862, 26, 267, 1145, 14, 4198, 63, 697, 14, 2242, 342, 272, 871, 1303, 573, 7697, 14, 1262, 9406, 16382, 547, 26, 267, 2512, 14, 705, 360, 6612, 4907, 358, 421, 199, 533, 510, 71, 4256, 26, 339, 28822, 24823, 275, 15492, 18, 14, 24823, 272, 28822, 547, 275, 15492, 18, 14, 547, 339, 768, 1829, 272, 347, 1592, 8, 277, 304, 267, 372, 291, 14, 3578, 14, 4198, 63, 697, 339, 768, 16675, 272, 347, 10275, 63, 3176, 8, 277, 12, 1817, 12, 1504, 29, 403, 12, 1011, 576, 304, 267, 408, 267, 7711, 7266, 17068, 5919, 370, 5518, 666, 267, 520, 1107, 1109, 892, 1962, 1159, 1305, 398, 5679, 447, 953, 922, 63, 344, 275, 1995, 291, 14, 4198, 63, 3176, 360, 3707, 297, 2420, 2473, 582, 298, 1421, 401, 298, 2060, 582, 298, 4731, 5984, 267, 408, 267, 340, 1504, 26, 288, 666, 275, 291, 14, 362, 63, 1069, 63, 807, 2031, 955, 9, 267, 587, 26, 288, 1504, 275, 769, 8, 576, 14, 1612, 1012, 267, 702, 822, 8, 576, 9, 690, 378, 221, 327, 1104, 666, 267, 1338, 275, 769, 8, 576, 14, 1459, 1012, 398, 3875, 275, 283, 10258, 12872, 1052, 11459, 1552, 13992, 11459, 1552, 17409, 1230, 6024, 1305, 283, 971, 288, 1275, 908, 8, 1224, 12, 490, 12814, 904, 8, 955, 395, 490, 12814, 904, 26861, 83, 418, 627, 822, 8, 955, 430, 490, 776, 267, 3920, 275, 1995, 291, 14, 4198, 63, 1131, 8, 3009, 12, 627, 1459, 9, 267, 372, 3920, 14, 11591, 3430, 16, 61, 339, 768, 16675, 272, 347, 10275, 63, 362, 1631, 8, 277, 304, 267, 862, 26, 288, 1950, 275, 1995, 291, 14, 697, 14, 362, 1631, 342, 288, 372, 1950, 267, 871, 15492, 18, 14, 31998, 547, 26, 288, 1995, 291, 14, 697, 14, 2242, 342, 288, 1995, 9435, 8, 16, 14, 21, 9, 288, 862, 26, 355, 1950, 275, 1995, 291, 14, 697, 14, 362, 1631, 342, 355, 372, 1950, 288, 871, 26, 355, 746, 15050, 8, 15773, 12, 298, 7243, 18735, 531, 267, 871, 334, 573, 573, 7697, 14, 5453, 14, 7243, 1763, 11464, 12, 1303, 573, 7697, 14, 3924, 14, 1262, 9406, 16382, 547, 304, 288, 746, 15050, 8, 15773, 12, 298, 7243, 18735, 531, 339, 768, 16675, 272, 347, 10275, 63, 873, 8, 277, 12, 1817, 12, 666, 304, 267, 1305, 63, 585, 275, 666, 14, 1935, 360, 344, 358, 267, 4493, 275, 359, 698, 435, 283, 275, 450, 83, 7, 367, 901, 315, 666, 14, 1612, 5106, 267, 3875, 275, 283, 10383, 1052, 11543, 1052, 6038, 1305, 275, 450, 83, 1370, 908, 8, 1224, 12, 12814, 904, 8, 6627, 430, 267, 1338, 275, 769, 8, 576, 14, 1459, 1012, 435, 359, 344, 63, 585, 61, 267, 3920, 275, 1995, 291, 14, 4198, 63, 1131, 8, 3009, 12, 627, 1459, 9, 267, 372, 3920, 339, 768, 16675, 272, 347, 10275, 63, 1131, 8, 277, 12, 1827, 12, 627, 1162, 304, 267, 408, 21766, 2166, 2146, 4086, 408, 267, 1950, 275, 1995, 291, 14, 4198, 63, 362, 1631, 342, 267, 543, 291, 14, 697, 14, 9053, 8, 2105, 304, 288, 3920, 275, 1995, 1950, 14, 2526, 8, 1131, 12, 1862, 9, 288, 372, 3920, 339, 347, 10275, 63, 3549, 8, 277, 12, 1962, 304, 267, 340, 440, 1962, 26, 288, 372, 267, 2203, 275, 1211, 8, 1143, 9, 340, 1228, 8, 1143, 12, 7448, 5810, 9, 587, 1962, 267, 372, 2203, 339, 768, 16675, 272, 347, 10275, 63, 2416, 8, 277, 12, 1827, 12, 627, 1162, 304, 267, 408, 267, 8133, 436, 3957, 1924, 2138, 1962, 398, 520, 1107, 4306, 267, 408, 267, 754, 275, 1995, 291, 14, 4198, 63, 1131, 8, 1131, 12, 627, 1162, 9, 267, 372, 334, 277, 14, 4198, 63, 3549, 8, 1143, 9, 367, 1962, 315, 754, 14, 10174, 1012, 339, 768, 16675, 272, 347, 10275, 63, 368, 8, 277, 12, 1827, 12, 627, 1162, 304, 267, 754, 275, 1995, 291, 14, 4198, 63, 1131, 8, 1131, 12, 627 ]
[ 2050, 199, 646, 3974, 2580, 199, 646, 5377, 199, 199, 646, 1303, 573, 7697, 199, 646, 1303, 573, 7697, 14, 3924, 199, 646, 15492, 18, 199, 504, 15492, 18, 14, 9975, 492, 7448, 8993, 12, 7448, 5810, 12, 2274, 63, 2580, 199, 646, 15492, 18, 14, 5359, 199, 199, 504, 12148, 14, 2268, 492, 1970, 13242, 12, 9435, 199, 504, 12148, 14, 2520, 492, 15050, 199, 646, 370, 6065, 199, 199, 2921, 275, 370, 6065, 14, 2921, 421, 199, 533, 7448, 2445, 8993, 8, 2141, 8993, 304, 339, 347, 5341, 8, 277, 12, 3875, 12, 1249, 29, 403, 304, 267, 2512, 14, 1757, 360, 20702, 938, 5385, 26, 450, 83, 297, 291, 14, 573, 7928, 1399, 8, 3009, 12, 1249, 680, 2708, 1012, 267, 372, 1613, 1252, 2526, 8, 3009, 12, 1249, 9, 421, 199, 32, 475, 6065, 14, 265, 360, 826, 358, 199, 318, 10275, 63, 826, 8, 571, 304, 272, 408, 24837, 370, 4205, 7711, 7266, 1303, 573, 7697, 5253, 14, 272, 366, 5167, 1101, 365, 1415, 12, 543, 6302, 2011, 465, 510, 1786, 11476, 18, 577, 8199, 14, 339, 15227, 2589, 14, 2730, 447, 398, 359, 10675, 61, 267, 366, 5167, 29, 13238, 1524, 7121, 63, 2339, 61, 267, 1568, 29, 18, 272, 408, 272, 2589, 275, 1145, 14, 888, 14, 1813, 459, 10675, 418, 272, 340, 2589, 14, 30356, 360, 793, 63, 573, 573, 7697, 735, 267, 2050, 14, 5572, 360, 573, 573, 7697, 1959, 13548, 8, 2921, 14, 362, 30754, 4670, 1012, 272, 1303, 573, 7697, 63, 3291, 275, 1211, 8, 267, 366, 5167, 29, 1813, 459, 32510, 995, 267, 1568, 29, 442, 8, 1813, 459, 890, 3815, 267, 1390, 63, 890, 29, 442, 8, 1813, 459, 988, 63, 890, 3815, 267, 2599, 63, 23733, 29, 1813, 14, 30356, 360, 2495, 63, 23733, 659, 267, 3920, 63, 3702, 2687, 2141, 2445, 8993, 340, 2589, 14, 30356, 360, 793, 358, 587, 7448, 8993, 395, 267, 327, 1950, 63, 3702, 29, 1813, 14, 362, 360, 2105, 63, 3702, 297, 488, 395, 272, 776, 272, 2274, 63, 2580, 342, 272, 1145, 14, 4198, 63, 697, 275, 1303, 573, 7697, 14, 5453, 3682, 573, 573, 7697, 63, 3291, 9, 272, 862, 26, 267, 1145, 14, 4198, 63, 697, 14, 2242, 342, 272, 871, 1303, 573, 7697, 14, 1262, 9406, 16382, 547, 26, 267, 2512, 14, 705, 360, 6612, 4907, 358, 421, 199, 533, 510, 71, 4256, 26, 339, 28822, 24823, 275, 15492, 18, 14, 24823, 272, 28822, 547, 275, 15492, 18, 14, 547, 339, 768, 1829, 272, 347, 1592, 8, 277, 304, 267, 372, 291, 14, 3578, 14, 4198, 63, 697, 339, 768, 16675, 272, 347, 10275, 63, 3176, 8, 277, 12, 1817, 12, 1504, 29, 403, 12, 1011, 576, 304, 267, 408, 267, 7711, 7266, 17068, 5919, 370, 5518, 666, 267, 520, 1107, 1109, 892, 1962, 1159, 1305, 398, 5679, 447, 953, 922, 63, 344, 275, 1995, 291, 14, 4198, 63, 3176, 360, 3707, 297, 2420, 2473, 582, 298, 1421, 401, 298, 2060, 582, 298, 4731, 5984, 267, 408, 267, 340, 1504, 26, 288, 666, 275, 291, 14, 362, 63, 1069, 63, 807, 2031, 955, 9, 267, 587, 26, 288, 1504, 275, 769, 8, 576, 14, 1612, 1012, 267, 702, 822, 8, 576, 9, 690, 378, 221, 327, 1104, 666, 267, 1338, 275, 769, 8, 576, 14, 1459, 1012, 398, 3875, 275, 283, 10258, 12872, 1052, 11459, 1552, 13992, 11459, 1552, 17409, 1230, 6024, 1305, 283, 971, 288, 1275, 908, 8, 1224, 12, 490, 12814, 904, 8, 955, 395, 490, 12814, 904, 26861, 83, 418, 627, 822, 8, 955, 430, 490, 776, 267, 3920, 275, 1995, 291, 14, 4198, 63, 1131, 8, 3009, 12, 627, 1459, 9, 267, 372, 3920, 14, 11591, 3430, 16, 61, 339, 768, 16675, 272, 347, 10275, 63, 362, 1631, 8, 277, 304, 267, 862, 26, 288, 1950, 275, 1995, 291, 14, 697, 14, 362, 1631, 342, 288, 372, 1950, 267, 871, 15492, 18, 14, 31998, 547, 26, 288, 1995, 291, 14, 697, 14, 2242, 342, 288, 1995, 9435, 8, 16, 14, 21, 9, 288, 862, 26, 355, 1950, 275, 1995, 291, 14, 697, 14, 362, 1631, 342, 355, 372, 1950, 288, 871, 26, 355, 746, 15050, 8, 15773, 12, 298, 7243, 18735, 531, 267, 871, 334, 573, 573, 7697, 14, 5453, 14, 7243, 1763, 11464, 12, 1303, 573, 7697, 14, 3924, 14, 1262, 9406, 16382, 547, 304, 288, 746, 15050, 8, 15773, 12, 298, 7243, 18735, 531, 339, 768, 16675, 272, 347, 10275, 63, 873, 8, 277, 12, 1817, 12, 666, 304, 267, 1305, 63, 585, 275, 666, 14, 1935, 360, 344, 358, 267, 4493, 275, 359, 698, 435, 283, 275, 450, 83, 7, 367, 901, 315, 666, 14, 1612, 5106, 267, 3875, 275, 283, 10383, 1052, 11543, 1052, 6038, 1305, 275, 450, 83, 1370, 908, 8, 1224, 12, 12814, 904, 8, 6627, 430, 267, 1338, 275, 769, 8, 576, 14, 1459, 1012, 435, 359, 344, 63, 585, 61, 267, 3920, 275, 1995, 291, 14, 4198, 63, 1131, 8, 3009, 12, 627, 1459, 9, 267, 372, 3920, 339, 768, 16675, 272, 347, 10275, 63, 1131, 8, 277, 12, 1827, 12, 627, 1162, 304, 267, 408, 21766, 2166, 2146, 4086, 408, 267, 1950, 275, 1995, 291, 14, 4198, 63, 362, 1631, 342, 267, 543, 291, 14, 697, 14, 9053, 8, 2105, 304, 288, 3920, 275, 1995, 1950, 14, 2526, 8, 1131, 12, 1862, 9, 288, 372, 3920, 339, 347, 10275, 63, 3549, 8, 277, 12, 1962, 304, 267, 340, 440, 1962, 26, 288, 372, 267, 2203, 275, 1211, 8, 1143, 9, 340, 1228, 8, 1143, 12, 7448, 5810, 9, 587, 1962, 267, 372, 2203, 339, 768, 16675, 272, 347, 10275, 63, 2416, 8, 277, 12, 1827, 12, 627, 1162, 304, 267, 408, 267, 8133, 436, 3957, 1924, 2138, 1962, 398, 520, 1107, 4306, 267, 408, 267, 754, 275, 1995, 291, 14, 4198, 63, 1131, 8, 1131, 12, 627, 1162, 9, 267, 372, 334, 277, 14, 4198, 63, 3549, 8, 1143, 9, 367, 1962, 315, 754, 14, 10174, 1012, 339, 768, 16675, 272, 347, 10275, 63, 368, 8, 277, 12, 1827, 12, 627, 1162, 304, 267, 754, 275, 1995, 291, 14, 4198, 63, 1131, 8, 1131, 12, 627, 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, 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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 ]
mccheung/kbengine
kbe/src/lib/python/Lib/dbm/dumb.py
72
10539
"""A dumb and slow but simple dbm clone. For database spam, spam.dir contains the index (a text file), spam.bak *may* contain a backup of the index (also a text file), while spam.dat contains the data (a binary file). XXX TO DO: - seems to contain a bug when updating... - reclaim free space (currently, space once occupied by deleted or expanded items is never reused) - support concurrent access (currently, if two processes take turns making updates, they can mess up the index) - support efficient access to large databases (currently, the whole index is read when the database is opened, and some updates rewrite the whole index) - support opening for read-only (flag = 'm') """ import io as _io import os as _os import collections __all__ = ["error", "open"] _BLOCKSIZE = 512 error = OSError class _Database(collections.MutableMapping): # The on-disk directory and data files can remain in mutually # inconsistent states for an arbitrarily long time (see comments # at the end of __setitem__). This is only repaired when _commit() # gets called. One place _commit() gets called is from __del__(), # and if that occurs at program shutdown time, module globals may # already have gotten rebound to None. Since it's crucial that # _commit() finish successfully, we can't ignore shutdown races # here, and _commit() must not reference any globals. _os = _os # for _commit() _io = _io # for _commit() def __init__(self, filebasename, mode): self._mode = mode # The directory file is a text file. Each line looks like # "%r, (%d, %d)\n" % (key, pos, siz) # where key is the string key, pos is the offset into the dat # file of the associated value's first byte, and siz is the number # of bytes in the associated value. self._dirfile = filebasename + '.dir' # The data file is a binary file pointed into by the directory # file, and holds the values associated with keys. Each value # begins at a _BLOCKSIZE-aligned byte offset, and is a raw # binary 8-bit string value. self._datfile = filebasename + '.dat' self._bakfile = filebasename + '.bak' # The index is an in-memory dict, mirroring the directory file. self._index = None # maps keys to (pos, siz) pairs # Mod by Jack: create data file if needed try: f = _io.open(self._datfile, 'r', encoding="Latin-1") except OSError: with _io.open(self._datfile, 'w', encoding="Latin-1") as f: self._chmod(self._datfile) else: f.close() self._update() # Read directory file into the in-memory index dict. def _update(self): self._index = {} try: f = _io.open(self._dirfile, 'r', encoding="Latin-1") except OSError: pass else: with f: for line in f: line = line.rstrip() key, pos_and_siz_pair = eval(line) key = key.encode('Latin-1') self._index[key] = pos_and_siz_pair # Write the index dict to the directory file. The original directory # file (if any) is renamed with a .bak extension first. If a .bak # file currently exists, it's deleted. def _commit(self): # CAUTION: It's vital that _commit() succeed, and _commit() can # be called from __del__(). Therefore we must never reference a # global in this routine. if self._index is None: return # nothing to do try: self._os.unlink(self._bakfile) except OSError: pass try: self._os.rename(self._dirfile, self._bakfile) except OSError: pass with self._io.open(self._dirfile, 'w', encoding="Latin-1") as f: self._chmod(self._dirfile) for key, pos_and_siz_pair in self._index.items(): # Use Latin-1 since it has no qualms with any value in any # position; UTF-8, though, does care sometimes. entry = "%r, %r\n" % (key.decode('Latin-1'), pos_and_siz_pair) f.write(entry) sync = _commit def _verify_open(self): if self._index is None: raise error('DBM object has already been closed') def __getitem__(self, key): if isinstance(key, str): key = key.encode('utf-8') self._verify_open() pos, siz = self._index[key] # may raise KeyError with _io.open(self._datfile, 'rb') as f: f.seek(pos) dat = f.read(siz) return dat # Append val to the data file, starting at a _BLOCKSIZE-aligned # offset. The data file is first padded with NUL bytes (if needed) # to get to an aligned offset. Return pair # (starting offset of val, len(val)) def _addval(self, val): with _io.open(self._datfile, 'rb+') as f: f.seek(0, 2) pos = int(f.tell()) npos = ((pos + _BLOCKSIZE - 1) // _BLOCKSIZE) * _BLOCKSIZE f.write(b'\0'*(npos-pos)) pos = npos f.write(val) return (pos, len(val)) # Write val to the data file, starting at offset pos. The caller # is responsible for ensuring that there's enough room starting at # pos to hold val, without overwriting some other value. Return # pair (pos, len(val)). def _setval(self, pos, val): with _io.open(self._datfile, 'rb+') as f: f.seek(pos) f.write(val) return (pos, len(val)) # key is a new key whose associated value starts in the data file # at offset pos and with length siz. Add an index record to # the in-memory index dict, and append one to the directory file. def _addkey(self, key, pos_and_siz_pair): self._index[key] = pos_and_siz_pair with _io.open(self._dirfile, 'a', encoding="Latin-1") as f: self._chmod(self._dirfile) f.write("%r, %r\n" % (key.decode("Latin-1"), pos_and_siz_pair)) def __setitem__(self, key, val): if isinstance(key, str): key = key.encode('utf-8') elif not isinstance(key, (bytes, bytearray)): raise TypeError("keys must be bytes or strings") if isinstance(val, str): val = val.encode('utf-8') elif not isinstance(val, (bytes, bytearray)): raise TypeError("values must be bytes or strings") self._verify_open() if key not in self._index: self._addkey(key, self._addval(val)) else: # See whether the new value is small enough to fit in the # (padded) space currently occupied by the old value. pos, siz = self._index[key] oldblocks = (siz + _BLOCKSIZE - 1) // _BLOCKSIZE newblocks = (len(val) + _BLOCKSIZE - 1) // _BLOCKSIZE if newblocks <= oldblocks: self._index[key] = self._setval(pos, val) else: # The new value doesn't fit in the (padded) space used # by the old value. The blocks used by the old value are # forever lost. self._index[key] = self._addval(val) # Note that _index may be out of synch with the directory # file now: _setval() and _addval() don't update the directory # file. This also means that the on-disk directory and data # files are in a mutually inconsistent state, and they'll # remain that way until _commit() is called. Note that this # is a disaster (for the database) if the program crashes # (so that _commit() never gets called). def __delitem__(self, key): if isinstance(key, str): key = key.encode('utf-8') self._verify_open() # The blocks used by the associated value are lost. del self._index[key] # XXX It's unclear why we do a _commit() here (the code always # XXX has, so I'm not changing it). __setitem__ doesn't try to # XXX keep the directory file in synch. Why should we? Or # XXX why shouldn't __setitem__? self._commit() def keys(self): try: return list(self._index) except TypeError: raise error('DBM object has already been closed') from None def items(self): self._verify_open() return [(key, self[key]) for key in self._index.keys()] def __contains__(self, key): if isinstance(key, str): key = key.encode('utf-8') try: return key in self._index except TypeError: if self._index is None: raise error('DBM object has already been closed') from None else: raise def iterkeys(self): try: return iter(self._index) except TypeError: raise error('DBM object has already been closed') from None __iter__ = iterkeys def __len__(self): try: return len(self._index) except TypeError: raise error('DBM object has already been closed') from None def close(self): self._commit() self._index = self._datfile = self._dirfile = self._bakfile = None __del__ = close def _chmod(self, file): if hasattr(self._os, 'chmod'): self._os.chmod(file, self._mode) def __enter__(self): return self def __exit__(self, *args): self.close() def open(file, flag=None, mode=0o666): """Open the database file, filename, and return corresponding object. The flag argument, used to control how the database is opened in the other DBM implementations, is ignored in the dbm.dumb module; the database is always opened for update, and will be created if it does not exist. The optional mode argument is the UNIX mode of the file, used only when the database has to be created. It defaults to octal code 0o666 (and will be modified by the prevailing umask). """ # flag argument is currently ignored # Modify mode depending on the umask try: um = _os.umask(0) _os.umask(um) except AttributeError: pass else: # Turn off any bits that are set in the umask mode = mode & (~um) return _Database(file, mode)
lgpl-3.0
[ 624, 33, 32490, 436, 11999, 1325, 3486, 31093, 7289, 14, 199, 199, 1858, 3050, 14909, 12, 14909, 14, 694, 3509, 314, 1478, 334, 65, 1318, 570, 395, 199, 8283, 14, 27162, 627, 7551, 10, 1395, 282, 6902, 402, 314, 1478, 334, 12344, 282, 1318, 570, 395, 199, 6710, 14909, 14, 4616, 3509, 314, 666, 334, 65, 3366, 570, 680, 199, 199, 13933, 2296, 3506, 26, 199, 199, 13, 12237, 370, 1395, 282, 6519, 1380, 12928, 1396, 199, 199, 13, 295, 17904, 2867, 4601, 334, 19767, 12, 4601, 5403, 26182, 5299, 701, 5463, 503, 11507, 199, 1744, 365, 7078, 24826, 9, 199, 199, 13, 2291, 23002, 2879, 334, 19767, 12, 340, 2877, 10358, 5452, 25449, 10663, 199, 7618, 12, 2985, 883, 15634, 1536, 314, 1478, 9, 199, 199, 13, 2291, 13402, 2879, 370, 7031, 16219, 334, 19767, 12, 314, 8852, 1478, 199, 374, 1586, 1380, 314, 3050, 365, 12123, 12, 436, 2005, 7029, 19913, 314, 8852, 1478, 9, 199, 199, 13, 2291, 13618, 367, 1586, 13, 2118, 334, 4173, 275, 283, 77, 358, 199, 199, 624, 199, 199, 646, 5890, 465, 485, 2308, 199, 646, 747, 465, 485, 736, 199, 646, 5055, 199, 199, 363, 452, 363, 275, 2097, 705, 401, 298, 1490, 937, 199, 199, 63, 8475, 4305, 275, 10574, 199, 199, 705, 275, 6440, 199, 199, 533, 485, 7243, 8, 7882, 14, 17707, 7674, 304, 339, 327, 710, 641, 13, 4032, 2082, 436, 666, 1584, 883, 5706, 315, 16108, 272, 327, 27253, 6363, 367, 376, 601, 2075, 82, 11406, 1846, 900, 334, 3239, 6786, 272, 327, 737, 314, 1284, 402, 636, 8617, 28634, 221, 961, 365, 1454, 295, 29796, 1380, 485, 3543, 342, 272, 327, 7545, 2797, 14, 221, 7309, 4192, 485, 3543, 342, 7545, 2797, 365, 687, 636, 2264, 29709, 272, 327, 436, 340, 626, 11058, 737, 2240, 12842, 900, 12, 859, 7992, 1443, 272, 327, 2575, 1172, 4788, 724, 295, 3556, 370, 488, 14, 221, 9336, 652, 1159, 2467, 85, 7180, 626, 272, 327, 485, 3543, 342, 9578, 8792, 12, 781, 883, 1133, 3686, 12842, 660, 823, 272, 327, 2348, 12, 436, 485, 3543, 342, 1471, 440, 3659, 1263, 7992, 14, 272, 485, 736, 275, 485, 736, 755, 327, 367, 485, 3543, 342, 272, 485, 2308, 275, 485, 2308, 755, 327, 367, 485, 3543, 342, 339, 347, 636, 826, 721, 277, 12, 570, 4846, 12, 818, 304, 267, 291, 423, 632, 275, 818, 398, 327, 710, 2082, 570, 365, 282, 1318, 570, 14, 221, 7048, 1004, 10734, 2839, 267, 327, 259, 2071, 82, 12, 4366, 68, 12, 450, 68, 2862, 78, 2, 450, 334, 498, 12, 2086, 12, 308, 565, 9, 267, 327, 2382, 790, 365, 314, 1059, 790, 12, 2086, 365, 314, 3268, 1901, 314, 6394, 267, 327, 570, 402, 314, 4568, 574, 1159, 1642, 3696, 12, 436, 308, 565, 365, 314, 1329, 267, 327, 402, 2783, 315, 314, 4568, 574, 14, 267, 291, 423, 694, 493, 275, 570, 4846, 435, 1987, 694, 7, 398, 327, 710, 666, 570, 365, 282, 3366, 570, 32031, 1901, 701, 314, 2082, 267, 327, 570, 12, 436, 15164, 314, 1338, 4568, 543, 2883, 14, 221, 7048, 574, 267, 327, 22241, 737, 282, 485, 8475, 4305, 13, 19175, 3696, 3268, 12, 436, 365, 282, 3066, 267, 327, 3366, 1695, 13, 2075, 1059, 574, 14, 267, 291, 423, 4616, 493, 275, 570, 4846, 435, 1987, 4616, 7, 267, 291, 423, 27162, 493, 275, 570, 4846, 435, 1987, 27162, 7, 398, 327, 710, 1478, 365, 376, 315, 13, 4844, 1211, 12, 15216, 316, 314, 2082, 570, 14, 267, 291, 423, 1080, 275, 488, 221, 327, 9033, 2883, 370, 334, 1712, 12, 308, 565, 9, 6342, 398, 327, 22035, 701, 1603, 564, 26, 1218, 666, 570, 340, 4346, 267, 862, 26, 288, 289, 275, 485, 2308, 14, 1490, 8, 277, 423, 4616, 493, 12, 283, 82, 297, 2644, 628, 27317, 13, 17, 531, 267, 871, 6440, 26, 288, 543, 485, 2308, 14, 1490, 8, 277, 423, 4616, 493, 12, 283, 87, 297, 2644, 628, 27317, 13, 17, 531, 465, 289, 26, 355, 291, 423, 11693, 8, 277, 423, 4616, 493, 9, 267, 587, 26, 288, 289, 14, 1600, 342, 267, 291, 423, 873, 342, 339, 327, 5574, 2082, 570, 1901, 314, 315, 13, 4844, 1478, 1211, 14, 272, 347, 485, 873, 8, 277, 304, 267, 291, 423, 1080, 275, 1052, 267, 862, 26, 288, 289, 275, 485, 2308, 14, 1490, 8, 277, 423, 694, 493, 12, 283, 82, 297, 2644, 628, 27317, 13, 17, 531, 267, 871, 6440, 26, 288, 986, 267, 587, 26, 288, 543, 289, 26, 355, 367, 1004, 315, 289, 26, 490, 1004, 275, 1004, 14, 6735, 342, 490, 790, 12, 2086, 63, 460, 63, 5946, 63, 3852, 275, 3468, 8, 604, 9, 490, 790, 275, 790, 14, 2143, 360, 27317, 13, 17, 358, 490, 291, 423, 1080, 59, 498, 61, 275, 2086, 63, 460, 63, 5946, 63, 3852, 339, 327, 6990, 314, 1478, 1211, 370, 314, 2082, 570, 14, 221, 710, 3379, 2082, 272, 327, 570, 334, 692, 1263, 9, 365, 17864, 543, 282, 1275, 27162, 3329, 1642, 14, 221, 982, 282, 1275, 27162, 272, 327, 570, 5544, 3495, 12, 652, 1159, 5463, 14, 272, 347, 485, 3543, 8, 277, 304, 267, 327, 7240, 27129, 26, 221, 2779, 1159, 373, 6910, 626, 485, 3543, 342, 17961, 12, 436, 485, 3543, 342, 883, 267, 327, 506, 2797, 687, 636, 2264, 31261, 221, 21039, 781, 1471, 7078, 3659, 282, 267, 327, 2288, 315, 642, 12981, 14, 267, 340, 291, 423, 1080, 365, 488, 26, 288, 372, 221, 327, 6548, 370, 886, 398, 862, 26, 288, 291, 423, 736, 14, 7162, 8, 277, 423, 27162, 493, 9, 267, 871, 6440, 26, 288, 986, 398, 862, 26, 288, 291, 423, 736, 14, 8165, 8, 277, 423, 694, 493, 12, 291, 423, 27162, 493, 9, 267, 871, 6440, 26, 288, 986, 398, 543, 291, 423, 2308, 14, 1490, 8, 277, 423, 694, 493, 12, 283, 87, 297, 2644, 628, 27317, 13, 17, 531, 465, 289, 26, 288, 291, 423, 11693, 8, 277, 423, 694, 493, 9, 288, 367, 790, 12, 2086, 63, 460, 63, 5946, 63, 3852, 315, 291, 423, 1080, 14, 1744, 837, 355, 327, 3645, 23864, 13 ]
[ 33, 32490, 436, 11999, 1325, 3486, 31093, 7289, 14, 199, 199, 1858, 3050, 14909, 12, 14909, 14, 694, 3509, 314, 1478, 334, 65, 1318, 570, 395, 199, 8283, 14, 27162, 627, 7551, 10, 1395, 282, 6902, 402, 314, 1478, 334, 12344, 282, 1318, 570, 395, 199, 6710, 14909, 14, 4616, 3509, 314, 666, 334, 65, 3366, 570, 680, 199, 199, 13933, 2296, 3506, 26, 199, 199, 13, 12237, 370, 1395, 282, 6519, 1380, 12928, 1396, 199, 199, 13, 295, 17904, 2867, 4601, 334, 19767, 12, 4601, 5403, 26182, 5299, 701, 5463, 503, 11507, 199, 1744, 365, 7078, 24826, 9, 199, 199, 13, 2291, 23002, 2879, 334, 19767, 12, 340, 2877, 10358, 5452, 25449, 10663, 199, 7618, 12, 2985, 883, 15634, 1536, 314, 1478, 9, 199, 199, 13, 2291, 13402, 2879, 370, 7031, 16219, 334, 19767, 12, 314, 8852, 1478, 199, 374, 1586, 1380, 314, 3050, 365, 12123, 12, 436, 2005, 7029, 19913, 314, 8852, 1478, 9, 199, 199, 13, 2291, 13618, 367, 1586, 13, 2118, 334, 4173, 275, 283, 77, 358, 199, 199, 624, 199, 199, 646, 5890, 465, 485, 2308, 199, 646, 747, 465, 485, 736, 199, 646, 5055, 199, 199, 363, 452, 363, 275, 2097, 705, 401, 298, 1490, 937, 199, 199, 63, 8475, 4305, 275, 10574, 199, 199, 705, 275, 6440, 199, 199, 533, 485, 7243, 8, 7882, 14, 17707, 7674, 304, 339, 327, 710, 641, 13, 4032, 2082, 436, 666, 1584, 883, 5706, 315, 16108, 272, 327, 27253, 6363, 367, 376, 601, 2075, 82, 11406, 1846, 900, 334, 3239, 6786, 272, 327, 737, 314, 1284, 402, 636, 8617, 28634, 221, 961, 365, 1454, 295, 29796, 1380, 485, 3543, 342, 272, 327, 7545, 2797, 14, 221, 7309, 4192, 485, 3543, 342, 7545, 2797, 365, 687, 636, 2264, 29709, 272, 327, 436, 340, 626, 11058, 737, 2240, 12842, 900, 12, 859, 7992, 1443, 272, 327, 2575, 1172, 4788, 724, 295, 3556, 370, 488, 14, 221, 9336, 652, 1159, 2467, 85, 7180, 626, 272, 327, 485, 3543, 342, 9578, 8792, 12, 781, 883, 1133, 3686, 12842, 660, 823, 272, 327, 2348, 12, 436, 485, 3543, 342, 1471, 440, 3659, 1263, 7992, 14, 272, 485, 736, 275, 485, 736, 755, 327, 367, 485, 3543, 342, 272, 485, 2308, 275, 485, 2308, 755, 327, 367, 485, 3543, 342, 339, 347, 636, 826, 721, 277, 12, 570, 4846, 12, 818, 304, 267, 291, 423, 632, 275, 818, 398, 327, 710, 2082, 570, 365, 282, 1318, 570, 14, 221, 7048, 1004, 10734, 2839, 267, 327, 259, 2071, 82, 12, 4366, 68, 12, 450, 68, 2862, 78, 2, 450, 334, 498, 12, 2086, 12, 308, 565, 9, 267, 327, 2382, 790, 365, 314, 1059, 790, 12, 2086, 365, 314, 3268, 1901, 314, 6394, 267, 327, 570, 402, 314, 4568, 574, 1159, 1642, 3696, 12, 436, 308, 565, 365, 314, 1329, 267, 327, 402, 2783, 315, 314, 4568, 574, 14, 267, 291, 423, 694, 493, 275, 570, 4846, 435, 1987, 694, 7, 398, 327, 710, 666, 570, 365, 282, 3366, 570, 32031, 1901, 701, 314, 2082, 267, 327, 570, 12, 436, 15164, 314, 1338, 4568, 543, 2883, 14, 221, 7048, 574, 267, 327, 22241, 737, 282, 485, 8475, 4305, 13, 19175, 3696, 3268, 12, 436, 365, 282, 3066, 267, 327, 3366, 1695, 13, 2075, 1059, 574, 14, 267, 291, 423, 4616, 493, 275, 570, 4846, 435, 1987, 4616, 7, 267, 291, 423, 27162, 493, 275, 570, 4846, 435, 1987, 27162, 7, 398, 327, 710, 1478, 365, 376, 315, 13, 4844, 1211, 12, 15216, 316, 314, 2082, 570, 14, 267, 291, 423, 1080, 275, 488, 221, 327, 9033, 2883, 370, 334, 1712, 12, 308, 565, 9, 6342, 398, 327, 22035, 701, 1603, 564, 26, 1218, 666, 570, 340, 4346, 267, 862, 26, 288, 289, 275, 485, 2308, 14, 1490, 8, 277, 423, 4616, 493, 12, 283, 82, 297, 2644, 628, 27317, 13, 17, 531, 267, 871, 6440, 26, 288, 543, 485, 2308, 14, 1490, 8, 277, 423, 4616, 493, 12, 283, 87, 297, 2644, 628, 27317, 13, 17, 531, 465, 289, 26, 355, 291, 423, 11693, 8, 277, 423, 4616, 493, 9, 267, 587, 26, 288, 289, 14, 1600, 342, 267, 291, 423, 873, 342, 339, 327, 5574, 2082, 570, 1901, 314, 315, 13, 4844, 1478, 1211, 14, 272, 347, 485, 873, 8, 277, 304, 267, 291, 423, 1080, 275, 1052, 267, 862, 26, 288, 289, 275, 485, 2308, 14, 1490, 8, 277, 423, 694, 493, 12, 283, 82, 297, 2644, 628, 27317, 13, 17, 531, 267, 871, 6440, 26, 288, 986, 267, 587, 26, 288, 543, 289, 26, 355, 367, 1004, 315, 289, 26, 490, 1004, 275, 1004, 14, 6735, 342, 490, 790, 12, 2086, 63, 460, 63, 5946, 63, 3852, 275, 3468, 8, 604, 9, 490, 790, 275, 790, 14, 2143, 360, 27317, 13, 17, 358, 490, 291, 423, 1080, 59, 498, 61, 275, 2086, 63, 460, 63, 5946, 63, 3852, 339, 327, 6990, 314, 1478, 1211, 370, 314, 2082, 570, 14, 221, 710, 3379, 2082, 272, 327, 570, 334, 692, 1263, 9, 365, 17864, 543, 282, 1275, 27162, 3329, 1642, 14, 221, 982, 282, 1275, 27162, 272, 327, 570, 5544, 3495, 12, 652, 1159, 5463, 14, 272, 347, 485, 3543, 8, 277, 304, 267, 327, 7240, 27129, 26, 221, 2779, 1159, 373, 6910, 626, 485, 3543, 342, 17961, 12, 436, 485, 3543, 342, 883, 267, 327, 506, 2797, 687, 636, 2264, 31261, 221, 21039, 781, 1471, 7078, 3659, 282, 267, 327, 2288, 315, 642, 12981, 14, 267, 340, 291, 423, 1080, 365, 488, 26, 288, 372, 221, 327, 6548, 370, 886, 398, 862, 26, 288, 291, 423, 736, 14, 7162, 8, 277, 423, 27162, 493, 9, 267, 871, 6440, 26, 288, 986, 398, 862, 26, 288, 291, 423, 736, 14, 8165, 8, 277, 423, 694, 493, 12, 291, 423, 27162, 493, 9, 267, 871, 6440, 26, 288, 986, 398, 543, 291, 423, 2308, 14, 1490, 8, 277, 423, 694, 493, 12, 283, 87, 297, 2644, 628, 27317, 13, 17, 531, 465, 289, 26, 288, 291, 423, 11693, 8, 277, 423, 694, 493, 9, 288, 367, 790, 12, 2086, 63, 460, 63, 5946, 63, 3852, 315, 291, 423, 1080, 14, 1744, 837, 355, 327, 3645, 23864, 13, 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, 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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 ]
AutorestCI/azure-sdk-for-python
azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/list_service_sas_response.py
6
1136
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class ListServiceSasResponse(Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. :ivar service_sas_token: List service SAS credentials of speicific resource. :vartype service_sas_token: str """ _validation = { 'service_sas_token': {'readonly': True}, } _attribute_map = { 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, } def __init__(self): super(ListServiceSasResponse, self).__init__() self.service_sas_token = None
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 421, 199, 533, 3820, 3167, 51, 305, 2364, 8, 1685, 304, 272, 408, 1918, 3820, 2435, 26124, 6235, 3439, 1177, 14, 339, 17198, 787, 1454, 16460, 701, 314, 1654, 12, 436, 911, 506, 5525, 1380, 272, 10209, 282, 1056, 14, 339, 520, 7725, 2435, 63, 22601, 63, 1418, 26, 3820, 2435, 26124, 6235, 402, 14475, 530, 12061, 1362, 2073, 14, 272, 520, 19729, 2435, 63, 22601, 63, 1418, 26, 620, 272, 408, 339, 485, 6136, 275, 469, 267, 283, 1364, 63, 22601, 63, 1418, 356, 791, 6753, 356, 715, 1386, 272, 789, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 1364, 63, 22601, 63, 1418, 356, 791, 498, 356, 283, 1364, 51, 305, 3264, 297, 283, 466, 356, 283, 495, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 1296, 3167, 51, 305, 2364, 12, 291, 2843, 826, 4533, 267, 291, 14, 1364, 63, 22601, 63, 1418, 275, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 421, 199, 533, 3820, 3167, 51, 305, 2364, 8, 1685, 304, 272, 408, 1918, 3820, 2435, 26124, 6235, 3439, 1177, 14, 339, 17198, 787, 1454, 16460, 701, 314, 1654, 12, 436, 911, 506, 5525, 1380, 272, 10209, 282, 1056, 14, 339, 520, 7725, 2435, 63, 22601, 63, 1418, 26, 3820, 2435, 26124, 6235, 402, 14475, 530, 12061, 1362, 2073, 14, 272, 520, 19729, 2435, 63, 22601, 63, 1418, 26, 620, 272, 408, 339, 485, 6136, 275, 469, 267, 283, 1364, 63, 22601, 63, 1418, 356, 791, 6753, 356, 715, 1386, 272, 789, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 1364, 63, 22601, 63, 1418, 356, 791, 498, 356, 283, 1364, 51, 305, 3264, 297, 283, 466, 356, 283, 495, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 1296, 3167, 51, 305, 2364, 12, 291, 2843, 826, 4533, 267, 291, 14, 1364, 63, 22601, 63, 1418, 275, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sserrot/champion_relationships
venv/Lib/site-packages/networkx/algorithms/shortest_paths/tests/test_weighted.py
1
27666
import pytest import networkx as nx from networkx.utils import pairwise def validate_path(G, s, t, soln_len, path): assert path[0] == s assert path[-1] == t if not G.is_multigraph(): computed = sum(G[u][v].get('weight', 1) for u, v in pairwise(path)) assert soln_len == computed else: computed = sum(min(e.get('weight', 1) for e in G[u][v].values()) for u, v in pairwise(path)) assert soln_len == computed def validate_length_path(G, s, t, soln_len, length, path): assert soln_len == length validate_path(G, s, t, length, path) class WeightedTestBase(object): """Base class for test classes that test functions for computing shortest paths in weighted graphs. """ def setup(self): """Creates some graphs for use in the unit tests.""" cnlti = nx.convert_node_labels_to_integers self.grid = cnlti(nx.grid_2d_graph(4, 4), first_label=1, ordering="sorted") self.cycle = nx.cycle_graph(7) self.directed_cycle = nx.cycle_graph(7, create_using=nx.DiGraph()) self.XG = nx.DiGraph() self.XG.add_weighted_edges_from([('s', 'u', 10), ('s', 'x', 5), ('u', 'v', 1), ('u', 'x', 2), ('v', 'y', 1), ('x', 'u', 3), ('x', 'v', 5), ('x', 'y', 2), ('y', 's', 7), ('y', 'v', 6)]) self.MXG = nx.MultiDiGraph(self.XG) self.MXG.add_edge('s', 'u', weight=15) self.XG2 = nx.DiGraph() self.XG2.add_weighted_edges_from([[1, 4, 1], [4, 5, 1], [5, 6, 1], [6, 3, 1], [1, 3, 50], [1, 2, 100], [2, 3, 100]]) self.XG3 = nx.Graph() self.XG3.add_weighted_edges_from([[0, 1, 2], [1, 2, 12], [2, 3, 1], [3, 4, 5], [4, 5, 1], [5, 0, 10]]) self.XG4 = nx.Graph() self.XG4.add_weighted_edges_from([[0, 1, 2], [1, 2, 2], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]]) self.MXG4 = nx.MultiGraph(self.XG4) self.MXG4.add_edge(0, 1, weight=3) self.G = nx.DiGraph() # no weights self.G.add_edges_from([('s', 'u'), ('s', 'x'), ('u', 'v'), ('u', 'x'), ('v', 'y'), ('x', 'u'), ('x', 'v'), ('x', 'y'), ('y', 's'), ('y', 'v')]) class TestWeightedPath(WeightedTestBase): def test_dijkstra(self): (D, P) = nx.single_source_dijkstra(self.XG, 's') validate_path(self.XG, 's', 'v', 9, P['v']) assert D['v'] == 9 validate_path( self.XG, 's', 'v', 9, nx.single_source_dijkstra_path(self.XG, 's')['v']) assert dict( nx.single_source_dijkstra_path_length(self.XG, 's'))['v'] == 9 validate_path( self.XG, 's', 'v', 9, nx.single_source_dijkstra(self.XG, 's')[1]['v']) validate_path( self.MXG, 's', 'v', 9, nx.single_source_dijkstra_path(self.MXG, 's')['v']) GG = self.XG.to_undirected() # make sure we get lower weight # to_undirected might choose either edge with weight 2 or weight 3 GG['u']['x']['weight'] = 2 (D, P) = nx.single_source_dijkstra(GG, 's') validate_path(GG, 's', 'v', 8, P['v']) assert D['v'] == 8 # uses lower weight of 2 on u<->x edge validate_path(GG, 's', 'v', 8, nx.dijkstra_path(GG, 's', 'v')) assert nx.dijkstra_path_length(GG, 's', 'v') == 8 validate_path(self.XG2, 1, 3, 4, nx.dijkstra_path(self.XG2, 1, 3)) validate_path(self.XG3, 0, 3, 15, nx.dijkstra_path(self.XG3, 0, 3)) assert nx.dijkstra_path_length(self.XG3, 0, 3) == 15 validate_path(self.XG4, 0, 2, 4, nx.dijkstra_path(self.XG4, 0, 2)) assert nx.dijkstra_path_length(self.XG4, 0, 2) == 4 validate_path(self.MXG4, 0, 2, 4, nx.dijkstra_path(self.MXG4, 0, 2)) validate_path( self.G, 's', 'v', 2, nx.single_source_dijkstra(self.G, 's', 'v')[1]) validate_path( self.G, 's', 'v', 2, nx.single_source_dijkstra(self.G, 's')[1]['v']) validate_path(self.G, 's', 'v', 2, nx.dijkstra_path(self.G, 's', 'v')) assert nx.dijkstra_path_length(self.G, 's', 'v') == 2 # NetworkXError: node s not reachable from moon pytest.raises(nx.NetworkXNoPath, nx.dijkstra_path, self.G, 's', 'moon') pytest.raises( nx.NetworkXNoPath, nx.dijkstra_path_length, self.G, 's', 'moon') validate_path(self.cycle, 0, 3, 3, nx.dijkstra_path(self.cycle, 0, 3)) validate_path(self.cycle, 0, 4, 3, nx.dijkstra_path(self.cycle, 0, 4)) assert nx.single_source_dijkstra(self.cycle, 0, 0) == (0, [0]) def test_bidirectional_dijkstra(self): validate_length_path( self.XG, 's', 'v', 9, *nx.bidirectional_dijkstra(self.XG, 's', 'v')) validate_length_path( self.G, 's', 'v', 2, *nx.bidirectional_dijkstra(self.G, 's', 'v')) validate_length_path( self.cycle, 0, 3, 3, *nx.bidirectional_dijkstra(self.cycle, 0, 3)) validate_length_path( self.cycle, 0, 4, 3, *nx.bidirectional_dijkstra(self.cycle, 0, 4)) validate_length_path( self.XG3, 0, 3, 15, *nx.bidirectional_dijkstra(self.XG3, 0, 3)) validate_length_path( self.XG4, 0, 2, 4, *nx.bidirectional_dijkstra(self.XG4, 0, 2)) # need more tests here P = nx.single_source_dijkstra_path(self.XG, 's')['v'] validate_path(self.XG, 's', 'v', sum(self.XG[u][v]['weight'] for u, v in zip( P[:-1], P[1:])), nx.dijkstra_path(self.XG, 's', 'v')) # check absent source G = nx.path_graph(2) pytest.raises(nx.NodeNotFound, nx.bidirectional_dijkstra, G, 3, 0) def test_bidirectional_dijkstra_no_path(self): with pytest.raises(nx.NetworkXNoPath): G = nx.Graph() nx.add_path(G, [1, 2, 3]) nx.add_path(G, [4, 5, 6]) path = nx.bidirectional_dijkstra(G, 1, 6) def test_absent_source(self): # the check is in _dijkstra_multisource, but this will provide # regression testing against later changes to any of the "client" # Dijkstra or Bellman-Ford functions G = nx.path_graph(2) for fn in (nx.dijkstra_path, nx.dijkstra_path_length, nx.single_source_dijkstra_path, nx.single_source_dijkstra_path_length, nx.single_source_dijkstra, nx.dijkstra_predecessor_and_distance,): pytest.raises(nx.NodeNotFound, fn, G, 3, 0) def test_dijkstra_predecessor1(self): G = nx.path_graph(4) assert (nx.dijkstra_predecessor_and_distance(G, 0) == ({0: [], 1: [0], 2: [1], 3: [2]}, {0: 0, 1: 1, 2: 2, 3: 3})) def test_dijkstra_predecessor2(self): # 4-cycle G = nx.Graph([(0, 1), (1, 2), (2, 3), (3, 0)]) pred, dist = nx.dijkstra_predecessor_and_distance(G, (0)) assert pred[0] == [] assert pred[1] == [0] assert pred[2] in [[1, 3], [3, 1]] assert pred[3] == [0] assert dist == {0: 0, 1: 1, 2: 2, 3: 1} def test_dijkstra_predecessor3(self): XG = nx.DiGraph() XG.add_weighted_edges_from([('s', 'u', 10), ('s', 'x', 5), ('u', 'v', 1), ('u', 'x', 2), ('v', 'y', 1), ('x', 'u', 3), ('x', 'v', 5), ('x', 'y', 2), ('y', 's', 7), ('y', 'v', 6)]) (P, D) = nx.dijkstra_predecessor_and_distance(XG, 's') assert P['v'] == ['u'] assert D['v'] == 9 (P, D) = nx.dijkstra_predecessor_and_distance(XG, 's', cutoff=8) assert not 'v' in D def test_single_source_dijkstra_path_length(self): pl = nx.single_source_dijkstra_path_length assert dict(pl(self.MXG4, 0))[2] == 4 spl = pl(self.MXG4, 0, cutoff=2) assert not 2 in spl def test_bidirectional_dijkstra_multigraph(self): G = nx.MultiGraph() G.add_edge('a', 'b', weight=10) G.add_edge('a', 'b', weight=100) dp = nx.bidirectional_dijkstra(G, 'a', 'b') assert dp == (10, ['a', 'b']) def test_dijkstra_pred_distance_multigraph(self): G = nx.MultiGraph() G.add_edge('a', 'b', key='short', foo=5, weight=100) G.add_edge('a', 'b', key='long', bar=1, weight=110) p, d = nx.dijkstra_predecessor_and_distance(G, 'a') assert p == {'a': [], 'b': ['a']} assert d == {'a': 0, 'b': 100} def test_negative_edge_cycle(self): G = nx.cycle_graph(5, create_using=nx.DiGraph()) assert nx.negative_edge_cycle(G) == False G.add_edge(8, 9, weight=-7) G.add_edge(9, 8, weight=3) graph_size = len(G) assert nx.negative_edge_cycle(G) == True assert graph_size == len(G) pytest.raises(ValueError, nx.single_source_dijkstra_path_length, G, 8) pytest.raises(ValueError, nx.single_source_dijkstra, G, 8) pytest.raises(ValueError, nx.dijkstra_predecessor_and_distance, G, 8) G.add_edge(9, 10) pytest.raises(ValueError, nx.bidirectional_dijkstra, G, 8, 10) def test_weight_function(self): """Tests that a callable weight is interpreted as a weight function instead of an edge attribute. """ # Create a triangle in which the edge from node 0 to node 2 has # a large weight and the other two edges have a small weight. G = nx.complete_graph(3) G.adj[0][2]['weight'] = 10 G.adj[0][1]['weight'] = 1 G.adj[1][2]['weight'] = 1 # The weight function will take the multiplicative inverse of # the weights on the edges. This way, weights that were large # before now become small and vice versa. def weight(u, v, d): return 1 / d['weight'] # The shortest path from 0 to 2 using the actual weights on the # edges should be [0, 1, 2]. distance, path = nx.single_source_dijkstra(G, 0, 2) assert distance == 2 assert path == [0, 1, 2] # However, with the above weight function, the shortest path # should be [0, 2], since that has a very small weight. distance, path = nx.single_source_dijkstra(G, 0, 2, weight=weight) assert distance == 1 / 10 assert path == [0, 2] def test_all_pairs_dijkstra_path(self): cycle = nx.cycle_graph(7) p = dict(nx.all_pairs_dijkstra_path(cycle)) assert p[0][3] == [0, 1, 2, 3] cycle[1][2]['weight'] = 10 p = dict(nx.all_pairs_dijkstra_path(cycle)) assert p[0][3] == [0, 6, 5, 4, 3] def test_all_pairs_dijkstra_path_length(self): cycle = nx.cycle_graph(7) pl = dict(nx.all_pairs_dijkstra_path_length(cycle)) assert pl[0] == {0: 0, 1: 1, 2: 2, 3: 3, 4: 3, 5: 2, 6: 1} cycle[1][2]['weight'] = 10 pl = dict(nx.all_pairs_dijkstra_path_length(cycle)) assert pl[0] == {0: 0, 1: 1, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1} def test_all_pairs_dijkstra(self): cycle = nx.cycle_graph(7) out = dict(nx.all_pairs_dijkstra(cycle)) assert out[0][0] == {0: 0, 1: 1, 2: 2, 3: 3, 4: 3, 5: 2, 6: 1} assert out[0][1][3] == [0, 1, 2, 3] cycle[1][2]['weight'] = 10 out = dict(nx.all_pairs_dijkstra(cycle)) assert out[0][0] == {0: 0, 1: 1, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1} assert out[0][1][3] == [0, 6, 5, 4, 3] class TestDijkstraPathLength(object): """Unit tests for the :func:`networkx.dijkstra_path_length` function. """ def test_weight_function(self): """Tests for computing the length of the shortest path using Dijkstra's algorithm with a user-defined weight function. """ # Create a triangle in which the edge from node 0 to node 2 has # a large weight and the other two edges have a small weight. G = nx.complete_graph(3) G.adj[0][2]['weight'] = 10 G.adj[0][1]['weight'] = 1 G.adj[1][2]['weight'] = 1 # The weight function will take the multiplicative inverse of # the weights on the edges. This way, weights that were large # before now become small and vice versa. def weight(u, v, d): return 1 / d['weight'] # The shortest path from 0 to 2 using the actual weights on the # edges should be [0, 1, 2]. However, with the above weight # function, the shortest path should be [0, 2], since that has a # very small weight. length = nx.dijkstra_path_length(G, 0, 2, weight=weight) assert length == 1 / 10 class TestMultiSourceDijkstra(object): """Unit tests for the multi-source dialect of Dijkstra's shortest path algorithms. """ def test_no_sources(self): with pytest.raises(ValueError): nx.multi_source_dijkstra(nx.Graph(), {}) def test_path_no_sources(self): with pytest.raises(ValueError): nx.multi_source_dijkstra_path(nx.Graph(), {}) def test_path_length_no_sources(self): with pytest.raises(ValueError): nx.multi_source_dijkstra_path_length(nx.Graph(), {}) def test_absent_source(self): G = nx.path_graph(2) for fn in (nx.multi_source_dijkstra_path, nx.multi_source_dijkstra_path_length, nx.multi_source_dijkstra,): pytest.raises(nx.NodeNotFound, fn, G, [3], 0) def test_two_sources(self): edges = [(0, 1, 1), (1, 2, 1), (2, 3, 10), (3, 4, 1)] G = nx.Graph() G.add_weighted_edges_from(edges) sources = {0, 4} distances, paths = nx.multi_source_dijkstra(G, sources) expected_distances = {0: 0, 1: 1, 2: 2, 3: 1, 4: 0} expected_paths = {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [4, 3], 4: [4]} assert distances == expected_distances assert paths == expected_paths def test_simple_paths(self): G = nx.path_graph(4) lengths = nx.multi_source_dijkstra_path_length(G, [0]) assert lengths == {n: n for n in G} paths = nx.multi_source_dijkstra_path(G, [0]) assert paths == {n: list(range(n + 1)) for n in G} class TestBellmanFordAndGoldbergRadzik(WeightedTestBase): def test_single_node_graph(self): G = nx.DiGraph() G.add_node(0) assert nx.single_source_bellman_ford_path(G, 0) == {0: [0]} assert nx.single_source_bellman_ford_path_length(G, 0) == {0: 0} assert nx.single_source_bellman_ford(G, 0) == ({0: 0}, {0: [0]}) assert nx.bellman_ford_predecessor_and_distance(G, 0) == ({0: []}, {0: 0}) assert nx.goldberg_radzik(G, 0) == ({0: None}, {0: 0}) def test_absent_source_bellman_ford(self): # the check is in _bellman_ford; this provides regression testing # against later changes to "client" Bellman-Ford functions G = nx.path_graph(2) for fn in (nx.bellman_ford_predecessor_and_distance, nx.bellman_ford_path, nx.bellman_ford_path_length, nx.single_source_bellman_ford_path, nx.single_source_bellman_ford_path_length, nx.single_source_bellman_ford,): pytest.raises(nx.NodeNotFound, fn, G, 3, 0) def test_absent_source_goldberg_radzik(self): with pytest.raises(nx.NodeNotFound): G = nx.path_graph(2) nx.goldberg_radzik(G, 3, 0) def test_negative_weight_cycle(self): G = nx.cycle_graph(5, create_using=nx.DiGraph()) G.add_edge(1, 2, weight=-7) for i in range(5): pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford_path, G, i) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford_path_length, G, i) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford, G, i) pytest.raises(nx.NetworkXUnbounded, nx.bellman_ford_predecessor_and_distance, G, i) pytest.raises(nx.NetworkXUnbounded, nx.goldberg_radzik, G, i) G = nx.cycle_graph(5) # undirected Graph G.add_edge(1, 2, weight=-3) for i in range(5): pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford_path, G, i) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford_path_length, G, i) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford, G, i) pytest.raises(nx.NetworkXUnbounded, nx.bellman_ford_predecessor_and_distance, G, i) pytest.raises(nx.NetworkXUnbounded, nx.goldberg_radzik, G, i) G = nx.DiGraph([(1, 1, {'weight': -1})]) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford_path, G, 1) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford_path_length, G, 1) pytest.raises(nx.NetworkXUnbounded, nx.single_source_bellman_ford, G, 1) pytest.raises(nx.NetworkXUnbounded, nx.bellman_ford_predecessor_and_distance, G, 1) pytest.raises(nx.NetworkXUnbounded, nx.goldberg_radzik, G, 1) # no negative cycle but negative weight G = nx.cycle_graph(5, create_using=nx.DiGraph()) G.add_edge(1, 2, weight=-3) assert (nx.single_source_bellman_ford_path(G, 0) == {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3], 4: [0, 1, 2, 3, 4]}) assert (nx.single_source_bellman_ford_path_length(G, 0) == {0: 0, 1: 1, 2: -2, 3: -1, 4: 0}) assert (nx.single_source_bellman_ford(G, 0) == ({0: 0, 1: 1, 2: -2, 3: -1, 4: 0}, {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3], 4: [0, 1, 2, 3, 4]})) assert (nx.bellman_ford_predecessor_and_distance(G, 0) == ({0: [], 1: [0], 2: [1], 3: [2], 4: [3]}, {0: 0, 1: 1, 2: -2, 3: -1, 4: 0})) assert (nx.goldberg_radzik(G, 0) == ({0: None, 1: 0, 2: 1, 3: 2, 4: 3}, {0: 0, 1: 1, 2: -2, 3: -1, 4: 0})) def test_not_connected(self): G = nx.complete_graph(6) G.add_edge(10, 11) G.add_edge(10, 12) assert (nx.single_source_bellman_ford_path(G, 0) == {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]}) assert (nx.single_source_bellman_ford_path_length(G, 0) == {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}) assert (nx.single_source_bellman_ford(G, 0) == ({0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}, {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]})) assert (nx.bellman_ford_predecessor_and_distance(G, 0) == ({0: [], 1: [0], 2: [0], 3: [0], 4: [0], 5: [0]}, {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})) assert (nx.goldberg_radzik(G, 0) == ({0: None, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}, {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})) # not connected, with a component not containing the source that # contains a negative cost cycle. G = nx.complete_graph(6) G.add_edges_from([('A', 'B', {'load': 3}), ('B', 'C', {'load': -10}), ('C', 'A', {'load': 2})]) assert (nx.single_source_bellman_ford_path(G, 0, weight='load') == {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]}) assert (nx.single_source_bellman_ford_path_length(G, 0, weight='load') == {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}) assert (nx.single_source_bellman_ford(G, 0, weight='load') == ({0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}, {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]})) assert (nx.bellman_ford_predecessor_and_distance(G, 0, weight='load') == ({0: [], 1: [0], 2: [0], 3: [0], 4: [0], 5: [0]}, {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})) assert (nx.goldberg_radzik(G, 0, weight='load') == ({0: None, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}, {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})) def test_multigraph(self): assert nx.bellman_ford_path(self.MXG, 's', 'v') == ['s', 'x', 'u', 'v'] assert nx.bellman_ford_path_length(self.MXG, 's', 'v') == 9 assert nx.single_source_bellman_ford_path(self.MXG, 's')['v'] == ['s', 'x', 'u', 'v'] assert nx.single_source_bellman_ford_path_length(self.MXG, 's')['v'] == 9 D, P = nx.single_source_bellman_ford(self.MXG, 's', target='v') assert D == 9 assert P == ['s', 'x', 'u', 'v'] P, D = nx.bellman_ford_predecessor_and_distance(self.MXG, 's') assert P['v'] == ['u'] assert D['v'] == 9 P, D = nx.goldberg_radzik(self.MXG, 's') assert P['v'] == 'u' assert D['v'] == 9 assert nx.bellman_ford_path(self.MXG4, 0, 2) == [0, 1, 2] assert nx.bellman_ford_path_length(self.MXG4, 0, 2) == 4 assert nx.single_source_bellman_ford_path(self.MXG4, 0)[2] == [0, 1, 2] assert nx.single_source_bellman_ford_path_length(self.MXG4, 0)[2] == 4 D, P = nx.single_source_bellman_ford(self.MXG4, 0, target=2) assert D == 4 assert P == [0, 1, 2] P, D = nx.bellman_ford_predecessor_and_distance(self.MXG4, 0) assert P[2] == [1] assert D[2] == 4 P, D = nx.goldberg_radzik(self.MXG4, 0) assert P[2] == 1 assert D[2] == 4 def test_others(self): assert nx.bellman_ford_path(self.XG, 's', 'v') == ['s', 'x', 'u', 'v'] assert nx.bellman_ford_path_length(self.XG, 's', 'v') == 9 assert nx.single_source_bellman_ford_path(self.XG, 's')['v'] == ['s', 'x', 'u', 'v'] assert nx.single_source_bellman_ford_path_length(self.XG, 's')['v'] == 9 D, P = nx.single_source_bellman_ford(self.XG, 's', target='v') assert D == 9 assert P == ['s', 'x', 'u', 'v'] (P, D) = nx.bellman_ford_predecessor_and_distance(self.XG, 's') assert P['v'] == ['u'] assert D['v'] == 9 (P, D) = nx.goldberg_radzik(self.XG, 's') assert P['v'] == 'u' assert D['v'] == 9 def test_path_graph(self): G = nx.path_graph(4) assert (nx.single_source_bellman_ford_path(G, 0) == {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]}) assert (nx.single_source_bellman_ford_path_length(G, 0) == {0: 0, 1: 1, 2: 2, 3: 3}) assert (nx.single_source_bellman_ford(G, 0) == ({0: 0, 1: 1, 2: 2, 3: 3}, {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]})) assert (nx.bellman_ford_predecessor_and_distance(G, 0) == ({0: [], 1: [0], 2: [1], 3: [2]}, {0: 0, 1: 1, 2: 2, 3: 3})) assert (nx.goldberg_radzik(G, 0) == ({0: None, 1: 0, 2: 1, 3: 2}, {0: 0, 1: 1, 2: 2, 3: 3})) assert (nx.single_source_bellman_ford_path(G, 3) == {0: [3, 2, 1, 0], 1: [3, 2, 1], 2: [3, 2], 3: [3]}) assert (nx.single_source_bellman_ford_path_length(G, 3) == {0: 3, 1: 2, 2: 1, 3: 0}) assert (nx.single_source_bellman_ford(G, 3) == ({0: 3, 1: 2, 2: 1, 3: 0}, {0: [3, 2, 1, 0], 1: [3, 2, 1], 2: [3, 2], 3: [3]})) assert (nx.bellman_ford_predecessor_and_distance(G, 3) == ({0: [1], 1: [2], 2: [3], 3: []}, {0: 3, 1: 2, 2: 1, 3: 0})) assert (nx.goldberg_radzik(G, 3) == ({0: 1, 1: 2, 2: 3, 3: None}, {0: 3, 1: 2, 2: 1, 3: 0})) def test_4_cycle(self): # 4-cycle G = nx.Graph([(0, 1), (1, 2), (2, 3), (3, 0)]) dist, path = nx.single_source_bellman_ford(G, 0) assert dist == {0: 0, 1: 1, 2: 2, 3: 1} assert path[0] == [0] assert path[1] == [0, 1] assert path[2] in [[0, 1, 2], [0, 3, 2]] assert path[3] == [0, 3] pred, dist = nx.bellman_ford_predecessor_and_distance(G, 0) assert pred[0] == [] assert pred[1] == [0] assert pred[2] in [[1, 3], [3, 1]] assert pred[3] == [0] assert dist == {0: 0, 1: 1, 2: 2, 3: 1} pred, dist = nx.goldberg_radzik(G, 0) assert pred[0] == None assert pred[1] == 0 assert pred[2] in [1, 3] assert pred[3] == 0 assert dist == {0: 0, 1: 1, 2: 2, 3: 1} def test_negative_weight(self): G = nx.DiGraph() G.add_nodes_from('abcd') G.add_edge('a','d', weight = 0) G.add_edge('a','b', weight = 1) G.add_edge('b','c', weight = -3) G.add_edge('c','d', weight = 1) assert nx.bellman_ford_path(G, 'a', 'd') == ['a', 'b', 'c', 'd'] assert nx.bellman_ford_path_length(G, 'a', 'd') == -1 class TestJohnsonAlgorithm(WeightedTestBase): def test_single_node_graph(self): with pytest.raises(nx.NetworkXError): G = nx.DiGraph() G.add_node(0) nx.johnson(G) def test_negative_cycle(self): G = nx.DiGraph() G.add_weighted_edges_from([('0', '3', 3), ('0', '1', -5), ('1', '0', -5), ('0', '2', 2), ('1', '2', 4), ('2', '3', 1)]) pytest.raises(nx.NetworkXUnbounded, nx.johnson, G) G = nx.Graph() G.add_weighted_edges_from([('0', '3', 3), ('0', '1', -5), ('1', '0', -5), ('0', '2', 2), ('1', '2', 4), ('2', '3', 1)]) pytest.raises(nx.NetworkXUnbounded, nx.johnson, G) def test_negative_weights(self): G = nx.DiGraph() G.add_weighted_edges_from([('0', '3', 3), ('0', '1', -5), ('0', '2', 2), ('1', '2', 4), ('2', '3', 1)]) paths = nx.johnson(G) assert paths == {'1': {'1': ['1'], '3': ['1', '2', '3'], '2': ['1', '2']}, '0': {'1': ['0', '1'], '0': ['0'], '3': ['0', '1', '2', '3'], '2': ['0', '1', '2']}, '3': {'3': ['3']}, '2': {'3': ['2', '3'], '2': ['2']}} def test_unweighted_graph(self): with pytest.raises(nx.NetworkXError): G = nx.path_graph(5) nx.johnson(G) def test_graphs(self): validate_path(self.XG, 's', 'v', 9, nx.johnson(self.XG)['s']['v']) validate_path(self.MXG, 's', 'v', 9, nx.johnson(self.MXG)['s']['v']) validate_path(self.XG2, 1, 3, 4, nx.johnson(self.XG2)[1][3]) validate_path(self.XG3, 0, 3, 15, nx.johnson(self.XG3)[0][3]) validate_path(self.XG4, 0, 2, 4, nx.johnson(self.XG4)[0][2]) validate_path(self.MXG4, 0, 2, 4, nx.johnson(self.MXG4)[0][2])
mit
[ 199, 646, 4613, 199, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 492, 24859, 421, 199, 318, 4107, 63, 515, 8, 39, 12, 308, 12, 307, 12, 8597, 78, 63, 552, 12, 931, 304, 272, 702, 931, 59, 16, 61, 508, 308, 272, 702, 931, 1988, 17, 61, 508, 307, 272, 340, 440, 598, 14, 374, 63, 3029, 2180, 837, 267, 9235, 275, 3089, 8, 39, 59, 85, 1527, 86, 1055, 362, 360, 3463, 297, 413, 9, 367, 399, 12, 373, 315, 24859, 8, 515, 430, 267, 702, 8597, 78, 63, 552, 508, 9235, 272, 587, 26, 267, 9235, 275, 3089, 8, 827, 8, 69, 14, 362, 360, 3463, 297, 413, 9, 367, 325, 315, 598, 59, 85, 1527, 86, 1055, 1459, 1012, 2432, 367, 399, 12, 373, 315, 24859, 8, 515, 430, 267, 702, 8597, 78, 63, 552, 508, 9235, 421, 199, 318, 4107, 63, 1267, 63, 515, 8, 39, 12, 308, 12, 307, 12, 8597, 78, 63, 552, 12, 2582, 12, 931, 304, 272, 702, 8597, 78, 63, 552, 508, 2582, 272, 4107, 63, 515, 8, 39, 12, 308, 12, 307, 12, 2582, 12, 931, 9, 421, 199, 533, 2136, 8364, 14440, 8, 785, 304, 272, 408, 1563, 1021, 367, 511, 3992, 626, 511, 3423, 367, 17226, 272, 26564, 3792, 315, 14609, 18312, 14, 339, 408, 339, 347, 3272, 8, 277, 304, 267, 408, 10607, 2005, 18312, 367, 675, 315, 314, 4137, 2295, 1041, 267, 286, 7530, 280, 275, 8484, 14, 3916, 63, 932, 63, 3512, 63, 475, 63, 23931, 267, 291, 14, 3825, 275, 286, 7530, 280, 8, 7343, 14, 3825, 63, 18, 68, 63, 2180, 8, 20, 12, 841, 395, 1642, 63, 1302, 29, 17, 12, 2079, 7794, 628, 5917, 531, 267, 291, 14, 7612, 275, 8484, 14, 7612, 63, 2180, 8, 23, 9, 267, 291, 14, 12080, 63, 7612, 275, 8484, 14, 7612, 63, 2180, 8, 23, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 291, 14, 56, 39, 275, 8484, 14, 23208, 342, 267, 291, 14, 56, 39, 14, 525, 63, 13522, 63, 6929, 63, 504, 8318, 83, 297, 283, 85, 297, 1616, 395, 661, 83, 297, 283, 88, 297, 959, 395, 1460, 661, 85, 297, 283, 86, 297, 413, 395, 661, 85, 297, 283, 88, 297, 499, 395, 1460, 661, 86, 297, 283, 89, 297, 413, 395, 661, 88, 297, 283, 85, 297, 650, 395, 1460, 661, 88, 297, 283, 86, 297, 959, 395, 661, 88, 297, 283, 89, 297, 499, 395, 1460, 661, 89, 297, 283, 83, 297, 1520, 395, 661, 89, 297, 283, 86, 297, 1227, 3948, 267, 291, 14, 17401, 39, 275, 8484, 14, 3947, 23208, 8, 277, 14, 56, 39, 9, 267, 291, 14, 17401, 39, 14, 525, 63, 5173, 360, 83, 297, 283, 85, 297, 5401, 29, 1046, 9, 267, 291, 14, 56, 39, 18, 275, 8484, 14, 23208, 342, 267, 291, 14, 56, 39, 18, 14, 525, 63, 13522, 63, 6929, 63, 504, 4038, 17, 12, 841, 12, 413, 467, 359, 20, 12, 959, 12, 413, 467, 5101, 359, 21, 12, 1227, 12, 413, 467, 359, 22, 12, 650, 12, 413, 467, 5101, 359, 17, 12, 650, 12, 5238, 467, 359, 17, 12, 499, 12, 2948, 467, 5101, 359, 18, 12, 650, 12, 2948, 3934, 398, 291, 14, 56, 39, 19, 275, 8484, 14, 4578, 342, 267, 291, 14, 56, 39, 19, 14, 525, 63, 13522, 63, 6929, 63, 504, 4038, 16, 12, 413, 12, 499, 467, 359, 17, 12, 499, 12, 3144, 467, 5101, 359, 18, 12, 650, 12, 413, 467, 359, 19, 12, 841, 12, 959, 467, 5101, 359, 20, 12, 959, 12, 413, 467, 359, 21, 12, 378, 12, 1616, 3934, 398, 291, 14, 56, 39, 20, 275, 8484, 14, 4578, 342, 267, 291, 14, 56, 39, 20, 14, 525, 63, 13522, 63, 6929, 63, 504, 4038, 16, 12, 413, 12, 499, 467, 359, 17, 12, 499, 12, 499, 467, 5101, 359, 18, 12, 650, 12, 413, 467, 359, 19, 12, 841, 12, 413, 467, 5101, 359, 20, 12, 959, 12, 413, 467, 359, 21, 12, 1227, 12, 413, 467, 5101, 359, 22, 12, 1520, 12, 413, 467, 359, 23, 12, 378, 12, 413, 3934, 267, 291, 14, 17401, 39, 20, 275, 8484, 14, 3947, 4578, 8, 277, 14, 56, 39, 20, 9, 267, 291, 14, 17401, 39, 20, 14, 525, 63, 5173, 8, 16, 12, 413, 12, 5401, 29, 19, 9, 267, 291, 14, 39, 275, 8484, 14, 23208, 342, 221, 327, 949, 4931, 267, 291, 14, 39, 14, 525, 63, 6929, 63, 504, 8318, 83, 297, 283, 85, 659, 661, 83, 297, 283, 88, 659, 3044, 661, 85, 297, 283, 86, 659, 661, 85, 297, 283, 88, 659, 3044, 661, 86, 297, 283, 89, 659, 661, 88, 297, 283, 85, 659, 3044, 661, 88, 297, 283, 86, 659, 661, 88, 297, 283, 89, 659, 3044, 661, 89, 297, 283, 83, 659, 661, 89, 297, 283, 86, 2023, 421, 199, 533, 1379, 6004, 8364, 2042, 8, 6004, 8364, 14440, 304, 339, 347, 511, 63, 328, 17421, 14183, 8, 277, 304, 267, 334, 36, 12, 510, 9, 275, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 8, 277, 14, 56, 39, 12, 283, 83, 358, 267, 4107, 63, 515, 8, 277, 14, 56, 39, 12, 283, 83, 297, 283, 86, 297, 1749, 12, 510, 459, 86, 1105, 267, 702, 577, 459, 86, 418, 508, 1749, 398, 4107, 63, 515, 8, 288, 291, 14, 56, 39, 12, 283, 83, 297, 283, 86, 297, 1749, 12, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 63, 515, 8, 277, 14, 56, 39, 12, 283, 83, 24211, 86, 1105, 267, 702, 1211, 8, 288, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 63, 515, 63, 1267, 8, 277, 14, 56, 39, 12, 283, 83, 1333, 459, 86, 418, 508, 1749, 398, 4107, 63, 515, 8, 288, 291, 14, 56, 39, 12, 283, 83, 297, 283, 86, 297, 1749, 12, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 8, 277, 14, 56, 39, 12, 283, 83, 5832, 17, 2733, 86, 1105, 267, 4107, 63, 515, 8, 288, 291, 14, 17401, 39, 12, 283, 83, 297 ]
[ 646, 4613, 199, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 492, 24859, 421, 199, 318, 4107, 63, 515, 8, 39, 12, 308, 12, 307, 12, 8597, 78, 63, 552, 12, 931, 304, 272, 702, 931, 59, 16, 61, 508, 308, 272, 702, 931, 1988, 17, 61, 508, 307, 272, 340, 440, 598, 14, 374, 63, 3029, 2180, 837, 267, 9235, 275, 3089, 8, 39, 59, 85, 1527, 86, 1055, 362, 360, 3463, 297, 413, 9, 367, 399, 12, 373, 315, 24859, 8, 515, 430, 267, 702, 8597, 78, 63, 552, 508, 9235, 272, 587, 26, 267, 9235, 275, 3089, 8, 827, 8, 69, 14, 362, 360, 3463, 297, 413, 9, 367, 325, 315, 598, 59, 85, 1527, 86, 1055, 1459, 1012, 2432, 367, 399, 12, 373, 315, 24859, 8, 515, 430, 267, 702, 8597, 78, 63, 552, 508, 9235, 421, 199, 318, 4107, 63, 1267, 63, 515, 8, 39, 12, 308, 12, 307, 12, 8597, 78, 63, 552, 12, 2582, 12, 931, 304, 272, 702, 8597, 78, 63, 552, 508, 2582, 272, 4107, 63, 515, 8, 39, 12, 308, 12, 307, 12, 2582, 12, 931, 9, 421, 199, 533, 2136, 8364, 14440, 8, 785, 304, 272, 408, 1563, 1021, 367, 511, 3992, 626, 511, 3423, 367, 17226, 272, 26564, 3792, 315, 14609, 18312, 14, 339, 408, 339, 347, 3272, 8, 277, 304, 267, 408, 10607, 2005, 18312, 367, 675, 315, 314, 4137, 2295, 1041, 267, 286, 7530, 280, 275, 8484, 14, 3916, 63, 932, 63, 3512, 63, 475, 63, 23931, 267, 291, 14, 3825, 275, 286, 7530, 280, 8, 7343, 14, 3825, 63, 18, 68, 63, 2180, 8, 20, 12, 841, 395, 1642, 63, 1302, 29, 17, 12, 2079, 7794, 628, 5917, 531, 267, 291, 14, 7612, 275, 8484, 14, 7612, 63, 2180, 8, 23, 9, 267, 291, 14, 12080, 63, 7612, 275, 8484, 14, 7612, 63, 2180, 8, 23, 12, 1218, 63, 4941, 29, 7343, 14, 23208, 1012, 267, 291, 14, 56, 39, 275, 8484, 14, 23208, 342, 267, 291, 14, 56, 39, 14, 525, 63, 13522, 63, 6929, 63, 504, 8318, 83, 297, 283, 85, 297, 1616, 395, 661, 83, 297, 283, 88, 297, 959, 395, 1460, 661, 85, 297, 283, 86, 297, 413, 395, 661, 85, 297, 283, 88, 297, 499, 395, 1460, 661, 86, 297, 283, 89, 297, 413, 395, 661, 88, 297, 283, 85, 297, 650, 395, 1460, 661, 88, 297, 283, 86, 297, 959, 395, 661, 88, 297, 283, 89, 297, 499, 395, 1460, 661, 89, 297, 283, 83, 297, 1520, 395, 661, 89, 297, 283, 86, 297, 1227, 3948, 267, 291, 14, 17401, 39, 275, 8484, 14, 3947, 23208, 8, 277, 14, 56, 39, 9, 267, 291, 14, 17401, 39, 14, 525, 63, 5173, 360, 83, 297, 283, 85, 297, 5401, 29, 1046, 9, 267, 291, 14, 56, 39, 18, 275, 8484, 14, 23208, 342, 267, 291, 14, 56, 39, 18, 14, 525, 63, 13522, 63, 6929, 63, 504, 4038, 17, 12, 841, 12, 413, 467, 359, 20, 12, 959, 12, 413, 467, 5101, 359, 21, 12, 1227, 12, 413, 467, 359, 22, 12, 650, 12, 413, 467, 5101, 359, 17, 12, 650, 12, 5238, 467, 359, 17, 12, 499, 12, 2948, 467, 5101, 359, 18, 12, 650, 12, 2948, 3934, 398, 291, 14, 56, 39, 19, 275, 8484, 14, 4578, 342, 267, 291, 14, 56, 39, 19, 14, 525, 63, 13522, 63, 6929, 63, 504, 4038, 16, 12, 413, 12, 499, 467, 359, 17, 12, 499, 12, 3144, 467, 5101, 359, 18, 12, 650, 12, 413, 467, 359, 19, 12, 841, 12, 959, 467, 5101, 359, 20, 12, 959, 12, 413, 467, 359, 21, 12, 378, 12, 1616, 3934, 398, 291, 14, 56, 39, 20, 275, 8484, 14, 4578, 342, 267, 291, 14, 56, 39, 20, 14, 525, 63, 13522, 63, 6929, 63, 504, 4038, 16, 12, 413, 12, 499, 467, 359, 17, 12, 499, 12, 499, 467, 5101, 359, 18, 12, 650, 12, 413, 467, 359, 19, 12, 841, 12, 413, 467, 5101, 359, 20, 12, 959, 12, 413, 467, 359, 21, 12, 1227, 12, 413, 467, 5101, 359, 22, 12, 1520, 12, 413, 467, 359, 23, 12, 378, 12, 413, 3934, 267, 291, 14, 17401, 39, 20, 275, 8484, 14, 3947, 4578, 8, 277, 14, 56, 39, 20, 9, 267, 291, 14, 17401, 39, 20, 14, 525, 63, 5173, 8, 16, 12, 413, 12, 5401, 29, 19, 9, 267, 291, 14, 39, 275, 8484, 14, 23208, 342, 221, 327, 949, 4931, 267, 291, 14, 39, 14, 525, 63, 6929, 63, 504, 8318, 83, 297, 283, 85, 659, 661, 83, 297, 283, 88, 659, 3044, 661, 85, 297, 283, 86, 659, 661, 85, 297, 283, 88, 659, 3044, 661, 86, 297, 283, 89, 659, 661, 88, 297, 283, 85, 659, 3044, 661, 88, 297, 283, 86, 659, 661, 88, 297, 283, 89, 659, 3044, 661, 89, 297, 283, 83, 659, 661, 89, 297, 283, 86, 2023, 421, 199, 533, 1379, 6004, 8364, 2042, 8, 6004, 8364, 14440, 304, 339, 347, 511, 63, 328, 17421, 14183, 8, 277, 304, 267, 334, 36, 12, 510, 9, 275, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 8, 277, 14, 56, 39, 12, 283, 83, 358, 267, 4107, 63, 515, 8, 277, 14, 56, 39, 12, 283, 83, 297, 283, 86, 297, 1749, 12, 510, 459, 86, 1105, 267, 702, 577, 459, 86, 418, 508, 1749, 398, 4107, 63, 515, 8, 288, 291, 14, 56, 39, 12, 283, 83, 297, 283, 86, 297, 1749, 12, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 63, 515, 8, 277, 14, 56, 39, 12, 283, 83, 24211, 86, 1105, 267, 702, 1211, 8, 288, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 63, 515, 63, 1267, 8, 277, 14, 56, 39, 12, 283, 83, 1333, 459, 86, 418, 508, 1749, 398, 4107, 63, 515, 8, 288, 291, 14, 56, 39, 12, 283, 83, 297, 283, 86, 297, 1749, 12, 8484, 14, 4780, 63, 1365, 63, 328, 17421, 14183, 8, 277, 14, 56, 39, 12, 283, 83, 5832, 17, 2733, 86, 1105, 267, 4107, 63, 515, 8, 288, 291, 14, 17401, 39, 12, 283, 83, 297, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
google/makani
gs/monitor2/apps/plugins/layouts/motor_layout.py
1
2241
# Copyright 2020 Makani Technologies LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Layout to monitor motors.""" from makani.gs.monitor2.apps.layout import base from makani.gs.monitor2.apps.plugins import common from makani.gs.monitor2.apps.plugins.indicators import motor class MotorLayout(base.BaseLayout): """Layout to monitor motors.""" _NAME = 'Motors' _DESIRED_VIEW_COLS = 2 _MODE = common.FULL_COMMS_MODE def Initialize(self): # Define how motors should be grouped, each group renders a chart. self._motor_groups = { 'PTO/SBO': ['Pto', 'Sbo'], 'PBO/STO': ['Pbo', 'Sto'], 'PTI/SBI': ['Pti', 'Sbi'], 'PBI/STI': ['Pbi', 'Sti'], } self._AddIndicators('Status', [ motor.AioUpdateIndicator(self._MODE), motor.ArmedIndicator(self._MODE), motor.ErrorIndicator(self._MODE), motor.WarningIndicator(self._MODE), motor.MotorBusVoltageIndicator(self._MODE), ]) self._AddIndicators('Temperatures', [ motor.BoardTemperatureIndicator(self._MODE), motor.HeatPlateTemperatureIndicator(self._MODE), motor.StatorCoreTemperatureIndicator(self._MODE), motor.WindingTemperatureIndicator(self._MODE), ]) self._AddIndicators('Warning and error printout', [ motor.MotorFlagNameIndicator(self._MODE, 'Warnings'), motor.MotorFlagNameIndicator(self._MODE, 'Errors'), ]) self._UpdateProperties('Warning and error printout', {'cols': 2}) self._AddIndicators('Speed', [ motor.SpeedStackingChart(self._MODE, group_name, motor_short_names) for group_name, motor_short_names in self._motor_groups.iteritems()]) self._UpdateProperties('Speed', {'cols': 2})
apache-2.0
[ 3, 1898, 25455, 603, 1151, 26455, 19215, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 624, 4798, 370, 8372, 333, 357, 1384, 1041, 199, 199, 504, 5475, 26455, 14, 458, 14, 7157, 18, 14, 5181, 14, 4209, 492, 1300, 199, 504, 5475, 26455, 14, 458, 14, 7157, 18, 14, 5181, 14, 5265, 492, 2863, 199, 504, 5475, 26455, 14, 458, 14, 7157, 18, 14, 5181, 14, 5265, 14, 13363, 2750, 492, 28496, 421, 199, 533, 603, 13147, 4798, 8, 1095, 14, 1563, 4798, 304, 523, 408, 4798, 370, 8372, 333, 357, 1384, 1041, 819, 485, 2339, 275, 283, 45, 357, 1384, 7, 523, 485, 4448, 10322, 63, 12058, 63, 3978, 51, 275, 499, 523, 485, 6963, 275, 2863, 14, 14742, 63, 11265, 3053, 63, 6963, 819, 347, 11578, 8, 277, 304, 272, 327, 13930, 4212, 333, 357, 1384, 1077, 506, 16251, 12, 1924, 1572, 3795, 83, 282, 10943, 14, 272, 291, 423, 27840, 63, 2634, 275, 469, 267, 283, 48, 2566, 15, 51, 3973, 356, 788, 48, 475, 297, 283, 51, 656, 995, 267, 283, 48, 3973, 15, 21739, 356, 788, 48, 656, 297, 283, 4759, 995, 267, 283, 4189, 41, 15, 12463, 41, 356, 788, 48, 280, 297, 283, 51, 4492, 995, 267, 283, 13167, 41, 15, 840, 41, 356, 788, 48, 4492, 297, 283, 51, 280, 995, 272, 789, 339, 291, 423, 1123, 21833, 2750, 360, 3694, 297, 359, 267, 28496, 14, 33, 2308, 4152, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 1596, 3594, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 547, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 3849, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 31642, 12106, 16969, 15028, 24000, 8, 277, 423, 6963, 395, 272, 4794, 339, 291, 423, 1123, 21833, 2750, 360, 6530, 281, 2093, 297, 359, 267, 28496, 14, 18995, 27409, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 30770, 29020, 27409, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 933, 707, 5402, 27409, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 55, 688, 316, 27409, 24000, 8, 277, 423, 6963, 395, 272, 4794, 339, 291, 423, 1123, 21833, 2750, 360, 3849, 436, 1125, 870, 548, 297, 359, 267, 28496, 14, 31642, 5318, 985, 24000, 8, 277, 423, 6963, 12, 283, 15921, 659, 267, 28496, 14, 31642, 5318, 985, 24000, 8, 277, 423, 6963, 12, 283, 9298, 659, 272, 4794, 339, 291, 423, 4152, 8516, 360, 3849, 436, 1125, 870, 548, 297, 791, 4574, 356, 499, 1552, 339, 291, 423, 1123, 21833, 2750, 360, 15146, 297, 359, 267, 28496, 14, 15146, 4851, 316, 16372, 8, 277, 423, 6963, 12, 1572, 63, 354, 12, 28496, 63, 3612, 63, 1247, 9, 267, 367, 1572, 63, 354, 12, 28496, 63, 3612, 63, 1247, 315, 291, 423, 27840, 63, 2634, 14, 4611, 9383, 339, 291, 423, 4152, 8516, 360, 15146, 297, 791, 4574, 356, 499, 1552, 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 ]
[ 1898, 25455, 603, 1151, 26455, 19215, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 624, 4798, 370, 8372, 333, 357, 1384, 1041, 199, 199, 504, 5475, 26455, 14, 458, 14, 7157, 18, 14, 5181, 14, 4209, 492, 1300, 199, 504, 5475, 26455, 14, 458, 14, 7157, 18, 14, 5181, 14, 5265, 492, 2863, 199, 504, 5475, 26455, 14, 458, 14, 7157, 18, 14, 5181, 14, 5265, 14, 13363, 2750, 492, 28496, 421, 199, 533, 603, 13147, 4798, 8, 1095, 14, 1563, 4798, 304, 523, 408, 4798, 370, 8372, 333, 357, 1384, 1041, 819, 485, 2339, 275, 283, 45, 357, 1384, 7, 523, 485, 4448, 10322, 63, 12058, 63, 3978, 51, 275, 499, 523, 485, 6963, 275, 2863, 14, 14742, 63, 11265, 3053, 63, 6963, 819, 347, 11578, 8, 277, 304, 272, 327, 13930, 4212, 333, 357, 1384, 1077, 506, 16251, 12, 1924, 1572, 3795, 83, 282, 10943, 14, 272, 291, 423, 27840, 63, 2634, 275, 469, 267, 283, 48, 2566, 15, 51, 3973, 356, 788, 48, 475, 297, 283, 51, 656, 995, 267, 283, 48, 3973, 15, 21739, 356, 788, 48, 656, 297, 283, 4759, 995, 267, 283, 4189, 41, 15, 12463, 41, 356, 788, 48, 280, 297, 283, 51, 4492, 995, 267, 283, 13167, 41, 15, 840, 41, 356, 788, 48, 4492, 297, 283, 51, 280, 995, 272, 789, 339, 291, 423, 1123, 21833, 2750, 360, 3694, 297, 359, 267, 28496, 14, 33, 2308, 4152, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 1596, 3594, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 547, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 3849, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 31642, 12106, 16969, 15028, 24000, 8, 277, 423, 6963, 395, 272, 4794, 339, 291, 423, 1123, 21833, 2750, 360, 6530, 281, 2093, 297, 359, 267, 28496, 14, 18995, 27409, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 30770, 29020, 27409, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 933, 707, 5402, 27409, 24000, 8, 277, 423, 6963, 395, 267, 28496, 14, 55, 688, 316, 27409, 24000, 8, 277, 423, 6963, 395, 272, 4794, 339, 291, 423, 1123, 21833, 2750, 360, 3849, 436, 1125, 870, 548, 297, 359, 267, 28496, 14, 31642, 5318, 985, 24000, 8, 277, 423, 6963, 12, 283, 15921, 659, 267, 28496, 14, 31642, 5318, 985, 24000, 8, 277, 423, 6963, 12, 283, 9298, 659, 272, 4794, 339, 291, 423, 4152, 8516, 360, 3849, 436, 1125, 870, 548, 297, 791, 4574, 356, 499, 1552, 339, 291, 423, 1123, 21833, 2750, 360, 15146, 297, 359, 267, 28496, 14, 15146, 4851, 316, 16372, 8, 277, 423, 6963, 12, 1572, 63, 354, 12, 28496, 63, 3612, 63, 1247, 9, 267, 367, 1572, 63, 354, 12, 28496, 63, 3612, 63, 1247, 315, 291, 423, 27840, 63, 2634, 14, 4611, 9383, 339, 291, 423, 4152, 8516, 360, 15146, 297, 791, 4574, 356, 499, 1552, 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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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 ]
40423103/2017springcd_ag2
plugin/tipue_search/tipue_search.py
251
3821
# -*- coding: utf-8 -*- """ Tipue Search ============ A Pelican plugin to serialize generated HTML to JSON that can be used by jQuery plugin - Tipue Search. Copyright (c) Talha Mansoor """ from __future__ import unicode_literals import os.path import json from bs4 import BeautifulSoup from codecs import open try: from urlparse import urljoin except ImportError: from urllib.parse import urljoin from pelican import signals class Tipue_Search_JSON_Generator(object): def __init__(self, context, settings, path, theme, output_path, *null): self.output_path = output_path self.context = context self.siteurl = settings.get('SITEURL') self.tpages = settings.get('TEMPLATE_PAGES') self.output_path = output_path self.json_nodes = [] def create_json_node(self, page): if getattr(page, 'status', 'published') != 'published': return soup_title = BeautifulSoup(page.title.replace('&nbsp;', ' '), 'html.parser') page_title = soup_title.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('^', '&#94;') soup_text = BeautifulSoup(page.content, 'html.parser') page_text = soup_text.get_text(' ', strip=True).replace('“', '"').replace('”', '"').replace('’', "'").replace('¶', ' ').replace('^', '&#94;') page_text = ' '.join(page_text.split()) if getattr(page, 'category', 'None') == 'None': page_category = '' else: page_category = page.category.name page_url = self.siteurl + '/' + page.url node = {'title': page_title, 'text': page_text, 'tags': page_category, 'url': page_url} self.json_nodes.append(node) def create_tpage_node(self, srclink): srcfile = open(os.path.join(self.output_path, self.tpages[srclink]), encoding='utf-8') soup = BeautifulSoup(srcfile, 'html.parser') page_text = soup.get_text() # What happens if there is not a title. if soup.title is not None: page_title = soup.title.string else: page_title = '' # Should set default category? page_category = '' page_url = urljoin(self.siteurl, self.tpages[srclink]) node = {'title': page_title, 'text': page_text, 'tags': page_category, 'url': page_url} self.json_nodes.append(node) def generate_output(self, writer): path = os.path.join(self.output_path, 'tipuesearch_content.json') pages = self.context['pages'] + self.context['articles'] for article in self.context['articles']: pages += article.translations for srclink in self.tpages: self.create_tpage_node(srclink) for page in pages: self.create_json_node(page) root_node = {'pages': self.json_nodes} #因為目前改為 local only, 所以蓋掉 .json 建立 #with open(path, 'w', encoding='utf-8') as fd: # 寫出所需要的 .json 檔案 #json.dump(root_node, fd, separators=(',', ':'), ensure_ascii=False) # 以下寫出 .js 檔案, 主要用於近端的 Tipue search js_path = os.path.join(self.output_path, 'tipuesearch_content.js') with open(js_path, 'w', encoding='utf-8') as fd: # 寫出所需要的 .js 檔案 search_text = json.dumps(root_node, separators=(',', ':'), ensure_ascii=False) fd.write('var tipuesearch = ') fd.write(search_text) fd.write(';') def get_generators(generators): return Tipue_Search_JSON_Generator def register(): signals.get_generators.connect(get_generators)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 15915, 310, 8730, 199, 5769, 199, 199, 33, 11379, 28091, 3589, 370, 8437, 4046, 4163, 370, 4840, 199, 9099, 883, 506, 1202, 701, 1335, 3227, 3589, 446, 377, 711, 310, 8730, 14, 199, 199, 7384, 334, 67, 9, 377, 279, 2411, 603, 796, 79, 269, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 14, 515, 199, 646, 2022, 199, 504, 9922, 20, 492, 17132, 199, 504, 6010, 492, 1551, 199, 893, 26, 272, 687, 7097, 492, 20818, 199, 2590, 3545, 26, 272, 687, 4011, 14, 1122, 492, 20818, 199, 199, 504, 4837, 28091, 492, 10166, 421, 199, 533, 377, 711, 310, 63, 5278, 63, 6243, 63, 7599, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1067, 12, 2202, 12, 931, 12, 8879, 12, 1072, 63, 515, 12, 627, 2307, 304, 398, 291, 14, 1199, 63, 515, 275, 1072, 63, 515, 267, 291, 14, 1100, 275, 1067, 267, 291, 14, 2124, 633, 275, 2202, 14, 362, 360, 7917, 2632, 358, 267, 291, 14, 84, 5856, 275, 2202, 14, 362, 360, 7433, 63, 48, 5383, 358, 267, 291, 14, 1199, 63, 515, 275, 1072, 63, 515, 267, 291, 14, 1001, 63, 2415, 275, 942, 2378, 347, 1218, 63, 1001, 63, 932, 8, 277, 12, 2034, 304, 398, 340, 2519, 8, 1606, 12, 283, 1205, 297, 283, 8987, 358, 1137, 283, 8987, 356, 288, 372, 398, 9108, 63, 1213, 275, 17132, 8, 1606, 14, 1213, 14, 1814, 20040, 10758, 10805, 283, 17748, 283, 1360, 14, 2087, 358, 267, 2034, 63, 1213, 275, 9108, 63, 1213, 14, 362, 63, 505, 360, 1656, 6202, 29, 549, 680, 1814, 360, 8477, 251, 297, 5522, 1959, 1814, 360, 8477, 252, 297, 5522, 1959, 1814, 360, 21045, 297, 3546, 3471, 1814, 9097, 297, 7673, 3, 2635, 10784, 398, 9108, 63, 505, 275, 17132, 8, 1606, 14, 1317, 12, 283, 1360, 14, 2087, 358, 267, 2034, 63, 505, 275, 9108, 63, 505, 14, 362, 63, 505, 360, 1656, 6202, 29, 549, 680, 1814, 360, 8477, 251, 297, 5522, 1959, 1814, 360, 8477, 252, 297, 5522, 1959, 1814, 360, 21045, 297, 3546, 3471, 1814, 360, 127, 115, 297, 283, 27274, 1814, 9097, 297, 7673, 3, 2635, 10784, 267, 2034, 63, 505, 275, 283, 1987, 904, 8, 1606, 63, 505, 14, 1294, 1012, 398, 340, 2519, 8, 1606, 12, 283, 3710, 297, 283, 403, 358, 508, 283, 403, 356, 288, 2034, 63, 3710, 275, 2125, 267, 587, 26, 288, 2034, 63, 3710, 275, 2034, 14, 3710, 14, 354, 398, 2034, 63, 633, 275, 291, 14, 2124, 633, 435, 7324, 435, 2034, 14, 633, 398, 1031, 275, 791, 1213, 356, 2034, 63, 1213, 12, 355, 283, 505, 356, 2034, 63, 505, 12, 355, 283, 2969, 356, 2034, 63, 3710, 12, 355, 283, 633, 356, 2034, 63, 633, 93, 398, 291, 14, 1001, 63, 2415, 14, 740, 8, 932, 9, 2378, 347, 1218, 63, 84, 1606, 63, 932, 8, 277, 12, 11483, 429, 2292, 304, 398, 2928, 493, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1199, 63, 515, 12, 291, 14, 84, 5856, 59, 5474, 429, 2292, 2522, 2644, 534, 1624, 13, 24, 358, 267, 9108, 275, 17132, 8, 29903, 12, 283, 1360, 14, 2087, 358, 267, 2034, 63, 505, 275, 9108, 14, 362, 63, 505, 342, 398, 327, 14791, 10986, 340, 2337, 365, 440, 282, 2538, 14, 267, 340, 9108, 14, 1213, 365, 440, 488, 26, 288, 2034, 63, 1213, 275, 9108, 14, 1213, 14, 875, 267, 587, 26, 288, 2034, 63, 1213, 275, 2125, 398, 327, 7719, 663, 849, 4637, 31, 267, 2034, 63, 3710, 275, 2125, 398, 2034, 63, 633, 275, 20818, 8, 277, 14, 2124, 633, 12, 291, 14, 84, 5856, 59, 5474, 429, 2292, 566, 398, 1031, 275, 791, 1213, 356, 2034, 63, 1213, 12, 355, 283, 505, 356, 2034, 63, 505, 12, 355, 283, 2969, 356, 2034, 63, 3710, 12, 355, 283, 633, 356, 2034, 63, 633, 93, 398, 291, 14, 1001, 63, 2415, 14, 740, 8, 932, 9, 2378, 347, 3550, 63, 1199, 8, 277, 12, 7060, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1199, 63, 515, 12, 283, 8996, 310, 1733, 63, 1317, 14, 1001, 358, 398, 6497, 275, 291, 14, 1100, 459, 5856, 418, 435, 291, 14, 1100, 459, 19813, 418, 398, 367, 9772, 315, 291, 14, 1100, 459, 19813, 2565, 288, 6497, 847, 9772, 14, 13982, 398, 367, 11483, 429, 2292, 315, 291, 14, 84, 5856, 26, 288, 291, 14, 981, 63, 84, 1606, 63, 932, 8, 5474, 429, 2292, 9, 398, 367, 2034, 315, 6497, 26, 288, 291, 14, 981, 63, 1001, 63, 932, 8, 1606, 9, 267, 1738, 63, 932, 275, 791, 5856, 356, 291, 14, 1001, 63, 2415, 93, 398, 327, 14339, 255, 24889, 31869, 27284, 17130, 118, 24889, 2257, 1454, 12, 8853, 232, 223, 23681, 165, 242, 234, 17797, 232, 1275, 1001, 7094, 120, 119, 21341, 234, 267, 327, 1045, 1551, 8, 515, 12, 283, 87, 297, 2644, 534, 1624, 13, 24, 358, 465, 6111, 26, 288, 327, 7094, 108, 105, 22914, 16570, 166, 251, 223, 22274, 8106, 1275, 1001, 8853, 104, 243, 31333, 231, 288, 327, 1001, 14, 2724, 8, 1231, 63, 932, 12, 6111, 12, 17658, 2687, 23324, 7596, 659, 4868, 63, 4371, 29, 797, 9, 199, 2728, 327, 221, 23681, 24233, 15150, 105, 22914, 1275, 3596, 8853, 104, 243, 31333, 231, 12, 221, 4344, 120, 22274, 11428, 10310, 121, 13201, 240, 21341, 108, 8106, 377, 711, 310, 2754, 267, 8586, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1199, 63, 515, 12, 283, 8996, 310, 1733, 63, 1317, 14, 3596, 358, 267, 543, 1551, 8, 3596, 63, 515, 12, 283, 87, 297, 2644, 534, 1624, 13, 24, 358, 465, 6111, 26, 288, 327, 7094, 108, 105, 22914, 16570, 166, 251, 223, 22274, 8106, 1275, 3596, 8853, 104, 243, 31333, 231, 288, 2754, 63, 505, 275, 2022, 14, 4180, 8, 1231, 63, 932, 12, 17658, 2687, 23324, 7596, 659, 4868, 63, 4371, 29, 797, 9, 288, 6111, 14, 952, 360, 1391, 19201, 310, 1733, 275, 5320, 288, 6111 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 15915, 310, 8730, 199, 5769, 199, 199, 33, 11379, 28091, 3589, 370, 8437, 4046, 4163, 370, 4840, 199, 9099, 883, 506, 1202, 701, 1335, 3227, 3589, 446, 377, 711, 310, 8730, 14, 199, 199, 7384, 334, 67, 9, 377, 279, 2411, 603, 796, 79, 269, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 14, 515, 199, 646, 2022, 199, 504, 9922, 20, 492, 17132, 199, 504, 6010, 492, 1551, 199, 893, 26, 272, 687, 7097, 492, 20818, 199, 2590, 3545, 26, 272, 687, 4011, 14, 1122, 492, 20818, 199, 199, 504, 4837, 28091, 492, 10166, 421, 199, 533, 377, 711, 310, 63, 5278, 63, 6243, 63, 7599, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1067, 12, 2202, 12, 931, 12, 8879, 12, 1072, 63, 515, 12, 627, 2307, 304, 398, 291, 14, 1199, 63, 515, 275, 1072, 63, 515, 267, 291, 14, 1100, 275, 1067, 267, 291, 14, 2124, 633, 275, 2202, 14, 362, 360, 7917, 2632, 358, 267, 291, 14, 84, 5856, 275, 2202, 14, 362, 360, 7433, 63, 48, 5383, 358, 267, 291, 14, 1199, 63, 515, 275, 1072, 63, 515, 267, 291, 14, 1001, 63, 2415, 275, 942, 2378, 347, 1218, 63, 1001, 63, 932, 8, 277, 12, 2034, 304, 398, 340, 2519, 8, 1606, 12, 283, 1205, 297, 283, 8987, 358, 1137, 283, 8987, 356, 288, 372, 398, 9108, 63, 1213, 275, 17132, 8, 1606, 14, 1213, 14, 1814, 20040, 10758, 10805, 283, 17748, 283, 1360, 14, 2087, 358, 267, 2034, 63, 1213, 275, 9108, 63, 1213, 14, 362, 63, 505, 360, 1656, 6202, 29, 549, 680, 1814, 360, 8477, 251, 297, 5522, 1959, 1814, 360, 8477, 252, 297, 5522, 1959, 1814, 360, 21045, 297, 3546, 3471, 1814, 9097, 297, 7673, 3, 2635, 10784, 398, 9108, 63, 505, 275, 17132, 8, 1606, 14, 1317, 12, 283, 1360, 14, 2087, 358, 267, 2034, 63, 505, 275, 9108, 63, 505, 14, 362, 63, 505, 360, 1656, 6202, 29, 549, 680, 1814, 360, 8477, 251, 297, 5522, 1959, 1814, 360, 8477, 252, 297, 5522, 1959, 1814, 360, 21045, 297, 3546, 3471, 1814, 360, 127, 115, 297, 283, 27274, 1814, 9097, 297, 7673, 3, 2635, 10784, 267, 2034, 63, 505, 275, 283, 1987, 904, 8, 1606, 63, 505, 14, 1294, 1012, 398, 340, 2519, 8, 1606, 12, 283, 3710, 297, 283, 403, 358, 508, 283, 403, 356, 288, 2034, 63, 3710, 275, 2125, 267, 587, 26, 288, 2034, 63, 3710, 275, 2034, 14, 3710, 14, 354, 398, 2034, 63, 633, 275, 291, 14, 2124, 633, 435, 7324, 435, 2034, 14, 633, 398, 1031, 275, 791, 1213, 356, 2034, 63, 1213, 12, 355, 283, 505, 356, 2034, 63, 505, 12, 355, 283, 2969, 356, 2034, 63, 3710, 12, 355, 283, 633, 356, 2034, 63, 633, 93, 398, 291, 14, 1001, 63, 2415, 14, 740, 8, 932, 9, 2378, 347, 1218, 63, 84, 1606, 63, 932, 8, 277, 12, 11483, 429, 2292, 304, 398, 2928, 493, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1199, 63, 515, 12, 291, 14, 84, 5856, 59, 5474, 429, 2292, 2522, 2644, 534, 1624, 13, 24, 358, 267, 9108, 275, 17132, 8, 29903, 12, 283, 1360, 14, 2087, 358, 267, 2034, 63, 505, 275, 9108, 14, 362, 63, 505, 342, 398, 327, 14791, 10986, 340, 2337, 365, 440, 282, 2538, 14, 267, 340, 9108, 14, 1213, 365, 440, 488, 26, 288, 2034, 63, 1213, 275, 9108, 14, 1213, 14, 875, 267, 587, 26, 288, 2034, 63, 1213, 275, 2125, 398, 327, 7719, 663, 849, 4637, 31, 267, 2034, 63, 3710, 275, 2125, 398, 2034, 63, 633, 275, 20818, 8, 277, 14, 2124, 633, 12, 291, 14, 84, 5856, 59, 5474, 429, 2292, 566, 398, 1031, 275, 791, 1213, 356, 2034, 63, 1213, 12, 355, 283, 505, 356, 2034, 63, 505, 12, 355, 283, 2969, 356, 2034, 63, 3710, 12, 355, 283, 633, 356, 2034, 63, 633, 93, 398, 291, 14, 1001, 63, 2415, 14, 740, 8, 932, 9, 2378, 347, 3550, 63, 1199, 8, 277, 12, 7060, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1199, 63, 515, 12, 283, 8996, 310, 1733, 63, 1317, 14, 1001, 358, 398, 6497, 275, 291, 14, 1100, 459, 5856, 418, 435, 291, 14, 1100, 459, 19813, 418, 398, 367, 9772, 315, 291, 14, 1100, 459, 19813, 2565, 288, 6497, 847, 9772, 14, 13982, 398, 367, 11483, 429, 2292, 315, 291, 14, 84, 5856, 26, 288, 291, 14, 981, 63, 84, 1606, 63, 932, 8, 5474, 429, 2292, 9, 398, 367, 2034, 315, 6497, 26, 288, 291, 14, 981, 63, 1001, 63, 932, 8, 1606, 9, 267, 1738, 63, 932, 275, 791, 5856, 356, 291, 14, 1001, 63, 2415, 93, 398, 327, 14339, 255, 24889, 31869, 27284, 17130, 118, 24889, 2257, 1454, 12, 8853, 232, 223, 23681, 165, 242, 234, 17797, 232, 1275, 1001, 7094, 120, 119, 21341, 234, 267, 327, 1045, 1551, 8, 515, 12, 283, 87, 297, 2644, 534, 1624, 13, 24, 358, 465, 6111, 26, 288, 327, 7094, 108, 105, 22914, 16570, 166, 251, 223, 22274, 8106, 1275, 1001, 8853, 104, 243, 31333, 231, 288, 327, 1001, 14, 2724, 8, 1231, 63, 932, 12, 6111, 12, 17658, 2687, 23324, 7596, 659, 4868, 63, 4371, 29, 797, 9, 199, 2728, 327, 221, 23681, 24233, 15150, 105, 22914, 1275, 3596, 8853, 104, 243, 31333, 231, 12, 221, 4344, 120, 22274, 11428, 10310, 121, 13201, 240, 21341, 108, 8106, 377, 711, 310, 2754, 267, 8586, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1199, 63, 515, 12, 283, 8996, 310, 1733, 63, 1317, 14, 3596, 358, 267, 543, 1551, 8, 3596, 63, 515, 12, 283, 87, 297, 2644, 534, 1624, 13, 24, 358, 465, 6111, 26, 288, 327, 7094, 108, 105, 22914, 16570, 166, 251, 223, 22274, 8106, 1275, 3596, 8853, 104, 243, 31333, 231, 288, 2754, 63, 505, 275, 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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 ]
jokey2k/sentry
tests/sentry/web/frontend/test_remove_project.py
18
2370
from __future__ import absolute_import import mock from django.core.urlresolvers import reverse from sentry.models import Project, ProjectStatus from sentry.testutils import TestCase, PermissionTestCase class RemoveProjectPermissionTest(PermissionTestCase): def setUp(self): super(RemoveProjectPermissionTest, self).setUp() self.project = self.create_project(team=self.team) self.path = reverse('sentry-remove-project', args=[self.organization.slug, self.project.slug]) def test_teamless_owner_cannot_load(self): self.assert_teamless_owner_cannot_access(self.path) def test_team_admin_cannot_load(self): self.assert_team_admin_cannot_access(self.path) def test_team_owner_can_load(self): self.assert_team_owner_can_access(self.path) def test_org_admin_cannot_load(self): self.assert_org_admin_cannot_access(self.path) def test_org_owner_can_load(self): self.assert_org_owner_can_access(self.path) class RemoveProjectTest(TestCase): def setUp(self): super(RemoveProjectTest, self).setUp() self.owner = self.create_user(email='example@example.com', is_superuser=False) organization = self.create_organization(owner=self.owner) self.team = self.create_team(name='bar', organization=organization) self.project = self.create_project(name='bar', team=self.team) self.path = reverse('sentry-remove-project', args=[organization.slug, self.project.slug]) def test_requires_authentication(self): self.assertRequiresAuthentication(self.path, 'POST') def test_renders_template_with_get(self): self.login_as(self.owner) resp = self.client.get(self.path) assert resp.status_code == 200 self.assertTemplateUsed(resp, 'sentry/projects/remove.html') assert resp.context['team'] == self.team assert resp.context['project'] == self.project @mock.patch('sentry.web.frontend.remove_project.delete_project') def test_deletion_flow(self, delete_project): self.login_as(self.owner) resp = self.client.post(self.path, {}) assert resp.status_code == 302 delete_project.delay.assert_called_once_with( object_id=self.project.id) assert Project.objects.get(id=self.project.id).status == ProjectStatus.PENDING_DELETION
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 1683, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 26230, 14, 992, 492, 7290, 12, 7290, 3694, 199, 504, 26230, 14, 396, 1208, 492, 7640, 12, 8779, 1746, 421, 199, 533, 5852, 4761, 7980, 774, 8, 7980, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 5587, 4761, 7980, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 5969, 29, 277, 14, 5969, 9, 267, 291, 14, 515, 275, 3837, 360, 3870, 13, 2168, 13, 1715, 297, 1249, 1524, 277, 14, 9071, 14, 5464, 12, 291, 14, 1715, 14, 5464, 566, 339, 347, 511, 63, 5969, 2003, 63, 4597, 63, 11250, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 5969, 2003, 63, 4597, 63, 11250, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 5969, 63, 2113, 63, 11250, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 5969, 63, 2113, 63, 11250, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 5969, 63, 4597, 63, 2425, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 5969, 63, 4597, 63, 2425, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 1308, 63, 2113, 63, 11250, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 1308, 63, 2113, 63, 11250, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 1308, 63, 4597, 63, 2425, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 1308, 63, 4597, 63, 2425, 63, 2732, 8, 277, 14, 515, 9, 421, 199, 533, 5852, 4761, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 5587, 4761, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 4597, 275, 291, 14, 981, 63, 751, 8, 2123, 534, 2694, 32, 2694, 14, 957, 297, 365, 63, 11434, 29, 797, 9, 267, 13237, 275, 291, 14, 981, 63, 9071, 8, 4597, 29, 277, 14, 4597, 9, 267, 291, 14, 5969, 275, 291, 14, 981, 63, 5969, 8, 354, 534, 1700, 297, 13237, 29, 9071, 9, 267, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 354, 534, 1700, 297, 8099, 29, 277, 14, 5969, 9, 267, 291, 14, 515, 275, 3837, 360, 3870, 13, 2168, 13, 1715, 297, 1249, 1524, 9071, 14, 5464, 12, 291, 14, 1715, 14, 5464, 566, 339, 347, 511, 63, 6537, 63, 11725, 8, 277, 304, 267, 291, 14, 479, 18153, 10348, 8, 277, 14, 515, 12, 283, 4030, 358, 339, 347, 511, 63, 3352, 83, 63, 1160, 63, 1045, 63, 362, 8, 277, 304, 267, 291, 14, 2886, 63, 305, 8, 277, 14, 4597, 9, 398, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 291, 14, 19661, 8, 4518, 12, 283, 3870, 15, 6776, 15, 2168, 14, 1360, 358, 267, 702, 3085, 14, 1100, 459, 5969, 418, 508, 291, 14, 5969, 267, 702, 3085, 14, 1100, 459, 1715, 418, 508, 291, 14, 1715, 339, 768, 1805, 14, 2068, 360, 3870, 14, 2520, 14, 18062, 14, 2168, 63, 1715, 14, 1807, 63, 1715, 358, 272, 347, 511, 63, 14281, 63, 1659, 8, 277, 12, 3145, 63, 1715, 304, 267, 291, 14, 2886, 63, 305, 8, 277, 14, 4597, 9, 398, 3085, 275, 291, 14, 1258, 14, 1932, 8, 277, 14, 515, 12, 5009, 267, 702, 3085, 14, 1205, 63, 600, 508, 11485, 267, 3145, 63, 1715, 14, 5814, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 288, 909, 63, 344, 29, 277, 14, 1715, 14, 344, 9, 267, 702, 7290, 14, 1462, 14, 362, 8, 344, 29, 277, 14, 1715, 14, 344, 680, 1205, 508, 7290, 3694, 14, 21243, 63, 4424, 31133, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 1683, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 26230, 14, 992, 492, 7290, 12, 7290, 3694, 199, 504, 26230, 14, 396, 1208, 492, 7640, 12, 8779, 1746, 421, 199, 533, 5852, 4761, 7980, 774, 8, 7980, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 5587, 4761, 7980, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 5969, 29, 277, 14, 5969, 9, 267, 291, 14, 515, 275, 3837, 360, 3870, 13, 2168, 13, 1715, 297, 1249, 1524, 277, 14, 9071, 14, 5464, 12, 291, 14, 1715, 14, 5464, 566, 339, 347, 511, 63, 5969, 2003, 63, 4597, 63, 11250, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 5969, 2003, 63, 4597, 63, 11250, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 5969, 63, 2113, 63, 11250, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 5969, 63, 2113, 63, 11250, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 5969, 63, 4597, 63, 2425, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 5969, 63, 4597, 63, 2425, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 1308, 63, 2113, 63, 11250, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 1308, 63, 2113, 63, 11250, 63, 2732, 8, 277, 14, 515, 9, 339, 347, 511, 63, 1308, 63, 4597, 63, 2425, 63, 912, 8, 277, 304, 267, 291, 14, 479, 63, 1308, 63, 4597, 63, 2425, 63, 2732, 8, 277, 14, 515, 9, 421, 199, 533, 5852, 4761, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 5587, 4761, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 4597, 275, 291, 14, 981, 63, 751, 8, 2123, 534, 2694, 32, 2694, 14, 957, 297, 365, 63, 11434, 29, 797, 9, 267, 13237, 275, 291, 14, 981, 63, 9071, 8, 4597, 29, 277, 14, 4597, 9, 267, 291, 14, 5969, 275, 291, 14, 981, 63, 5969, 8, 354, 534, 1700, 297, 13237, 29, 9071, 9, 267, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 354, 534, 1700, 297, 8099, 29, 277, 14, 5969, 9, 267, 291, 14, 515, 275, 3837, 360, 3870, 13, 2168, 13, 1715, 297, 1249, 1524, 9071, 14, 5464, 12, 291, 14, 1715, 14, 5464, 566, 339, 347, 511, 63, 6537, 63, 11725, 8, 277, 304, 267, 291, 14, 479, 18153, 10348, 8, 277, 14, 515, 12, 283, 4030, 358, 339, 347, 511, 63, 3352, 83, 63, 1160, 63, 1045, 63, 362, 8, 277, 304, 267, 291, 14, 2886, 63, 305, 8, 277, 14, 4597, 9, 398, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 291, 14, 19661, 8, 4518, 12, 283, 3870, 15, 6776, 15, 2168, 14, 1360, 358, 267, 702, 3085, 14, 1100, 459, 5969, 418, 508, 291, 14, 5969, 267, 702, 3085, 14, 1100, 459, 1715, 418, 508, 291, 14, 1715, 339, 768, 1805, 14, 2068, 360, 3870, 14, 2520, 14, 18062, 14, 2168, 63, 1715, 14, 1807, 63, 1715, 358, 272, 347, 511, 63, 14281, 63, 1659, 8, 277, 12, 3145, 63, 1715, 304, 267, 291, 14, 2886, 63, 305, 8, 277, 14, 4597, 9, 398, 3085, 275, 291, 14, 1258, 14, 1932, 8, 277, 14, 515, 12, 5009, 267, 702, 3085, 14, 1205, 63, 600, 508, 11485, 267, 3145, 63, 1715, 14, 5814, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 288, 909, 63, 344, 29, 277, 14, 1715, 14, 344, 9, 267, 702, 7290, 14, 1462, 14, 362, 8, 344, 29, 277, 14, 1715, 14, 344, 680, 1205, 508, 7290, 3694, 14, 21243, 63, 4424, 31133, 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, 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 ]
Vishanth/product-private-paas
components/org.wso2.ppaas.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/instance/status/events.py
11
4337
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import json class InstanceActivatedEvent: def __init__(self, service_name, cluster_id, cluster_instance_id, member_id, instance_id, network_partition_id, partition_id): self.serviceName = service_name """ :type : str """ self.clusterId = cluster_id """ :type : str """ self.clusterInstanceId = cluster_instance_id """ :type : str """ self.memberId = member_id """ :type : str """ self.instanceId = instance_id """ :type : str """ self.networkPartitionId = network_partition_id """ :type : str """ self.partitionId = partition_id """ :type : str """ def to_json(self): return to_json(self) class InstanceStartedEvent: def __init__(self, application_id, service_name, cluster_id, cluster_instance_id, member_id, instance_id, network_partition_id, partition_id): self.applicationId = application_id """ :type : str """ self.serviceName = service_name """ :type : str """ self.clusterId = cluster_id """ :type : str """ self.clusterInstanceId = cluster_instance_id """ :type : str """ self.memberId = member_id """ :type : str """ self.instanceId = instance_id """ :type : str """ self.networkPartitionId = network_partition_id """ :type : str """ self.partitionId = partition_id """ :type : str """ def to_json(self): return to_json(self) class InstanceMaintenanceModeEvent: def __init__(self, service_name, cluster_id, cluster_instance_id, member_id, instance_id, network_partition_id, partition_id): self.serviceName = service_name """ :type : str """ self.clusterId = cluster_id """ :type : str """ self.clusterInstanceId = cluster_instance_id """ :type : str """ self.memberId = member_id """ :type : str """ self.instanceId = instance_id """ :type : str """ self.networkPartitionId = network_partition_id """ :type : str """ self.partitionId = partition_id """ :type : str """ def to_json(self): return to_json(self) class InstanceReadyToShutdownEvent: def __init__(self, service_name, cluster_id, cluster_instance_id, member_id, instance_id, network_partition_id, partition_id): self.serviceName = service_name """ :type : str """ self.clusterId = cluster_id """ :type : str """ self.clusterInstanceId = cluster_instance_id """ :type : str """ self.memberId = member_id """ :type : str """ self.instanceId = instance_id """ :type : str """ self.networkPartitionId = network_partition_id """ :type : str """ self.partitionId = partition_id """ :type : str """ def to_json(self): return to_json(self) class CompleteTopologyRequestEvent: def __init__(self): pass def to_json(self): return to_json(self) class CompleteTenantRequestEvent: def __init__(self): pass def to_json(self): return to_json(self) def to_json(instance): """ common function to serialize status event object :param obj instance: :return: serialized json string :rtype str """ return json.dumps(instance, default=lambda o: o.__dict__, sort_keys=True, indent=4)
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2022, 421, 199, 533, 10066, 13767, 12529, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 10066, 21031, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 4223, 63, 344, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 3578, 1304, 275, 4223, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 10066, 6756, 12182, 1385, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 10066, 17960, 1378, 20043, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 28393, 15696, 2017, 2390, 26, 272, 347, 636, 826, 721, 277, 304, 267, 986, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 28393, 27807, 2017, 2390, 26, 272, 347, 636, 826, 721, 277, 304, 267, 986, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2022, 421, 199, 533, 10066, 13767, 12529, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 10066, 21031, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 4223, 63, 344, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 3578, 1304, 275, 4223, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 10066, 6756, 12182, 1385, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 10066, 17960, 1378, 20043, 2390, 26, 272, 347, 636, 826, 721, 277, 12, 2435, 63, 354, 12, 4350, 63, 344, 12, 4350, 63, 842, 63, 344, 12, 3653, 63, 344, 12, 1256, 63, 344, 12, 326, 2784, 63, 5312, 63, 344, 12, 6484, 63, 344, 304, 267, 291, 14, 1364, 985, 275, 2435, 63, 354, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 1304, 275, 4350, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 4201, 3244, 1304, 275, 4350, 63, 842, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1114, 1304, 275, 3653, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 842, 1304, 275, 1256, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 1200, 13068, 1304, 275, 2784, 63, 5312, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 267, 291, 14, 5312, 1304, 275, 6484, 63, 344, 267, 408, 520, 466, 520, 620, 221, 408, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 28393, 15696, 2017, 2390, 26, 272, 347, 636, 826, 721, 277, 304, 267, 986, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 63, 1001, 8, 277, 9, 421, 199, 533, 28393, 27807, 2017, 2390, 26, 272, 347, 636, 826, 721, 277, 304, 267, 986, 339, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 370, 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, 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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, 1 ]
peter-jang/ansible
contrib/inventory/abiquo.py
110
8860
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' External inventory script for Abiquo ==================================== Shamelessly copied from an existing inventory script. This script generates an inventory that Ansible can understand by making API requests to Abiquo API Requires some python libraries, ensure to have them installed when using this script. This script has been tested in Abiquo 3.0 but it may work also for Abiquo 2.6. Before using this script you may want to modify abiquo.ini config file. This script generates an Ansible hosts file with these host groups: ABQ_xxx: Defines a hosts itself by Abiquo VM name label all: Contains all hosts defined in Abiquo user's enterprise virtualdatecenter: Creates a host group for each virtualdatacenter containing all hosts defined on it virtualappliance: Creates a host group for each virtualappliance containing all hosts defined on it imagetemplate: Creates a host group for each image template containing all hosts using it ''' # (c) 2014, Daniel Beneyto <daniel.beneyto@abiquo.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 sys import time import ConfigParser try: import json except ImportError: import simplejson as json from ansible.module_utils.urls import open_url def api_get(link, config): try: if link == None: url = config.get('api','uri') + config.get('api','login_path') headers = {"Accept": config.get('api','login_type')} else: url = link['href'] + '?limit=0' headers = {"Accept": link['type']} result = open_url(url, headers=headers, url_username=config.get('auth','apiuser').replace('\n', ''), url_password=config.get('auth','apipass').replace('\n', '')) return json.loads(result.read()) except: return None def save_cache(data, config): ''' saves item to cache ''' dpath = config.get('cache','cache_dir') try: cache = open('/'.join([dpath,'inventory']), 'w') cache.write(json.dumps(data)) cache.close() except IOError as e: pass # not really sure what to do here def get_cache(cache_item, config): ''' returns cached item ''' dpath = config.get('cache','cache_dir') inv = {} try: cache = open('/'.join([dpath,'inventory']), 'r') inv = cache.read() cache.close() except IOError as e: pass # not really sure what to do here return inv def cache_available(config): ''' checks if we have a 'fresh' cache available for item requested ''' if config.has_option('cache','cache_dir'): dpath = config.get('cache','cache_dir') try: existing = os.stat( '/'.join([dpath,'inventory'])) except: # cache doesn't exist or isn't accessible return False if config.has_option('cache', 'cache_max_age'): maxage = config.get('cache', 'cache_max_age') if ((int(time.time()) - int(existing.st_mtime)) <= int(maxage)): return True return False def generate_inv_from_api(enterprise_entity,config): try: inventory['all'] = {} inventory['all']['children'] = [] inventory['all']['hosts'] = [] inventory['_meta'] = {} inventory['_meta']['hostvars'] = {} enterprise = api_get(enterprise_entity,config) vms_entity = next(link for link in (enterprise['links']) if (link['rel']=='virtualmachines')) vms = api_get(vms_entity,config) for vmcollection in vms['collection']: vm_vapp = next(link for link in (vmcollection['links']) if (link['rel']=='virtualappliance'))['title'].replace('[','').replace(']','').replace(' ','_') vm_vdc = next(link for link in (vmcollection['links']) if (link['rel']=='virtualdatacenter'))['title'].replace('[','').replace(']','').replace(' ','_') vm_template = next(link for link in (vmcollection['links']) if (link['rel']=='virtualmachinetemplate'))['title'].replace('[','').replace(']','').replace(' ','_') # From abiquo.ini: Only adding to inventory VMs with public IP if (config.getboolean('defaults', 'public_ip_only')) == True: for link in vmcollection['links']: if (link['type']=='application/vnd.abiquo.publicip+json' and link['rel']=='ip'): vm_nic = link['title'] break else: vm_nic = None # Otherwise, assigning defined network interface IP address else: for link in vmcollection['links']: if (link['rel']==config.get('defaults', 'default_net_interface')): vm_nic = link['title'] break else: vm_nic = None vm_state = True # From abiquo.ini: Only adding to inventory VMs deployed if ((config.getboolean('defaults', 'deployed_only') == True) and (vmcollection['state'] == 'NOT_ALLOCATED')): vm_state = False if not vm_nic == None and vm_state: if not vm_vapp in inventory.keys(): inventory[vm_vapp] = {} inventory[vm_vapp]['children'] = [] inventory[vm_vapp]['hosts'] = [] if not vm_vdc in inventory.keys(): inventory[vm_vdc] = {} inventory[vm_vdc]['hosts'] = [] inventory[vm_vdc]['children'] = [] if not vm_template in inventory.keys(): inventory[vm_template] = {} inventory[vm_template]['children'] = [] inventory[vm_template]['hosts'] = [] if config.getboolean('defaults', 'get_metadata') == True: meta_entity = next(link for link in (vmcollection['links']) if (link['rel']=='metadata')) try: metadata = api_get(meta_entity,config) if (config.getfloat("api","version") >= 3.0): vm_metadata = metadata['metadata'] else: vm_metadata = metadata['metadata']['metadata'] inventory['_meta']['hostvars'][vm_nic] = vm_metadata except Exception as e: pass inventory[vm_vapp]['children'].append(vmcollection['name']) inventory[vm_vdc]['children'].append(vmcollection['name']) inventory[vm_template]['children'].append(vmcollection['name']) inventory['all']['children'].append(vmcollection['name']) inventory[vmcollection['name']] = [] inventory[vmcollection['name']].append(vm_nic) return inventory except Exception as e: # Return empty hosts output return { 'all': {'hosts': []}, '_meta': { 'hostvars': {} } } def get_inventory(enterprise, config): ''' Reads the inventory from cache or Abiquo api ''' if cache_available(config): inv = get_cache('inventory', config) else: default_group = os.path.basename(sys.argv[0]).rstrip('.py') # MAKE ABIQUO API CALLS # inv = generate_inv_from_api(enterprise,config) save_cache(inv, config) return json.dumps(inv) if __name__ == '__main__': inventory = {} enterprise = {} # Read config config = ConfigParser.SafeConfigParser() for configfilename in [os.path.abspath(sys.argv[0]).rstrip('.py') + '.ini', 'abiquo.ini']: if os.path.exists(configfilename): config.read(configfilename) break try: login = api_get(None,config) enterprise = next(link for link in (login['links']) if (link['rel']=='enterprise')) except Exception as e: enterprise = None if cache_available(config): inventory = get_cache('inventory', config) else: inventory = get_inventory(enterprise, config) # return to ansible sys.stdout.write(str(inventory)) sys.stdout.flush()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 2344, 199, 11389, 8200, 2884, 367, 437, 4492, 14209, 199, 2486, 532, 199, 199, 2662, 313, 2003, 590, 8876, 687, 376, 3411, 8200, 2884, 14, 199, 199, 2765, 2884, 12821, 376, 8200, 626, 2622, 883, 20647, 701, 10663, 3261, 4145, 370, 437, 4492, 14209, 3261, 199, 18153, 2005, 2366, 8363, 12, 4868, 370, 1172, 3062, 4903, 1380, 1808, 642, 2884, 14, 199, 199, 2765, 2884, 965, 2757, 12470, 315, 437, 4492, 14209, 650, 14, 16, 1325, 652, 1443, 1736, 2597, 367, 437, 4492, 14209, 499, 14, 22, 14, 199, 199, 13569, 1808, 642, 2884, 1265, 1443, 2934, 370, 2811, 25570, 14209, 14, 2730, 1101, 570, 14, 199, 199, 2765, 2884, 12821, 376, 2622, 7057, 570, 543, 3520, 1591, 4652, 26, 199, 199, 18984, 63, 10013, 26, 25022, 282, 7057, 6337, 701, 437, 4492, 14209, 7525, 536, 1768, 199, 452, 26, 22493, 1006, 7057, 3247, 315, 437, 4492, 14209, 922, 1159, 9509, 13219, 199, 2065, 602, 4218, 26, 10560, 282, 1591, 1572, 367, 1924, 5791, 17770, 3035, 1006, 7057, 3247, 641, 652, 221, 199, 2065, 19858, 26, 10560, 282, 1591, 1572, 367, 1924, 5791, 19858, 3035, 1006, 7057, 3247, 641, 652, 199, 1569, 1160, 26, 10560, 282, 1591, 1572, 367, 1924, 1834, 1978, 3035, 1006, 7057, 1808, 652, 199, 199, 2344, 199, 199, 3, 334, 67, 9, 6927, 12, 24747, 14769, 699, 6349, 89, 475, 665, 24863, 14769, 14, 66, 6349, 89, 475, 32, 14677, 14209, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 12, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 14196, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 3603, 492, 1551, 63, 633, 199, 199, 318, 2986, 63, 362, 8, 1073, 12, 1101, 304, 272, 862, 26, 267, 340, 2142, 508, 488, 26, 288, 1166, 275, 1101, 14, 362, 360, 1246, 1673, 2302, 358, 435, 1101, 14, 362, 360, 1246, 1673, 2886, 63, 515, 358, 288, 2323, 275, 2420, 8422, 582, 1101, 14, 362, 360, 1246, 1673, 2886, 63, 466, 21004, 267, 587, 26, 288, 1166, 275, 2142, 459, 6399, 418, 435, 8720, 3097, 29, 16, 7, 288, 2323, 275, 2420, 8422, 582, 2142, 459, 466, 12074, 267, 754, 275, 1551, 63, 633, 8, 633, 12, 2323, 29, 2139, 12, 1166, 63, 2473, 29, 888, 14, 362, 360, 1178, 1673, 1246, 751, 1959, 1814, 2258, 78, 297, 9929, 355, 1166, 63, 2060, 29, 888, 14, 362, 360, 1178, 1673, 439, 711, 405, 1959, 1814, 2258, 78, 297, 12381, 267, 372, 2022, 14, 3640, 8, 1099, 14, 739, 1012, 272, 871, 26, 267, 372, 488, 199, 199, 318, 3354, 63, 1637, 8, 576, 12, 1101, 304, 272, 1449, 23050, 1242, 370, 2581, 1449, 272, 366, 515, 275, 1101, 14, 362, 360, 1637, 1673, 1637, 63, 694, 358, 272, 862, 26, 267, 2581, 275, 1551, 2336, 1370, 904, 779, 68, 515, 2584, 7212, 3815, 283, 87, 358, 267, 2581, 14, 952, 8, 1001, 14, 4180, 8, 576, 430, 267, 2581, 14, 1600, 342, 272, 871, 5925, 465, 325, 26, 267, 986, 327, 440, 7710, 3238, 4052, 370, 886, 2348, 421, 199, 318, 664, 63, 1637, 8, 1637, 63, 1053, 12, 1101, 304, 272, 1449, 2529, 6328, 1242, 221, 1449, 272, 366, 515, 275, 1101, 14, 362, 360, 1637, 1673, 1637, 63, 694, 358, 272, 4572, 275, 1052, 272, 862, 26, 267, 2581, 275, 1551, 2336, 1370, 904, 779, 68, 515, 2584, 7212, 3815, 283, 82, 358, 267, 4572, 275, 2581, 14, 739, 342, 267, 2581, 14, 1600, 342, 272, 871, 5925, 465, 325, 26, 267, 986, 327, 440, 7710, 3238, 4052, 370, 886, 2348, 339, 372, 4572, 199, 199, 318, 2581, 63, 4561, 8, 888, 304, 272, 1449, 5920, 340, 781, 1172, 282, 283, 25488, 7, 2581, 2808, 367, 1242, 5839, 1449, 339, 340, 1101, 14, 1989, 63, 1422, 360, 1637, 1673, 1637, 63, 694, 735, 267, 366, 515, 275, 1101, 14, 362, 360, 1637, 1673, 1637, 63, 694, 358, 398, 862, 26, 288, 3411, 275, 747, 14, 3736, 8, 20538, 904, 779, 68, 515, 2584, 7212, 5156, 267, 871, 26, 288, 327, 2581, 3181, 1133, 2187, 503, 5712, 1133, 17909, 288, 372, 756, 398, 340, 1101, 14, 1989, 63, 1422, 360, 1637, 297, 283, 1637, 63, 988, 63, 474, 735, 288, 1390, 474, 275, 1101, 14, 362, 360, 1637, 297, 283, 1637, 63, 988, 63, 474, 358, 288, 340, 3666, 442, 8, 521, 14, 521, 1012, 446, 1109, 8, 5952, 14, 270, 63, 8180, 430, 2695, 1109, 8, 988, 474, 2298, 355, 372, 715, 339, 372, 756, 199, 199, 318, 3550, 63, 5350, 63, 504, 63, 1246, 8, 24375, 63, 4502, 12, 888, 304, 14821, 862, 26, 267, 8200, 459, 452, 418, 275, 1052, 267, 8200, 459, 452, 2545, 3223, 418, 275, 942, 267, 8200, 459, 452, 2545, 5146, 418, 275, 942, 267, 8200, 8680, 2024, 418, 275, 1052, 267, 8200, 8680, 2024, 2545, 23265, 418, 275, 1052, 398, 9509, 13219, 275, 2986, 63, 362, 8, 24375, 63, 4502, 12, 888, 9, 267, 22505, 63, 4502, 275, 2163, 8, 1073, 367, 2142, 315, 334, 24375, 459, 4614, 1105, 340, 334 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 2344, 199, 11389, 8200, 2884, 367, 437, 4492, 14209, 199, 2486, 532, 199, 199, 2662, 313, 2003, 590, 8876, 687, 376, 3411, 8200, 2884, 14, 199, 199, 2765, 2884, 12821, 376, 8200, 626, 2622, 883, 20647, 701, 10663, 3261, 4145, 370, 437, 4492, 14209, 3261, 199, 18153, 2005, 2366, 8363, 12, 4868, 370, 1172, 3062, 4903, 1380, 1808, 642, 2884, 14, 199, 199, 2765, 2884, 965, 2757, 12470, 315, 437, 4492, 14209, 650, 14, 16, 1325, 652, 1443, 1736, 2597, 367, 437, 4492, 14209, 499, 14, 22, 14, 199, 199, 13569, 1808, 642, 2884, 1265, 1443, 2934, 370, 2811, 25570, 14209, 14, 2730, 1101, 570, 14, 199, 199, 2765, 2884, 12821, 376, 2622, 7057, 570, 543, 3520, 1591, 4652, 26, 199, 199, 18984, 63, 10013, 26, 25022, 282, 7057, 6337, 701, 437, 4492, 14209, 7525, 536, 1768, 199, 452, 26, 22493, 1006, 7057, 3247, 315, 437, 4492, 14209, 922, 1159, 9509, 13219, 199, 2065, 602, 4218, 26, 10560, 282, 1591, 1572, 367, 1924, 5791, 17770, 3035, 1006, 7057, 3247, 641, 652, 221, 199, 2065, 19858, 26, 10560, 282, 1591, 1572, 367, 1924, 5791, 19858, 3035, 1006, 7057, 3247, 641, 652, 199, 1569, 1160, 26, 10560, 282, 1591, 1572, 367, 1924, 1834, 1978, 3035, 1006, 7057, 1808, 652, 199, 199, 2344, 199, 199, 3, 334, 67, 9, 6927, 12, 24747, 14769, 699, 6349, 89, 475, 665, 24863, 14769, 14, 66, 6349, 89, 475, 32, 14677, 14209, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 12, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 14196, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 3603, 492, 1551, 63, 633, 199, 199, 318, 2986, 63, 362, 8, 1073, 12, 1101, 304, 272, 862, 26, 267, 340, 2142, 508, 488, 26, 288, 1166, 275, 1101, 14, 362, 360, 1246, 1673, 2302, 358, 435, 1101, 14, 362, 360, 1246, 1673, 2886, 63, 515, 358, 288, 2323, 275, 2420, 8422, 582, 1101, 14, 362, 360, 1246, 1673, 2886, 63, 466, 21004, 267, 587, 26, 288, 1166, 275, 2142, 459, 6399, 418, 435, 8720, 3097, 29, 16, 7, 288, 2323, 275, 2420, 8422, 582, 2142, 459, 466, 12074, 267, 754, 275, 1551, 63, 633, 8, 633, 12, 2323, 29, 2139, 12, 1166, 63, 2473, 29, 888, 14, 362, 360, 1178, 1673, 1246, 751, 1959, 1814, 2258, 78, 297, 9929, 355, 1166, 63, 2060, 29, 888, 14, 362, 360, 1178, 1673, 439, 711, 405, 1959, 1814, 2258, 78, 297, 12381, 267, 372, 2022, 14, 3640, 8, 1099, 14, 739, 1012, 272, 871, 26, 267, 372, 488, 199, 199, 318, 3354, 63, 1637, 8, 576, 12, 1101, 304, 272, 1449, 23050, 1242, 370, 2581, 1449, 272, 366, 515, 275, 1101, 14, 362, 360, 1637, 1673, 1637, 63, 694, 358, 272, 862, 26, 267, 2581, 275, 1551, 2336, 1370, 904, 779, 68, 515, 2584, 7212, 3815, 283, 87, 358, 267, 2581, 14, 952, 8, 1001, 14, 4180, 8, 576, 430, 267, 2581, 14, 1600, 342, 272, 871, 5925, 465, 325, 26, 267, 986, 327, 440, 7710, 3238, 4052, 370, 886, 2348, 421, 199, 318, 664, 63, 1637, 8, 1637, 63, 1053, 12, 1101, 304, 272, 1449, 2529, 6328, 1242, 221, 1449, 272, 366, 515, 275, 1101, 14, 362, 360, 1637, 1673, 1637, 63, 694, 358, 272, 4572, 275, 1052, 272, 862, 26, 267, 2581, 275, 1551, 2336, 1370, 904, 779, 68, 515, 2584, 7212, 3815, 283, 82, 358, 267, 4572, 275, 2581, 14, 739, 342, 267, 2581, 14, 1600, 342, 272, 871, 5925, 465, 325, 26, 267, 986, 327, 440, 7710, 3238, 4052, 370, 886, 2348, 339, 372, 4572, 199, 199, 318, 2581, 63, 4561, 8, 888, 304, 272, 1449, 5920, 340, 781, 1172, 282, 283, 25488, 7, 2581, 2808, 367, 1242, 5839, 1449, 339, 340, 1101, 14, 1989, 63, 1422, 360, 1637, 1673, 1637, 63, 694, 735, 267, 366, 515, 275, 1101, 14, 362, 360, 1637, 1673, 1637, 63, 694, 358, 398, 862, 26, 288, 3411, 275, 747, 14, 3736, 8, 20538, 904, 779, 68, 515, 2584, 7212, 5156, 267, 871, 26, 288, 327, 2581, 3181, 1133, 2187, 503, 5712, 1133, 17909, 288, 372, 756, 398, 340, 1101, 14, 1989, 63, 1422, 360, 1637, 297, 283, 1637, 63, 988, 63, 474, 735, 288, 1390, 474, 275, 1101, 14, 362, 360, 1637, 297, 283, 1637, 63, 988, 63, 474, 358, 288, 340, 3666, 442, 8, 521, 14, 521, 1012, 446, 1109, 8, 5952, 14, 270, 63, 8180, 430, 2695, 1109, 8, 988, 474, 2298, 355, 372, 715, 339, 372, 756, 199, 199, 318, 3550, 63, 5350, 63, 504, 63, 1246, 8, 24375, 63, 4502, 12, 888, 304, 14821, 862, 26, 267, 8200, 459, 452, 418, 275, 1052, 267, 8200, 459, 452, 2545, 3223, 418, 275, 942, 267, 8200, 459, 452, 2545, 5146, 418, 275, 942, 267, 8200, 8680, 2024, 418, 275, 1052, 267, 8200, 8680, 2024, 2545, 23265, 418, 275, 1052, 398, 9509, 13219, 275, 2986, 63, 362, 8, 24375, 63, 4502, 12, 888, 9, 267, 22505, 63, 4502, 275, 2163, 8, 1073, 367, 2142, 315, 334, 24375, 459, 4614, 1105, 340, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zakuro9715/lettuce
tests/integration/lib/Django-1.3/tests/regressiontests/cache/tests.py
26
64411
# -*- coding: utf-8 -*- # Unit tests for cache framework # Uses whatever cache backend is set in the test settings file. import os import tempfile import time import warnings from django.conf import settings from django.core import management from django.core.cache import get_cache, DEFAULT_CACHE_ALIAS from django.core.cache.backends.base import CacheKeyWarning from django.http import HttpResponse, HttpRequest, QueryDict from django.middleware.cache import FetchFromCacheMiddleware, UpdateCacheMiddleware, CacheMiddleware from django.test import RequestFactory from django.test.utils import get_warnings_state, restore_warnings_state from django.utils import translation from django.utils import unittest from django.utils.cache import patch_vary_headers, get_cache_key, learn_cache_key from django.utils.hashcompat import md5_constructor from django.views.decorators.cache import cache_page from regressiontests.cache.models import Poll, expensive_calculation # functions/classes for complex data type tests def f(): return 42 class C: def m(n): return 24 class DummyCacheTests(unittest.TestCase): # The Dummy cache backend doesn't really behave like a test backend, # so it has different test requirements. def setUp(self): self.cache = get_cache('django.core.cache.backends.dummy.DummyCache') def test_simple(self): "Dummy cache backend ignores cache set calls" self.cache.set("key", "value") self.assertEqual(self.cache.get("key"), None) def test_add(self): "Add doesn't do anything in dummy cache backend" self.cache.add("addkey1", "value") result = self.cache.add("addkey1", "newvalue") self.assertEqual(result, True) self.assertEqual(self.cache.get("addkey1"), None) def test_non_existent(self): "Non-existent keys aren't found in the dummy cache backend" self.assertEqual(self.cache.get("does_not_exist"), None) self.assertEqual(self.cache.get("does_not_exist", "bang!"), "bang!") def test_get_many(self): "get_many returns nothing for the dummy cache backend" self.cache.set('a', 'a') self.cache.set('b', 'b') self.cache.set('c', 'c') self.cache.set('d', 'd') self.assertEqual(self.cache.get_many(['a', 'c', 'd']), {}) self.assertEqual(self.cache.get_many(['a', 'b', 'e']), {}) def test_delete(self): "Cache deletion is transparently ignored on the dummy cache backend" self.cache.set("key1", "spam") self.cache.set("key2", "eggs") self.assertEqual(self.cache.get("key1"), None) self.cache.delete("key1") self.assertEqual(self.cache.get("key1"), None) self.assertEqual(self.cache.get("key2"), None) def test_has_key(self): "The has_key method doesn't ever return True for the dummy cache backend" self.cache.set("hello1", "goodbye1") self.assertEqual(self.cache.has_key("hello1"), False) self.assertEqual(self.cache.has_key("goodbye1"), False) def test_in(self): "The in operator doesn't ever return True for the dummy cache backend" self.cache.set("hello2", "goodbye2") self.assertEqual("hello2" in self.cache, False) self.assertEqual("goodbye2" in self.cache, False) def test_incr(self): "Dummy cache values can't be incremented" self.cache.set('answer', 42) self.assertRaises(ValueError, self.cache.incr, 'answer') self.assertRaises(ValueError, self.cache.incr, 'does_not_exist') def test_decr(self): "Dummy cache values can't be decremented" self.cache.set('answer', 42) self.assertRaises(ValueError, self.cache.decr, 'answer') self.assertRaises(ValueError, self.cache.decr, 'does_not_exist') def test_data_types(self): "All data types are ignored equally by the dummy cache" stuff = { 'string' : 'this is a string', 'int' : 42, 'list' : [1, 2, 3, 4], 'tuple' : (1, 2, 3, 4), 'dict' : {'A': 1, 'B' : 2}, 'function' : f, 'class' : C, } self.cache.set("stuff", stuff) self.assertEqual(self.cache.get("stuff"), None) def test_expiration(self): "Expiration has no effect on the dummy cache" self.cache.set('expire1', 'very quickly', 1) self.cache.set('expire2', 'very quickly', 1) self.cache.set('expire3', 'very quickly', 1) time.sleep(2) self.assertEqual(self.cache.get("expire1"), None) self.cache.add("expire2", "newvalue") self.assertEqual(self.cache.get("expire2"), None) self.assertEqual(self.cache.has_key("expire3"), False) def test_unicode(self): "Unicode values are ignored by the dummy cache" stuff = { u'ascii': u'ascii_value', u'unicode_ascii': u'Iñtërnâtiônàlizætiøn1', u'Iñtërnâtiônàlizætiøn': u'Iñtërnâtiônàlizætiøn2', u'ascii': {u'x' : 1 } } for (key, value) in stuff.items(): self.cache.set(key, value) self.assertEqual(self.cache.get(key), None) def test_set_many(self): "set_many does nothing for the dummy cache backend" self.cache.set_many({'a': 1, 'b': 2}) def test_delete_many(self): "delete_many does nothing for the dummy cache backend" self.cache.delete_many(['a', 'b']) def test_clear(self): "clear does nothing for the dummy cache backend" self.cache.clear() def test_incr_version(self): "Dummy cache versions can't be incremented" self.cache.set('answer', 42) self.assertRaises(ValueError, self.cache.incr_version, 'answer') self.assertRaises(ValueError, self.cache.incr_version, 'does_not_exist') def test_decr_version(self): "Dummy cache versions can't be decremented" self.cache.set('answer', 42) self.assertRaises(ValueError, self.cache.decr_version, 'answer') self.assertRaises(ValueError, self.cache.decr_version, 'does_not_exist') class BaseCacheTests(object): # A common set of tests to apply to all cache backends def test_simple(self): # Simple cache set/get works self.cache.set("key", "value") self.assertEqual(self.cache.get("key"), "value") def test_add(self): # A key can be added to a cache self.cache.add("addkey1", "value") result = self.cache.add("addkey1", "newvalue") self.assertEqual(result, False) self.assertEqual(self.cache.get("addkey1"), "value") def test_prefix(self): # Test for same cache key conflicts between shared backend self.cache.set('somekey', 'value') # should not be set in the prefixed cache self.assertFalse(self.prefix_cache.has_key('somekey')) self.prefix_cache.set('somekey', 'value2') self.assertEqual(self.cache.get('somekey'), 'value') self.assertEqual(self.prefix_cache.get('somekey'), 'value2') def test_non_existent(self): # Non-existent cache keys return as None/default # get with non-existent keys self.assertEqual(self.cache.get("does_not_exist"), None) self.assertEqual(self.cache.get("does_not_exist", "bang!"), "bang!") def test_get_many(self): # Multiple cache keys can be returned using get_many self.cache.set('a', 'a') self.cache.set('b', 'b') self.cache.set('c', 'c') self.cache.set('d', 'd') self.assertEqual(self.cache.get_many(['a', 'c', 'd']), {'a' : 'a', 'c' : 'c', 'd' : 'd'}) self.assertEqual(self.cache.get_many(['a', 'b', 'e']), {'a' : 'a', 'b' : 'b'}) def test_delete(self): # Cache keys can be deleted self.cache.set("key1", "spam") self.cache.set("key2", "eggs") self.assertEqual(self.cache.get("key1"), "spam") self.cache.delete("key1") self.assertEqual(self.cache.get("key1"), None) self.assertEqual(self.cache.get("key2"), "eggs") def test_has_key(self): # The cache can be inspected for cache keys self.cache.set("hello1", "goodbye1") self.assertEqual(self.cache.has_key("hello1"), True) self.assertEqual(self.cache.has_key("goodbye1"), False) def test_in(self): # The in operator can be used to inspet cache contents self.cache.set("hello2", "goodbye2") self.assertEqual("hello2" in self.cache, True) self.assertEqual("goodbye2" in self.cache, False) def test_incr(self): # Cache values can be incremented self.cache.set('answer', 41) self.assertEqual(self.cache.incr('answer'), 42) self.assertEqual(self.cache.get('answer'), 42) self.assertEqual(self.cache.incr('answer', 10), 52) self.assertEqual(self.cache.get('answer'), 52) self.assertRaises(ValueError, self.cache.incr, 'does_not_exist') def test_decr(self): # Cache values can be decremented self.cache.set('answer', 43) self.assertEqual(self.cache.decr('answer'), 42) self.assertEqual(self.cache.get('answer'), 42) self.assertEqual(self.cache.decr('answer', 10), 32) self.assertEqual(self.cache.get('answer'), 32) self.assertRaises(ValueError, self.cache.decr, 'does_not_exist') def test_data_types(self): # Many different data types can be cached stuff = { 'string' : 'this is a string', 'int' : 42, 'list' : [1, 2, 3, 4], 'tuple' : (1, 2, 3, 4), 'dict' : {'A': 1, 'B' : 2}, 'function' : f, 'class' : C, } self.cache.set("stuff", stuff) self.assertEqual(self.cache.get("stuff"), stuff) def test_cache_read_for_model_instance(self): # Don't want fields with callable as default to be called on cache read expensive_calculation.num_runs = 0 Poll.objects.all().delete() my_poll = Poll.objects.create(question="Well?") self.assertEqual(Poll.objects.count(), 1) pub_date = my_poll.pub_date self.cache.set('question', my_poll) cached_poll = self.cache.get('question') self.assertEqual(cached_poll.pub_date, pub_date) # We only want the default expensive calculation run once self.assertEqual(expensive_calculation.num_runs, 1) def test_cache_write_for_model_instance_with_deferred(self): # Don't want fields with callable as default to be called on cache write expensive_calculation.num_runs = 0 Poll.objects.all().delete() my_poll = Poll.objects.create(question="What?") self.assertEqual(expensive_calculation.num_runs, 1) defer_qs = Poll.objects.all().defer('question') self.assertEqual(defer_qs.count(), 1) self.assertEqual(expensive_calculation.num_runs, 1) self.cache.set('deferred_queryset', defer_qs) # cache set should not re-evaluate default functions self.assertEqual(expensive_calculation.num_runs, 1) def test_cache_read_for_model_instance_with_deferred(self): # Don't want fields with callable as default to be called on cache read expensive_calculation.num_runs = 0 Poll.objects.all().delete() my_poll = Poll.objects.create(question="What?") self.assertEqual(expensive_calculation.num_runs, 1) defer_qs = Poll.objects.all().defer('question') self.assertEqual(defer_qs.count(), 1) self.cache.set('deferred_queryset', defer_qs) self.assertEqual(expensive_calculation.num_runs, 1) runs_before_cache_read = expensive_calculation.num_runs cached_polls = self.cache.get('deferred_queryset') # We only want the default expensive calculation run on creation and set self.assertEqual(expensive_calculation.num_runs, runs_before_cache_read) def test_expiration(self): # Cache values can be set to expire self.cache.set('expire1', 'very quickly', 1) self.cache.set('expire2', 'very quickly', 1) self.cache.set('expire3', 'very quickly', 1) time.sleep(2) self.assertEqual(self.cache.get("expire1"), None) self.cache.add("expire2", "newvalue") self.assertEqual(self.cache.get("expire2"), "newvalue") self.assertEqual(self.cache.has_key("expire3"), False) def test_unicode(self): # Unicode values can be cached stuff = { u'ascii': u'ascii_value', u'unicode_ascii': u'Iñtërnâtiônàlizætiøn1', u'Iñtërnâtiônàlizætiøn': u'Iñtërnâtiônàlizætiøn2', u'ascii': {u'x' : 1 } } # Test `set` for (key, value) in stuff.items(): self.cache.set(key, value) self.assertEqual(self.cache.get(key), value) # Test `add` for (key, value) in stuff.items(): self.cache.delete(key) self.cache.add(key, value) self.assertEqual(self.cache.get(key), value) # Test `set_many` for (key, value) in stuff.items(): self.cache.delete(key) self.cache.set_many(stuff) for (key, value) in stuff.items(): self.assertEqual(self.cache.get(key), value) def test_binary_string(self): # Binary strings should be cachable from zlib import compress, decompress value = 'value_to_be_compressed' compressed_value = compress(value) # Test set self.cache.set('binary1', compressed_value) compressed_result = self.cache.get('binary1') self.assertEqual(compressed_value, compressed_result) self.assertEqual(value, decompress(compressed_result)) # Test add self.cache.add('binary1-add', compressed_value) compressed_result = self.cache.get('binary1-add') self.assertEqual(compressed_value, compressed_result) self.assertEqual(value, decompress(compressed_result)) # Test set_many self.cache.set_many({'binary1-set_many': compressed_value}) compressed_result = self.cache.get('binary1-set_many') self.assertEqual(compressed_value, compressed_result) self.assertEqual(value, decompress(compressed_result)) def test_set_many(self): # Multiple keys can be set using set_many self.cache.set_many({"key1": "spam", "key2": "eggs"}) self.assertEqual(self.cache.get("key1"), "spam") self.assertEqual(self.cache.get("key2"), "eggs") def test_set_many_expiration(self): # set_many takes a second ``timeout`` parameter self.cache.set_many({"key1": "spam", "key2": "eggs"}, 1) time.sleep(2) self.assertEqual(self.cache.get("key1"), None) self.assertEqual(self.cache.get("key2"), None) def test_delete_many(self): # Multiple keys can be deleted using delete_many self.cache.set("key1", "spam") self.cache.set("key2", "eggs") self.cache.set("key3", "ham") self.cache.delete_many(["key1", "key2"]) self.assertEqual(self.cache.get("key1"), None) self.assertEqual(self.cache.get("key2"), None) self.assertEqual(self.cache.get("key3"), "ham") def test_clear(self): # The cache can be emptied using clear self.cache.set("key1", "spam") self.cache.set("key2", "eggs") self.cache.clear() self.assertEqual(self.cache.get("key1"), None) self.assertEqual(self.cache.get("key2"), None) def test_long_timeout(self): ''' Using a timeout greater than 30 days makes memcached think it is an absolute expiration timestamp instead of a relative offset. Test that we honour this convention. Refs #12399. ''' self.cache.set('key1', 'eggs', 60*60*24*30 + 1) #30 days + 1 second self.assertEqual(self.cache.get('key1'), 'eggs') self.cache.add('key2', 'ham', 60*60*24*30 + 1) self.assertEqual(self.cache.get('key2'), 'ham') self.cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, 60*60*24*30 + 1) self.assertEqual(self.cache.get('key3'), 'sausage') self.assertEqual(self.cache.get('key4'), 'lobster bisque') def perform_cull_test(self, initial_count, final_count): """This is implemented as a utility method, because only some of the backends implement culling. The culling algorithm also varies slightly, so the final number of entries will vary between backends""" # Create initial cache key entries. This will overflow the cache, causing a cull for i in range(1, initial_count): self.cache.set('cull%d' % i, 'value', 1000) count = 0 # Count how many keys are left in the cache. for i in range(1, initial_count): if self.cache.has_key('cull%d' % i): count = count + 1 self.assertEqual(count, final_count) def test_invalid_keys(self): """ All the builtin backends (except memcached, see below) should warn on keys that would be refused by memcached. This encourages portable caching code without making it too difficult to use production backends with more liberal key rules. Refs #6447. """ # mimic custom ``make_key`` method being defined since the default will # never show the below warnings def func(key, *args): return key old_func = self.cache.key_func self.cache.key_func = func # On Python 2.6+ we could use the catch_warnings context # manager to test this warning nicely. Since we can't do that # yet, the cleanest option is to temporarily ask for # CacheKeyWarning to be raised as an exception. _warnings_state = get_warnings_state() warnings.simplefilter("error", CacheKeyWarning) try: # memcached does not allow whitespace or control characters in keys self.assertRaises(CacheKeyWarning, self.cache.set, 'key with spaces', 'value') # memcached limits key length to 250 self.assertRaises(CacheKeyWarning, self.cache.set, 'a' * 251, 'value') finally: restore_warnings_state(_warnings_state) self.cache.key_func = old_func def test_cache_versioning_get_set(self): # set, using default version = 1 self.cache.set('answer1', 42) self.assertEqual(self.cache.get('answer1'), 42) self.assertEqual(self.cache.get('answer1', version=1), 42) self.assertEqual(self.cache.get('answer1', version=2), None) self.assertEqual(self.v2_cache.get('answer1'), None) self.assertEqual(self.v2_cache.get('answer1', version=1), 42) self.assertEqual(self.v2_cache.get('answer1', version=2), None) # set, default version = 1, but manually override version = 2 self.cache.set('answer2', 42, version=2) self.assertEqual(self.cache.get('answer2'), None) self.assertEqual(self.cache.get('answer2', version=1), None) self.assertEqual(self.cache.get('answer2', version=2), 42) self.assertEqual(self.v2_cache.get('answer2'), 42) self.assertEqual(self.v2_cache.get('answer2', version=1), None) self.assertEqual(self.v2_cache.get('answer2', version=2), 42) # v2 set, using default version = 2 self.v2_cache.set('answer3', 42) self.assertEqual(self.cache.get('answer3'), None) self.assertEqual(self.cache.get('answer3', version=1), None) self.assertEqual(self.cache.get('answer3', version=2), 42) self.assertEqual(self.v2_cache.get('answer3'), 42) self.assertEqual(self.v2_cache.get('answer3', version=1), None) self.assertEqual(self.v2_cache.get('answer3', version=2), 42) # v2 set, default version = 2, but manually override version = 1 self.v2_cache.set('answer4', 42, version=1) self.assertEqual(self.cache.get('answer4'), 42) self.assertEqual(self.cache.get('answer4', version=1), 42) self.assertEqual(self.cache.get('answer4', version=2), None) self.assertEqual(self.v2_cache.get('answer4'), None) self.assertEqual(self.v2_cache.get('answer4', version=1), 42) self.assertEqual(self.v2_cache.get('answer4', version=2), None) def test_cache_versioning_add(self): # add, default version = 1, but manually override version = 2 self.cache.add('answer1', 42, version=2) self.assertEqual(self.cache.get('answer1', version=1), None) self.assertEqual(self.cache.get('answer1', version=2), 42) self.cache.add('answer1', 37, version=2) self.assertEqual(self.cache.get('answer1', version=1), None) self.assertEqual(self.cache.get('answer1', version=2), 42) self.cache.add('answer1', 37, version=1) self.assertEqual(self.cache.get('answer1', version=1), 37) self.assertEqual(self.cache.get('answer1', version=2), 42) # v2 add, using default version = 2 self.v2_cache.add('answer2', 42) self.assertEqual(self.cache.get('answer2', version=1), None) self.assertEqual(self.cache.get('answer2', version=2), 42) self.v2_cache.add('answer2', 37) self.assertEqual(self.cache.get('answer2', version=1), None) self.assertEqual(self.cache.get('answer2', version=2), 42) self.v2_cache.add('answer2', 37, version=1) self.assertEqual(self.cache.get('answer2', version=1), 37) self.assertEqual(self.cache.get('answer2', version=2), 42) # v2 add, default version = 2, but manually override version = 1 self.v2_cache.add('answer3', 42, version=1) self.assertEqual(self.cache.get('answer3', version=1), 42) self.assertEqual(self.cache.get('answer3', version=2), None) self.v2_cache.add('answer3', 37, version=1) self.assertEqual(self.cache.get('answer3', version=1), 42) self.assertEqual(self.cache.get('answer3', version=2), None) self.v2_cache.add('answer3', 37) self.assertEqual(self.cache.get('answer3', version=1), 42) self.assertEqual(self.cache.get('answer3', version=2), 37) def test_cache_versioning_has_key(self): self.cache.set('answer1', 42) # has_key self.assertTrue(self.cache.has_key('answer1')) self.assertTrue(self.cache.has_key('answer1', version=1)) self.assertFalse(self.cache.has_key('answer1', version=2)) self.assertFalse(self.v2_cache.has_key('answer1')) self.assertTrue(self.v2_cache.has_key('answer1', version=1)) self.assertFalse(self.v2_cache.has_key('answer1', version=2)) def test_cache_versioning_delete(self): self.cache.set('answer1', 37, version=1) self.cache.set('answer1', 42, version=2) self.cache.delete('answer1') self.assertEqual(self.cache.get('answer1', version=1), None) self.assertEqual(self.cache.get('answer1', version=2), 42) self.cache.set('answer2', 37, version=1) self.cache.set('answer2', 42, version=2) self.cache.delete('answer2', version=2) self.assertEqual(self.cache.get('answer2', version=1), 37) self.assertEqual(self.cache.get('answer2', version=2), None) self.cache.set('answer3', 37, version=1) self.cache.set('answer3', 42, version=2) self.v2_cache.delete('answer3') self.assertEqual(self.cache.get('answer3', version=1), 37) self.assertEqual(self.cache.get('answer3', version=2), None) self.cache.set('answer4', 37, version=1) self.cache.set('answer4', 42, version=2) self.v2_cache.delete('answer4', version=1) self.assertEqual(self.cache.get('answer4', version=1), None) self.assertEqual(self.cache.get('answer4', version=2), 42) def test_cache_versioning_incr_decr(self): self.cache.set('answer1', 37, version=1) self.cache.set('answer1', 42, version=2) self.cache.incr('answer1') self.assertEqual(self.cache.get('answer1', version=1), 38) self.assertEqual(self.cache.get('answer1', version=2), 42) self.cache.decr('answer1') self.assertEqual(self.cache.get('answer1', version=1), 37) self.assertEqual(self.cache.get('answer1', version=2), 42) self.cache.set('answer2', 37, version=1) self.cache.set('answer2', 42, version=2) self.cache.incr('answer2', version=2) self.assertEqual(self.cache.get('answer2', version=1), 37) self.assertEqual(self.cache.get('answer2', version=2), 43) self.cache.decr('answer2', version=2) self.assertEqual(self.cache.get('answer2', version=1), 37) self.assertEqual(self.cache.get('answer2', version=2), 42) self.cache.set('answer3', 37, version=1) self.cache.set('answer3', 42, version=2) self.v2_cache.incr('answer3') self.assertEqual(self.cache.get('answer3', version=1), 37) self.assertEqual(self.cache.get('answer3', version=2), 43) self.v2_cache.decr('answer3') self.assertEqual(self.cache.get('answer3', version=1), 37) self.assertEqual(self.cache.get('answer3', version=2), 42) self.cache.set('answer4', 37, version=1) self.cache.set('answer4', 42, version=2) self.v2_cache.incr('answer4', version=1) self.assertEqual(self.cache.get('answer4', version=1), 38) self.assertEqual(self.cache.get('answer4', version=2), 42) self.v2_cache.decr('answer4', version=1) self.assertEqual(self.cache.get('answer4', version=1), 37) self.assertEqual(self.cache.get('answer4', version=2), 42) def test_cache_versioning_get_set_many(self): # set, using default version = 1 self.cache.set_many({'ford1': 37, 'arthur1': 42}) self.assertEqual(self.cache.get_many(['ford1','arthur1']), {'ford1': 37, 'arthur1': 42}) self.assertEqual(self.cache.get_many(['ford1','arthur1'], version=1), {'ford1': 37, 'arthur1': 42}) self.assertEqual(self.cache.get_many(['ford1','arthur1'], version=2), {}) self.assertEqual(self.v2_cache.get_many(['ford1','arthur1']), {}) self.assertEqual(self.v2_cache.get_many(['ford1','arthur1'], version=1), {'ford1': 37, 'arthur1': 42}) self.assertEqual(self.v2_cache.get_many(['ford1','arthur1'], version=2), {}) # set, default version = 1, but manually override version = 2 self.cache.set_many({'ford2': 37, 'arthur2': 42}, version=2) self.assertEqual(self.cache.get_many(['ford2','arthur2']), {}) self.assertEqual(self.cache.get_many(['ford2','arthur2'], version=1), {}) self.assertEqual(self.cache.get_many(['ford2','arthur2'], version=2), {'ford2': 37, 'arthur2': 42}) self.assertEqual(self.v2_cache.get_many(['ford2','arthur2']), {'ford2': 37, 'arthur2': 42}) self.assertEqual(self.v2_cache.get_many(['ford2','arthur2'], version=1), {}) self.assertEqual(self.v2_cache.get_many(['ford2','arthur2'], version=2), {'ford2': 37, 'arthur2': 42}) # v2 set, using default version = 2 self.v2_cache.set_many({'ford3': 37, 'arthur3': 42}) self.assertEqual(self.cache.get_many(['ford3','arthur3']), {}) self.assertEqual(self.cache.get_many(['ford3','arthur3'], version=1), {}) self.assertEqual(self.cache.get_many(['ford3','arthur3'], version=2), {'ford3': 37, 'arthur3': 42}) self.assertEqual(self.v2_cache.get_many(['ford3','arthur3']), {'ford3': 37, 'arthur3': 42}) self.assertEqual(self.v2_cache.get_many(['ford3','arthur3'], version=1), {}) self.assertEqual(self.v2_cache.get_many(['ford3','arthur3'], version=2), {'ford3': 37, 'arthur3': 42}) # v2 set, default version = 2, but manually override version = 1 self.v2_cache.set_many({'ford4': 37, 'arthur4': 42}, version=1) self.assertEqual(self.cache.get_many(['ford4','arthur4']), {'ford4': 37, 'arthur4': 42}) self.assertEqual(self.cache.get_many(['ford4','arthur4'], version=1), {'ford4': 37, 'arthur4': 42}) self.assertEqual(self.cache.get_many(['ford4','arthur4'], version=2), {}) self.assertEqual(self.v2_cache.get_many(['ford4','arthur4']), {}) self.assertEqual(self.v2_cache.get_many(['ford4','arthur4'], version=1), {'ford4': 37, 'arthur4': 42}) self.assertEqual(self.v2_cache.get_many(['ford4','arthur4'], version=2), {}) def test_incr_version(self): self.cache.set('answer', 42, version=2) self.assertEqual(self.cache.get('answer'), None) self.assertEqual(self.cache.get('answer', version=1), None) self.assertEqual(self.cache.get('answer', version=2), 42) self.assertEqual(self.cache.get('answer', version=3), None) self.assertEqual(self.cache.incr_version('answer', version=2), 3) self.assertEqual(self.cache.get('answer'), None) self.assertEqual(self.cache.get('answer', version=1), None) self.assertEqual(self.cache.get('answer', version=2), None) self.assertEqual(self.cache.get('answer', version=3), 42) self.v2_cache.set('answer2', 42) self.assertEqual(self.v2_cache.get('answer2'), 42) self.assertEqual(self.v2_cache.get('answer2', version=1), None) self.assertEqual(self.v2_cache.get('answer2', version=2), 42) self.assertEqual(self.v2_cache.get('answer2', version=3), None) self.assertEqual(self.v2_cache.incr_version('answer2'), 3) self.assertEqual(self.v2_cache.get('answer2'), None) self.assertEqual(self.v2_cache.get('answer2', version=1), None) self.assertEqual(self.v2_cache.get('answer2', version=2), None) self.assertEqual(self.v2_cache.get('answer2', version=3), 42) self.assertRaises(ValueError, self.cache.incr_version, 'does_not_exist') def test_decr_version(self): self.cache.set('answer', 42, version=2) self.assertEqual(self.cache.get('answer'), None) self.assertEqual(self.cache.get('answer', version=1), None) self.assertEqual(self.cache.get('answer', version=2), 42) self.assertEqual(self.cache.decr_version('answer', version=2), 1) self.assertEqual(self.cache.get('answer'), 42) self.assertEqual(self.cache.get('answer', version=1), 42) self.assertEqual(self.cache.get('answer', version=2), None) self.v2_cache.set('answer2', 42) self.assertEqual(self.v2_cache.get('answer2'), 42) self.assertEqual(self.v2_cache.get('answer2', version=1), None) self.assertEqual(self.v2_cache.get('answer2', version=2), 42) self.assertEqual(self.v2_cache.decr_version('answer2'), 1) self.assertEqual(self.v2_cache.get('answer2'), None) self.assertEqual(self.v2_cache.get('answer2', version=1), 42) self.assertEqual(self.v2_cache.get('answer2', version=2), None) self.assertRaises(ValueError, self.cache.decr_version, 'does_not_exist', version=2) def test_custom_key_func(self): # Two caches with different key functions aren't visible to each other self.cache.set('answer1', 42) self.assertEqual(self.cache.get('answer1'), 42) self.assertEqual(self.custom_key_cache.get('answer1'), None) self.assertEqual(self.custom_key_cache2.get('answer1'), None) self.custom_key_cache.set('answer2', 42) self.assertEqual(self.cache.get('answer2'), None) self.assertEqual(self.custom_key_cache.get('answer2'), 42) self.assertEqual(self.custom_key_cache2.get('answer2'), 42) def custom_key_func(key, key_prefix, version): "A customized cache key function" return 'CUSTOM-' + '-'.join([key_prefix, str(version), key]) class DBCacheTests(unittest.TestCase, BaseCacheTests): def setUp(self): # Spaces are used in the table name to ensure quoting/escaping is working self._table_name = 'test cache table' management.call_command('createcachetable', self._table_name, verbosity=0, interactive=False) self.cache = get_cache('django.core.cache.backends.db.DatabaseCache', LOCATION=self._table_name, OPTIONS={'MAX_ENTRIES': 30}) self.prefix_cache = get_cache('django.core.cache.backends.db.DatabaseCache', LOCATION=self._table_name, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache('django.core.cache.backends.db.DatabaseCache', LOCATION=self._table_name, VERSION=2) self.custom_key_cache = get_cache('django.core.cache.backends.db.DatabaseCache', LOCATION=self._table_name, KEY_FUNCTION=custom_key_func) self.custom_key_cache2 = get_cache('django.core.cache.backends.db.DatabaseCache', LOCATION=self._table_name, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') def tearDown(self): from django.db import connection cursor = connection.cursor() cursor.execute('DROP TABLE %s' % connection.ops.quote_name(self._table_name)) def test_cull(self): self.perform_cull_test(50, 29) def test_zero_cull(self): self.cache = get_cache('django.core.cache.backends.db.DatabaseCache', LOCATION=self._table_name, OPTIONS={'MAX_ENTRIES': 30, 'CULL_FREQUENCY': 0}) self.perform_cull_test(50, 18) def test_old_initialization(self): self.cache = get_cache('db://%s?max_entries=30&cull_frequency=0' % self._table_name) self.perform_cull_test(50, 18) class LocMemCacheTests(unittest.TestCase, BaseCacheTests): def setUp(self): self.cache = get_cache('django.core.cache.backends.locmem.LocMemCache', OPTIONS={'MAX_ENTRIES': 30}) self.prefix_cache = get_cache('django.core.cache.backends.locmem.LocMemCache', KEY_PREFIX='cacheprefix') self.v2_cache = get_cache('django.core.cache.backends.locmem.LocMemCache', VERSION=2) self.custom_key_cache = get_cache('django.core.cache.backends.locmem.LocMemCache', OPTIONS={'MAX_ENTRIES': 30}, KEY_FUNCTION=custom_key_func) self.custom_key_cache2 = get_cache('django.core.cache.backends.locmem.LocMemCache', OPTIONS={'MAX_ENTRIES': 30}, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') # LocMem requires a hack to make the other caches # share a data store with the 'normal' cache. self.prefix_cache._cache = self.cache._cache self.prefix_cache._expire_info = self.cache._expire_info self.v2_cache._cache = self.cache._cache self.v2_cache._expire_info = self.cache._expire_info self.custom_key_cache._cache = self.cache._cache self.custom_key_cache._expire_info = self.cache._expire_info self.custom_key_cache2._cache = self.cache._cache self.custom_key_cache2._expire_info = self.cache._expire_info def tearDown(self): self.cache.clear() def test_cull(self): self.perform_cull_test(50, 29) def test_zero_cull(self): self.cache = get_cache('django.core.cache.backends.locmem.LocMemCache', OPTIONS={'MAX_ENTRIES': 30, 'CULL_FREQUENCY': 0}) self.perform_cull_test(50, 19) def test_old_initialization(self): self.cache = get_cache('locmem://?max_entries=30&cull_frequency=0') self.perform_cull_test(50, 19) def test_multiple_caches(self): "Check that multiple locmem caches are isolated" mirror_cache = get_cache('django.core.cache.backends.locmem.LocMemCache') other_cache = get_cache('django.core.cache.backends.locmem.LocMemCache', LOCATION='other') self.cache.set('value1', 42) self.assertEqual(mirror_cache.get('value1'), 42) self.assertEqual(other_cache.get('value1'), None) # memcached backend isn't guaranteed to be available. # To check the memcached backend, the test settings file will # need to contain a cache backend setting that points at # your memcache server. class MemcachedCacheTests(unittest.TestCase, BaseCacheTests): def setUp(self): name = settings.CACHES[DEFAULT_CACHE_ALIAS]['LOCATION'] self.cache = get_cache('django.core.cache.backends.memcached.MemcachedCache', LOCATION=name) self.prefix_cache = get_cache('django.core.cache.backends.memcached.MemcachedCache', LOCATION=name, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache('django.core.cache.backends.memcached.MemcachedCache', LOCATION=name, VERSION=2) self.custom_key_cache = get_cache('django.core.cache.backends.memcached.MemcachedCache', LOCATION=name, KEY_FUNCTION=custom_key_func) self.custom_key_cache2 = get_cache('django.core.cache.backends.memcached.MemcachedCache', LOCATION=name, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') def tearDown(self): self.cache.clear() def test_invalid_keys(self): """ On memcached, we don't introduce a duplicate key validation step (for speed reasons), we just let the memcached API library raise its own exception on bad keys. Refs #6447. In order to be memcached-API-library agnostic, we only assert that a generic exception of some kind is raised. """ # memcached does not allow whitespace or control characters in keys self.assertRaises(Exception, self.cache.set, 'key with spaces', 'value') # memcached limits key length to 250 self.assertRaises(Exception, self.cache.set, 'a' * 251, 'value') MemcachedCacheTests = unittest.skipUnless(settings.CACHES[DEFAULT_CACHE_ALIAS]['BACKEND'].startswith('django.core.cache.backends.memcached.'), "memcached not available")(MemcachedCacheTests) class FileBasedCacheTests(unittest.TestCase, BaseCacheTests): """ Specific test cases for the file-based cache. """ def setUp(self): self.dirname = tempfile.mkdtemp() self.cache = get_cache('django.core.cache.backends.filebased.FileBasedCache', LOCATION=self.dirname, OPTIONS={'MAX_ENTRIES': 30}) self.prefix_cache = get_cache('django.core.cache.backends.filebased.FileBasedCache', LOCATION=self.dirname, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache('django.core.cache.backends.filebased.FileBasedCache', LOCATION=self.dirname, VERSION=2) self.custom_key_cache = get_cache('django.core.cache.backends.filebased.FileBasedCache', LOCATION=self.dirname, KEY_FUNCTION=custom_key_func) self.custom_key_cache2 = get_cache('django.core.cache.backends.filebased.FileBasedCache', LOCATION=self.dirname, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') def tearDown(self): self.cache.clear() def test_hashing(self): """Test that keys are hashed into subdirectories correctly""" self.cache.set("foo", "bar") key = self.cache.make_key("foo") keyhash = md5_constructor(key).hexdigest() keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:]) self.assertTrue(os.path.exists(keypath)) def test_subdirectory_removal(self): """ Make sure that the created subdirectories are correctly removed when empty. """ self.cache.set("foo", "bar") key = self.cache.make_key("foo") keyhash = md5_constructor(key).hexdigest() keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:]) self.assertTrue(os.path.exists(keypath)) self.cache.delete("foo") self.assertTrue(not os.path.exists(keypath)) self.assertTrue(not os.path.exists(os.path.dirname(keypath))) self.assertTrue(not os.path.exists(os.path.dirname(os.path.dirname(keypath)))) def test_cull(self): self.perform_cull_test(50, 29) def test_old_initialization(self): self.cache = get_cache('file://%s?max_entries=30' % self.dirname) self.perform_cull_test(50, 29) class CustomCacheKeyValidationTests(unittest.TestCase): """ Tests for the ability to mixin a custom ``validate_key`` method to a custom cache backend that otherwise inherits from a builtin backend, and override the default key validation. Refs #6447. """ def test_custom_key_validation(self): cache = get_cache('regressiontests.cache.liberal_backend://') # this key is both longer than 250 characters, and has spaces key = 'some key with spaces' * 15 val = 'a value' cache.set(key, val) self.assertEqual(cache.get(key), val) class CacheUtils(unittest.TestCase): """TestCase for django.utils.cache functions.""" def setUp(self): self.path = '/cache/test/' self.old_cache_middleware_key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.old_cache_middleware_seconds = settings.CACHE_MIDDLEWARE_SECONDS self.orig_use_i18n = settings.USE_I18N settings.CACHE_MIDDLEWARE_KEY_PREFIX = 'settingsprefix' settings.CACHE_MIDDLEWARE_SECONDS = 1 settings.USE_I18N = False def tearDown(self): settings.CACHE_MIDDLEWARE_KEY_PREFIX = self.old_cache_middleware_key_prefix settings.CACHE_MIDDLEWARE_SECONDS = self.old_cache_middleware_seconds settings.USE_I18N = self.orig_use_i18n def _get_request(self, path, method='GET'): request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } request.method = method request.path = request.path_info = "/cache/%s" % path return request def test_patch_vary_headers(self): headers = ( # Initial vary, new headers, resulting vary. (None, ('Accept-Encoding',), 'Accept-Encoding'), ('Accept-Encoding', ('accept-encoding',), 'Accept-Encoding'), ('Accept-Encoding', ('ACCEPT-ENCODING',), 'Accept-Encoding'), ('Cookie', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), ('Cookie, Accept-Encoding', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), (None, ('Accept-Encoding', 'COOKIE'), 'Accept-Encoding, COOKIE'), ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), ('Cookie , Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), ) for initial_vary, newheaders, resulting_vary in headers: response = HttpResponse() if initial_vary is not None: response['Vary'] = initial_vary patch_vary_headers(response, newheaders) self.assertEqual(response['Vary'], resulting_vary) def test_get_cache_key(self): request = self._get_request(self.path) response = HttpResponse() key_prefix = 'localprefix' # Expect None if no headers have been set yet. self.assertEqual(get_cache_key(request), None) # Set headers to an empty list. learn_cache_key(request, response) self.assertEqual(get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.a8c87a3d8c44853d7f79474f7ffe4ad5.d41d8cd98f00b204e9800998ecf8427e') # Verify that a specified key_prefix is taken into account. learn_cache_key(request, response, key_prefix=key_prefix) self.assertEqual(get_cache_key(request, key_prefix=key_prefix), 'views.decorators.cache.cache_page.localprefix.GET.a8c87a3d8c44853d7f79474f7ffe4ad5.d41d8cd98f00b204e9800998ecf8427e') def test_get_cache_key_with_query(self): request = self._get_request(self.path + '?test=1') response = HttpResponse() # Expect None if no headers have been set yet. self.assertEqual(get_cache_key(request), None) # Set headers to an empty list. learn_cache_key(request, response) # Verify that the querystring is taken into account. self.assertEqual(get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.bd889c5a59603af44333ed21504db3cd.d41d8cd98f00b204e9800998ecf8427e') def test_learn_cache_key(self): request = self._get_request(self.path, 'HEAD') response = HttpResponse() response['Vary'] = 'Pony' # Make sure that the Vary header is added to the key hash learn_cache_key(request, response) self.assertEqual(get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.HEAD.a8c87a3d8c44853d7f79474f7ffe4ad5.d41d8cd98f00b204e9800998ecf8427e') class PrefixedCacheUtils(CacheUtils): def setUp(self): super(PrefixedCacheUtils, self).setUp() self.old_cache_key_prefix = settings.CACHES['default'].get('KEY_PREFIX', None) settings.CACHES['default']['KEY_PREFIX'] = 'cacheprefix' def tearDown(self): super(PrefixedCacheUtils, self).tearDown() if self.old_cache_key_prefix is None: del settings.CACHES['default']['KEY_PREFIX'] else: settings.CACHES['default']['KEY_PREFIX'] = self.old_cache_key_prefix class CacheHEADTest(unittest.TestCase): def setUp(self): self.orig_cache_middleware_seconds = settings.CACHE_MIDDLEWARE_SECONDS self.orig_cache_middleware_key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.orig_caches = settings.CACHES settings.CACHE_MIDDLEWARE_SECONDS = 60 settings.CACHE_MIDDLEWARE_KEY_PREFIX = 'test' settings.CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' } } self.path = '/cache/test/' def tearDown(self): settings.CACHE_MIDDLEWARE_SECONDS = self.orig_cache_middleware_seconds settings.CACHE_MIDDLEWARE_KEY_PREFIX = self.orig_cache_middleware_key_prefix settings.CACHES = self.orig_caches def _get_request(self, method): request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } request.method = method request.path = request.path_info = self.path return request def _get_request_cache(self, method): request = self._get_request(method) request._cache_update_cache = True return request def _set_cache(self, request, msg): response = HttpResponse() response.content = msg return UpdateCacheMiddleware().process_response(request, response) def test_head_caches_correctly(self): test_content = 'test content' request = self._get_request_cache('HEAD') self._set_cache(request, test_content) request = self._get_request('HEAD') get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertNotEqual(get_cache_data, None) self.assertEqual(test_content, get_cache_data.content) def test_head_with_cached_get(self): test_content = 'test content' request = self._get_request_cache('GET') self._set_cache(request, test_content) request = self._get_request('HEAD') get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertNotEqual(get_cache_data, None) self.assertEqual(test_content, get_cache_data.content) class CacheI18nTest(unittest.TestCase): def setUp(self): self.orig_cache_middleware_seconds = settings.CACHE_MIDDLEWARE_SECONDS self.orig_cache_middleware_key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.orig_caches = settings.CACHES self.orig_use_i18n = settings.USE_I18N self.orig_languages = settings.LANGUAGES settings.LANGUAGES = ( ('en', 'English'), ('es', 'Spanish'), ) settings.CACHE_MIDDLEWARE_KEY_PREFIX = 'settingsprefix' self.path = '/cache/test/' def tearDown(self): settings.CACHE_MIDDLEWARE_SECONDS = self.orig_cache_middleware_seconds settings.CACHE_MIDDLEWARE_KEY_PREFIX = self.orig_cache_middleware_key_prefix settings.CACHES = self.orig_caches settings.USE_I18N = self.orig_use_i18n settings.LANGUAGES = self.orig_languages translation.deactivate() def _get_request(self): request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } request.path = request.path_info = self.path return request def _get_request_cache(self, query_string=None): request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } if query_string: request.META['QUERY_STRING'] = query_string request.GET = QueryDict(query_string) request.path = request.path_info = self.path request._cache_update_cache = True request.method = 'GET' request.session = {} return request def test_cache_key_i18n(self): settings.USE_I18N = True request = self._get_request() lang = translation.get_language() response = HttpResponse() key = learn_cache_key(request, response) self.assertTrue(key.endswith(lang), "Cache keys should include the language name when i18n is active") key2 = get_cache_key(request) self.assertEqual(key, key2) def test_cache_key_no_i18n (self): settings.USE_I18N = False request = self._get_request() lang = translation.get_language() response = HttpResponse() key = learn_cache_key(request, response) self.assertFalse(key.endswith(lang), "Cache keys shouldn't include the language name when i18n is inactive") def test_middleware(self): def set_cache(request, lang, msg): translation.activate(lang) response = HttpResponse() response.content= msg return UpdateCacheMiddleware().process_response(request, response) settings.CACHE_MIDDLEWARE_SECONDS = 60 settings.CACHE_MIDDLEWARE_KEY_PREFIX = "test" settings.CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' } } settings.USE_ETAGS = True settings.USE_I18N = True # cache with non empty request.GET request = self._get_request_cache(query_string='foo=bar&other=true') get_cache_data = FetchFromCacheMiddleware().process_request(request) # first access, cache must return None self.assertEqual(get_cache_data, None) response = HttpResponse() content = 'Check for cache with QUERY_STRING' response.content = content UpdateCacheMiddleware().process_response(request, response) get_cache_data = FetchFromCacheMiddleware().process_request(request) # cache must return content self.assertNotEqual(get_cache_data, None) self.assertEqual(get_cache_data.content, content) # different QUERY_STRING, cache must be empty request = self._get_request_cache(query_string='foo=bar&somethingelse=true') get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertEqual(get_cache_data, None) # i18n tests en_message ="Hello world!" es_message ="Hola mundo!" request = self._get_request_cache() set_cache(request, 'en', en_message) get_cache_data = FetchFromCacheMiddleware().process_request(request) # Check that we can recover the cache self.assertNotEqual(get_cache_data.content, None) self.assertEqual(en_message, get_cache_data.content) # Check that we use etags self.assertTrue(get_cache_data.has_header('ETag')) # Check that we can disable etags settings.USE_ETAGS = False request._cache_update_cache = True set_cache(request, 'en', en_message) get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertFalse(get_cache_data.has_header('ETag')) # change the session language and set content request = self._get_request_cache() set_cache(request, 'es', es_message) # change again the language translation.activate('en') # retrieve the content from cache get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertEqual(get_cache_data.content, en_message) # change again the language translation.activate('es') get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertEqual(get_cache_data.content, es_message) class PrefixedCacheI18nTest(CacheI18nTest): def setUp(self): super(PrefixedCacheI18nTest, self).setUp() self.old_cache_key_prefix = settings.CACHES['default'].get('KEY_PREFIX', None) settings.CACHES['default']['KEY_PREFIX'] = 'cacheprefix' def tearDown(self): super(PrefixedCacheI18nTest, self).tearDown() if self.old_cache_key_prefix is not None: del settings.CACHES['default']['KEY_PREFIX'] else: settings.CACHES['default']['KEY_PREFIX'] = self.old_cache_key_prefix def hello_world_view(request, value): return HttpResponse('Hello World %s' % value) class CacheMiddlewareTest(unittest.TestCase): def setUp(self): self.factory = RequestFactory() self.orig_cache_middleware_alias = settings.CACHE_MIDDLEWARE_ALIAS self.orig_cache_middleware_key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.orig_cache_middleware_seconds = settings.CACHE_MIDDLEWARE_SECONDS self.orig_cache_middleware_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) self.orig_caches = settings.CACHES settings.CACHE_MIDDLEWARE_ALIAS = 'other' settings.CACHE_MIDDLEWARE_KEY_PREFIX = 'middlewareprefix' settings.CACHE_MIDDLEWARE_SECONDS = 30 settings.CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False settings.CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' }, 'other': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'other', 'TIMEOUT': '1' } } def tearDown(self): settings.CACHE_MIDDLEWARE_ALIAS = self.orig_cache_middleware_alias settings.CACHE_MIDDLEWARE_KEY_PREFIX = self.orig_cache_middleware_key_prefix settings.CACHE_MIDDLEWARE_SECONDS = self.orig_cache_middleware_seconds settings.CACHE_MIDDLEWARE_ANONYMOUS_ONLY = self.orig_cache_middleware_anonymous_only settings.CACHES = self.orig_caches def test_constructor(self): """ Ensure the constructor is correctly distinguishing between usage of CacheMiddleware as Middleware vs. usage of CacheMiddleware as view decorator and setting attributes appropriately. """ # If no arguments are passed in construction, it's being used as middleware. middleware = CacheMiddleware() # Now test object attributes against values defined in setUp above self.assertEqual(middleware.cache_timeout, 30) self.assertEqual(middleware.key_prefix, 'middlewareprefix') self.assertEqual(middleware.cache_alias, 'other') self.assertEqual(middleware.cache_anonymous_only, False) # If arguments are being passed in construction, it's being used as a decorator. # First, test with "defaults": as_view_decorator = CacheMiddleware(cache_alias=None, key_prefix=None) self.assertEqual(as_view_decorator.cache_timeout, 300) # Timeout value for 'default' cache, i.e. 300 self.assertEqual(as_view_decorator.key_prefix, '') self.assertEqual(as_view_decorator.cache_alias, 'default') # Value of DEFAULT_CACHE_ALIAS from django.core.cache self.assertEqual(as_view_decorator.cache_anonymous_only, False) # Next, test with custom values: as_view_decorator_with_custom = CacheMiddleware(cache_anonymous_only=True, cache_timeout=60, cache_alias='other', key_prefix='foo') self.assertEqual(as_view_decorator_with_custom.cache_timeout, 60) self.assertEqual(as_view_decorator_with_custom.key_prefix, 'foo') self.assertEqual(as_view_decorator_with_custom.cache_alias, 'other') self.assertEqual(as_view_decorator_with_custom.cache_anonymous_only, True) def test_middleware(self): middleware = CacheMiddleware() prefix_middleware = CacheMiddleware(key_prefix='prefix1') timeout_middleware = CacheMiddleware(cache_timeout=1) request = self.factory.get('/view/') # Put the request through the request middleware result = middleware.process_request(request) self.assertEqual(result, None) response = hello_world_view(request, '1') # Now put the response through the response middleware response = middleware.process_response(request, response) # Repeating the request should result in a cache hit result = middleware.process_request(request) self.assertNotEquals(result, None) self.assertEqual(result.content, 'Hello World 1') # The same request through a different middleware won't hit result = prefix_middleware.process_request(request) self.assertEqual(result, None) # The same request with a timeout _will_ hit result = timeout_middleware.process_request(request) self.assertNotEquals(result, None) self.assertEqual(result.content, 'Hello World 1') def test_cache_middleware_anonymous_only_wont_cause_session_access(self): """ The cache middleware shouldn't cause a session access due to CACHE_MIDDLEWARE_ANONYMOUS_ONLY if nothing else has accessed the session. Refs 13283 """ settings.CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True from django.contrib.sessions.middleware import SessionMiddleware from django.contrib.auth.middleware import AuthenticationMiddleware middleware = CacheMiddleware() session_middleware = SessionMiddleware() auth_middleware = AuthenticationMiddleware() request = self.factory.get('/view_anon/') # Put the request through the request middleware session_middleware.process_request(request) auth_middleware.process_request(request) result = middleware.process_request(request) self.assertEqual(result, None) response = hello_world_view(request, '1') # Now put the response through the response middleware session_middleware.process_response(request, response) response = middleware.process_response(request, response) self.assertEqual(request.session.accessed, False) def test_cache_middleware_anonymous_only_with_cache_page(self): """CACHE_MIDDLEWARE_ANONYMOUS_ONLY should still be effective when used with the cache_page decorator: the response to a request from an authenticated user should not be cached.""" settings.CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True request = self.factory.get('/view_anon/') class MockAuthenticatedUser(object): def is_authenticated(self): return True class MockAccessedSession(object): accessed = True request.user = MockAuthenticatedUser() request.session = MockAccessedSession() response = cache_page(hello_world_view)(request, '1') self.assertFalse("Cache-Control" in response) def test_view_decorator(self): # decorate the same view with different cache decorators default_view = cache_page(hello_world_view) default_with_prefix_view = cache_page(key_prefix='prefix1')(hello_world_view) explicit_default_view = cache_page(cache='default')(hello_world_view) explicit_default_with_prefix_view = cache_page(cache='default', key_prefix='prefix1')(hello_world_view) other_view = cache_page(cache='other')(hello_world_view) other_with_prefix_view = cache_page(cache='other', key_prefix='prefix2')(hello_world_view) other_with_timeout_view = cache_page(4, cache='other', key_prefix='prefix3')(hello_world_view) request = self.factory.get('/view/') # Request the view once response = default_view(request, '1') self.assertEqual(response.content, 'Hello World 1') # Request again -- hit the cache response = default_view(request, '2') self.assertEqual(response.content, 'Hello World 1') # Requesting the same view with the explicit cache should yield the same result response = explicit_default_view(request, '3') self.assertEqual(response.content, 'Hello World 1') # Requesting with a prefix will hit a different cache key response = explicit_default_with_prefix_view(request, '4') self.assertEqual(response.content, 'Hello World 4') # Hitting the same view again gives a cache hit response = explicit_default_with_prefix_view(request, '5') self.assertEqual(response.content, 'Hello World 4') # And going back to the implicit cache will hit the same cache response = default_with_prefix_view(request, '6') self.assertEqual(response.content, 'Hello World 4') # Requesting from an alternate cache won't hit cache response = other_view(request, '7') self.assertEqual(response.content, 'Hello World 7') # But a repeated hit will hit cache response = other_view(request, '8') self.assertEqual(response.content, 'Hello World 7') # And prefixing the alternate cache yields yet another cache entry response = other_with_prefix_view(request, '9') self.assertEqual(response.content, 'Hello World 9') # Request from the alternate cache with a new prefix and a custom timeout response = other_with_timeout_view(request, '10') self.assertEqual(response.content, 'Hello World 10') # But if we wait a couple of seconds... time.sleep(2) # ... the default cache will still hit cache = get_cache('default') response = default_view(request, '11') self.assertEqual(response.content, 'Hello World 1') # ... the default cache with a prefix will still hit response = default_with_prefix_view(request, '12') self.assertEqual(response.content, 'Hello World 4') # ... the explicit default cache will still hit response = explicit_default_view(request, '13') self.assertEqual(response.content, 'Hello World 1') # ... the explicit default cache with a prefix will still hit response = explicit_default_with_prefix_view(request, '14') self.assertEqual(response.content, 'Hello World 4') # .. but a rapidly expiring cache won't hit response = other_view(request, '15') self.assertEqual(response.content, 'Hello World 15') # .. even if it has a prefix response = other_with_prefix_view(request, '16') self.assertEqual(response.content, 'Hello World 16') # ... but a view with a custom timeout will still hit response = other_with_timeout_view(request, '17') self.assertEqual(response.content, 'Hello World 10') # And if we wait a few more seconds time.sleep(2) # the custom timeouot cache will miss response = other_with_timeout_view(request, '18') self.assertEqual(response.content, 'Hello World 18') if __name__ == '__main__': unittest.main()
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 12008, 2295, 367, 2581, 10059, 199, 3, 14911, 15685, 2581, 4865, 365, 663, 315, 314, 511, 2202, 570, 14, 199, 199, 646, 747, 199, 646, 5549, 199, 646, 900, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 12, 6186, 63, 8677, 63, 12644, 199, 504, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 1095, 492, 11977, 1197, 3849, 199, 504, 1639, 14, 1014, 492, 6183, 12, 20730, 12, 8133, 2141, 199, 504, 1639, 14, 5754, 14, 1637, 492, 16347, 2532, 4437, 6608, 12, 6162, 4437, 6608, 12, 11977, 6608, 199, 504, 1639, 14, 396, 492, 18638, 199, 504, 1639, 14, 396, 14, 1208, 492, 664, 63, 5451, 63, 929, 12, 9066, 63, 5451, 63, 929, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 492, 2882, 199, 504, 1639, 14, 1208, 14, 1637, 492, 3371, 63, 21989, 63, 2139, 12, 664, 63, 1637, 63, 498, 12, 12537, 63, 1637, 63, 498, 199, 504, 1639, 14, 1208, 14, 2227, 5819, 492, 6128, 21, 63, 1880, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 2581, 63, 1606, 199, 199, 504, 10864, 2219, 14, 1637, 14, 992, 492, 25306, 12, 23133, 63, 31458, 199, 199, 3, 3423, 15, 2888, 367, 6114, 666, 730, 2295, 199, 318, 289, 837, 272, 372, 5685, 199, 533, 445, 26, 272, 347, 333, 8, 78, 304, 267, 372, 5504, 199, 199, 533, 9762, 4437, 2925, 8, 2796, 14, 1746, 304, 272, 327, 710, 9762, 2581, 4865, 3181, 1133, 7710, 24062, 2839, 282, 511, 4865, 12, 272, 327, 880, 652, 965, 3365, 511, 9760, 14, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1637, 275, 664, 63, 1637, 360, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 5869, 14, 11324, 4437, 358, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 298, 11324, 2581, 4865, 24010, 2581, 663, 4882, 2, 267, 291, 14, 1637, 14, 409, 480, 498, 401, 298, 585, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 1288, 488, 9, 339, 347, 511, 63, 525, 8, 277, 304, 267, 298, 1123, 3181, 1133, 886, 7003, 315, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 525, 480, 525, 498, 17, 401, 298, 585, 531, 267, 754, 275, 291, 14, 1637, 14, 525, 480, 525, 498, 17, 401, 298, 1222, 585, 531, 267, 291, 14, 629, 8, 1099, 12, 715, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 525, 498, 17, 1288, 488, 9, 339, 347, 511, 63, 2865, 63, 15025, 8, 277, 304, 267, 298, 6932, 13, 15025, 2883, 10621, 1133, 1911, 315, 314, 7283, 2581, 4865, 2, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 1288, 488, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 401, 298, 66, 621, 1, 1288, 298, 66, 621, 9124, 339, 347, 511, 63, 362, 63, 3479, 8, 277, 304, 267, 298, 362, 63, 3479, 2529, 6548, 367, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 360, 65, 297, 283, 65, 358, 267, 291, 14, 1637, 14, 409, 360, 66, 297, 283, 66, 358, 267, 291, 14, 1637, 14, 409, 360, 67, 297, 283, 67, 358, 267, 291, 14, 1637, 14, 409, 360, 68, 297, 283, 68, 358, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 67, 297, 283, 68, 3815, 5009, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 66, 297, 283, 69, 3815, 5009, 339, 347, 511, 63, 1807, 8, 277, 304, 267, 298, 4437, 14068, 365, 17265, 590, 5525, 641, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 480, 498, 17, 401, 298, 8283, 531, 267, 291, 14, 1637, 14, 409, 480, 498, 18, 401, 298, 14488, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 17, 1288, 488, 9, 267, 291, 14, 1637, 14, 1807, 480, 498, 17, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 17, 1288, 488, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 18, 1288, 488, 9, 339, 347, 511, 63, 1989, 63, 498, 8, 277, 304, 267, 298, 1918, 965, 63, 498, 1083, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 480, 5006, 17, 401, 298, 8302, 16481, 17, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 1989, 63, 498, 480, 5006, 17, 1288, 756, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 1989, 63, 498, 480, 8302, 16481, 17, 1288, 756, 9, 339, 347, 511, 63, 262, 8, 277, 304, 267, 298, 1918, 315, 4182, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 480, 5006, 18, 401, 298, 8302, 16481, 18, 531, 267, 291, 14, 629, 480, 5006, 18, 2, 315, 291, 14, 1637, 12, 756, 9, 267, 291, 14, 629, 480, 8302, 16481, 18, 2, 315, 291, 14, 1637, 12, 756, 9, 339, 347, 511, 63, 19362, 8, 277, 304, 267, 298, 11324, 2581, 1338, 883, 1133, 506, 10035, 2509, 2, 267, 291, 14, 1637, 14, 409, 360, 5934, 297, 5685, 9, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 19362, 12, 283, 5934, 358, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 19362, 12, 283, 9105, 63, 1397, 63, 4494, 358, 339, 347, 511, 63, 271, 1556, 8, 277, 304, 267, 298, 11324, 2581, 1338, 883, 1133, 506, 477, 1353, 2509, 2, 267, 291, 14, 1637, 14, 409, 360, 5934, 297, 5685, 9, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 271, 1556, 12, 283, 5934, 358, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 271, 1556, 12, 283, 9105, 63, 1397, 63, 4494, 358, 339, 347, 511, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 12008, 2295, 367, 2581, 10059, 199, 3, 14911, 15685, 2581, 4865, 365, 663, 315, 314, 511, 2202, 570, 14, 199, 199, 646, 747, 199, 646, 5549, 199, 646, 900, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 12, 6186, 63, 8677, 63, 12644, 199, 504, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 1095, 492, 11977, 1197, 3849, 199, 504, 1639, 14, 1014, 492, 6183, 12, 20730, 12, 8133, 2141, 199, 504, 1639, 14, 5754, 14, 1637, 492, 16347, 2532, 4437, 6608, 12, 6162, 4437, 6608, 12, 11977, 6608, 199, 504, 1639, 14, 396, 492, 18638, 199, 504, 1639, 14, 396, 14, 1208, 492, 664, 63, 5451, 63, 929, 12, 9066, 63, 5451, 63, 929, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 492, 2882, 199, 504, 1639, 14, 1208, 14, 1637, 492, 3371, 63, 21989, 63, 2139, 12, 664, 63, 1637, 63, 498, 12, 12537, 63, 1637, 63, 498, 199, 504, 1639, 14, 1208, 14, 2227, 5819, 492, 6128, 21, 63, 1880, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 2581, 63, 1606, 199, 199, 504, 10864, 2219, 14, 1637, 14, 992, 492, 25306, 12, 23133, 63, 31458, 199, 199, 3, 3423, 15, 2888, 367, 6114, 666, 730, 2295, 199, 318, 289, 837, 272, 372, 5685, 199, 533, 445, 26, 272, 347, 333, 8, 78, 304, 267, 372, 5504, 199, 199, 533, 9762, 4437, 2925, 8, 2796, 14, 1746, 304, 272, 327, 710, 9762, 2581, 4865, 3181, 1133, 7710, 24062, 2839, 282, 511, 4865, 12, 272, 327, 880, 652, 965, 3365, 511, 9760, 14, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1637, 275, 664, 63, 1637, 360, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 5869, 14, 11324, 4437, 358, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 298, 11324, 2581, 4865, 24010, 2581, 663, 4882, 2, 267, 291, 14, 1637, 14, 409, 480, 498, 401, 298, 585, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 1288, 488, 9, 339, 347, 511, 63, 525, 8, 277, 304, 267, 298, 1123, 3181, 1133, 886, 7003, 315, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 525, 480, 525, 498, 17, 401, 298, 585, 531, 267, 754, 275, 291, 14, 1637, 14, 525, 480, 525, 498, 17, 401, 298, 1222, 585, 531, 267, 291, 14, 629, 8, 1099, 12, 715, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 525, 498, 17, 1288, 488, 9, 339, 347, 511, 63, 2865, 63, 15025, 8, 277, 304, 267, 298, 6932, 13, 15025, 2883, 10621, 1133, 1911, 315, 314, 7283, 2581, 4865, 2, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 1288, 488, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 401, 298, 66, 621, 1, 1288, 298, 66, 621, 9124, 339, 347, 511, 63, 362, 63, 3479, 8, 277, 304, 267, 298, 362, 63, 3479, 2529, 6548, 367, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 360, 65, 297, 283, 65, 358, 267, 291, 14, 1637, 14, 409, 360, 66, 297, 283, 66, 358, 267, 291, 14, 1637, 14, 409, 360, 67, 297, 283, 67, 358, 267, 291, 14, 1637, 14, 409, 360, 68, 297, 283, 68, 358, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 67, 297, 283, 68, 3815, 5009, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 66, 297, 283, 69, 3815, 5009, 339, 347, 511, 63, 1807, 8, 277, 304, 267, 298, 4437, 14068, 365, 17265, 590, 5525, 641, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 480, 498, 17, 401, 298, 8283, 531, 267, 291, 14, 1637, 14, 409, 480, 498, 18, 401, 298, 14488, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 17, 1288, 488, 9, 267, 291, 14, 1637, 14, 1807, 480, 498, 17, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 17, 1288, 488, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 362, 480, 498, 18, 1288, 488, 9, 339, 347, 511, 63, 1989, 63, 498, 8, 277, 304, 267, 298, 1918, 965, 63, 498, 1083, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 480, 5006, 17, 401, 298, 8302, 16481, 17, 531, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 1989, 63, 498, 480, 5006, 17, 1288, 756, 9, 267, 291, 14, 629, 8, 277, 14, 1637, 14, 1989, 63, 498, 480, 8302, 16481, 17, 1288, 756, 9, 339, 347, 511, 63, 262, 8, 277, 304, 267, 298, 1918, 315, 4182, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 291, 14, 1637, 14, 409, 480, 5006, 18, 401, 298, 8302, 16481, 18, 531, 267, 291, 14, 629, 480, 5006, 18, 2, 315, 291, 14, 1637, 12, 756, 9, 267, 291, 14, 629, 480, 8302, 16481, 18, 2, 315, 291, 14, 1637, 12, 756, 9, 339, 347, 511, 63, 19362, 8, 277, 304, 267, 298, 11324, 2581, 1338, 883, 1133, 506, 10035, 2509, 2, 267, 291, 14, 1637, 14, 409, 360, 5934, 297, 5685, 9, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 19362, 12, 283, 5934, 358, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 19362, 12, 283, 9105, 63, 1397, 63, 4494, 358, 339, 347, 511, 63, 271, 1556, 8, 277, 304, 267, 298, 11324, 2581, 1338, 883, 1133, 506, 477, 1353, 2509, 2, 267, 291, 14, 1637, 14, 409, 360, 5934, 297, 5685, 9, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 271, 1556, 12, 283, 5934, 358, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 1637, 14, 271, 1556, 12, 283,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
benoitsteiner/tensorflow-opencl
tensorflow/contrib/gan/python/features/python/virtual_batchnorm_test.py
30
11083
# 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 tfgan.python.features.virtual_batchnorm.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.contrib.framework.python.ops import variables as contrib_variables_lib from tensorflow.contrib.gan.python.features.python import virtual_batchnorm_impl as virtual_batchnorm from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import random_seed from tensorflow.python.layers import normalization from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn from tensorflow.python.ops import random_ops from tensorflow.python.ops import variable_scope from tensorflow.python.ops import variables as variables_lib from tensorflow.python.platform import test class VirtualBatchnormTest(test.TestCase): def test_syntax(self): reference_batch = array_ops.zeros([5, 3, 16, 9, 15]) vbn = virtual_batchnorm.VBN(reference_batch, batch_axis=1) vbn(array_ops.ones([5, 7, 16, 9, 15])) def test_no_broadcast_needed(self): """When `axis` and `batch_axis` are at the end, no broadcast is needed.""" reference_batch = array_ops.zeros([5, 3, 16, 9, 15]) minibatch = array_ops.zeros([5, 3, 16, 3, 15]) vbn = virtual_batchnorm.VBN(reference_batch, axis=-1, batch_axis=-2) vbn(minibatch) def test_statistics(self): """Check that `_statistics` gives the same result as `nn.moments`.""" random_seed.set_random_seed(1234) tensors = random_ops.random_normal([4, 5, 7, 3]) for axes in [(3), (0, 2), (1, 2, 3)]: vb_mean, mean_sq = virtual_batchnorm._statistics(tensors, axes) mom_mean, mom_var = nn.moments(tensors, axes) vb_var = mean_sq - math_ops.square(vb_mean) with self.test_session(use_gpu=True) as sess: vb_mean_np, vb_var_np, mom_mean_np, mom_var_np = sess.run([ vb_mean, vb_var, mom_mean, mom_var]) self.assertAllClose(mom_mean_np, vb_mean_np) self.assertAllClose(mom_var_np, vb_var_np) def test_virtual_statistics(self): """Check that `_virtual_statistics` gives same result as `nn.moments`.""" random_seed.set_random_seed(1234) batch_axis = 0 partial_batch = random_ops.random_normal([4, 5, 7, 3]) single_example = random_ops.random_normal([1, 5, 7, 3]) full_batch = array_ops.concat([partial_batch, single_example], axis=0) for reduction_axis in range(1, 4): # Get `nn.moments` on the full batch. reduction_axes = list(range(4)) del reduction_axes[reduction_axis] mom_mean, mom_variance = nn.moments(full_batch, reduction_axes) # Get virtual batch statistics. vb_reduction_axes = list(range(4)) del vb_reduction_axes[reduction_axis] del vb_reduction_axes[batch_axis] vbn = virtual_batchnorm.VBN(partial_batch, reduction_axis) vb_mean, mean_sq = vbn._virtual_statistics( single_example, vb_reduction_axes) vb_variance = mean_sq - math_ops.square(vb_mean) # Remove singleton batch dim for easy comparisons. vb_mean = array_ops.squeeze(vb_mean, batch_axis) vb_variance = array_ops.squeeze(vb_variance, batch_axis) with self.test_session(use_gpu=True) as sess: vb_mean_np, vb_var_np, mom_mean_np, mom_var_np = sess.run([ vb_mean, vb_variance, mom_mean, mom_variance]) self.assertAllClose(mom_mean_np, vb_mean_np) self.assertAllClose(mom_var_np, vb_var_np) def test_reference_batch_normalization(self): """Check that batch norm from VBN agrees with opensource implementation.""" random_seed.set_random_seed(1234) batch = random_ops.random_normal([6, 5, 7, 3, 3]) for axis in range(5): # Get `layers` batchnorm result. bn_normalized = normalization.batch_normalization( batch, axis, training=True) # Get VBN's batch normalization on reference batch. batch_axis = 0 if axis is not 0 else 1 # axis and batch_axis can't same vbn = virtual_batchnorm.VBN(batch, axis, batch_axis=batch_axis) vbn_normalized = vbn.reference_batch_normalization() with self.test_session(use_gpu=True) as sess: variables_lib.global_variables_initializer().run() bn_normalized_np, vbn_normalized_np = sess.run( [bn_normalized, vbn_normalized]) self.assertAllClose(bn_normalized_np, vbn_normalized_np) def test_same_as_batchnorm(self): """Check that batch norm on set X is the same as ref of X / y on `y`.""" random_seed.set_random_seed(1234) num_examples = 4 examples = [random_ops.random_normal([5, 7, 3]) for _ in range(num_examples)] # Get the result of the opensource batch normalization. batch_normalized = normalization.batch_normalization( array_ops.stack(examples), training=True) for i in range(num_examples): examples_except_i = array_ops.stack(examples[:i] + examples[i+1:]) # Get the result of VBN's batch normalization. vbn = virtual_batchnorm.VBN(examples_except_i) vb_normed = array_ops.squeeze( vbn(array_ops.expand_dims(examples[i], [0])), [0]) with self.test_session(use_gpu=True) as sess: variables_lib.global_variables_initializer().run() bn_np, vb_np = sess.run([batch_normalized, vb_normed]) self.assertAllClose(bn_np[i, ...], vb_np) def test_minibatch_independent(self): """Test that virtual batch normalized exampels are independent. Unlike batch normalization, virtual batch normalization has the property that the virtual batch normalized value of an example is independent of the other examples in the minibatch. In this test, we verify this property. """ random_seed.set_random_seed(1234) # These can be random, but must be the same for all session calls. reference_batch = constant_op.constant( np.random.normal(size=[4, 7, 3]), dtype=dtypes.float32) fixed_example = constant_op.constant(np.random.normal(size=[7, 3]), dtype=dtypes.float32) # Get the VBN object and the virtual batch normalized value for # `fixed_example`. vbn = virtual_batchnorm.VBN(reference_batch) vbn_fixed_example = array_ops.squeeze( vbn(array_ops.expand_dims(fixed_example, 0)), 0) with self.test_session(use_gpu=True): variables_lib.global_variables_initializer().run() vbn_fixed_example_np = vbn_fixed_example.eval() # Check that the value is the same for different minibatches, and different # sized minibatches. for minibatch_size in range(1, 6): examples = [random_ops.random_normal([7, 3]) for _ in range(minibatch_size)] minibatch = array_ops.stack([fixed_example] + examples) vbn_minibatch = vbn(minibatch) cur_vbn_fixed_example = vbn_minibatch[0, ...] with self.test_session(use_gpu=True): variables_lib.global_variables_initializer().run() cur_vbn_fixed_example_np = cur_vbn_fixed_example.eval() self.assertAllClose(vbn_fixed_example_np, cur_vbn_fixed_example_np) def test_variable_reuse(self): """Test that variable scopes work and inference on a real-ish case.""" tensor1_ref = array_ops.zeros([6, 5, 7, 3, 3]) tensor1_examples = array_ops.zeros([4, 5, 7, 3, 3]) tensor2_ref = array_ops.zeros([4, 2, 3]) tensor2_examples = array_ops.zeros([2, 2, 3]) with variable_scope.variable_scope('dummy_scope', reuse=True): with self.assertRaisesRegexp( ValueError, 'does not exist, or was not created with ' 'tf.get_variable()'): virtual_batchnorm.VBN(tensor1_ref) vbn1 = virtual_batchnorm.VBN(tensor1_ref, name='vbn1') vbn2 = virtual_batchnorm.VBN(tensor2_ref, name='vbn2') # Fetch reference and examples after virtual batch normalization. Also # fetch in variable reuse case. to_fetch = [] to_fetch.append(vbn1.reference_batch_normalization()) to_fetch.append(vbn2.reference_batch_normalization()) to_fetch.append(vbn1(tensor1_examples)) to_fetch.append(vbn2(tensor2_examples)) variable_scope.get_variable_scope().reuse_variables() to_fetch.append(vbn1.reference_batch_normalization()) to_fetch.append(vbn2.reference_batch_normalization()) to_fetch.append(vbn1(tensor1_examples)) to_fetch.append(vbn2(tensor2_examples)) self.assertEqual(4, len(contrib_variables_lib.get_variables())) with self.test_session(use_gpu=True) as sess: variables_lib.global_variables_initializer().run() sess.run(to_fetch) def test_invalid_input(self): # Reference batch has unknown dimensions. with self.assertRaisesRegexp( ValueError, '`reference_batch` has unknown dimensions.'): virtual_batchnorm.VBN(array_ops.placeholder(dtypes.float32), name='vbn1') # Axis too negative. with self.assertRaisesRegexp( ValueError, 'Value of `axis` argument .* is out of range'): virtual_batchnorm.VBN(array_ops.zeros([1, 2]), axis=-3, name='vbn2') # Axis too large. with self.assertRaisesRegexp( ValueError, 'Value of `axis` argument .* is out of range'): virtual_batchnorm.VBN(array_ops.zeros([1, 2]), axis=2, name='vbn3') # Batch axis too negative. with self.assertRaisesRegexp( ValueError, 'Value of `axis` argument .* is out of range'): virtual_batchnorm.VBN(array_ops.zeros([1, 2]), name='vbn4', batch_axis=-3) # Batch axis too large. with self.assertRaisesRegexp( ValueError, 'Value of `axis` argument .* is out of range'): virtual_batchnorm.VBN(array_ops.zeros([1, 2]), name='vbn5', batch_axis=2) # Axis and batch axis are the same. with self.assertRaisesRegexp( ValueError, '`axis` and `batch_axis` cannot be the same.'): virtual_batchnorm.VBN(array_ops.zeros( [1, 2]), axis=1, name='vbn6', batch_axis=1) # Reference Tensor and example Tensor have incompatible shapes. tensor_ref = array_ops.zeros([5, 2, 3]) tensor_examples = array_ops.zeros([3, 2, 3]) vbn = virtual_batchnorm.VBN(tensor_ref, name='vbn7', batch_axis=1) with self.assertRaisesRegexp(ValueError, 'Shapes .* are incompatible'): vbn(tensor_examples) 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, 2833, 24975, 14, 1548, 14, 3179, 14, 2065, 63, 2912, 4791, 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, 2828, 14, 4857, 14, 1548, 14, 1483, 492, 2860, 465, 5914, 63, 3669, 63, 773, 199, 504, 3228, 14, 2828, 14, 24975, 14, 1548, 14, 3179, 14, 1548, 492, 5791, 63, 2912, 4791, 63, 5472, 465, 5791, 63, 2912, 4791, 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, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4359, 492, 16973, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 465, 2860, 63, 773, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 13311, 8842, 4791, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 7093, 8, 277, 304, 272, 3659, 63, 2912, 275, 1625, 63, 1483, 14, 4250, 779, 21, 12, 650, 12, 3193, 12, 1749, 12, 4114, 566, 272, 373, 10472, 275, 5791, 63, 2912, 4791, 14, 54, 18273, 8, 4443, 63, 2912, 12, 3522, 63, 3127, 29, 17, 9, 272, 373, 10472, 8, 1144, 63, 1483, 14, 4548, 779, 21, 12, 1520, 12, 3193, 12, 1749, 12, 4114, 2459, 819, 347, 511, 63, 889, 63, 10786, 63, 11368, 8, 277, 304, 272, 408, 11423, 658, 3127, 64, 436, 658, 2912, 63, 3127, 64, 787, 737, 314, 1284, 12, 949, 11180, 365, 4346, 1041, 272, 3659, 63, 2912, 275, 1625, 63, 1483, 14, 4250, 779, 21, 12, 650, 12, 3193, 12, 1749, 12, 4114, 566, 272, 30829, 275, 1625, 63, 1483, 14, 4250, 779, 21, 12, 650, 12, 3193, 12, 650, 12, 4114, 566, 272, 373, 10472, 275, 5791, 63, 2912, 4791, 14, 54, 18273, 8, 4443, 63, 2912, 12, 3114, 4022, 17, 12, 3522, 63, 3127, 4022, 18, 9, 272, 373, 10472, 8, 827, 21454, 9, 819, 347, 511, 63, 13724, 8, 277, 304, 272, 408, 1799, 626, 18494, 13724, 64, 10557, 314, 2011, 754, 465, 658, 4411, 14, 573, 1470, 17105, 272, 2196, 63, 5176, 14, 409, 63, 2355, 63, 5176, 8, 4321, 9, 339, 10519, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 20, 12, 959, 12, 1520, 12, 650, 566, 272, 367, 7824, 315, 3842, 19, 395, 334, 16, 12, 499, 395, 334, 17, 12, 499, 12, 650, 19532, 489, 373, 66, 63, 3670, 12, 4615, 63, 3526, 275, 5791, 63, 2912, 4791, 423, 13724, 8, 10206, 12, 7824, 9, 489, 30202, 63, 3670, 12, 30202, 63, 1391, 275, 11542, 14, 573, 1470, 8, 10206, 12, 7824, 9, 489, 373, 66, 63, 1391, 275, 4615, 63, 3526, 446, 3473, 63, 1483, 14, 9646, 8, 18708, 63, 3670, 9, 2541, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 267, 373, 66, 63, 3670, 63, 1590, 12, 373, 66, 63, 1391, 63, 1590, 12, 30202, 63, 3670, 63, 1590, 12, 30202, 63, 1391, 63, 1590, 275, 4043, 14, 1065, 779, 288, 373, 66, 63, 3670, 12, 373, 66, 63, 1391, 12, 30202, 63, 3670, 12, 30202, 63, 1391, 566, 2541, 291, 14, 7260, 8, 31714, 63, 3670, 63, 1590, 12, 373, 66, 63, 3670, 63, 1590, 9, 489, 291, 14, 7260, 8, 31714, 63, 1391, 63, 1590, 12, 373, 66, 63, 1391, 63, 1590, 9, 819, 347, 511, 63, 2065, 63, 13724, 8, 277, 304, 272, 408, 1799, 626, 18494, 2065, 63, 13724, 64, 10557, 2011, 754, 465, 658, 4411, 14, 573, 1470, 17105, 272, 2196, 63, 5176, 14, 409, 63, 2355, 63, 5176, 8, 4321, 9, 339, 3522, 63, 3127, 275, 378, 272, 7417, 63, 2912, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 20, 12, 959, 12, 1520, 12, 650, 566, 272, 2849, 63, 2694, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 17, 12, 959, 12, 1520, 12, 650, 566, 272, 2615, 63, 2912, 275, 1625, 63, 1483, 14, 9419, 779, 6672, 63, 2912, 12, 2849, 63, 2694, 467, 3114, 29, 16, 9, 339, 367, 16773, 63, 3127, 315, 1425, 8, 17, 12, 841, 304, 489, 327, 2372, 658, 4411, 14, 573, 1470, 64, 641, 314, 2615, 3522, 14, 489, 16773, 63, 6402, 275, 769, 8, 1842, 8, 20, 430, 489, 2150, 16773, 63, 6402, 59, 22508, 63, 3127, 61, 489, 30202, 63, 3670, 12, 30202, 63, 6221, 275, 11542, 14, 573, 1470, 8, 2861, 63, 2912, 12, 16773, 63, 6402, 9, 2541, 327, 2372, 5791, 3522, 11076, 14, 489, 373, 66, 63, 22508, 63, 6402, 275, 769, 8, 1842, 8, 20, 430, 489, 2150, 373, 66, 63, 22508, 63, 6402, 59, 22508, 63, 3127, 61, 489, 2150, 373, 66, 63, 22508, 63, 6402, 59, 2912, 63, 3127, 61, 489, 373, 10472, 275, 5791, 63, 2912, 4791, 14, 54, 18273, 8, 6672 ]
[ 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, 2833, 24975, 14, 1548, 14, 3179, 14, 2065, 63, 2912, 4791, 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, 2828, 14, 4857, 14, 1548, 14, 1483, 492, 2860, 465, 5914, 63, 3669, 63, 773, 199, 504, 3228, 14, 2828, 14, 24975, 14, 1548, 14, 3179, 14, 1548, 492, 5791, 63, 2912, 4791, 63, 5472, 465, 5791, 63, 2912, 4791, 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, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4359, 492, 16973, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 465, 2860, 63, 773, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 13311, 8842, 4791, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 7093, 8, 277, 304, 272, 3659, 63, 2912, 275, 1625, 63, 1483, 14, 4250, 779, 21, 12, 650, 12, 3193, 12, 1749, 12, 4114, 566, 272, 373, 10472, 275, 5791, 63, 2912, 4791, 14, 54, 18273, 8, 4443, 63, 2912, 12, 3522, 63, 3127, 29, 17, 9, 272, 373, 10472, 8, 1144, 63, 1483, 14, 4548, 779, 21, 12, 1520, 12, 3193, 12, 1749, 12, 4114, 2459, 819, 347, 511, 63, 889, 63, 10786, 63, 11368, 8, 277, 304, 272, 408, 11423, 658, 3127, 64, 436, 658, 2912, 63, 3127, 64, 787, 737, 314, 1284, 12, 949, 11180, 365, 4346, 1041, 272, 3659, 63, 2912, 275, 1625, 63, 1483, 14, 4250, 779, 21, 12, 650, 12, 3193, 12, 1749, 12, 4114, 566, 272, 30829, 275, 1625, 63, 1483, 14, 4250, 779, 21, 12, 650, 12, 3193, 12, 650, 12, 4114, 566, 272, 373, 10472, 275, 5791, 63, 2912, 4791, 14, 54, 18273, 8, 4443, 63, 2912, 12, 3114, 4022, 17, 12, 3522, 63, 3127, 4022, 18, 9, 272, 373, 10472, 8, 827, 21454, 9, 819, 347, 511, 63, 13724, 8, 277, 304, 272, 408, 1799, 626, 18494, 13724, 64, 10557, 314, 2011, 754, 465, 658, 4411, 14, 573, 1470, 17105, 272, 2196, 63, 5176, 14, 409, 63, 2355, 63, 5176, 8, 4321, 9, 339, 10519, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 20, 12, 959, 12, 1520, 12, 650, 566, 272, 367, 7824, 315, 3842, 19, 395, 334, 16, 12, 499, 395, 334, 17, 12, 499, 12, 650, 19532, 489, 373, 66, 63, 3670, 12, 4615, 63, 3526, 275, 5791, 63, 2912, 4791, 423, 13724, 8, 10206, 12, 7824, 9, 489, 30202, 63, 3670, 12, 30202, 63, 1391, 275, 11542, 14, 573, 1470, 8, 10206, 12, 7824, 9, 489, 373, 66, 63, 1391, 275, 4615, 63, 3526, 446, 3473, 63, 1483, 14, 9646, 8, 18708, 63, 3670, 9, 2541, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 267, 373, 66, 63, 3670, 63, 1590, 12, 373, 66, 63, 1391, 63, 1590, 12, 30202, 63, 3670, 63, 1590, 12, 30202, 63, 1391, 63, 1590, 275, 4043, 14, 1065, 779, 288, 373, 66, 63, 3670, 12, 373, 66, 63, 1391, 12, 30202, 63, 3670, 12, 30202, 63, 1391, 566, 2541, 291, 14, 7260, 8, 31714, 63, 3670, 63, 1590, 12, 373, 66, 63, 3670, 63, 1590, 9, 489, 291, 14, 7260, 8, 31714, 63, 1391, 63, 1590, 12, 373, 66, 63, 1391, 63, 1590, 9, 819, 347, 511, 63, 2065, 63, 13724, 8, 277, 304, 272, 408, 1799, 626, 18494, 2065, 63, 13724, 64, 10557, 2011, 754, 465, 658, 4411, 14, 573, 1470, 17105, 272, 2196, 63, 5176, 14, 409, 63, 2355, 63, 5176, 8, 4321, 9, 339, 3522, 63, 3127, 275, 378, 272, 7417, 63, 2912, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 20, 12, 959, 12, 1520, 12, 650, 566, 272, 2849, 63, 2694, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 17, 12, 959, 12, 1520, 12, 650, 566, 272, 2615, 63, 2912, 275, 1625, 63, 1483, 14, 9419, 779, 6672, 63, 2912, 12, 2849, 63, 2694, 467, 3114, 29, 16, 9, 339, 367, 16773, 63, 3127, 315, 1425, 8, 17, 12, 841, 304, 489, 327, 2372, 658, 4411, 14, 573, 1470, 64, 641, 314, 2615, 3522, 14, 489, 16773, 63, 6402, 275, 769, 8, 1842, 8, 20, 430, 489, 2150, 16773, 63, 6402, 59, 22508, 63, 3127, 61, 489, 30202, 63, 3670, 12, 30202, 63, 6221, 275, 11542, 14, 573, 1470, 8, 2861, 63, 2912, 12, 16773, 63, 6402, 9, 2541, 327, 2372, 5791, 3522, 11076, 14, 489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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 ]
MingdaZhou/gnuradio
gr-audio/examples/python/noise.py
58
1968
#!/usr/bin/env python # # Copyright 2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, or (at your option) # any later version. # # GNU Radio 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 GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # from gnuradio import gr from gnuradio import audio from gnuradio import digital from gnuradio.eng_option import eng_option from optparse import OptionParser class my_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, b2f, dst) if __name__ == '__main__': try: my_top_block().run() except KeyboardInterrupt: pass
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 24526, 492, 7192, 199, 504, 24526, 492, 10491, 199, 504, 24526, 492, 20545, 199, 504, 24526, 14, 7420, 63, 1422, 492, 20171, 63, 1422, 199, 504, 8691, 492, 13491, 199, 199, 533, 3002, 63, 2119, 63, 1457, 8, 2587, 14, 2119, 63, 1457, 304, 339, 347, 636, 826, 721, 277, 304, 267, 7192, 14, 2119, 63, 1457, 855, 826, 721, 277, 9, 398, 1798, 275, 13491, 8, 1422, 63, 533, 29, 7420, 63, 1422, 9, 267, 1798, 14, 525, 63, 1422, 6096, 47, 401, 4320, 8130, 13, 1199, 401, 730, 628, 875, 401, 849, 8772, 2079, 1720, 628, 2352, 77, 1072, 2243, 536, 14, 221, 662, 14, 71, 2020, 12073, 26, 16, 12, 16, 503, 1182, 2374, 15, 68, 681, 531, 267, 1798, 14, 525, 63, 1422, 6096, 82, 401, 4320, 3271, 13, 1866, 401, 730, 628, 7420, 63, 1609, 401, 849, 29, 2006, 1493, 12, 2079, 1720, 628, 409, 2690, 6634, 370, 820, 1951, 334, 2006, 1493, 6320, 267, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 6248, 267, 340, 822, 8, 589, 9, 1137, 378, 26, 288, 1798, 14, 1361, 63, 3437, 342, 288, 746, 14838, 12, 413, 398, 2690, 63, 1866, 275, 1109, 8, 1419, 14, 3271, 63, 1866, 9, 267, 282, 2421, 275, 378, 14, 17, 398, 2928, 275, 20545, 14, 71, 276, 5474, 63, 1365, 63, 66, 8, 708, 9, 258, 327, 510, 261, 1181, 269, 1241, 11145, 1350, 267, 330, 18, 70, 275, 20545, 14, 10660, 63, 475, 63, 7450, 63, 4361, 779, 65, 2421, 12, 446, 65, 2421, 467, 413, 9, 267, 5042, 275, 10491, 14, 11279, 8, 3271, 63, 1866, 12, 1511, 14, 8130, 63, 1199, 9, 267, 291, 14, 2242, 8, 2164, 12, 330, 18, 70, 12, 5042, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 862, 26, 267, 3002, 63, 2119, 63, 1457, 1252, 1065, 342, 272, 871, 13483, 26, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 24526, 492, 7192, 199, 504, 24526, 492, 10491, 199, 504, 24526, 492, 20545, 199, 504, 24526, 14, 7420, 63, 1422, 492, 20171, 63, 1422, 199, 504, 8691, 492, 13491, 199, 199, 533, 3002, 63, 2119, 63, 1457, 8, 2587, 14, 2119, 63, 1457, 304, 339, 347, 636, 826, 721, 277, 304, 267, 7192, 14, 2119, 63, 1457, 855, 826, 721, 277, 9, 398, 1798, 275, 13491, 8, 1422, 63, 533, 29, 7420, 63, 1422, 9, 267, 1798, 14, 525, 63, 1422, 6096, 47, 401, 4320, 8130, 13, 1199, 401, 730, 628, 875, 401, 849, 8772, 2079, 1720, 628, 2352, 77, 1072, 2243, 536, 14, 221, 662, 14, 71, 2020, 12073, 26, 16, 12, 16, 503, 1182, 2374, 15, 68, 681, 531, 267, 1798, 14, 525, 63, 1422, 6096, 82, 401, 4320, 3271, 13, 1866, 401, 730, 628, 7420, 63, 1609, 401, 849, 29, 2006, 1493, 12, 2079, 1720, 628, 409, 2690, 6634, 370, 820, 1951, 334, 2006, 1493, 6320, 267, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 6248, 267, 340, 822, 8, 589, 9, 1137, 378, 26, 288, 1798, 14, 1361, 63, 3437, 342, 288, 746, 14838, 12, 413, 398, 2690, 63, 1866, 275, 1109, 8, 1419, 14, 3271, 63, 1866, 9, 267, 282, 2421, 275, 378, 14, 17, 398, 2928, 275, 20545, 14, 71, 276, 5474, 63, 1365, 63, 66, 8, 708, 9, 258, 327, 510, 261, 1181, 269, 1241, 11145, 1350, 267, 330, 18, 70, 275, 20545, 14, 10660, 63, 475, 63, 7450, 63, 4361, 779, 65, 2421, 12, 446, 65, 2421, 467, 413, 9, 267, 5042, 275, 10491, 14, 11279, 8, 3271, 63, 1866, 12, 1511, 14, 8130, 63, 1199, 9, 267, 291, 14, 2242, 8, 2164, 12, 330, 18, 70, 12, 5042, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 862, 26, 267, 3002, 63, 2119, 63, 1457, 1252, 1065, 342, 272, 871, 13483, 26, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chris-chambers/llvm
examples/Kaleidoscope/MCJIT/lazy/genk-timing.py
214
10499
#!/usr/bin/env python import sys import random class TimingScriptGenerator: """Used to generate a bash script which will invoke the toy and time it""" def __init__(self, scriptname, outputname): self.timeFile = outputname self.shfile = open(scriptname, 'w') self.shfile.write("echo \"\" > %s\n" % self.timeFile) def writeTimingCall(self, filename, numFuncs, funcsCalled, totalCalls): """Echo some comments and invoke both versions of toy""" rootname = filename if '.' in filename: rootname = filename[:filename.rfind('.')] self.shfile.write("echo \"%s: Calls %d of %d functions, %d total\" >> %s\n" % (filename, funcsCalled, numFuncs, totalCalls, self.timeFile)) self.shfile.write("echo \"\" >> %s\n" % self.timeFile) self.shfile.write("echo \"With MCJIT\" >> %s\n" % self.timeFile) self.shfile.write("/usr/bin/time -f \"Command %C\\n\\tuser time: %U s\\n\\tsytem time: %S s\\n\\tmax set: %M kb\"") self.shfile.write(" -o %s -a " % self.timeFile) self.shfile.write("./toy-mcjit < %s > %s-mcjit.out 2> %s-mcjit.err\n" % (filename, rootname, rootname)) self.shfile.write("echo \"\" >> %s\n" % self.timeFile) self.shfile.write("echo \"With JIT\" >> %s\n" % self.timeFile) self.shfile.write("/usr/bin/time -f \"Command %C\\n\\tuser time: %U s\\n\\tsytem time: %S s\\n\\tmax set: %M kb\"") self.shfile.write(" -o %s -a " % self.timeFile) self.shfile.write("./toy-jit < %s > %s-jit.out 2> %s-jit.err\n" % (filename, rootname, rootname)) self.shfile.write("echo \"\" >> %s\n" % self.timeFile) self.shfile.write("echo \"\" >> %s\n" % self.timeFile) class KScriptGenerator: """Used to generate random Kaleidoscope code""" def __init__(self, filename): self.kfile = open(filename, 'w') self.nextFuncNum = 1 self.lastFuncNum = None self.callWeighting = 0.1 # A mapping of calls within functions with no duplicates self.calledFunctionTable = {} # A list of function calls which will actually be executed self.calledFunctions = [] # A comprehensive mapping of calls within functions # used for computing the total number of calls self.comprehensiveCalledFunctionTable = {} self.totalCallsExecuted = 0 def updateTotalCallCount(self, callee): # Count this call self.totalCallsExecuted += 1 # Then count all the functions it calls if callee in self.comprehensiveCalledFunctionTable: for child in self.comprehensiveCalledFunctionTable[callee]: self.updateTotalCallCount(child) def updateFunctionCallMap(self, caller, callee): """Maintains a map of functions that are called from other functions""" if not caller in self.calledFunctionTable: self.calledFunctionTable[caller] = [] if not callee in self.calledFunctionTable[caller]: self.calledFunctionTable[caller].append(callee) if not caller in self.comprehensiveCalledFunctionTable: self.comprehensiveCalledFunctionTable[caller] = [] self.comprehensiveCalledFunctionTable[caller].append(callee) def updateCalledFunctionList(self, callee): """Maintains a list of functions that will actually be called""" # Update the total call count self.updateTotalCallCount(callee) # If this function is already in the list, don't do anything else if callee in self.calledFunctions: return # Add this function to the list of those that will be called. self.calledFunctions.append(callee) # If this function calls other functions, add them too if callee in self.calledFunctionTable: for subCallee in self.calledFunctionTable[callee]: self.updateCalledFunctionList(subCallee) def setCallWeighting(self, weight): """ Sets the probably of generating a function call""" self.callWeighting = weight def writeln(self, line): self.kfile.write(line + '\n') def writeComment(self, comment): self.writeln('# ' + comment) def writeEmptyLine(self): self.writeln("") def writePredefinedFunctions(self): self.writeComment("Define ':' for sequencing: as a low-precedence operator that ignores operands") self.writeComment("and just returns the RHS.") self.writeln("def binary : 1 (x y) y;") self.writeEmptyLine() self.writeComment("Helper functions defined within toy") self.writeln("extern putchard(x);") self.writeln("extern printd(d);") self.writeln("extern printlf();") self.writeEmptyLine() self.writeComment("Print the result of a function call") self.writeln("def printresult(N Result)") self.writeln(" # 'result('") self.writeln(" putchard(114) : putchard(101) : putchard(115) : putchard(117) : putchard(108) : putchard(116) : putchard(40) :") self.writeln(" printd(N) :"); self.writeln(" # ') = '") self.writeln(" putchard(41) : putchard(32) : putchard(61) : putchard(32) :") self.writeln(" printd(Result) :"); self.writeln(" printlf();") self.writeEmptyLine() def writeRandomOperation(self, LValue, LHS, RHS): shouldCallFunc = (self.lastFuncNum > 2 and random.random() < self.callWeighting) if shouldCallFunc: funcToCall = random.randrange(1, self.lastFuncNum - 1) self.updateFunctionCallMap(self.lastFuncNum, funcToCall) self.writeln(" %s = func%d(%s, %s) :" % (LValue, funcToCall, LHS, RHS)) else: possibleOperations = ["+", "-", "*", "/"] operation = random.choice(possibleOperations) if operation == "-": # Don't let our intermediate value become zero # This is complicated by the fact that '<' is our only comparison operator self.writeln(" if %s < %s then" % (LHS, RHS)) self.writeln(" %s = %s %s %s" % (LValue, LHS, operation, RHS)) self.writeln(" else if %s < %s then" % (RHS, LHS)) self.writeln(" %s = %s %s %s" % (LValue, LHS, operation, RHS)) self.writeln(" else") self.writeln(" %s = %s %s %f :" % (LValue, LHS, operation, random.uniform(1, 100))) else: self.writeln(" %s = %s %s %s :" % (LValue, LHS, operation, RHS)) def getNextFuncNum(self): result = self.nextFuncNum self.nextFuncNum += 1 self.lastFuncNum = result return result def writeFunction(self, elements): funcNum = self.getNextFuncNum() self.writeComment("Auto-generated function number %d" % funcNum) self.writeln("def func%d(X Y)" % funcNum) self.writeln(" var temp1 = X,") self.writeln(" temp2 = Y,") self.writeln(" temp3 in") # Initialize the variable names to be rotated first = "temp3" second = "temp1" third = "temp2" # Write some random operations for i in range(elements): self.writeRandomOperation(first, second, third) # Rotate the variables temp = first first = second second = third third = temp self.writeln(" " + third + ";") self.writeEmptyLine() def writeFunctionCall(self): self.writeComment("Call the last function") arg1 = random.uniform(1, 100) arg2 = random.uniform(1, 100) self.writeln("printresult(%d, func%d(%f, %f) )" % (self.lastFuncNum, self.lastFuncNum, arg1, arg2)) self.writeEmptyLine() self.updateCalledFunctionList(self.lastFuncNum) def writeFinalFunctionCounts(self): self.writeComment("Called %d of %d functions" % (len(self.calledFunctions), self.lastFuncNum)) def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript): """ Generate a random Kaleidoscope script based on the given parameters """ print "Generating " + filename print(" %d functions, %d elements per function, %d functions between execution" % (numFuncs, elementsPerFunc, funcsBetweenExec)) print(" Call weighting = %f" % callWeighting) script = KScriptGenerator(filename) script.setCallWeighting(callWeighting) script.writeComment("===========================================================================") script.writeComment("Auto-generated script") script.writeComment(" %d functions, %d elements per function, %d functions between execution" % (numFuncs, elementsPerFunc, funcsBetweenExec)) script.writeComment(" call weighting = %f" % callWeighting) script.writeComment("===========================================================================") script.writeEmptyLine() script.writePredefinedFunctions() funcsSinceLastExec = 0 for i in range(numFuncs): script.writeFunction(elementsPerFunc) funcsSinceLastExec += 1 if funcsSinceLastExec == funcsBetweenExec: script.writeFunctionCall() funcsSinceLastExec = 0 # Always end with a function call if funcsSinceLastExec > 0: script.writeFunctionCall() script.writeEmptyLine() script.writeFinalFunctionCounts() funcsCalled = len(script.calledFunctions) print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted) timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted) # Execution begins here random.seed() timingScript = TimingScriptGenerator("time-toy.sh", "timing-data.txt") dataSets = [(5000, 3, 50, 0.50), (5000, 10, 100, 0.10), (5000, 10, 5, 0.10), (5000, 10, 1, 0.0), (1000, 3, 10, 0.50), (1000, 10, 100, 0.10), (1000, 10, 5, 0.10), (1000, 10, 1, 0.0), ( 200, 3, 2, 0.50), ( 200, 10, 40, 0.10), ( 200, 10, 2, 0.10), ( 200, 10, 1, 0.0)] # Generate the code for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets: filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100)) generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript) print "All done!"
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 2196, 199, 199, 533, 26244, 316, 5229, 7599, 26, 272, 408, 9167, 370, 3550, 282, 20387, 2884, 1314, 911, 12677, 314, 31239, 436, 900, 652, 624, 272, 347, 636, 826, 721, 277, 12, 2884, 354, 12, 1072, 354, 304, 267, 291, 14, 521, 1173, 275, 1072, 354, 267, 291, 14, 609, 493, 275, 1551, 8, 1579, 354, 12, 283, 87, 358, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 690, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 339, 347, 2218, 30101, 2176, 8, 277, 12, 1788, 12, 1967, 7465, 83, 12, 18805, 10474, 12, 3141, 18287, 304, 267, 408, 18690, 2005, 6786, 436, 12677, 3865, 5459, 402, 31239, 624, 267, 1738, 354, 275, 1788, 267, 340, 7815, 315, 1788, 26, 288, 1738, 354, 275, 1788, 1491, 1501, 14, 14542, 7563, 61, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 18321, 83, 26, 28055, 450, 68, 402, 450, 68, 3423, 12, 450, 68, 3141, 4451, 4331, 450, 83, 60, 78, 2, 450, 334, 1501, 12, 18805, 10474, 12, 1967, 7465, 83, 12, 3141, 18287, 12, 291, 14, 521, 1173, 430, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 8441, 3007, 32685, 42, 649, 4451, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 4769, 2647, 15, 1393, 15, 521, 446, 70, 8441, 3110, 450, 35, 1103, 78, 1103, 84, 751, 900, 26, 450, 53, 308, 1103, 78, 1103, 1086, 89, 563, 900, 26, 450, 51, 308, 1103, 78, 1103, 84, 988, 663, 26, 450, 45, 19932, 60, 7230, 267, 291, 14, 609, 493, 14, 952, 480, 446, 79, 450, 83, 446, 65, 298, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 28615, 19126, 13, 5466, 17676, 665, 450, 83, 690, 450, 83, 13, 5466, 17676, 14, 548, 499, 30, 450, 83, 13, 5466, 17676, 14, 1508, 60, 78, 2, 450, 334, 1501, 12, 1738, 354, 12, 1738, 354, 430, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 8441, 3007, 1603, 649, 4451, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 4769, 2647, 15, 1393, 15, 521, 446, 70, 8441, 3110, 450, 35, 1103, 78, 1103, 84, 751, 900, 26, 450, 53, 308, 1103, 78, 1103, 1086, 89, 563, 900, 26, 450, 51, 308, 1103, 78, 1103, 84, 988, 663, 26, 450, 45, 19932, 60, 7230, 267, 291, 14, 609, 493, 14, 952, 480, 446, 79, 450, 83, 446, 65, 298, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 28615, 19126, 13, 17676, 665, 450, 83, 690, 450, 83, 13, 17676, 14, 548, 499, 30, 450, 83, 13, 17676, 14, 1508, 60, 78, 2, 450, 334, 1501, 12, 1738, 354, 12, 1738, 354, 430, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 199, 199, 533, 1804, 5229, 7599, 26, 272, 408, 9167, 370, 3550, 2196, 1804, 1895, 344, 736, 1859, 1233, 624, 272, 347, 636, 826, 721, 277, 12, 1788, 304, 267, 291, 14, 75, 493, 275, 1551, 8, 1501, 12, 283, 87, 358, 267, 291, 14, 2184, 7465, 5667, 275, 413, 267, 291, 14, 2019, 7465, 5667, 275, 488, 267, 291, 14, 1250, 16359, 316, 275, 378, 14, 17, 267, 327, 437, 4412, 402, 4882, 4453, 3423, 543, 949, 15755, 267, 291, 14, 3527, 3481, 3186, 275, 1052, 267, 327, 437, 769, 402, 805, 4882, 1314, 911, 5965, 506, 7934, 267, 291, 14, 3527, 13967, 275, 942, 267, 327, 437, 1013, 22868, 3398, 4412, 402, 4882, 4453, 3423, 267, 327, 1202, 367, 17226, 314, 3141, 1329, 402, 4882, 267, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 275, 1052, 267, 291, 14, 2923, 18287, 4858, 4241, 275, 378, 339, 347, 1678, 7316, 2176, 2353, 8, 277, 12, 3213, 18387, 304, 267, 327, 14826, 642, 1240, 267, 291, 14, 2923, 18287, 4858, 4241, 847, 413, 267, 327, 9442, 2338, 1006, 314, 3423, 652, 4882, 267, 340, 3213, 18387, 315, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 26, 288, 367, 1982, 315, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 59, 915, 18387, 2189, 355, 291, 14, 873, 7316, 2176, 2353, 8, 1739, 9, 339, 347, 1678, 3481, 2176, 2956, 8, 277, 12, 8025, 12, 3213, 18387, 304, 267, 408, 11903, 8368, 83, 282, 2341, 402, 3423, 626, 787, 2797, 687, 1163, 3423, 624, 267, 340, 440, 8025, 315, 291, 14, 3527, 3481, 3186, 26, 288, 291, 14, 3527, 3481, 3186, 59, 11219, 61, 275, 942, 267, 340, 440, 3213, 18387, 315, 291, 14, 3527, 3481, 3186, 59, 11219, 2189, 288, 291, 14, 3527, 3481, 3186, 59, 11219, 1055, 740, 8, 915, 18387, 9, 267, 340, 440, 8025, 315, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 26, 288, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 59, 11219, 61, 275, 942, 267, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 59, 11219, 1055, 740, 8, 915, 18387, 9, 339, 347, 1678, 10474, 3481, 1296, 8, 277, 12, 3213, 18387, 304, 267, 408, 11903, 8368, 83, 282, 769, 402, 3423, 626, 911, 5965, 506, 2797, 624, 267, 327, 6162, 314, 3141, 1240, 2338, 267, 291, 14, 873, 7316, 2176, 2353, 8, 915, 18387, 9, 267, 327, 982, 642, 805, 365, 2575, 315, 314, 769, 12, 2793, 1133, 886, 7003, 587, 267, 340, 3213, 18387, 315, 291, 14, 3527, 13967, 26, 288, 372, 267, 327, 2654, 642, 805, 370, 314, 769, 402, 5204, 626, 911, 506, 2797, 14, 267, 291, 14, 3527, 13967, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 2196, 199, 199, 533, 26244, 316, 5229, 7599, 26, 272, 408, 9167, 370, 3550, 282, 20387, 2884, 1314, 911, 12677, 314, 31239, 436, 900, 652, 624, 272, 347, 636, 826, 721, 277, 12, 2884, 354, 12, 1072, 354, 304, 267, 291, 14, 521, 1173, 275, 1072, 354, 267, 291, 14, 609, 493, 275, 1551, 8, 1579, 354, 12, 283, 87, 358, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 690, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 339, 347, 2218, 30101, 2176, 8, 277, 12, 1788, 12, 1967, 7465, 83, 12, 18805, 10474, 12, 3141, 18287, 304, 267, 408, 18690, 2005, 6786, 436, 12677, 3865, 5459, 402, 31239, 624, 267, 1738, 354, 275, 1788, 267, 340, 7815, 315, 1788, 26, 288, 1738, 354, 275, 1788, 1491, 1501, 14, 14542, 7563, 61, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 18321, 83, 26, 28055, 450, 68, 402, 450, 68, 3423, 12, 450, 68, 3141, 4451, 4331, 450, 83, 60, 78, 2, 450, 334, 1501, 12, 18805, 10474, 12, 1967, 7465, 83, 12, 3141, 18287, 12, 291, 14, 521, 1173, 430, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 8441, 3007, 32685, 42, 649, 4451, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 4769, 2647, 15, 1393, 15, 521, 446, 70, 8441, 3110, 450, 35, 1103, 78, 1103, 84, 751, 900, 26, 450, 53, 308, 1103, 78, 1103, 1086, 89, 563, 900, 26, 450, 51, 308, 1103, 78, 1103, 84, 988, 663, 26, 450, 45, 19932, 60, 7230, 267, 291, 14, 609, 493, 14, 952, 480, 446, 79, 450, 83, 446, 65, 298, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 28615, 19126, 13, 5466, 17676, 665, 450, 83, 690, 450, 83, 13, 5466, 17676, 14, 548, 499, 30, 450, 83, 13, 5466, 17676, 14, 1508, 60, 78, 2, 450, 334, 1501, 12, 1738, 354, 12, 1738, 354, 430, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 8441, 3007, 1603, 649, 4451, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 4769, 2647, 15, 1393, 15, 521, 446, 70, 8441, 3110, 450, 35, 1103, 78, 1103, 84, 751, 900, 26, 450, 53, 308, 1103, 78, 1103, 1086, 89, 563, 900, 26, 450, 51, 308, 1103, 78, 1103, 84, 988, 663, 26, 450, 45, 19932, 60, 7230, 267, 291, 14, 609, 493, 14, 952, 480, 446, 79, 450, 83, 446, 65, 298, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 28615, 19126, 13, 17676, 665, 450, 83, 690, 450, 83, 13, 17676, 14, 548, 499, 30, 450, 83, 13, 17676, 14, 1508, 60, 78, 2, 450, 334, 1501, 12, 1738, 354, 12, 1738, 354, 430, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 267, 291, 14, 609, 493, 14, 952, 480, 7878, 971, 3212, 2, 4331, 450, 83, 60, 78, 2, 450, 291, 14, 521, 1173, 9, 199, 199, 533, 1804, 5229, 7599, 26, 272, 408, 9167, 370, 3550, 2196, 1804, 1895, 344, 736, 1859, 1233, 624, 272, 347, 636, 826, 721, 277, 12, 1788, 304, 267, 291, 14, 75, 493, 275, 1551, 8, 1501, 12, 283, 87, 358, 267, 291, 14, 2184, 7465, 5667, 275, 413, 267, 291, 14, 2019, 7465, 5667, 275, 488, 267, 291, 14, 1250, 16359, 316, 275, 378, 14, 17, 267, 327, 437, 4412, 402, 4882, 4453, 3423, 543, 949, 15755, 267, 291, 14, 3527, 3481, 3186, 275, 1052, 267, 327, 437, 769, 402, 805, 4882, 1314, 911, 5965, 506, 7934, 267, 291, 14, 3527, 13967, 275, 942, 267, 327, 437, 1013, 22868, 3398, 4412, 402, 4882, 4453, 3423, 267, 327, 1202, 367, 17226, 314, 3141, 1329, 402, 4882, 267, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 275, 1052, 267, 291, 14, 2923, 18287, 4858, 4241, 275, 378, 339, 347, 1678, 7316, 2176, 2353, 8, 277, 12, 3213, 18387, 304, 267, 327, 14826, 642, 1240, 267, 291, 14, 2923, 18287, 4858, 4241, 847, 413, 267, 327, 9442, 2338, 1006, 314, 3423, 652, 4882, 267, 340, 3213, 18387, 315, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 26, 288, 367, 1982, 315, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 59, 915, 18387, 2189, 355, 291, 14, 873, 7316, 2176, 2353, 8, 1739, 9, 339, 347, 1678, 3481, 2176, 2956, 8, 277, 12, 8025, 12, 3213, 18387, 304, 267, 408, 11903, 8368, 83, 282, 2341, 402, 3423, 626, 787, 2797, 687, 1163, 3423, 624, 267, 340, 440, 8025, 315, 291, 14, 3527, 3481, 3186, 26, 288, 291, 14, 3527, 3481, 3186, 59, 11219, 61, 275, 942, 267, 340, 440, 3213, 18387, 315, 291, 14, 3527, 3481, 3186, 59, 11219, 2189, 288, 291, 14, 3527, 3481, 3186, 59, 11219, 1055, 740, 8, 915, 18387, 9, 267, 340, 440, 8025, 315, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 26, 288, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 59, 11219, 61, 275, 942, 267, 291, 14, 863, 22868, 3398, 10474, 3481, 3186, 59, 11219, 1055, 740, 8, 915, 18387, 9, 339, 347, 1678, 10474, 3481, 1296, 8, 277, 12, 3213, 18387, 304, 267, 408, 11903, 8368, 83, 282, 769, 402, 3423, 626, 911, 5965, 506, 2797, 624, 267, 327, 6162, 314, 3141, 1240, 2338, 267, 291, 14, 873, 7316, 2176, 2353, 8, 915, 18387, 9, 267, 327, 982, 642, 805, 365, 2575, 315, 314, 769, 12, 2793, 1133, 886, 7003, 587, 267, 340, 3213, 18387, 315, 291, 14, 3527, 13967, 26, 288, 372, 267, 327, 2654, 642, 805, 370, 314, 769, 402, 5204, 626, 911, 506, 2797, 14, 267, 291, 14, 3527, 13967, 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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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 ]
OTWillems/GEO1005
SpatialDecision/external/networkx/algorithms/link_prediction.py
40
16527
""" Link prediction algorithms. """ from __future__ import division import math import networkx as nx from networkx.utils.decorators import * __all__ = ['resource_allocation_index', 'jaccard_coefficient', 'adamic_adar_index', 'preferential_attachment', 'cn_soundarajan_hopcroft', 'ra_index_soundarajan_hopcroft', 'within_inter_cluster'] @not_implemented_for('directed') @not_implemented_for('multigraph') def resource_allocation_index(G, ebunch=None): r"""Compute the resource allocation index of all node pairs in ebunch. Resource allocation index of `u` and `v` is defined as .. math:: \sum_{w \in \Gamma(u) \cap \Gamma(v)} \frac{1}{|\Gamma(w)|} where :math:`\Gamma(u)` denotes the set of neighbors of `u`. Parameters ---------- G : graph A NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) Resource allocation index will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their resource allocation index. Examples -------- >>> import networkx as nx >>> G = nx.complete_graph(5) >>> preds = nx.resource_allocation_index(G, [(0, 1), (2, 3)]) >>> for u, v, p in preds: ... '(%d, %d) -> %.8f' % (u, v, p) ... '(0, 1) -> 0.75000000' '(2, 3) -> 0.75000000' References ---------- .. [1] T. Zhou, L. Lu, Y.-C. Zhang. Predicting missing links via local information. Eur. Phys. J. B 71 (2009) 623. http://arxiv.org/pdf/0901.0553.pdf """ if ebunch is None: ebunch = nx.non_edges(G) def predict(u, v): return sum(1 / G.degree(w) for w in nx.common_neighbors(G, u, v)) return ((u, v, predict(u, v)) for u, v in ebunch) @not_implemented_for('directed') @not_implemented_for('multigraph') def jaccard_coefficient(G, ebunch=None): r"""Compute the Jaccard coefficient of all node pairs in ebunch. Jaccard coefficient of nodes `u` and `v` is defined as .. math:: \frac{|\Gamma(u) \cap \Gamma(v)|}{|\Gamma(u) \cup \Gamma(v)|} where :math:`\Gamma(u)` denotes the set of neighbors of `u`. Parameters ---------- G : graph A NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) Jaccard coefficient will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their Jaccard coefficient. Examples -------- >>> import networkx as nx >>> G = nx.complete_graph(5) >>> preds = nx.jaccard_coefficient(G, [(0, 1), (2, 3)]) >>> for u, v, p in preds: ... '(%d, %d) -> %.8f' % (u, v, p) ... '(0, 1) -> 0.60000000' '(2, 3) -> 0.60000000' References ---------- .. [1] D. Liben-Nowell, J. Kleinberg. The Link Prediction Problem for Social Networks (2004). http://www.cs.cornell.edu/home/kleinber/link-pred.pdf """ if ebunch is None: ebunch = nx.non_edges(G) def predict(u, v): cnbors = list(nx.common_neighbors(G, u, v)) union_size = len(set(G[u]) | set(G[v])) if union_size == 0: return 0 else: return len(cnbors) / union_size return ((u, v, predict(u, v)) for u, v in ebunch) @not_implemented_for('directed') @not_implemented_for('multigraph') def adamic_adar_index(G, ebunch=None): r"""Compute the Adamic-Adar index of all node pairs in ebunch. Adamic-Adar index of `u` and `v` is defined as .. math:: \sum_{w \in \Gamma(u) \cap \Gamma(v)} \frac{1}{\log |\Gamma(w)|} where :math:`\Gamma(u)` denotes the set of neighbors of `u`. Parameters ---------- G : graph NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) Adamic-Adar index will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their Adamic-Adar index. Examples -------- >>> import networkx as nx >>> G = nx.complete_graph(5) >>> preds = nx.adamic_adar_index(G, [(0, 1), (2, 3)]) >>> for u, v, p in preds: ... '(%d, %d) -> %.8f' % (u, v, p) ... '(0, 1) -> 2.16404256' '(2, 3) -> 2.16404256' References ---------- .. [1] D. Liben-Nowell, J. Kleinberg. The Link Prediction Problem for Social Networks (2004). http://www.cs.cornell.edu/home/kleinber/link-pred.pdf """ if ebunch is None: ebunch = nx.non_edges(G) def predict(u, v): return sum(1 / math.log(G.degree(w)) for w in nx.common_neighbors(G, u, v)) return ((u, v, predict(u, v)) for u, v in ebunch) @not_implemented_for('directed') @not_implemented_for('multigraph') def preferential_attachment(G, ebunch=None): r"""Compute the preferential attachment score of all node pairs in ebunch. Preferential attachment score of `u` and `v` is defined as .. math:: |\Gamma(u)| |\Gamma(v)| where :math:`\Gamma(u)` denotes the set of neighbors of `u`. Parameters ---------- G : graph NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) Preferential attachment score will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their preferential attachment score. Examples -------- >>> import networkx as nx >>> G = nx.complete_graph(5) >>> preds = nx.preferential_attachment(G, [(0, 1), (2, 3)]) >>> for u, v, p in preds: ... '(%d, %d) -> %d' % (u, v, p) ... '(0, 1) -> 16' '(2, 3) -> 16' References ---------- .. [1] D. Liben-Nowell, J. Kleinberg. The Link Prediction Problem for Social Networks (2004). http://www.cs.cornell.edu/home/kleinber/link-pred.pdf """ if ebunch is None: ebunch = nx.non_edges(G) return ((u, v, G.degree(u) * G.degree(v)) for u, v in ebunch) @not_implemented_for('directed') @not_implemented_for('multigraph') def cn_soundarajan_hopcroft(G, ebunch=None, community='community'): r"""Count the number of common neighbors of all node pairs in ebunch using community information. For two nodes `u` and `v`, this function computes the number of common neighbors and bonus one for each common neighbor belonging to the same community as `u` and `v`. Mathematically, .. math:: |\Gamma(u) \cap \Gamma(v)| + \sum_{w \in \Gamma(u) \cap \Gamma(v)} f(w) where `f(w)` equals 1 if `w` belongs to the same community as `u` and `v` or 0 otherwise and :math:`\Gamma(u)` denotes the set of neighbors of `u`. Parameters ---------- G : graph A NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) The score will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. community : string, optional (default = 'community') Nodes attribute name containing the community information. G[u][community] identifies which community u belongs to. Each node belongs to at most one community. Default value: 'community'. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their score. Examples -------- >>> import networkx as nx >>> G = nx.path_graph(3) >>> G.node[0]['community'] = 0 >>> G.node[1]['community'] = 0 >>> G.node[2]['community'] = 0 >>> preds = nx.cn_soundarajan_hopcroft(G, [(0, 2)]) >>> for u, v, p in preds: ... '(%d, %d) -> %d' % (u, v, p) ... '(0, 2) -> 2' References ---------- .. [1] Sucheta Soundarajan and John Hopcroft. Using community information to improve the precision of link prediction methods. In Proceedings of the 21st international conference companion on World Wide Web (WWW '12 Companion). ACM, New York, NY, USA, 607-608. http://doi.acm.org/10.1145/2187980.2188150 """ if ebunch is None: ebunch = nx.non_edges(G) def predict(u, v): Cu = _community(G, u, community) Cv = _community(G, v, community) cnbors = list(nx.common_neighbors(G, u, v)) if Cu == Cv: return len(cnbors) + sum(_community(G, w, community) == Cu for w in cnbors) else: return len(cnbors) return ((u, v, predict(u, v)) for u, v in ebunch) @not_implemented_for('directed') @not_implemented_for('multigraph') def ra_index_soundarajan_hopcroft(G, ebunch=None, community='community'): r"""Compute the resource allocation index of all node pairs in ebunch using community information. For two nodes `u` and `v`, this function computes the resource allocation index considering only common neighbors belonging to the same community as `u` and `v`. Mathematically, .. math:: \sum_{w \in \Gamma(u) \cap \Gamma(v)} \frac{f(w)}{|\Gamma(w)|} where `f(w)` equals 1 if `w` belongs to the same community as `u` and `v` or 0 otherwise and :math:`\Gamma(u)` denotes the set of neighbors of `u`. Parameters ---------- G : graph A NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) The score will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. community : string, optional (default = 'community') Nodes attribute name containing the community information. G[u][community] identifies which community u belongs to. Each node belongs to at most one community. Default value: 'community'. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their score. Examples -------- >>> import networkx as nx >>> G = nx.Graph() >>> G.add_edges_from([(0, 1), (0, 2), (1, 3), (2, 3)]) >>> G.node[0]['community'] = 0 >>> G.node[1]['community'] = 0 >>> G.node[2]['community'] = 1 >>> G.node[3]['community'] = 0 >>> preds = nx.ra_index_soundarajan_hopcroft(G, [(0, 3)]) >>> for u, v, p in preds: ... '(%d, %d) -> %.8f' % (u, v, p) ... '(0, 3) -> 0.50000000' References ---------- .. [1] Sucheta Soundarajan and John Hopcroft. Using community information to improve the precision of link prediction methods. In Proceedings of the 21st international conference companion on World Wide Web (WWW '12 Companion). ACM, New York, NY, USA, 607-608. http://doi.acm.org/10.1145/2187980.2188150 """ if ebunch is None: ebunch = nx.non_edges(G) def predict(u, v): Cu = _community(G, u, community) Cv = _community(G, v, community) if Cu == Cv: cnbors = nx.common_neighbors(G, u, v) return sum(1 / G.degree(w) for w in cnbors if _community(G, w, community) == Cu) else: return 0 return ((u, v, predict(u, v)) for u, v in ebunch) @not_implemented_for('directed') @not_implemented_for('multigraph') def within_inter_cluster(G, ebunch=None, delta=0.001, community='community'): """Compute the ratio of within- and inter-cluster common neighbors of all node pairs in ebunch. For two nodes `u` and `v`, if a common neighbor `w` belongs to the same community as them, `w` is considered as within-cluster common neighbor of `u` and `v`. Otherwise, it is considered as inter-cluster common neighbor of `u` and `v`. The ratio between the size of the set of within- and inter-cluster common neighbors is defined as the WIC measure. [1]_ Parameters ---------- G : graph A NetworkX undirected graph. ebunch : iterable of node pairs, optional (default = None) The WIC measure will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None. delta : float, optional (default = 0.001) Value to prevent division by zero in case there is no inter-cluster common neighbor between two nodes. See [1]_ for details. Default value: 0.001. community : string, optional (default = 'community') Nodes attribute name containing the community information. G[u][community] identifies which community u belongs to. Each node belongs to at most one community. Default value: 'community'. Returns ------- piter : iterator An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their WIC measure. Examples -------- >>> import networkx as nx >>> G = nx.Graph() >>> G.add_edges_from([(0, 1), (0, 2), (0, 3), (1, 4), (2, 4), (3, 4)]) >>> G.node[0]['community'] = 0 >>> G.node[1]['community'] = 1 >>> G.node[2]['community'] = 0 >>> G.node[3]['community'] = 0 >>> G.node[4]['community'] = 0 >>> preds = nx.within_inter_cluster(G, [(0, 4)]) >>> for u, v, p in preds: ... '(%d, %d) -> %.8f' % (u, v, p) ... '(0, 4) -> 1.99800200' >>> preds = nx.within_inter_cluster(G, [(0, 4)], delta=0.5) >>> for u, v, p in preds: ... '(%d, %d) -> %.8f' % (u, v, p) ... '(0, 4) -> 1.33333333' References ---------- .. [1] Jorge Carlos Valverde-Rebaza and Alneu de Andrade Lopes. Link prediction in complex networks based on cluster information. In Proceedings of the 21st Brazilian conference on Advances in Artificial Intelligence (SBIA'12) http://dx.doi.org/10.1007/978-3-642-34459-6_10 """ if delta <= 0: raise nx.NetworkXAlgorithmError('Delta must be greater than zero') if ebunch is None: ebunch = nx.non_edges(G) def predict(u, v): Cu = _community(G, u, community) Cv = _community(G, v, community) if Cu == Cv: cnbors = set(nx.common_neighbors(G, u, v)) within = set(w for w in cnbors if _community(G, w, community) == Cu) inter = cnbors - within return len(within) / (len(inter) + delta) else: return 0 return ((u, v, predict(u, v)) for u, v in ebunch) def _community(G, u, community): """Get the community of the given node.""" node_u = G.node[u] try: return node_u[community] except KeyError: raise nx.NetworkXAlgorithmError('No community information')
gpl-2.0
[ 624, 199, 3834, 12044, 18036, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 3473, 199, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 14, 11582, 492, 627, 199, 199, 363, 452, 363, 275, 788, 1927, 63, 14940, 63, 1080, 297, 1779, 283, 74, 5470, 1005, 63, 21329, 297, 1779, 283, 27679, 530, 63, 350, 285, 63, 1080, 297, 1779, 283, 657, 1485, 1009, 63, 8905, 297, 1779, 283, 6413, 63, 14990, 285, 9091, 290, 63, 13376, 67, 293, 856, 297, 1779, 283, 345, 63, 1080, 63, 14990, 285, 9091, 290, 63, 13376, 67, 293, 856, 297, 1779, 283, 12541, 63, 1058, 63, 4201, 418, 421, 199, 32, 1397, 63, 13825, 63, 509, 360, 12080, 358, 199, 32, 1397, 63, 13825, 63, 509, 360, 3029, 2180, 358, 199, 318, 2073, 63, 14940, 63, 1080, 8, 39, 12, 26669, 4689, 29, 403, 304, 272, 519, 624, 8564, 314, 2073, 18723, 1478, 402, 1006, 1031, 6342, 315, 26669, 4689, 14, 339, 7337, 18723, 1478, 402, 658, 85, 64, 436, 658, 86, 64, 365, 3247, 465, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 87, 971, 262, 971, 15091, 8, 85, 9, 971, 2874, 971, 15091, 8, 86, 6769, 971, 10865, 91, 17, 8847, 6113, 15091, 8, 87, 8636, 93, 339, 2382, 520, 3442, 1705, 60, 15091, 8, 85, 12544, 477, 5983, 314, 663, 402, 15845, 402, 658, 85, 2313, 339, 3897, 272, 4143, 272, 598, 520, 3343, 267, 437, 7220, 56, 625, 12080, 3343, 14, 339, 26669, 4689, 520, 6076, 402, 1031, 6342, 12, 2716, 334, 885, 275, 488, 9, 267, 7337, 18723, 1478, 911, 506, 9235, 367, 1924, 4092, 402, 267, 3380, 1627, 315, 314, 6076, 14, 710, 6342, 1471, 506, 1627, 465, 267, 499, 13, 11760, 334, 85, 12, 373, 9, 2382, 399, 436, 373, 787, 3380, 315, 314, 3343, 14, 982, 26669, 4689, 267, 365, 488, 2066, 1006, 2222, 13, 15025, 8207, 315, 314, 3343, 911, 506, 1202, 14, 267, 3758, 574, 26, 488, 14, 339, 1803, 272, 5514, 272, 299, 1661, 520, 6122, 267, 1626, 6122, 402, 650, 13, 11760, 315, 314, 1824, 334, 85, 12, 373, 12, 299, 9, 2382, 334, 85, 12, 373, 9, 365, 282, 267, 4092, 402, 3380, 436, 299, 365, 3932, 2073, 18723, 1478, 14, 339, 6058, 272, 3001, 272, 1306, 492, 24313, 465, 8484, 272, 1306, 598, 275, 8484, 14, 4883, 63, 2180, 8, 21, 9, 272, 1306, 24960, 275, 8484, 14, 1927, 63, 14940, 63, 1080, 8, 39, 12, 3842, 16, 12, 413, 395, 334, 18, 12, 650, 3948, 272, 1306, 367, 399, 12, 373, 12, 299, 315, 24960, 26, 272, 2263, 258, 25676, 68, 12, 450, 68, 9, 1035, 10536, 24, 70, 7, 450, 334, 85, 12, 373, 12, 299, 9, 272, 2263, 272, 8189, 16, 12, 413, 9, 1035, 378, 14, 2194, 3273, 7, 272, 8189, 18, 12, 650, 9, 1035, 378, 14, 2194, 3273, 7, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 377, 14, 3107, 11586, 12, 491, 14, 30936, 12, 1488, 23683, 35, 14, 3107, 27304, 14, 2126, 5543, 807, 316, 4124, 6220, 4799, 2257, 2556, 14, 2126, 662, 300, 14, 11308, 588, 14, 1603, 14, 699, 17245, 334, 8664, 9, 1227, 1789, 14, 2126, 1455, 921, 27290, 14, 1308, 15, 5607, 15, 1643, 614, 14, 16458, 19, 14, 5607, 272, 408, 272, 340, 26669, 4689, 365, 488, 26, 267, 26669, 4689, 275, 8484, 14, 2865, 63, 6929, 8, 39, 9, 339, 347, 12610, 8, 85, 12, 373, 304, 267, 372, 3089, 8, 17, 1182, 598, 14, 10956, 8, 87, 9, 367, 336, 315, 8484, 14, 2330, 63, 11113, 8, 39, 12, 399, 12, 373, 430, 339, 372, 3666, 85, 12, 373, 12, 12610, 8, 85, 12, 373, 430, 367, 399, 12, 373, 315, 26669, 4689, 9, 421, 199, 32, 1397, 63, 13825, 63, 509, 360, 12080, 358, 199, 32, 1397, 63, 13825, 63, 509, 360, 3029, 2180, 358, 199, 318, 1335, 5470, 1005, 63, 21329, 8, 39, 12, 26669, 4689, 29, 403, 304, 272, 519, 624, 8564, 314, 1603, 5470, 1005, 9421, 402, 1006, 1031, 6342, 315, 26669, 4689, 14, 339, 1603, 5470, 1005, 9421, 402, 3380, 658, 85, 64, 436, 658, 86, 64, 365, 3247, 465, 339, 2508, 3473, 447, 398, 971, 10865, 91, 6113, 15091, 8, 85, 9, 971, 2874, 971, 15091, 8, 86, 8636, 8847, 6113, 15091, 8, 85, 9, 971, 17500, 971, 15091, 8, 86, 8636, 93, 339, 2382, 520, 3442, 1705, 60, 15091, 8, 85, 12544, 477, 5983, 314, 663, 402, 15845, 402, 658, 85, 2313, 339, 3897, 272, 4143, 272, 598, 520, 3343, 267, 437, 7220, 56, 625, 12080, 3343, 14, 339, 26669, 4689, 520, 6076, 402, 1031, 6342, 12, 2716, 334, 885, 275, 488, 9, 267, 1603, 5470, 1005, 9421, 911, 506, 9235, 367, 1924, 4092, 402, 3380, 267, 1627, 315, 314, 6076, 14, 710, 6342, 1471, 506, 1627, 465, 499, 13, 11760, 267, 334, 85, 12, 373, 9, 2382, 399, 436, 373, 787, 3380, 315, 314, 3343, 14, 982, 26669, 4689, 365, 488, 267, 2066, 1006, 2222, 13, 15025, 8207, 315, 314, 3343, 911, 506, 1202, 14, 267, 3758, 574, 26, 488, 14, 339, 1803, 272, 5514, 272, 299, 1661, 520, 6122, 267, 1626, 6122, 402, 650, 13, 11760, 315, 314, 1824, 334, 85, 12, 373, 12, 299, 9, 2382, 334, 85, 12, 373, 9, 365, 282, 267, 4092, 402, 3380, 436, 299, 365, 3932, 1603, 5470, 1005, 9421, 14, 339, 6058, 272, 3001, 272, 1306, 492, 24313, 465, 8484, 272, 1306, 598, 275, 8484, 14, 4883, 63, 2180, 8, 21, 9, 272, 1306, 24960, 275, 8484, 14, 74, 5470, 1005, 63, 21329, 8, 39, 12, 3842, 16, 12, 413, 395, 334, 18, 12, 650, 3948, 272, 1306, 367, 399, 12, 373, 12, 299, 315, 24960, 26, 272, 2263, 258, 25676, 68, 12, 450, 68, 9, 1035, 10536, 24, 70, 7, 450, 334, 85, 12, 373, 12, 299, 9, 272, 2263, 272, 8189, 16, 12, 413, 9, 1035, 378, 14, 22, 9084, 7, 272, 8189, 18, 12, 650, 9, 1035, 378, 14, 22, 9084, 7, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 577, 14, 8003, 287, 13, 14351, 1697, 12, 1603 ]
[ 199, 3834, 12044, 18036, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 3473, 199, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 14, 11582, 492, 627, 199, 199, 363, 452, 363, 275, 788, 1927, 63, 14940, 63, 1080, 297, 1779, 283, 74, 5470, 1005, 63, 21329, 297, 1779, 283, 27679, 530, 63, 350, 285, 63, 1080, 297, 1779, 283, 657, 1485, 1009, 63, 8905, 297, 1779, 283, 6413, 63, 14990, 285, 9091, 290, 63, 13376, 67, 293, 856, 297, 1779, 283, 345, 63, 1080, 63, 14990, 285, 9091, 290, 63, 13376, 67, 293, 856, 297, 1779, 283, 12541, 63, 1058, 63, 4201, 418, 421, 199, 32, 1397, 63, 13825, 63, 509, 360, 12080, 358, 199, 32, 1397, 63, 13825, 63, 509, 360, 3029, 2180, 358, 199, 318, 2073, 63, 14940, 63, 1080, 8, 39, 12, 26669, 4689, 29, 403, 304, 272, 519, 624, 8564, 314, 2073, 18723, 1478, 402, 1006, 1031, 6342, 315, 26669, 4689, 14, 339, 7337, 18723, 1478, 402, 658, 85, 64, 436, 658, 86, 64, 365, 3247, 465, 339, 2508, 3473, 447, 398, 971, 1838, 7348, 87, 971, 262, 971, 15091, 8, 85, 9, 971, 2874, 971, 15091, 8, 86, 6769, 971, 10865, 91, 17, 8847, 6113, 15091, 8, 87, 8636, 93, 339, 2382, 520, 3442, 1705, 60, 15091, 8, 85, 12544, 477, 5983, 314, 663, 402, 15845, 402, 658, 85, 2313, 339, 3897, 272, 4143, 272, 598, 520, 3343, 267, 437, 7220, 56, 625, 12080, 3343, 14, 339, 26669, 4689, 520, 6076, 402, 1031, 6342, 12, 2716, 334, 885, 275, 488, 9, 267, 7337, 18723, 1478, 911, 506, 9235, 367, 1924, 4092, 402, 267, 3380, 1627, 315, 314, 6076, 14, 710, 6342, 1471, 506, 1627, 465, 267, 499, 13, 11760, 334, 85, 12, 373, 9, 2382, 399, 436, 373, 787, 3380, 315, 314, 3343, 14, 982, 26669, 4689, 267, 365, 488, 2066, 1006, 2222, 13, 15025, 8207, 315, 314, 3343, 911, 506, 1202, 14, 267, 3758, 574, 26, 488, 14, 339, 1803, 272, 5514, 272, 299, 1661, 520, 6122, 267, 1626, 6122, 402, 650, 13, 11760, 315, 314, 1824, 334, 85, 12, 373, 12, 299, 9, 2382, 334, 85, 12, 373, 9, 365, 282, 267, 4092, 402, 3380, 436, 299, 365, 3932, 2073, 18723, 1478, 14, 339, 6058, 272, 3001, 272, 1306, 492, 24313, 465, 8484, 272, 1306, 598, 275, 8484, 14, 4883, 63, 2180, 8, 21, 9, 272, 1306, 24960, 275, 8484, 14, 1927, 63, 14940, 63, 1080, 8, 39, 12, 3842, 16, 12, 413, 395, 334, 18, 12, 650, 3948, 272, 1306, 367, 399, 12, 373, 12, 299, 315, 24960, 26, 272, 2263, 258, 25676, 68, 12, 450, 68, 9, 1035, 10536, 24, 70, 7, 450, 334, 85, 12, 373, 12, 299, 9, 272, 2263, 272, 8189, 16, 12, 413, 9, 1035, 378, 14, 2194, 3273, 7, 272, 8189, 18, 12, 650, 9, 1035, 378, 14, 2194, 3273, 7, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 377, 14, 3107, 11586, 12, 491, 14, 30936, 12, 1488, 23683, 35, 14, 3107, 27304, 14, 2126, 5543, 807, 316, 4124, 6220, 4799, 2257, 2556, 14, 2126, 662, 300, 14, 11308, 588, 14, 1603, 14, 699, 17245, 334, 8664, 9, 1227, 1789, 14, 2126, 1455, 921, 27290, 14, 1308, 15, 5607, 15, 1643, 614, 14, 16458, 19, 14, 5607, 272, 408, 272, 340, 26669, 4689, 365, 488, 26, 267, 26669, 4689, 275, 8484, 14, 2865, 63, 6929, 8, 39, 9, 339, 347, 12610, 8, 85, 12, 373, 304, 267, 372, 3089, 8, 17, 1182, 598, 14, 10956, 8, 87, 9, 367, 336, 315, 8484, 14, 2330, 63, 11113, 8, 39, 12, 399, 12, 373, 430, 339, 372, 3666, 85, 12, 373, 12, 12610, 8, 85, 12, 373, 430, 367, 399, 12, 373, 315, 26669, 4689, 9, 421, 199, 32, 1397, 63, 13825, 63, 509, 360, 12080, 358, 199, 32, 1397, 63, 13825, 63, 509, 360, 3029, 2180, 358, 199, 318, 1335, 5470, 1005, 63, 21329, 8, 39, 12, 26669, 4689, 29, 403, 304, 272, 519, 624, 8564, 314, 1603, 5470, 1005, 9421, 402, 1006, 1031, 6342, 315, 26669, 4689, 14, 339, 1603, 5470, 1005, 9421, 402, 3380, 658, 85, 64, 436, 658, 86, 64, 365, 3247, 465, 339, 2508, 3473, 447, 398, 971, 10865, 91, 6113, 15091, 8, 85, 9, 971, 2874, 971, 15091, 8, 86, 8636, 8847, 6113, 15091, 8, 85, 9, 971, 17500, 971, 15091, 8, 86, 8636, 93, 339, 2382, 520, 3442, 1705, 60, 15091, 8, 85, 12544, 477, 5983, 314, 663, 402, 15845, 402, 658, 85, 2313, 339, 3897, 272, 4143, 272, 598, 520, 3343, 267, 437, 7220, 56, 625, 12080, 3343, 14, 339, 26669, 4689, 520, 6076, 402, 1031, 6342, 12, 2716, 334, 885, 275, 488, 9, 267, 1603, 5470, 1005, 9421, 911, 506, 9235, 367, 1924, 4092, 402, 3380, 267, 1627, 315, 314, 6076, 14, 710, 6342, 1471, 506, 1627, 465, 499, 13, 11760, 267, 334, 85, 12, 373, 9, 2382, 399, 436, 373, 787, 3380, 315, 314, 3343, 14, 982, 26669, 4689, 365, 488, 267, 2066, 1006, 2222, 13, 15025, 8207, 315, 314, 3343, 911, 506, 1202, 14, 267, 3758, 574, 26, 488, 14, 339, 1803, 272, 5514, 272, 299, 1661, 520, 6122, 267, 1626, 6122, 402, 650, 13, 11760, 315, 314, 1824, 334, 85, 12, 373, 12, 299, 9, 2382, 334, 85, 12, 373, 9, 365, 282, 267, 4092, 402, 3380, 436, 299, 365, 3932, 1603, 5470, 1005, 9421, 14, 339, 6058, 272, 3001, 272, 1306, 492, 24313, 465, 8484, 272, 1306, 598, 275, 8484, 14, 4883, 63, 2180, 8, 21, 9, 272, 1306, 24960, 275, 8484, 14, 74, 5470, 1005, 63, 21329, 8, 39, 12, 3842, 16, 12, 413, 395, 334, 18, 12, 650, 3948, 272, 1306, 367, 399, 12, 373, 12, 299, 315, 24960, 26, 272, 2263, 258, 25676, 68, 12, 450, 68, 9, 1035, 10536, 24, 70, 7, 450, 334, 85, 12, 373, 12, 299, 9, 272, 2263, 272, 8189, 16, 12, 413, 9, 1035, 378, 14, 22, 9084, 7, 272, 8189, 18, 12, 650, 9, 1035, 378, 14, 22, 9084, 7, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 577, 14, 8003, 287, 13, 14351, 1697, 12, 1603, 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,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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 ]
MalloyPower/parsing-python
front-end/testsuite-python-lib/Python-2.4.3/Lib/plat-mac/Carbon/Dialogs.py
81
2156
# Generated from 'Dialogs.h' def FOUR_CHAR_CODE(x): return x kControlDialogItem = 4 kButtonDialogItem = kControlDialogItem | 0 kCheckBoxDialogItem = kControlDialogItem | 1 kRadioButtonDialogItem = kControlDialogItem | 2 kResourceControlDialogItem = kControlDialogItem | 3 kStaticTextDialogItem = 8 kEditTextDialogItem = 16 kIconDialogItem = 32 kPictureDialogItem = 64 kUserDialogItem = 0 kHelpDialogItem = 1 kItemDisableBit = 128 ctrlItem = 4 btnCtrl = 0 chkCtrl = 1 radCtrl = 2 resCtrl = 3 statText = 8 editText = 16 iconItem = 32 picItem = 64 userItem = 0 itemDisable = 128 kStdOkItemIndex = 1 kStdCancelItemIndex = 2 ok = kStdOkItemIndex cancel = kStdCancelItemIndex kStopIcon = 0 kNoteIcon = 1 kCautionIcon = 2 stopIcon = kStopIcon noteIcon = kNoteIcon cautionIcon = kCautionIcon kOkItemIndex = 1 kCancelItemIndex = 2 overlayDITL = 0 appendDITLRight = 1 appendDITLBottom = 2 kAlertStopAlert = 0 kAlertNoteAlert = 1 kAlertCautionAlert = 2 kAlertPlainAlert = 3 kAlertDefaultOKText = -1 kAlertDefaultCancelText = -1 kAlertDefaultOtherText = -1 kAlertStdAlertOKButton = 1 kAlertStdAlertCancelButton = 2 kAlertStdAlertOtherButton = 3 kAlertStdAlertHelpButton = 4 kDialogFlagsUseThemeBackground = (1 << 0) kDialogFlagsUseControlHierarchy = (1 << 1) kDialogFlagsHandleMovableModal = (1 << 2) kDialogFlagsUseThemeControls = (1 << 3) kAlertFlagsUseThemeBackground = (1 << 0) kAlertFlagsUseControlHierarchy = (1 << 1) kAlertFlagsAlertIsMovable = (1 << 2) kAlertFlagsUseThemeControls = (1 << 3) kDialogFontNoFontStyle = 0 kDialogFontUseFontMask = 0x0001 kDialogFontUseFaceMask = 0x0002 kDialogFontUseSizeMask = 0x0004 kDialogFontUseForeColorMask = 0x0008 kDialogFontUseBackColorMask = 0x0010 kDialogFontUseModeMask = 0x0020 kDialogFontUseJustMask = 0x0040 kDialogFontUseAllMask = 0x00FF kDialogFontAddFontSizeMask = 0x0100 kDialogFontUseFontNameMask = 0x0200 kDialogFontAddToMetaFontMask = 0x0400 kDialogFontUseThemeFontIDMask = 0x0080 kHICommandOther = FOUR_CHAR_CODE('othr') kStdCFStringAlertVersionOne = 1 kStdAlertDoNotDisposeSheet = 1 << 0 kStdAlertDoNotAnimateOnDefault = 1 << 1 kStdAlertDoNotAnimateOnCancel = 1 << 2 kStdAlertDoNotAnimateOnOther = 1 << 3
mit
[ 3, 17065, 687, 283, 1341, 18238, 14, 72, 7, 199, 199, 318, 14473, 63, 5901, 63, 6012, 8, 88, 304, 372, 671, 199, 29233, 5619, 2081, 275, 841, 199, 75, 4259, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 378, 199, 75, 20530, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 413, 199, 75, 16065, 4259, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 499, 199, 75, 4031, 3717, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 650, 199, 75, 25289, 5619, 2081, 275, 1695, 199, 75, 4685, 1872, 5619, 2081, 275, 3193, 199, 75, 8954, 5619, 2081, 275, 4337, 199, 75, 29439, 5619, 2081, 275, 5049, 199, 75, 1899, 5619, 2081, 275, 378, 199, 75, 8673, 5619, 2081, 275, 413, 199, 75, 2081, 13707, 4734, 275, 7960, 199, 12476, 2081, 275, 841, 199, 9633, 9778, 275, 378, 199, 14823, 9778, 275, 413, 199, 9525, 9778, 275, 499, 199, 470, 9778, 275, 650, 199, 3736, 1872, 275, 1695, 199, 3773, 1872, 275, 3193, 199, 4677, 2081, 275, 4337, 199, 12475, 2081, 275, 5049, 199, 751, 2081, 275, 378, 199, 1053, 13707, 275, 7960, 199, 75, 11976, 11622, 2081, 2681, 275, 413, 199, 75, 11976, 9083, 2081, 2681, 275, 499, 199, 745, 275, 1022, 11976, 11622, 2081, 2681, 199, 6406, 275, 1022, 11976, 9083, 2081, 2681, 199, 75, 6293, 8954, 275, 378, 199, 75, 7443, 8954, 275, 413, 199, 75, 3630, 2206, 8954, 275, 499, 199, 2379, 8954, 275, 1022, 6293, 8954, 199, 4610, 8954, 275, 1022, 7443, 8954, 199, 696, 2206, 8954, 275, 1022, 3630, 2206, 8954, 199, 75, 11622, 2081, 2681, 275, 413, 199, 75, 9083, 2081, 2681, 275, 499, 199, 18534, 3841, 44, 275, 378, 199, 740, 3841, 44, 9121, 275, 413, 199, 740, 3841, 11568, 357, 3151, 275, 499, 199, 75, 18758, 6293, 18758, 275, 378, 199, 75, 18758, 7443, 18758, 275, 413, 199, 75, 18758, 3630, 2206, 18758, 275, 499, 199, 75, 18758, 20711, 18758, 275, 650, 199, 75, 18758, 2698, 3593, 1872, 275, 446, 17, 199, 75, 18758, 2698, 9083, 1872, 275, 446, 17, 199, 75, 18758, 2698, 8632, 1872, 275, 446, 17, 199, 75, 18758, 11976, 18758, 3593, 4259, 275, 413, 199, 75, 18758, 11976, 18758, 9083, 4259, 275, 499, 199, 75, 18758, 11976, 18758, 8632, 4259, 275, 650, 199, 75, 18758, 11976, 18758, 8673, 4259, 275, 841, 199, 75, 5619, 6381, 6119, 16849, 14148, 275, 334, 17, 5213, 378, 9, 199, 75, 5619, 6381, 6119, 3717, 29460, 275, 334, 17, 5213, 413, 9, 199, 75, 5619, 6381, 5940, 3716, 30456, 23689, 275, 334, 17, 5213, 499, 9, 199, 75, 5619, 6381, 6119, 16849, 25457, 275, 334, 17, 5213, 650, 9, 199, 75, 18758, 6381, 6119, 16849, 14148, 275, 334, 17, 5213, 378, 9, 199, 75, 18758, 6381, 6119, 3717, 29460, 275, 334, 17, 5213, 413, 9, 199, 75, 18758, 6381, 18758, 1831, 3716, 30456, 275, 334, 17, 5213, 499, 9, 199, 75, 18758, 6381, 6119, 16849, 25457, 275, 334, 17, 5213, 650, 9, 199, 75, 5619, 6986, 1944, 6986, 6609, 275, 378, 199, 75, 5619, 6986, 6119, 6986, 5144, 275, 378, 88, 4183, 199, 75, 5619, 6986, 6119, 13414, 5144, 275, 378, 88, 9425, 199, 75, 5619, 6986, 6119, 2320, 5144, 275, 378, 88, 16643, 199, 75, 5619, 6986, 6119, 13099, 4117, 5144, 275, 378, 88, 19141, 199, 75, 5619, 6986, 6119, 4540, 4117, 5144, 275, 378, 88, 17657, 199, 75, 5619, 6986, 6119, 1385, 5144, 275, 378, 88, 20734, 199, 75, 5619, 6986, 6119, 22850, 5144, 275, 378, 88, 25665, 199, 75, 5619, 6986, 6119, 2422, 5144, 275, 378, 88, 383, 1665, 199, 75, 5619, 6986, 1123, 6986, 2320, 5144, 275, 378, 88, 16569, 199, 75, 5619, 6986, 6119, 6986, 985, 5144, 275, 378, 88, 24215, 199, 75, 5619, 6986, 1123, 1378, 3396, 6986, 5144, 275, 378, 88, 27130, 199, 75, 5619, 6986, 6119, 16849, 6986, 998, 5144, 275, 378, 88, 23686, 199, 75, 40, 948, 79, 861, 8632, 275, 14473, 63, 5901, 63, 6012, 360, 79, 28854, 358, 199, 75, 11976, 5487, 1558, 18758, 3353, 4395, 275, 413, 199, 75, 11976, 18758, 2585, 1763, 15613, 16715, 275, 413, 5213, 378, 199, 75, 11976, 18758, 2585, 1763, 2493, 6897, 3314, 2698, 275, 413, 5213, 413, 199, 75, 11976, 18758, 2585, 1763, 2493, 6897, 3314, 9083, 275, 413, 5213, 499, 199, 75, 11976, 18758, 2585, 1763, 2493, 6897, 3314, 8632, 275, 413, 5213, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17065, 687, 283, 1341, 18238, 14, 72, 7, 199, 199, 318, 14473, 63, 5901, 63, 6012, 8, 88, 304, 372, 671, 199, 29233, 5619, 2081, 275, 841, 199, 75, 4259, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 378, 199, 75, 20530, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 413, 199, 75, 16065, 4259, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 499, 199, 75, 4031, 3717, 5619, 2081, 275, 1022, 3717, 5619, 2081, 1204, 650, 199, 75, 25289, 5619, 2081, 275, 1695, 199, 75, 4685, 1872, 5619, 2081, 275, 3193, 199, 75, 8954, 5619, 2081, 275, 4337, 199, 75, 29439, 5619, 2081, 275, 5049, 199, 75, 1899, 5619, 2081, 275, 378, 199, 75, 8673, 5619, 2081, 275, 413, 199, 75, 2081, 13707, 4734, 275, 7960, 199, 12476, 2081, 275, 841, 199, 9633, 9778, 275, 378, 199, 14823, 9778, 275, 413, 199, 9525, 9778, 275, 499, 199, 470, 9778, 275, 650, 199, 3736, 1872, 275, 1695, 199, 3773, 1872, 275, 3193, 199, 4677, 2081, 275, 4337, 199, 12475, 2081, 275, 5049, 199, 751, 2081, 275, 378, 199, 1053, 13707, 275, 7960, 199, 75, 11976, 11622, 2081, 2681, 275, 413, 199, 75, 11976, 9083, 2081, 2681, 275, 499, 199, 745, 275, 1022, 11976, 11622, 2081, 2681, 199, 6406, 275, 1022, 11976, 9083, 2081, 2681, 199, 75, 6293, 8954, 275, 378, 199, 75, 7443, 8954, 275, 413, 199, 75, 3630, 2206, 8954, 275, 499, 199, 2379, 8954, 275, 1022, 6293, 8954, 199, 4610, 8954, 275, 1022, 7443, 8954, 199, 696, 2206, 8954, 275, 1022, 3630, 2206, 8954, 199, 75, 11622, 2081, 2681, 275, 413, 199, 75, 9083, 2081, 2681, 275, 499, 199, 18534, 3841, 44, 275, 378, 199, 740, 3841, 44, 9121, 275, 413, 199, 740, 3841, 11568, 357, 3151, 275, 499, 199, 75, 18758, 6293, 18758, 275, 378, 199, 75, 18758, 7443, 18758, 275, 413, 199, 75, 18758, 3630, 2206, 18758, 275, 499, 199, 75, 18758, 20711, 18758, 275, 650, 199, 75, 18758, 2698, 3593, 1872, 275, 446, 17, 199, 75, 18758, 2698, 9083, 1872, 275, 446, 17, 199, 75, 18758, 2698, 8632, 1872, 275, 446, 17, 199, 75, 18758, 11976, 18758, 3593, 4259, 275, 413, 199, 75, 18758, 11976, 18758, 9083, 4259, 275, 499, 199, 75, 18758, 11976, 18758, 8632, 4259, 275, 650, 199, 75, 18758, 11976, 18758, 8673, 4259, 275, 841, 199, 75, 5619, 6381, 6119, 16849, 14148, 275, 334, 17, 5213, 378, 9, 199, 75, 5619, 6381, 6119, 3717, 29460, 275, 334, 17, 5213, 413, 9, 199, 75, 5619, 6381, 5940, 3716, 30456, 23689, 275, 334, 17, 5213, 499, 9, 199, 75, 5619, 6381, 6119, 16849, 25457, 275, 334, 17, 5213, 650, 9, 199, 75, 18758, 6381, 6119, 16849, 14148, 275, 334, 17, 5213, 378, 9, 199, 75, 18758, 6381, 6119, 3717, 29460, 275, 334, 17, 5213, 413, 9, 199, 75, 18758, 6381, 18758, 1831, 3716, 30456, 275, 334, 17, 5213, 499, 9, 199, 75, 18758, 6381, 6119, 16849, 25457, 275, 334, 17, 5213, 650, 9, 199, 75, 5619, 6986, 1944, 6986, 6609, 275, 378, 199, 75, 5619, 6986, 6119, 6986, 5144, 275, 378, 88, 4183, 199, 75, 5619, 6986, 6119, 13414, 5144, 275, 378, 88, 9425, 199, 75, 5619, 6986, 6119, 2320, 5144, 275, 378, 88, 16643, 199, 75, 5619, 6986, 6119, 13099, 4117, 5144, 275, 378, 88, 19141, 199, 75, 5619, 6986, 6119, 4540, 4117, 5144, 275, 378, 88, 17657, 199, 75, 5619, 6986, 6119, 1385, 5144, 275, 378, 88, 20734, 199, 75, 5619, 6986, 6119, 22850, 5144, 275, 378, 88, 25665, 199, 75, 5619, 6986, 6119, 2422, 5144, 275, 378, 88, 383, 1665, 199, 75, 5619, 6986, 1123, 6986, 2320, 5144, 275, 378, 88, 16569, 199, 75, 5619, 6986, 6119, 6986, 985, 5144, 275, 378, 88, 24215, 199, 75, 5619, 6986, 1123, 1378, 3396, 6986, 5144, 275, 378, 88, 27130, 199, 75, 5619, 6986, 6119, 16849, 6986, 998, 5144, 275, 378, 88, 23686, 199, 75, 40, 948, 79, 861, 8632, 275, 14473, 63, 5901, 63, 6012, 360, 79, 28854, 358, 199, 75, 11976, 5487, 1558, 18758, 3353, 4395, 275, 413, 199, 75, 11976, 18758, 2585, 1763, 15613, 16715, 275, 413, 5213, 378, 199, 75, 11976, 18758, 2585, 1763, 2493, 6897, 3314, 2698, 275, 413, 5213, 413, 199, 75, 11976, 18758, 2585, 1763, 2493, 6897, 3314, 9083, 275, 413, 5213, 499, 199, 75, 11976, 18758, 2585, 1763, 2493, 6897, 3314, 8632, 275, 413, 5213, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
talha81/TACTIC-DEV
src/tactic/ui/container/dynamic_list_wdg.py
6
5020
############################################################ # # Copyright (c) 2010, Southpaw Technology # All Rights Reserved # # PROPRIETARY INFORMATION. This software is proprietary to # Southpaw Technology, and is not to be reproduced, transmitted, # or disclosed in any way without written permission. # # __all__ = ['DynamicListWdg'] from tactic.ui.common import BaseRefreshWdg from pyasm.web import DivWdg from pyasm.widget import CheckboxWdg, HiddenWdg, IconWdg, IconButtonWdg class DynamicListWdg(BaseRefreshWdg): ARGS_KEYS = { 'show_enabled': 'determines whether or not to show enabled checkboxes' } def init(my): my.items = [] my.template = None my.show_enabled = my.kwargs.get('show_enabled') if my.show_enabled in ['true', True]: my.show_enabled = True else: my.show_enabled = False def add_item(my, item): my.items.append(item) def add_template(my, template): my.template = template def get_display(my): #assert my.template top = DivWdg() top.add_class("spt_list_top") top.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_remove', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_list_top"); var items = top.getElements(".spt_list_item"); if (items.length > 1) { var item = bvr.src_el.getParent(".spt_list_item"); item.destroy(); } ''' } ) top.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_add', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_list_top"); var template = top.getElement(".spt_list_template_item"); var new_item = spt.behavior.clone(template); var item = bvr.src_el.getParent(".spt_list_item"); new_item.removeClass("spt_list_template_item"); new_item.addClass("spt_list_item") new_item.setStyle("display", "") //new_item.inject(top, 'bottom'); new_item.inject(item, 'after'); ''' } ) if my.template: template_wdg = my.get_item_wdg(my.template, is_template=True) top.add(template_wdg ) for item in my.items: item_wdg = my.get_item_wdg(item) top.add( item_wdg ) return top def get_item_wdg(my, item, is_template=False): item_div = DivWdg() item_div.add_style("margin-top: 3px") if is_template == True: item_div.add_style("display: none") #item_div.add_style("border: solid 1px blue") item_div.add_class("spt_list_template_item") else: item_div.add_class("spt_list_item") outer = DivWdg() outer.add_style("float: left") outer.add_style("text-align: left") outer.add(item) if my.show_enabled: checkbox = CheckboxWdg("enabled") checkbox.add_style("float: left") checkbox.set_checked() else: checkbox = HiddenWdg("enabled") item_div.add(checkbox) #item_div.add(item) item_div.add(outer) add_wdg = DivWdg() add_wdg.add_class("hand") add_wdg.add_class("SPT_DTS") add_wdg.add("(+)") add_wdg.add_class("spt_add") #from tactic.ui.widget import IconButtonWdg #button = IconButtonWdg(title="Add Entry", icon=IconWdg.ADD) #add_wdg.add(button) #button.add_behavior( { add_wdg.add_style("float: left") add_wdg.add_style("margin: 3px") item_div.add(add_wdg) remove_wdg = DivWdg() remove_wdg.add_class("hand") remove_wdg.add_class("SPT_DTS") remove_wdg.add("(-)") remove_wdg.add_class("spt_remove") #button = IconButtonWdg(title="Remove Entry", icon=IconWdg.DELETE) #remove_wdg.add(button) #button.add_behavior( { remove_wdg.add_style("float: left") remove_wdg.add_style("margin: 3px") item_div.add(remove_wdg) item_div.add("<br clear='all'/>") return item_div def get_values_script(my): save_button = IconButtonWdg("Save Settings", IconWdg.SAVE) save_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' get_values = function() { var top = bvr.src_el.getParent(".spt_list_top"); var elements = bvr.src_el.getElements(".spt_list_items"); var data = []; for (var i=0; i<elements.length; i++) { var values = spt.api.get_input_values(elements[i]); data.push(values) } return data; } ''' } ) content_div.add(save_button)
epl-1.0
[ 26207, 381, 199, 3, 199, 3, 259, 1898, 334, 67, 9, 7129, 12, 23150, 387, 87, 21580, 199, 3, 12788, 2900, 5924, 5702, 199, 3, 199, 3, 259, 3611, 20076, 775, 4392, 1621, 18623, 14, 221, 961, 2032, 365, 557, 1359, 386, 695, 370, 199, 3, 259, 23150, 387, 87, 21580, 12, 436, 365, 440, 370, 506, 9172, 68, 12, 29818, 12, 199, 3, 259, 503, 4339, 320, 939, 315, 1263, 4340, 1928, 5313, 4983, 14, 199, 3, 199, 3, 199, 199, 363, 452, 363, 275, 788, 14451, 1296, 21700, 418, 421, 199, 504, 307, 27296, 14, 1907, 14, 2330, 492, 3523, 18730, 21700, 199, 199, 504, 1134, 11374, 14, 2520, 492, 32077, 21700, 199, 504, 1134, 11374, 14, 3440, 492, 2670, 1977, 21700, 12, 26401, 21700, 12, 473, 388, 21700, 12, 473, 388, 4259, 21700, 421, 199, 533, 21907, 1296, 21700, 8, 1563, 18730, 21700, 304, 339, 4160, 8021, 63, 17434, 275, 469, 272, 283, 2384, 63, 3827, 356, 283, 17061, 397, 3775, 503, 440, 370, 2498, 5223, 1104, 12922, 7, 272, 789, 339, 347, 4205, 8, 1662, 304, 267, 3002, 14, 1744, 275, 942, 267, 3002, 14, 1160, 275, 488, 398, 3002, 14, 2384, 63, 3827, 275, 3002, 14, 958, 14, 362, 360, 2384, 63, 3827, 358, 267, 340, 3002, 14, 2384, 63, 3827, 315, 788, 2052, 297, 715, 2189, 288, 3002, 14, 2384, 63, 3827, 275, 715, 267, 587, 26, 288, 3002, 14, 2384, 63, 3827, 275, 756, 2378, 347, 1050, 63, 1053, 8, 1662, 12, 1242, 304, 267, 3002, 14, 1744, 14, 740, 8, 1053, 9, 339, 347, 1050, 63, 1160, 8, 1662, 12, 1978, 304, 267, 3002, 14, 1160, 275, 1978, 339, 347, 664, 63, 2918, 8, 1662, 304, 267, 327, 479, 3002, 14, 1160, 7318, 2746, 275, 32077, 21700, 342, 267, 2746, 14, 525, 63, 533, 480, 83, 541, 63, 513, 63, 2119, 531, 398, 2746, 14, 525, 63, 21855, 63, 17537, 8, 469, 288, 283, 466, 356, 283, 10544, 384, 297, 288, 283, 66, 10922, 63, 1431, 63, 533, 356, 283, 83, 541, 63, 2168, 297, 288, 283, 67, 468, 83, 63, 1287, 356, 1449, 288, 2729, 2746, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 2119, 3547, 288, 2729, 2974, 275, 2746, 14, 362, 6255, 9520, 83, 541, 63, 513, 63, 1053, 3547, 288, 340, 334, 1744, 14, 1267, 690, 413, 9, 469, 355, 2729, 1242, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 1053, 3547, 355, 1242, 14, 7237, 7303, 288, 789, 288, 1449, 267, 789, 776, 398, 2746, 14, 525, 63, 21855, 63, 17537, 8, 469, 288, 283, 466, 356, 283, 10544, 384, 297, 288, 283, 66, 10922, 63, 1431, 63, 533, 356, 283, 83, 541, 63, 525, 297, 288, 283, 67, 468, 83, 63, 1287, 356, 1449, 288, 2729, 2746, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 2119, 3547, 288, 2729, 1978, 275, 2746, 14, 21720, 9520, 83, 541, 63, 513, 63, 1160, 63, 1053, 3547, 288, 2729, 892, 63, 1053, 275, 308, 541, 14, 17537, 14, 6311, 8, 1160, 2736, 288, 2729, 1242, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 1053, 3547, 288, 892, 63, 1053, 14, 2168, 2543, 480, 83, 541, 63, 513, 63, 1160, 63, 1053, 3547, 288, 892, 63, 1053, 14, 525, 2543, 480, 83, 541, 63, 513, 63, 1053, 531, 288, 892, 63, 1053, 14, 31091, 480, 2918, 401, 6899, 288, 5001, 1222, 63, 1053, 14, 14815, 8, 2119, 12, 283, 8305, 11339, 288, 892, 63, 1053, 14, 14815, 8, 1053, 12, 283, 4399, 11339, 288, 1449, 267, 789, 776, 7318, 340, 3002, 14, 1160, 26, 288, 1978, 63, 2989, 71, 275, 3002, 14, 362, 63, 1053, 63, 2989, 71, 8, 1662, 14, 1160, 12, 365, 63, 1160, 29, 549, 9, 288, 2746, 14, 525, 8, 1160, 63, 2989, 71, 776, 398, 367, 1242, 315, 3002, 14, 1744, 26, 288, 1242, 63, 2989, 71, 275, 3002, 14, 362, 63, 1053, 63, 2989, 71, 8, 1053, 9, 288, 2746, 14, 525, 8, 1242, 63, 2989, 71, 776, 398, 372, 2746, 16478, 347, 664, 63, 1053, 63, 2989, 71, 8, 1662, 12, 1242, 12, 365, 63, 1160, 29, 797, 304, 267, 1242, 63, 3015, 275, 32077, 21700, 342, 267, 1242, 63, 3015, 14, 525, 63, 2487, 480, 9650, 13, 2119, 26, 650, 5326, 531, 398, 340, 365, 63, 1160, 508, 715, 26, 288, 1242, 63, 3015, 14, 525, 63, 2487, 480, 2918, 26, 7179, 531, 288, 327, 1053, 63, 3015, 14, 525, 63, 2487, 480, 8665, 26, 18609, 413, 5326, 10030, 531, 288, 1242, 63, 3015, 14, 525, 63, 533, 480, 83, 541, 63, 513, 63, 1160, 63, 1053, 531, 267, 587, 26, 288, 1242, 63, 3015, 14, 525, 63, 533, 480, 83, 541, 63, 513, 63, 1053, 531, 398, 6890, 275, 32077, 21700, 342, 267, 6890, 14, 525, 63, 2487, 480, 1609, 26, 3602, 531, 267, 6890, 14, 525, 63, 2487, 480, 505, 13, 5743, 26, 3602, 531, 267, 6890, 14, 525, 8, 1053, 9, 7318, 340, 3002, 14, 2384, 63, 3827, 26, 288, 24190, 275, 2670, 1977, 21700, 480, 3827, 531, 288, 24190, 14, 525, 63, 2487, 480, 1609, 26, 3602, 531, 288, 24190, 14, 409, 63, 10718, 342, 267, 587, 26, 288, 24190, 275, 26401, 21700, 480, 3827, 531, 267, 1242, 63, 3015, 14, 525, 8, 13456, 9, 398, 327, 1053, 63, 3015, 14, 525, 8, 1053, 9, 267, 1242, 63, 3015, 14, 525, 8, 7837, 9, 7318, 1050, 63, 2989, 71, 275, 32077, 21700, 342, 267, 1050, 63, 2989, 71, 14, 525, 63, 533, 480, 6868, 531, 267, 1050, 63, 2989, 71, 14, 525, 63, 533, 480, 51, 4189, 63, 7438, 51, 531, 267, 1050, 63, 2989, 71, 14, 525, 18353, 11, 6320, 267, 1050, 63, 2989, 71, 14, 525, 63, 533, 480, 83, 541, 63, 525, 531, 267, 327, 504, 307, 27296, 14, 1907, 14, 3440, 492, 473, 388, 4259, 21700, 267, 327, 3887, 275, 473, 388, 4259, 21700, 8, 1213, 628, 1123, 11855, 401, 7016, 29, 8954, 21700, 14, 9732 ]
[ 381, 199, 3, 199, 3, 259, 1898, 334, 67, 9, 7129, 12, 23150, 387, 87, 21580, 199, 3, 12788, 2900, 5924, 5702, 199, 3, 199, 3, 259, 3611, 20076, 775, 4392, 1621, 18623, 14, 221, 961, 2032, 365, 557, 1359, 386, 695, 370, 199, 3, 259, 23150, 387, 87, 21580, 12, 436, 365, 440, 370, 506, 9172, 68, 12, 29818, 12, 199, 3, 259, 503, 4339, 320, 939, 315, 1263, 4340, 1928, 5313, 4983, 14, 199, 3, 199, 3, 199, 199, 363, 452, 363, 275, 788, 14451, 1296, 21700, 418, 421, 199, 504, 307, 27296, 14, 1907, 14, 2330, 492, 3523, 18730, 21700, 199, 199, 504, 1134, 11374, 14, 2520, 492, 32077, 21700, 199, 504, 1134, 11374, 14, 3440, 492, 2670, 1977, 21700, 12, 26401, 21700, 12, 473, 388, 21700, 12, 473, 388, 4259, 21700, 421, 199, 533, 21907, 1296, 21700, 8, 1563, 18730, 21700, 304, 339, 4160, 8021, 63, 17434, 275, 469, 272, 283, 2384, 63, 3827, 356, 283, 17061, 397, 3775, 503, 440, 370, 2498, 5223, 1104, 12922, 7, 272, 789, 339, 347, 4205, 8, 1662, 304, 267, 3002, 14, 1744, 275, 942, 267, 3002, 14, 1160, 275, 488, 398, 3002, 14, 2384, 63, 3827, 275, 3002, 14, 958, 14, 362, 360, 2384, 63, 3827, 358, 267, 340, 3002, 14, 2384, 63, 3827, 315, 788, 2052, 297, 715, 2189, 288, 3002, 14, 2384, 63, 3827, 275, 715, 267, 587, 26, 288, 3002, 14, 2384, 63, 3827, 275, 756, 2378, 347, 1050, 63, 1053, 8, 1662, 12, 1242, 304, 267, 3002, 14, 1744, 14, 740, 8, 1053, 9, 339, 347, 1050, 63, 1160, 8, 1662, 12, 1978, 304, 267, 3002, 14, 1160, 275, 1978, 339, 347, 664, 63, 2918, 8, 1662, 304, 267, 327, 479, 3002, 14, 1160, 7318, 2746, 275, 32077, 21700, 342, 267, 2746, 14, 525, 63, 533, 480, 83, 541, 63, 513, 63, 2119, 531, 398, 2746, 14, 525, 63, 21855, 63, 17537, 8, 469, 288, 283, 466, 356, 283, 10544, 384, 297, 288, 283, 66, 10922, 63, 1431, 63, 533, 356, 283, 83, 541, 63, 2168, 297, 288, 283, 67, 468, 83, 63, 1287, 356, 1449, 288, 2729, 2746, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 2119, 3547, 288, 2729, 2974, 275, 2746, 14, 362, 6255, 9520, 83, 541, 63, 513, 63, 1053, 3547, 288, 340, 334, 1744, 14, 1267, 690, 413, 9, 469, 355, 2729, 1242, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 1053, 3547, 355, 1242, 14, 7237, 7303, 288, 789, 288, 1449, 267, 789, 776, 398, 2746, 14, 525, 63, 21855, 63, 17537, 8, 469, 288, 283, 466, 356, 283, 10544, 384, 297, 288, 283, 66, 10922, 63, 1431, 63, 533, 356, 283, 83, 541, 63, 525, 297, 288, 283, 67, 468, 83, 63, 1287, 356, 1449, 288, 2729, 2746, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 2119, 3547, 288, 2729, 1978, 275, 2746, 14, 21720, 9520, 83, 541, 63, 513, 63, 1160, 63, 1053, 3547, 288, 2729, 892, 63, 1053, 275, 308, 541, 14, 17537, 14, 6311, 8, 1160, 2736, 288, 2729, 1242, 275, 330, 10922, 14, 2164, 63, 352, 14, 362, 6652, 9520, 83, 541, 63, 513, 63, 1053, 3547, 288, 892, 63, 1053, 14, 2168, 2543, 480, 83, 541, 63, 513, 63, 1160, 63, 1053, 3547, 288, 892, 63, 1053, 14, 525, 2543, 480, 83, 541, 63, 513, 63, 1053, 531, 288, 892, 63, 1053, 14, 31091, 480, 2918, 401, 6899, 288, 5001, 1222, 63, 1053, 14, 14815, 8, 2119, 12, 283, 8305, 11339, 288, 892, 63, 1053, 14, 14815, 8, 1053, 12, 283, 4399, 11339, 288, 1449, 267, 789, 776, 7318, 340, 3002, 14, 1160, 26, 288, 1978, 63, 2989, 71, 275, 3002, 14, 362, 63, 1053, 63, 2989, 71, 8, 1662, 14, 1160, 12, 365, 63, 1160, 29, 549, 9, 288, 2746, 14, 525, 8, 1160, 63, 2989, 71, 776, 398, 367, 1242, 315, 3002, 14, 1744, 26, 288, 1242, 63, 2989, 71, 275, 3002, 14, 362, 63, 1053, 63, 2989, 71, 8, 1053, 9, 288, 2746, 14, 525, 8, 1242, 63, 2989, 71, 776, 398, 372, 2746, 16478, 347, 664, 63, 1053, 63, 2989, 71, 8, 1662, 12, 1242, 12, 365, 63, 1160, 29, 797, 304, 267, 1242, 63, 3015, 275, 32077, 21700, 342, 267, 1242, 63, 3015, 14, 525, 63, 2487, 480, 9650, 13, 2119, 26, 650, 5326, 531, 398, 340, 365, 63, 1160, 508, 715, 26, 288, 1242, 63, 3015, 14, 525, 63, 2487, 480, 2918, 26, 7179, 531, 288, 327, 1053, 63, 3015, 14, 525, 63, 2487, 480, 8665, 26, 18609, 413, 5326, 10030, 531, 288, 1242, 63, 3015, 14, 525, 63, 533, 480, 83, 541, 63, 513, 63, 1160, 63, 1053, 531, 267, 587, 26, 288, 1242, 63, 3015, 14, 525, 63, 533, 480, 83, 541, 63, 513, 63, 1053, 531, 398, 6890, 275, 32077, 21700, 342, 267, 6890, 14, 525, 63, 2487, 480, 1609, 26, 3602, 531, 267, 6890, 14, 525, 63, 2487, 480, 505, 13, 5743, 26, 3602, 531, 267, 6890, 14, 525, 8, 1053, 9, 7318, 340, 3002, 14, 2384, 63, 3827, 26, 288, 24190, 275, 2670, 1977, 21700, 480, 3827, 531, 288, 24190, 14, 525, 63, 2487, 480, 1609, 26, 3602, 531, 288, 24190, 14, 409, 63, 10718, 342, 267, 587, 26, 288, 24190, 275, 26401, 21700, 480, 3827, 531, 267, 1242, 63, 3015, 14, 525, 8, 13456, 9, 398, 327, 1053, 63, 3015, 14, 525, 8, 1053, 9, 267, 1242, 63, 3015, 14, 525, 8, 7837, 9, 7318, 1050, 63, 2989, 71, 275, 32077, 21700, 342, 267, 1050, 63, 2989, 71, 14, 525, 63, 533, 480, 6868, 531, 267, 1050, 63, 2989, 71, 14, 525, 63, 533, 480, 51, 4189, 63, 7438, 51, 531, 267, 1050, 63, 2989, 71, 14, 525, 18353, 11, 6320, 267, 1050, 63, 2989, 71, 14, 525, 63, 533, 480, 83, 541, 63, 525, 531, 267, 327, 504, 307, 27296, 14, 1907, 14, 3440, 492, 473, 388, 4259, 21700, 267, 327, 3887, 275, 473, 388, 4259, 21700, 8, 1213, 628, 1123, 11855, 401, 7016, 29, 8954, 21700, 14, 9732, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
benlangmuir/swift
utils/swift_build_support/swift_build_support/products/product.py
3
2016
# swift_build_support/products/product.py -----------------------*- python -*- # # This source file is part of the Swift.org open source project # # Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See https://swift.org/LICENSE.txt for license information # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # # ---------------------------------------------------------------------------- class Product(object): @classmethod def product_name(cls): """product_name() -> str The identifier-style name to use for this product. """ return cls.__name__.lower() @classmethod def product_source_name(cls): """product_source_name() -> str The name of the source code directory of this product. It provides a customization point for Product subclasses. It is set to the value of product_name() by default for this reason. """ return cls.product_name() @classmethod def get_build_directory_name(cls, host_target): return "{}-{}".format(cls.product_name(), host_target.name) @classmethod def is_build_script_impl_product(cls): """is_build_script_impl_product -> bool Whether this product is produced by build-script-impl. """ return True def do_build(self, host_target): """do_build() -> void Perform the build, for a non-build-script-impl product. """ raise NotImplementedError def do_test(self, host_target): """do_build() -> void Run the tests, for a non-build-script-impl product. """ raise NotImplementedError def __init__(self, args, toolchain, source_dir, build_dir): self.args = args self.toolchain = toolchain self.source_dir = source_dir self.build_dir = build_dir self.cmake_options = []
apache-2.0
[ 3, 16275, 63, 1506, 63, 4058, 15, 13336, 15, 2558, 14, 647, 10652, 12797, 1837, 2366, 1882, 199, 3, 199, 3, 961, 1350, 570, 365, 1777, 402, 314, 16666, 2949, 14, 1308, 1551, 1350, 2199, 199, 3, 199, 3, 1898, 334, 67, 9, 6927, 446, 9708, 21257, 3277, 14, 436, 314, 16666, 2949, 2199, 11462, 199, 3, 3909, 1334, 3668, 844, 373, 18, 14, 16, 543, 19103, 11243, 2186, 199, 3, 199, 3, 1666, 4178, 921, 13215, 14, 1308, 15, 3961, 14, 2424, 367, 4190, 2556, 199, 3, 1666, 4178, 921, 13215, 14, 1308, 15, 1864, 1766, 6436, 14, 2424, 367, 314, 769, 402, 16666, 2949, 2199, 11462, 199, 3, 199, 3, 27103, 421, 199, 533, 12705, 8, 785, 304, 272, 768, 3744, 272, 347, 3336, 63, 354, 8, 1886, 304, 267, 408, 2558, 63, 354, 342, 1035, 620, 398, 710, 5148, 13, 2487, 536, 370, 675, 367, 642, 3336, 14, 267, 408, 267, 372, 843, 855, 354, 4343, 2325, 342, 339, 768, 3744, 272, 347, 3336, 63, 1365, 63, 354, 8, 1886, 304, 267, 408, 2558, 63, 1365, 63, 354, 342, 1035, 620, 398, 710, 536, 402, 314, 1350, 1233, 2082, 402, 642, 3336, 14, 267, 2779, 6571, 282, 32715, 2376, 367, 12705, 9180, 14, 2779, 365, 663, 370, 267, 314, 574, 402, 3336, 63, 354, 342, 701, 849, 367, 642, 4499, 14, 267, 408, 267, 372, 843, 14, 2558, 63, 354, 342, 339, 768, 3744, 272, 347, 664, 63, 1506, 63, 3619, 63, 354, 8, 1886, 12, 1591, 63, 1375, 304, 267, 372, 11491, 13, 13536, 908, 8, 1886, 14, 2558, 63, 354, 1062, 2892, 1591, 63, 1375, 14, 354, 9, 339, 768, 3744, 272, 347, 365, 63, 1506, 63, 1579, 63, 5472, 63, 2558, 8, 1886, 304, 267, 408, 374, 63, 1506, 63, 1579, 63, 5472, 63, 2558, 1035, 2155, 398, 7480, 642, 3336, 365, 13584, 701, 1900, 13, 1579, 13, 5472, 14, 267, 408, 267, 372, 715, 339, 347, 886, 63, 1506, 8, 277, 12, 1591, 63, 1375, 304, 267, 408, 1117, 63, 1506, 342, 1035, 2309, 398, 14795, 314, 1900, 12, 367, 282, 2222, 13, 1506, 13, 1579, 13, 5472, 3336, 14, 267, 408, 267, 746, 4279, 339, 347, 886, 63, 396, 8, 277, 12, 1591, 63, 1375, 304, 267, 408, 1117, 63, 1506, 342, 1035, 2309, 398, 3378, 314, 2295, 12, 367, 282, 2222, 13, 1506, 13, 1579, 13, 5472, 3336, 14, 267, 408, 267, 746, 4279, 339, 347, 636, 826, 721, 277, 12, 1249, 12, 22689, 12, 1350, 63, 694, 12, 1900, 63, 694, 304, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 22572, 275, 22689, 267, 291, 14, 1365, 63, 694, 275, 1350, 63, 694, 267, 291, 14, 1506, 63, 694, 275, 1900, 63, 694, 267, 291, 14, 16472, 63, 1419, 275, 942, 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 ]
[ 16275, 63, 1506, 63, 4058, 15, 13336, 15, 2558, 14, 647, 10652, 12797, 1837, 2366, 1882, 199, 3, 199, 3, 961, 1350, 570, 365, 1777, 402, 314, 16666, 2949, 14, 1308, 1551, 1350, 2199, 199, 3, 199, 3, 1898, 334, 67, 9, 6927, 446, 9708, 21257, 3277, 14, 436, 314, 16666, 2949, 2199, 11462, 199, 3, 3909, 1334, 3668, 844, 373, 18, 14, 16, 543, 19103, 11243, 2186, 199, 3, 199, 3, 1666, 4178, 921, 13215, 14, 1308, 15, 3961, 14, 2424, 367, 4190, 2556, 199, 3, 1666, 4178, 921, 13215, 14, 1308, 15, 1864, 1766, 6436, 14, 2424, 367, 314, 769, 402, 16666, 2949, 2199, 11462, 199, 3, 199, 3, 27103, 421, 199, 533, 12705, 8, 785, 304, 272, 768, 3744, 272, 347, 3336, 63, 354, 8, 1886, 304, 267, 408, 2558, 63, 354, 342, 1035, 620, 398, 710, 5148, 13, 2487, 536, 370, 675, 367, 642, 3336, 14, 267, 408, 267, 372, 843, 855, 354, 4343, 2325, 342, 339, 768, 3744, 272, 347, 3336, 63, 1365, 63, 354, 8, 1886, 304, 267, 408, 2558, 63, 1365, 63, 354, 342, 1035, 620, 398, 710, 536, 402, 314, 1350, 1233, 2082, 402, 642, 3336, 14, 267, 2779, 6571, 282, 32715, 2376, 367, 12705, 9180, 14, 2779, 365, 663, 370, 267, 314, 574, 402, 3336, 63, 354, 342, 701, 849, 367, 642, 4499, 14, 267, 408, 267, 372, 843, 14, 2558, 63, 354, 342, 339, 768, 3744, 272, 347, 664, 63, 1506, 63, 3619, 63, 354, 8, 1886, 12, 1591, 63, 1375, 304, 267, 372, 11491, 13, 13536, 908, 8, 1886, 14, 2558, 63, 354, 1062, 2892, 1591, 63, 1375, 14, 354, 9, 339, 768, 3744, 272, 347, 365, 63, 1506, 63, 1579, 63, 5472, 63, 2558, 8, 1886, 304, 267, 408, 374, 63, 1506, 63, 1579, 63, 5472, 63, 2558, 1035, 2155, 398, 7480, 642, 3336, 365, 13584, 701, 1900, 13, 1579, 13, 5472, 14, 267, 408, 267, 372, 715, 339, 347, 886, 63, 1506, 8, 277, 12, 1591, 63, 1375, 304, 267, 408, 1117, 63, 1506, 342, 1035, 2309, 398, 14795, 314, 1900, 12, 367, 282, 2222, 13, 1506, 13, 1579, 13, 5472, 3336, 14, 267, 408, 267, 746, 4279, 339, 347, 886, 63, 396, 8, 277, 12, 1591, 63, 1375, 304, 267, 408, 1117, 63, 1506, 342, 1035, 2309, 398, 3378, 314, 2295, 12, 367, 282, 2222, 13, 1506, 13, 1579, 13, 5472, 3336, 14, 267, 408, 267, 746, 4279, 339, 347, 636, 826, 721, 277, 12, 1249, 12, 22689, 12, 1350, 63, 694, 12, 1900, 63, 694, 304, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 22572, 275, 22689, 267, 291, 14, 1365, 63, 694, 275, 1350, 63, 694, 267, 291, 14, 1506, 63, 694, 275, 1900, 63, 694, 267, 291, 14, 16472, 63, 1419, 275, 942, 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, 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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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 ]
ernstbaslerpartner/send2geoadmin
env/Lib/encodings/iso8859_13.py
593
13527
""" Python Character Mapping Codec iso8859_13 generated from 'MAPPINGS/ISO8859/8859-13.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='iso8859-13', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> NULL u'\x01' # 0x01 -> START OF HEADING u'\x02' # 0x02 -> START OF TEXT u'\x03' # 0x03 -> END OF TEXT u'\x04' # 0x04 -> END OF TRANSMISSION u'\x05' # 0x05 -> ENQUIRY u'\x06' # 0x06 -> ACKNOWLEDGE u'\x07' # 0x07 -> BELL u'\x08' # 0x08 -> BACKSPACE u'\t' # 0x09 -> HORIZONTAL TABULATION u'\n' # 0x0A -> LINE FEED u'\x0b' # 0x0B -> VERTICAL TABULATION u'\x0c' # 0x0C -> FORM FEED u'\r' # 0x0D -> CARRIAGE RETURN u'\x0e' # 0x0E -> SHIFT OUT u'\x0f' # 0x0F -> SHIFT IN u'\x10' # 0x10 -> DATA LINK ESCAPE u'\x11' # 0x11 -> DEVICE CONTROL ONE u'\x12' # 0x12 -> DEVICE CONTROL TWO u'\x13' # 0x13 -> DEVICE CONTROL THREE u'\x14' # 0x14 -> DEVICE CONTROL FOUR u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x16 -> SYNCHRONOUS IDLE u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK u'\x18' # 0x18 -> CANCEL u'\x19' # 0x19 -> END OF MEDIUM u'\x1a' # 0x1A -> SUBSTITUTE u'\x1b' # 0x1B -> ESCAPE u'\x1c' # 0x1C -> FILE SEPARATOR u'\x1d' # 0x1D -> GROUP SEPARATOR u'\x1e' # 0x1E -> RECORD SEPARATOR u'\x1f' # 0x1F -> UNIT SEPARATOR u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> DELETE u'\x80' # 0x80 -> <control> u'\x81' # 0x81 -> <control> u'\x82' # 0x82 -> <control> u'\x83' # 0x83 -> <control> u'\x84' # 0x84 -> <control> u'\x85' # 0x85 -> <control> u'\x86' # 0x86 -> <control> u'\x87' # 0x87 -> <control> u'\x88' # 0x88 -> <control> u'\x89' # 0x89 -> <control> u'\x8a' # 0x8A -> <control> u'\x8b' # 0x8B -> <control> u'\x8c' # 0x8C -> <control> u'\x8d' # 0x8D -> <control> u'\x8e' # 0x8E -> <control> u'\x8f' # 0x8F -> <control> u'\x90' # 0x90 -> <control> u'\x91' # 0x91 -> <control> u'\x92' # 0x92 -> <control> u'\x93' # 0x93 -> <control> u'\x94' # 0x94 -> <control> u'\x95' # 0x95 -> <control> u'\x96' # 0x96 -> <control> u'\x97' # 0x97 -> <control> u'\x98' # 0x98 -> <control> u'\x99' # 0x99 -> <control> u'\x9a' # 0x9A -> <control> u'\x9b' # 0x9B -> <control> u'\x9c' # 0x9C -> <control> u'\x9d' # 0x9D -> <control> u'\x9e' # 0x9E -> <control> u'\x9f' # 0x9F -> <control> u'\xa0' # 0xA0 -> NO-BREAK SPACE u'\u201d' # 0xA1 -> RIGHT DOUBLE QUOTATION MARK u'\xa2' # 0xA2 -> CENT SIGN u'\xa3' # 0xA3 -> POUND SIGN u'\xa4' # 0xA4 -> CURRENCY SIGN u'\u201e' # 0xA5 -> DOUBLE LOW-9 QUOTATION MARK u'\xa6' # 0xA6 -> BROKEN BAR u'\xa7' # 0xA7 -> SECTION SIGN u'\xd8' # 0xA8 -> LATIN CAPITAL LETTER O WITH STROKE u'\xa9' # 0xA9 -> COPYRIGHT SIGN u'\u0156' # 0xAA -> LATIN CAPITAL LETTER R WITH CEDILLA u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xac' # 0xAC -> NOT SIGN u'\xad' # 0xAD -> SOFT HYPHEN u'\xae' # 0xAE -> REGISTERED SIGN u'\xc6' # 0xAF -> LATIN CAPITAL LETTER AE u'\xb0' # 0xB0 -> DEGREE SIGN u'\xb1' # 0xB1 -> PLUS-MINUS SIGN u'\xb2' # 0xB2 -> SUPERSCRIPT TWO u'\xb3' # 0xB3 -> SUPERSCRIPT THREE u'\u201c' # 0xB4 -> LEFT DOUBLE QUOTATION MARK u'\xb5' # 0xB5 -> MICRO SIGN u'\xb6' # 0xB6 -> PILCROW SIGN u'\xb7' # 0xB7 -> MIDDLE DOT u'\xf8' # 0xB8 -> LATIN SMALL LETTER O WITH STROKE u'\xb9' # 0xB9 -> SUPERSCRIPT ONE u'\u0157' # 0xBA -> LATIN SMALL LETTER R WITH CEDILLA u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS u'\xe6' # 0xBF -> LATIN SMALL LETTER AE u'\u0104' # 0xC0 -> LATIN CAPITAL LETTER A WITH OGONEK u'\u012e' # 0xC1 -> LATIN CAPITAL LETTER I WITH OGONEK u'\u0100' # 0xC2 -> LATIN CAPITAL LETTER A WITH MACRON u'\u0106' # 0xC3 -> LATIN CAPITAL LETTER C WITH ACUTE u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE u'\u0118' # 0xC6 -> LATIN CAPITAL LETTER E WITH OGONEK u'\u0112' # 0xC7 -> LATIN CAPITAL LETTER E WITH MACRON u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE u'\u0179' # 0xCA -> LATIN CAPITAL LETTER Z WITH ACUTE u'\u0116' # 0xCB -> LATIN CAPITAL LETTER E WITH DOT ABOVE u'\u0122' # 0xCC -> LATIN CAPITAL LETTER G WITH CEDILLA u'\u0136' # 0xCD -> LATIN CAPITAL LETTER K WITH CEDILLA u'\u012a' # 0xCE -> LATIN CAPITAL LETTER I WITH MACRON u'\u013b' # 0xCF -> LATIN CAPITAL LETTER L WITH CEDILLA u'\u0160' # 0xD0 -> LATIN CAPITAL LETTER S WITH CARON u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE u'\u0145' # 0xD2 -> LATIN CAPITAL LETTER N WITH CEDILLA u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE u'\u014c' # 0xD4 -> LATIN CAPITAL LETTER O WITH MACRON u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xd7' # 0xD7 -> MULTIPLICATION SIGN u'\u0172' # 0xD8 -> LATIN CAPITAL LETTER U WITH OGONEK u'\u0141' # 0xD9 -> LATIN CAPITAL LETTER L WITH STROKE u'\u015a' # 0xDA -> LATIN CAPITAL LETTER S WITH ACUTE u'\u016a' # 0xDB -> LATIN CAPITAL LETTER U WITH MACRON u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\u017b' # 0xDD -> LATIN CAPITAL LETTER Z WITH DOT ABOVE u'\u017d' # 0xDE -> LATIN CAPITAL LETTER Z WITH CARON u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German) u'\u0105' # 0xE0 -> LATIN SMALL LETTER A WITH OGONEK u'\u012f' # 0xE1 -> LATIN SMALL LETTER I WITH OGONEK u'\u0101' # 0xE2 -> LATIN SMALL LETTER A WITH MACRON u'\u0107' # 0xE3 -> LATIN SMALL LETTER C WITH ACUTE u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE u'\u0119' # 0xE6 -> LATIN SMALL LETTER E WITH OGONEK u'\u0113' # 0xE7 -> LATIN SMALL LETTER E WITH MACRON u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE u'\u017a' # 0xEA -> LATIN SMALL LETTER Z WITH ACUTE u'\u0117' # 0xEB -> LATIN SMALL LETTER E WITH DOT ABOVE u'\u0123' # 0xEC -> LATIN SMALL LETTER G WITH CEDILLA u'\u0137' # 0xED -> LATIN SMALL LETTER K WITH CEDILLA u'\u012b' # 0xEE -> LATIN SMALL LETTER I WITH MACRON u'\u013c' # 0xEF -> LATIN SMALL LETTER L WITH CEDILLA u'\u0161' # 0xF0 -> LATIN SMALL LETTER S WITH CARON u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE u'\u0146' # 0xF2 -> LATIN SMALL LETTER N WITH CEDILLA u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE u'\u014d' # 0xF4 -> LATIN SMALL LETTER O WITH MACRON u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS u'\xf7' # 0xF7 -> DIVISION SIGN u'\u0173' # 0xF8 -> LATIN SMALL LETTER U WITH OGONEK u'\u0142' # 0xF9 -> LATIN SMALL LETTER L WITH STROKE u'\u015b' # 0xFA -> LATIN SMALL LETTER S WITH ACUTE u'\u016b' # 0xFB -> LATIN SMALL LETTER U WITH MACRON u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS u'\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE u'\u017e' # 0xFE -> LATIN SMALL LETTER Z WITH CARON u'\u2019' # 0xFF -> RIGHT SINGLE QUOTATION MARK ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
apache-2.0
[ 624, 2018, 17660, 12340, 13732, 11601, 4830, 63, 969, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 969, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 4830, 13, 969, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221 ]
[ 2018, 17660, 12340, 13732, 11601, 4830, 63, 969, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 969, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 4830, 13, 969, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221, 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, 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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 ]
fishtown-analytics/dbt
test/unit/test_linker.py
1
6077
import os import tempfile import unittest from unittest import mock from dbt import linker try: from queue import Empty except ImportError: from Queue import Empty def _mock_manifest(nodes): manifest = mock.MagicMock(nodes={ n: mock.MagicMock(unique_id=n) for n in nodes }) manifest.expect.side_effect = lambda n: mock.MagicMock(unique_id=n) return manifest class LinkerTest(unittest.TestCase): def setUp(self): self.patcher = mock.patch.object(linker, 'is_blocking_dependency') self.is_blocking_dependency = self.patcher.start() self.is_blocking_dependency.return_value = True self.linker = linker.Linker() def tearDown(self): self.patcher.stop() def test_linker_add_node(self): expected_nodes = ['A', 'B', 'C'] for node in expected_nodes: self.linker.add_node(node) actual_nodes = self.linker.nodes() for node in expected_nodes: self.assertIn(node, actual_nodes) self.assertEqual(len(actual_nodes), len(expected_nodes)) def test_linker_write_and_read_graph(self): expected_nodes = ['A', 'B', 'C'] for node in expected_nodes: self.linker.add_node(node) manifest = _mock_manifest('ABC') (fd, fname) = tempfile.mkstemp() os.close(fd) try: self.linker.write_graph(fname, manifest) new_linker = linker.from_file(fname) finally: os.unlink(fname) actual_nodes = new_linker.nodes() for node in expected_nodes: self.assertIn(node, actual_nodes) self.assertEqual(len(actual_nodes), len(expected_nodes)) def assert_would_join(self, queue): """test join() without timeout risk""" self.assertEqual(queue.inner.unfinished_tasks, 0) def test_linker_add_dependency(self): actual_deps = [('A', 'B'), ('A', 'C'), ('B', 'C')] for (l, r) in actual_deps: self.linker.dependency(l, r) manifest = _mock_manifest('ABC') queue = self.linker.as_graph_queue(manifest) got = queue.get(block=False) self.assertEqual(got.unique_id, 'C') with self.assertRaises(Empty): queue.get(block=False) self.assertFalse(queue.empty()) queue.mark_done('C') self.assertFalse(queue.empty()) got = queue.get(block=False) self.assertEqual(got.unique_id, 'B') with self.assertRaises(Empty): queue.get(block=False) self.assertFalse(queue.empty()) queue.mark_done('B') self.assertFalse(queue.empty()) got = queue.get(block=False) self.assertEqual(got.unique_id, 'A') with self.assertRaises(Empty): queue.get(block=False) self.assertTrue(queue.empty()) queue.mark_done('A') self.assert_would_join(queue) self.assertTrue(queue.empty()) def test_linker_add_disjoint_dependencies(self): actual_deps = [('A', 'B')] additional_node = 'Z' for (l, r) in actual_deps: self.linker.dependency(l, r) self.linker.add_node(additional_node) manifest = _mock_manifest('ABZ') queue = self.linker.as_graph_queue(manifest) # the first one we get must be B, it has the longest dep chain first = queue.get(block=False) self.assertEqual(first.unique_id, 'B') self.assertFalse(queue.empty()) queue.mark_done('B') self.assertFalse(queue.empty()) second = queue.get(block=False) self.assertIn(second.unique_id, {'A', 'Z'}) self.assertFalse(queue.empty()) queue.mark_done(second.unique_id) self.assertFalse(queue.empty()) third = queue.get(block=False) self.assertIn(third.unique_id, {'A', 'Z'}) with self.assertRaises(Empty): queue.get(block=False) self.assertNotEqual(second.unique_id, third.unique_id) self.assertTrue(queue.empty()) queue.mark_done(third.unique_id) self.assert_would_join(queue) self.assertTrue(queue.empty()) def test_linker_dependencies_limited_to_some_nodes(self): actual_deps = [('A', 'B'), ('B', 'C'), ('C', 'D')] for (l, r) in actual_deps: self.linker.dependency(l, r) queue = self.linker.as_graph_queue(_mock_manifest('ABCD'), ['B']) got = queue.get(block=False) self.assertEqual(got.unique_id, 'B') self.assertTrue(queue.empty()) queue.mark_done('B') self.assert_would_join(queue) queue_2 = self.linker.as_graph_queue(_mock_manifest('ABCD'), ['A', 'B']) got = queue_2.get(block=False) self.assertEqual(got.unique_id, 'B') self.assertFalse(queue_2.empty()) with self.assertRaises(Empty): queue_2.get(block=False) queue_2.mark_done('B') self.assertFalse(queue_2.empty()) got = queue_2.get(block=False) self.assertEqual(got.unique_id, 'A') self.assertTrue(queue_2.empty()) with self.assertRaises(Empty): queue_2.get(block=False) self.assertTrue(queue_2.empty()) queue_2.mark_done('A') self.assert_would_join(queue_2) def test_linker_bad_limit_throws_runtime_error(self): actual_deps = [('A', 'B'), ('B', 'C'), ('C', 'D')] for (l, r) in actual_deps: self.linker.dependency(l, r) with self.assertRaises(RuntimeError): self.linker.as_graph_queue(_mock_manifest('ABCD'), ['ZZZ']) def test__find_cycles__cycles(self): actual_deps = [('A', 'B'), ('B', 'C'), ('C', 'A')] for (l, r) in actual_deps: self.linker.dependency(l, r) self.assertIsNotNone(self.linker.find_cycles()) def test__find_cycles__no_cycles(self): actual_deps = [('A', 'B'), ('B', 'C'), ('C', 'D')] for (l, r) in actual_deps: self.linker.dependency(l, r) self.assertIsNone(self.linker.find_cycles())
apache-2.0
[ 646, 747, 199, 646, 5549, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 504, 1592, 84, 492, 17261, 199, 893, 26, 272, 687, 4126, 492, 9630, 199, 2590, 3545, 26, 272, 687, 10703, 492, 9630, 421, 199, 318, 485, 1805, 63, 6418, 8, 2415, 304, 272, 7712, 275, 1683, 14, 11988, 8, 2415, 3126, 267, 302, 26, 1683, 14, 11988, 8, 3235, 63, 344, 29, 78, 9, 367, 302, 315, 3380, 272, 3828, 272, 7712, 14, 4921, 14, 2441, 63, 5881, 275, 2400, 302, 26, 1683, 14, 11988, 8, 3235, 63, 344, 29, 78, 9, 272, 372, 7712, 421, 199, 533, 10967, 281, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 11238, 275, 1683, 14, 2068, 14, 785, 8, 20311, 12, 283, 374, 63, 13091, 63, 8575, 358, 267, 291, 14, 374, 63, 13091, 63, 8575, 275, 291, 14, 11238, 14, 928, 342, 267, 291, 14, 374, 63, 13091, 63, 8575, 14, 1107, 63, 585, 275, 715, 267, 291, 14, 20311, 275, 17261, 14, 3834, 281, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 11238, 14, 2379, 342, 339, 347, 511, 63, 20311, 63, 525, 63, 932, 8, 277, 304, 267, 1420, 63, 2415, 275, 788, 33, 297, 283, 34, 297, 283, 35, 418, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 20311, 14, 525, 63, 932, 8, 932, 9, 398, 3503, 63, 2415, 275, 291, 14, 20311, 14, 2415, 342, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 4080, 8, 932, 12, 3503, 63, 2415, 9, 398, 291, 14, 629, 8, 552, 8, 6514, 63, 2415, 395, 822, 8, 2062, 63, 2415, 430, 339, 347, 511, 63, 20311, 63, 952, 63, 460, 63, 739, 63, 2180, 8, 277, 304, 267, 1420, 63, 2415, 275, 788, 33, 297, 283, 34, 297, 283, 35, 418, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 20311, 14, 525, 63, 932, 8, 932, 9, 398, 7712, 275, 485, 1805, 63, 6418, 360, 8390, 358, 267, 334, 2592, 12, 6748, 9, 275, 5549, 14, 17721, 342, 267, 747, 14, 1600, 8, 2592, 9, 267, 862, 26, 288, 291, 14, 20311, 14, 952, 63, 2180, 8, 5252, 12, 7712, 9, 288, 892, 63, 20311, 275, 17261, 14, 504, 63, 493, 8, 5252, 9, 267, 3753, 26, 288, 747, 14, 7162, 8, 5252, 9, 398, 3503, 63, 2415, 275, 892, 63, 20311, 14, 2415, 342, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 4080, 8, 932, 12, 3503, 63, 2415, 9, 398, 291, 14, 629, 8, 552, 8, 6514, 63, 2415, 395, 822, 8, 2062, 63, 2415, 430, 339, 347, 702, 63, 2027, 854, 63, 904, 8, 277, 12, 4126, 304, 267, 408, 396, 4263, 342, 1928, 2653, 22633, 624, 267, 291, 14, 629, 8, 1825, 14, 5216, 14, 324, 8669, 63, 5054, 12, 378, 9, 339, 347, 511, 63, 20311, 63, 525, 63, 8575, 8, 277, 304, 267, 3503, 63, 5846, 275, 4274, 33, 297, 283, 34, 659, 661, 33, 297, 283, 35, 659, 661, 34, 297, 283, 35, 5440, 398, 367, 334, 76, 12, 519, 9, 315, 3503, 63, 5846, 26, 288, 291, 14, 20311, 14, 8575, 8, 76, 12, 519, 9, 398, 7712, 275, 485, 1805, 63, 6418, 360, 8390, 358, 267, 4126, 275, 291, 14, 20311, 14, 305, 63, 2180, 63, 1825, 8, 6418, 9, 398, 4788, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 7808, 14, 3235, 63, 344, 12, 283, 35, 358, 267, 543, 291, 14, 1855, 8, 4699, 304, 288, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 35, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 4788, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 7808, 14, 3235, 63, 344, 12, 283, 34, 358, 267, 543, 291, 14, 1855, 8, 4699, 304, 288, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 34, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 4788, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 7808, 14, 3235, 63, 344, 12, 283, 33, 358, 267, 543, 291, 14, 1855, 8, 4699, 304, 288, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 1815, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 33, 358, 267, 291, 14, 479, 63, 2027, 854, 63, 904, 8, 1825, 9, 267, 291, 14, 1815, 8, 1825, 14, 1667, 1012, 339, 347, 511, 63, 20311, 63, 525, 63, 31880, 63, 5714, 8, 277, 304, 267, 3503, 63, 5846, 275, 4274, 33, 297, 283, 34, 5440, 267, 4722, 63, 932, 275, 283, 58, 7, 398, 367, 334, 76, 12, 519, 9, 315, 3503, 63, 5846, 26, 288, 291, 14, 20311, 14, 8575, 8, 76, 12, 519, 9, 267, 291, 14, 20311, 14, 525, 63, 932, 8, 8460, 63, 932, 9, 7318, 7712, 275, 485, 1805, 63, 6418, 360, 1217, 58, 358, 267, 4126, 275, 291, 14, 20311, 14, 305, 63, 2180, 63, 1825, 8, 6418, 9, 398, 327, 314, 1642, 1373, 781, 664, 1471, 506, 699, 12, 652, 965, 314, 21303, 2657, 6036, 267, 1642, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 2246, 14, 3235, 63, 344, 12, 283, 34, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 34, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 3499, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 4080, 8, 4375, 14, 3235, 63, 344, 12, 791, 33, 297, 283, 58, 3071, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 8, 4375, 14, 3235, 63, 344, 9, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 10919, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 4080, 8, 11470 ]
[ 747, 199, 646, 5549, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 504, 1592, 84, 492, 17261, 199, 893, 26, 272, 687, 4126, 492, 9630, 199, 2590, 3545, 26, 272, 687, 10703, 492, 9630, 421, 199, 318, 485, 1805, 63, 6418, 8, 2415, 304, 272, 7712, 275, 1683, 14, 11988, 8, 2415, 3126, 267, 302, 26, 1683, 14, 11988, 8, 3235, 63, 344, 29, 78, 9, 367, 302, 315, 3380, 272, 3828, 272, 7712, 14, 4921, 14, 2441, 63, 5881, 275, 2400, 302, 26, 1683, 14, 11988, 8, 3235, 63, 344, 29, 78, 9, 272, 372, 7712, 421, 199, 533, 10967, 281, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 11238, 275, 1683, 14, 2068, 14, 785, 8, 20311, 12, 283, 374, 63, 13091, 63, 8575, 358, 267, 291, 14, 374, 63, 13091, 63, 8575, 275, 291, 14, 11238, 14, 928, 342, 267, 291, 14, 374, 63, 13091, 63, 8575, 14, 1107, 63, 585, 275, 715, 267, 291, 14, 20311, 275, 17261, 14, 3834, 281, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 11238, 14, 2379, 342, 339, 347, 511, 63, 20311, 63, 525, 63, 932, 8, 277, 304, 267, 1420, 63, 2415, 275, 788, 33, 297, 283, 34, 297, 283, 35, 418, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 20311, 14, 525, 63, 932, 8, 932, 9, 398, 3503, 63, 2415, 275, 291, 14, 20311, 14, 2415, 342, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 4080, 8, 932, 12, 3503, 63, 2415, 9, 398, 291, 14, 629, 8, 552, 8, 6514, 63, 2415, 395, 822, 8, 2062, 63, 2415, 430, 339, 347, 511, 63, 20311, 63, 952, 63, 460, 63, 739, 63, 2180, 8, 277, 304, 267, 1420, 63, 2415, 275, 788, 33, 297, 283, 34, 297, 283, 35, 418, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 20311, 14, 525, 63, 932, 8, 932, 9, 398, 7712, 275, 485, 1805, 63, 6418, 360, 8390, 358, 267, 334, 2592, 12, 6748, 9, 275, 5549, 14, 17721, 342, 267, 747, 14, 1600, 8, 2592, 9, 267, 862, 26, 288, 291, 14, 20311, 14, 952, 63, 2180, 8, 5252, 12, 7712, 9, 288, 892, 63, 20311, 275, 17261, 14, 504, 63, 493, 8, 5252, 9, 267, 3753, 26, 288, 747, 14, 7162, 8, 5252, 9, 398, 3503, 63, 2415, 275, 892, 63, 20311, 14, 2415, 342, 267, 367, 1031, 315, 1420, 63, 2415, 26, 288, 291, 14, 4080, 8, 932, 12, 3503, 63, 2415, 9, 398, 291, 14, 629, 8, 552, 8, 6514, 63, 2415, 395, 822, 8, 2062, 63, 2415, 430, 339, 347, 702, 63, 2027, 854, 63, 904, 8, 277, 12, 4126, 304, 267, 408, 396, 4263, 342, 1928, 2653, 22633, 624, 267, 291, 14, 629, 8, 1825, 14, 5216, 14, 324, 8669, 63, 5054, 12, 378, 9, 339, 347, 511, 63, 20311, 63, 525, 63, 8575, 8, 277, 304, 267, 3503, 63, 5846, 275, 4274, 33, 297, 283, 34, 659, 661, 33, 297, 283, 35, 659, 661, 34, 297, 283, 35, 5440, 398, 367, 334, 76, 12, 519, 9, 315, 3503, 63, 5846, 26, 288, 291, 14, 20311, 14, 8575, 8, 76, 12, 519, 9, 398, 7712, 275, 485, 1805, 63, 6418, 360, 8390, 358, 267, 4126, 275, 291, 14, 20311, 14, 305, 63, 2180, 63, 1825, 8, 6418, 9, 398, 4788, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 7808, 14, 3235, 63, 344, 12, 283, 35, 358, 267, 543, 291, 14, 1855, 8, 4699, 304, 288, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 35, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 4788, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 7808, 14, 3235, 63, 344, 12, 283, 34, 358, 267, 543, 291, 14, 1855, 8, 4699, 304, 288, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 34, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 4788, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 7808, 14, 3235, 63, 344, 12, 283, 33, 358, 267, 543, 291, 14, 1855, 8, 4699, 304, 288, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 1815, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 33, 358, 267, 291, 14, 479, 63, 2027, 854, 63, 904, 8, 1825, 9, 267, 291, 14, 1815, 8, 1825, 14, 1667, 1012, 339, 347, 511, 63, 20311, 63, 525, 63, 31880, 63, 5714, 8, 277, 304, 267, 3503, 63, 5846, 275, 4274, 33, 297, 283, 34, 5440, 267, 4722, 63, 932, 275, 283, 58, 7, 398, 367, 334, 76, 12, 519, 9, 315, 3503, 63, 5846, 26, 288, 291, 14, 20311, 14, 8575, 8, 76, 12, 519, 9, 267, 291, 14, 20311, 14, 525, 63, 932, 8, 8460, 63, 932, 9, 7318, 7712, 275, 485, 1805, 63, 6418, 360, 1217, 58, 358, 267, 4126, 275, 291, 14, 20311, 14, 305, 63, 2180, 63, 1825, 8, 6418, 9, 398, 327, 314, 1642, 1373, 781, 664, 1471, 506, 699, 12, 652, 965, 314, 21303, 2657, 6036, 267, 1642, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 629, 8, 2246, 14, 3235, 63, 344, 12, 283, 34, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 360, 34, 358, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 3499, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 4080, 8, 4375, 14, 3235, 63, 344, 12, 791, 33, 297, 283, 58, 3071, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 267, 4126, 14, 1657, 63, 4456, 8, 4375, 14, 3235, 63, 344, 9, 267, 291, 14, 3334, 8, 1825, 14, 1667, 1012, 398, 10919, 275, 4126, 14, 362, 8, 1457, 29, 797, 9, 267, 291, 14, 4080, 8, 11470, 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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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 ]
dronefly/dronefly.github.io
flask/lib/python2.7/site-packages/whoosh/matching/__init__.py
96
1678
# Copyright 2012 Matt Chaput. All rights reserved. # # 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 MATT CHAPUT ``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 MATT CHAPUT 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. # # The views and conclusions contained in the software and documentation are # those of the authors and should not be interpreted as representing official # policies, either expressed or implied, of Matt Chaput. from whoosh.matching.mcore import * from whoosh.matching.binary import * from whoosh.matching.wrappers import * from whoosh.matching.combo import *
apache-2.0
[ 3, 1898, 6029, 31653, 2799, 439, 337, 14, 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, 259, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 259, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 603, 11712, 6624, 1282, 934, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 199, 3, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 199, 3, 6461, 7000, 603, 11712, 6624, 1282, 934, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 199, 3, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 199, 3, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 710, 6858, 436, 406, 18540, 10470, 315, 314, 2032, 436, 3794, 787, 199, 3, 5204, 402, 314, 11462, 436, 1077, 440, 506, 11922, 465, 6144, 25410, 199, 3, 14118, 12, 1902, 19147, 503, 2478, 12, 402, 31653, 2799, 439, 337, 14, 199, 199, 504, 3963, 22267, 14, 9467, 14, 77, 1018, 492, 627, 199, 504, 3963, 22267, 14, 9467, 14, 3008, 492, 627, 199, 504, 3963, 22267, 14, 9467, 14, 21148, 492, 627, 199, 504, 3963, 22267, 14, 9467, 14, 12650, 492, 627, 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 ]
[ 1898, 6029, 31653, 2799, 439, 337, 14, 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, 259, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 259, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 603, 11712, 6624, 1282, 934, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 199, 3, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 199, 3, 6461, 7000, 603, 11712, 6624, 1282, 934, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 199, 3, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 199, 3, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 710, 6858, 436, 406, 18540, 10470, 315, 314, 2032, 436, 3794, 787, 199, 3, 5204, 402, 314, 11462, 436, 1077, 440, 506, 11922, 465, 6144, 25410, 199, 3, 14118, 12, 1902, 19147, 503, 2478, 12, 402, 31653, 2799, 439, 337, 14, 199, 199, 504, 3963, 22267, 14, 9467, 14, 77, 1018, 492, 627, 199, 504, 3963, 22267, 14, 9467, 14, 3008, 492, 627, 199, 504, 3963, 22267, 14, 9467, 14, 21148, 492, 627, 199, 504, 3963, 22267, 14, 9467, 14, 12650, 492, 627, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bumper-app/bumper-bianca
bianca/analyzer/bugfinder.py
1
3624
""" file: bugfinder.py author: Christoffer Rosen <cbr4830@rit.edu> date: November 2013 description: Links changes that introduces bugs by identifying changes that fix problems. """ import re from orm.commit import * from caslogging import logging from analyzer.git_commit_linker import * import json class BugFinder: """ BugFinder(): description: Links changes that introduces bugs. """ def __init__(self, allCommits, correctiveCommits, issueTracker): """ Constructor @param commits: All commits in ascending order by date @param correctiveCommits: All commits/changes which are identified as fixing problems. @param issueTracker: Issue tracker (e.g., GitHub Issues) """ self.allCommits = allCommits self.correctiveCommits = correctiveCommits self.issueTracker = issueTracker def findIssueOpened(self, correctiveCommit): """ findIssueIds() If the corrective change/commit links to a issue in the issue tracker, returns the date of oldest open issue found otherwise returns none """ issue_opened = None if(self.issueTracker is None or hasattr(self.issueTracker, "getDateOpened") == False): return None idMatch = re.compile('#[\d]+') issue_ids = idMatch.findall(correctiveCommit.commit_message) issue_ids = [issue_id.strip('#') for issue_id in issue_ids] # Remove the '#' from ids if len(issue_ids) > 0: issue_opened = self.issueTracker.getDateOpened(issue_ids[0]) # Use the oldest open bug for issue_id in issue_ids: logging.info('Searching for issue id: ' + issue_id) curr_issue_opened = self.issueTracker.getDateOpened(issue_id) # Verify that an issue was found. if curr_issue_opened is not None: if int(curr_issue_opened) < int(issue_opened): issue_opened = curr_issue_opened return issue_opened def searchForBuggyCommit(self, correctiveCommit): """ Finds the buggy commit based on the bug fixing commit Helper method for markBuggyCommits. If commir links to an issue tracker, we check files changed prior to this date. Otherwise, me only check date prior to the fix. @param correctiveCommits: the bug fixing commit """ bug_introduced_prior = correctiveCommit.author_date_unix_timestamp issue_opened = self.findIssueOpened(correctiveCommit) if issue_opened is not None: bug_introduced_prior = issue_opened if 'CAS_DELIMITER' in correctiveCommit.fileschanged: # Provide legacy support for the previous fileschanged format correctiveFiles = correctiveCommit.fileschanged.split(",CAS_DELIMITER,") else: correctiveFiles = json.loads(correctiveCommit.fileschanged) for commit in self.allCommits: if int(commit.author_date_unix_timestamp) < int(bug_introduced_prior): if 'CAS_DELIMITER' in commit.fileschanged: # Provide legacy support for the previous fileschanged format commitFiles = commit.fileschanged.split(",CAS_DELIMITER,") else: commitFiles = json.loads(commit.fileschanged) for commitFile in commitFiles: # This introudced the bug! if commitFile in correctiveFiles: return commit return -1 # Not found def markBuggyCommits(self): """ Finds bug inducing commits based on those that are bug fixing. It checks commits prior to this and determines it to be bug inducing if it changes the same file in a bug fixing commit """ for correctiveCommit in self.correctiveCommits: buggyCommit = self.searchForBuggyCommit(correctiveCommit) if buggyCommit is not -1: buggyCommit.contains_bug = True #else: #print("Cound not find the bug inducing commit for: " + # correctiveCommit.commit_message)
mit
[ 624, 199, 493, 26, 6519, 11681, 14, 647, 199, 2502, 26, 2799, 18824, 12786, 6848, 2464, 665, 2894, 82, 2006, 1216, 32, 11133, 14, 8654, 30, 199, 602, 26, 3091, 432, 976, 6171, 199, 1802, 26, 10967, 83, 4493, 626, 13318, 10569, 18227, 701, 21119, 4493, 199, 9099, 5325, 8826, 14, 199, 624, 199, 199, 646, 295, 199, 504, 9813, 14, 3543, 492, 627, 199, 504, 14984, 4806, 492, 2050, 199, 504, 24608, 14, 3187, 63, 3543, 63, 20311, 492, 627, 199, 646, 2022, 199, 199, 533, 21605, 11791, 26, 199, 198, 624, 199, 198, 17545, 11791, 837, 199, 198, 1802, 26, 10967, 83, 4493, 626, 13318, 10569, 18227, 14, 199, 198, 624, 421, 198, 318, 636, 826, 721, 277, 12, 1006, 5150, 1405, 12, 1970, 8374, 5150, 1405, 12, 4976, 13652, 304, 507, 198, 624, 507, 198, 11447, 2742, 198, 32, 635, 20835, 26, 2900, 20835, 315, 24525, 1865, 701, 1434, 507, 198, 32, 635, 1970, 8374, 5150, 1405, 26, 2900, 20835, 15, 6627, 1314, 787, 15836, 507, 198, 305, 5325, 316, 8826, 14, 507, 198, 32, 635, 4976, 13652, 26, 13383, 15271, 334, 69, 14, 71, 2020, 25141, 13383, 83, 9, 507, 198, 624, 507, 198, 277, 14, 452, 5150, 1405, 275, 1006, 5150, 1405, 507, 198, 277, 14, 989, 8374, 5150, 1405, 275, 1970, 8374, 5150, 1405, 507, 198, 277, 14, 5237, 13652, 275, 4976, 13652, 421, 198, 318, 2342, 17106, 4299, 379, 8, 277, 12, 1970, 8374, 11421, 304, 507, 198, 624, 507, 198, 1623, 17106, 11506, 342, 507, 198, 3917, 314, 1970, 8374, 1570, 15, 3543, 6220, 370, 282, 4976, 315, 314, 4976, 15271, 12, 2529, 507, 198, 1589, 1434, 402, 29493, 1551, 4976, 1911, 4257, 2529, 7179, 507, 198, 624, 507, 198, 5237, 63, 19234, 275, 488, 2742, 198, 692, 8, 277, 14, 5237, 13652, 365, 488, 503, 2688, 8, 277, 14, 5237, 13652, 12, 298, 362, 2506, 4299, 379, 531, 508, 756, 304, 686, 198, 1107, 488, 2742, 198, 344, 4486, 275, 295, 14, 2014, 7863, 7023, 68, 2807, 358, 507, 198, 5237, 63, 1580, 275, 1305, 4486, 14, 6452, 8, 989, 8374, 11421, 14, 3543, 63, 1188, 9, 507, 198, 5237, 63, 1580, 275, 359, 5237, 63, 344, 14, 1913, 7863, 358, 367, 4976, 63, 344, 315, 4976, 63, 1580, 61, 327, 5852, 314, 19619, 687, 2762, 2742, 198, 692, 822, 8, 5237, 63, 1580, 9, 690, 378, 26, 686, 198, 5237, 63, 19234, 275, 291, 14, 5237, 13652, 14, 362, 2506, 4299, 379, 8, 5237, 63, 1580, 59, 16, 566, 686, 198, 3, 3645, 314, 29493, 1551, 6519, 686, 198, 509, 4976, 63, 344, 315, 4976, 63, 1580, 26, 1585, 198, 4806, 14, 815, 360, 5278, 316, 367, 4976, 1305, 26, 283, 435, 4976, 63, 344, 9, 1585, 198, 9808, 63, 5237, 63, 19234, 275, 291, 14, 5237, 13652, 14, 362, 2506, 4299, 379, 8, 5237, 63, 344, 9, 16737, 198, 3, 7635, 626, 376, 4976, 1990, 1911, 14, 1585, 198, 692, 8230, 63, 5237, 63, 19234, 365, 440, 488, 26, 1871, 198, 692, 1109, 8, 9808, 63, 5237, 63, 19234, 9, 665, 1109, 8, 5237, 63, 19234, 304, 4671, 198, 5237, 63, 19234, 275, 8230, 63, 5237, 63, 19234, 2742, 198, 1107, 4976, 63, 19234, 421, 198, 318, 2754, 1858, 17545, 4312, 11421, 8, 277, 12, 1970, 8374, 11421, 304, 507, 198, 624, 507, 198, 30344, 314, 1032, 26435, 5532, 4079, 641, 314, 6519, 5325, 316, 5532, 507, 198, 4433, 1083, 367, 2216, 17545, 4312, 5150, 1405, 14, 982, 1923, 723, 6220, 370, 376, 507, 198, 5237, 15271, 12, 781, 1104, 1584, 2896, 6791, 370, 642, 1434, 14, 507, 198, 8632, 2605, 12, 562, 1454, 1104, 1434, 6791, 370, 314, 5325, 14, 2742, 198, 32, 635, 1970, 8374, 5150, 1405, 26, 314, 6519, 5325, 316, 5532, 507, 198, 624, 507, 198, 1266, 63, 18206, 16584, 63, 13775, 275, 1970, 8374, 11421, 14, 2502, 63, 602, 63, 11864, 63, 3954, 507, 198, 5237, 63, 19234, 275, 291, 14, 1623, 17106, 4299, 379, 8, 989, 8374, 11421, 9, 2742, 198, 692, 4976, 63, 19234, 365, 440, 488, 26, 686, 198, 1266, 63, 18206, 16584, 63, 13775, 275, 4976, 63, 19234, 2742, 198, 692, 283, 9777, 63, 32717, 540, 7, 315, 1970, 8374, 11421, 14, 1725, 2489, 26, 686, 198, 3, 22896, 12139, 2291, 367, 314, 4136, 1584, 2489, 1475, 686, 198, 989, 8374, 5535, 275, 1970, 8374, 11421, 14, 1725, 2489, 14, 1294, 11854, 9777, 63, 32717, 540, 12, 531, 507, 198, 2836, 26, 686, 198, 989, 8374, 5535, 275, 2022, 14, 3640, 8, 989, 8374, 11421, 14, 1725, 2489, 9, 2742, 198, 509, 5532, 315, 291, 14, 452, 5150, 1405, 26, 6319, 198, 692, 1109, 8, 3543, 14, 2502, 63, 602, 63, 11864, 63, 3954, 9, 665, 1109, 8, 1266, 63, 18206, 16584, 63, 13775, 304, 16737, 198, 692, 283, 9777, 63, 32717, 540, 7, 315, 5532, 14, 1725, 2489, 26, 1871, 198, 3, 22896, 12139, 2291, 367, 314, 4136, 1584, 2489, 1475, 1871, 198, 3543, 5535, 275, 5532, 14, 1725, 2489, 14, 1294, 11854, 9777, 63, 32717, 540, 12, 531, 1585, 198, 2836, 26, 1871, 198, 3543, 5535, 275, 2022, 14, 3640, 8, 3543, 14, 1725, 2489, 9, 16737, 198, 509, 5532, 1173, 315, 5532, 5535, 26, 28558, 198, 3, 961, 13318, 1181, 6867, 314, 6519, 1, 1871, 198, 692, 5532, 1173, 315, 1970, 8374, 5535, 26, 4671, 198, 1107, 5532, 2742, 198, 1107, 446, 17, 327, 2832, 1911, 421, 198, 318, 2216, 17545, 4312, 5150, 1405, 8, 277, 304, 507, 198, 624, 507, 198, 30344, 6519, 315, 14713, 20835, 4079, 641, 5204, 626, 787, 507, 198, 1266, 5325, 316, 14, 2779, 5920, 20835, 6791, 370, 642, 436, 16756, 507, 198, 390, 370, 506, 6519, 315, 14713, 340, 652, 4493, 314, 2011, 570, 315, 282, 6519, 5325, 316, 507, 198, 3543, 507, 198, 624, 2742, 198, 509, 1970, 8374, 11421, 315, 291, 14, 989, 8374, 5150, 1405, 26, 686, 198, 1266, 4312, 11421, 275, 291, 14, 1733, 1858, 17545, 4312, 11421, 8, 989, 8374, 11421, 9, 686, 198, 692, 1032, 26435, 11421, 365, 440, 446, 17, 26, 1585, 198, 1266, 4312, 11421, 14, 6134, 63, 1266, 275, 715, 686, 198, 3, 2836, 26, 1585 ]
[ 199, 493, 26, 6519, 11681, 14, 647, 199, 2502, 26, 2799, 18824, 12786, 6848, 2464, 665, 2894, 82, 2006, 1216, 32, 11133, 14, 8654, 30, 199, 602, 26, 3091, 432, 976, 6171, 199, 1802, 26, 10967, 83, 4493, 626, 13318, 10569, 18227, 701, 21119, 4493, 199, 9099, 5325, 8826, 14, 199, 624, 199, 199, 646, 295, 199, 504, 9813, 14, 3543, 492, 627, 199, 504, 14984, 4806, 492, 2050, 199, 504, 24608, 14, 3187, 63, 3543, 63, 20311, 492, 627, 199, 646, 2022, 199, 199, 533, 21605, 11791, 26, 199, 198, 624, 199, 198, 17545, 11791, 837, 199, 198, 1802, 26, 10967, 83, 4493, 626, 13318, 10569, 18227, 14, 199, 198, 624, 421, 198, 318, 636, 826, 721, 277, 12, 1006, 5150, 1405, 12, 1970, 8374, 5150, 1405, 12, 4976, 13652, 304, 507, 198, 624, 507, 198, 11447, 2742, 198, 32, 635, 20835, 26, 2900, 20835, 315, 24525, 1865, 701, 1434, 507, 198, 32, 635, 1970, 8374, 5150, 1405, 26, 2900, 20835, 15, 6627, 1314, 787, 15836, 507, 198, 305, 5325, 316, 8826, 14, 507, 198, 32, 635, 4976, 13652, 26, 13383, 15271, 334, 69, 14, 71, 2020, 25141, 13383, 83, 9, 507, 198, 624, 507, 198, 277, 14, 452, 5150, 1405, 275, 1006, 5150, 1405, 507, 198, 277, 14, 989, 8374, 5150, 1405, 275, 1970, 8374, 5150, 1405, 507, 198, 277, 14, 5237, 13652, 275, 4976, 13652, 421, 198, 318, 2342, 17106, 4299, 379, 8, 277, 12, 1970, 8374, 11421, 304, 507, 198, 624, 507, 198, 1623, 17106, 11506, 342, 507, 198, 3917, 314, 1970, 8374, 1570, 15, 3543, 6220, 370, 282, 4976, 315, 314, 4976, 15271, 12, 2529, 507, 198, 1589, 1434, 402, 29493, 1551, 4976, 1911, 4257, 2529, 7179, 507, 198, 624, 507, 198, 5237, 63, 19234, 275, 488, 2742, 198, 692, 8, 277, 14, 5237, 13652, 365, 488, 503, 2688, 8, 277, 14, 5237, 13652, 12, 298, 362, 2506, 4299, 379, 531, 508, 756, 304, 686, 198, 1107, 488, 2742, 198, 344, 4486, 275, 295, 14, 2014, 7863, 7023, 68, 2807, 358, 507, 198, 5237, 63, 1580, 275, 1305, 4486, 14, 6452, 8, 989, 8374, 11421, 14, 3543, 63, 1188, 9, 507, 198, 5237, 63, 1580, 275, 359, 5237, 63, 344, 14, 1913, 7863, 358, 367, 4976, 63, 344, 315, 4976, 63, 1580, 61, 327, 5852, 314, 19619, 687, 2762, 2742, 198, 692, 822, 8, 5237, 63, 1580, 9, 690, 378, 26, 686, 198, 5237, 63, 19234, 275, 291, 14, 5237, 13652, 14, 362, 2506, 4299, 379, 8, 5237, 63, 1580, 59, 16, 566, 686, 198, 3, 3645, 314, 29493, 1551, 6519, 686, 198, 509, 4976, 63, 344, 315, 4976, 63, 1580, 26, 1585, 198, 4806, 14, 815, 360, 5278, 316, 367, 4976, 1305, 26, 283, 435, 4976, 63, 344, 9, 1585, 198, 9808, 63, 5237, 63, 19234, 275, 291, 14, 5237, 13652, 14, 362, 2506, 4299, 379, 8, 5237, 63, 344, 9, 16737, 198, 3, 7635, 626, 376, 4976, 1990, 1911, 14, 1585, 198, 692, 8230, 63, 5237, 63, 19234, 365, 440, 488, 26, 1871, 198, 692, 1109, 8, 9808, 63, 5237, 63, 19234, 9, 665, 1109, 8, 5237, 63, 19234, 304, 4671, 198, 5237, 63, 19234, 275, 8230, 63, 5237, 63, 19234, 2742, 198, 1107, 4976, 63, 19234, 421, 198, 318, 2754, 1858, 17545, 4312, 11421, 8, 277, 12, 1970, 8374, 11421, 304, 507, 198, 624, 507, 198, 30344, 314, 1032, 26435, 5532, 4079, 641, 314, 6519, 5325, 316, 5532, 507, 198, 4433, 1083, 367, 2216, 17545, 4312, 5150, 1405, 14, 982, 1923, 723, 6220, 370, 376, 507, 198, 5237, 15271, 12, 781, 1104, 1584, 2896, 6791, 370, 642, 1434, 14, 507, 198, 8632, 2605, 12, 562, 1454, 1104, 1434, 6791, 370, 314, 5325, 14, 2742, 198, 32, 635, 1970, 8374, 5150, 1405, 26, 314, 6519, 5325, 316, 5532, 507, 198, 624, 507, 198, 1266, 63, 18206, 16584, 63, 13775, 275, 1970, 8374, 11421, 14, 2502, 63, 602, 63, 11864, 63, 3954, 507, 198, 5237, 63, 19234, 275, 291, 14, 1623, 17106, 4299, 379, 8, 989, 8374, 11421, 9, 2742, 198, 692, 4976, 63, 19234, 365, 440, 488, 26, 686, 198, 1266, 63, 18206, 16584, 63, 13775, 275, 4976, 63, 19234, 2742, 198, 692, 283, 9777, 63, 32717, 540, 7, 315, 1970, 8374, 11421, 14, 1725, 2489, 26, 686, 198, 3, 22896, 12139, 2291, 367, 314, 4136, 1584, 2489, 1475, 686, 198, 989, 8374, 5535, 275, 1970, 8374, 11421, 14, 1725, 2489, 14, 1294, 11854, 9777, 63, 32717, 540, 12, 531, 507, 198, 2836, 26, 686, 198, 989, 8374, 5535, 275, 2022, 14, 3640, 8, 989, 8374, 11421, 14, 1725, 2489, 9, 2742, 198, 509, 5532, 315, 291, 14, 452, 5150, 1405, 26, 6319, 198, 692, 1109, 8, 3543, 14, 2502, 63, 602, 63, 11864, 63, 3954, 9, 665, 1109, 8, 1266, 63, 18206, 16584, 63, 13775, 304, 16737, 198, 692, 283, 9777, 63, 32717, 540, 7, 315, 5532, 14, 1725, 2489, 26, 1871, 198, 3, 22896, 12139, 2291, 367, 314, 4136, 1584, 2489, 1475, 1871, 198, 3543, 5535, 275, 5532, 14, 1725, 2489, 14, 1294, 11854, 9777, 63, 32717, 540, 12, 531, 1585, 198, 2836, 26, 1871, 198, 3543, 5535, 275, 2022, 14, 3640, 8, 3543, 14, 1725, 2489, 9, 16737, 198, 509, 5532, 1173, 315, 5532, 5535, 26, 28558, 198, 3, 961, 13318, 1181, 6867, 314, 6519, 1, 1871, 198, 692, 5532, 1173, 315, 1970, 8374, 5535, 26, 4671, 198, 1107, 5532, 2742, 198, 1107, 446, 17, 327, 2832, 1911, 421, 198, 318, 2216, 17545, 4312, 5150, 1405, 8, 277, 304, 507, 198, 624, 507, 198, 30344, 6519, 315, 14713, 20835, 4079, 641, 5204, 626, 787, 507, 198, 1266, 5325, 316, 14, 2779, 5920, 20835, 6791, 370, 642, 436, 16756, 507, 198, 390, 370, 506, 6519, 315, 14713, 340, 652, 4493, 314, 2011, 570, 315, 282, 6519, 5325, 316, 507, 198, 3543, 507, 198, 624, 2742, 198, 509, 1970, 8374, 11421, 315, 291, 14, 989, 8374, 5150, 1405, 26, 686, 198, 1266, 4312, 11421, 275, 291, 14, 1733, 1858, 17545, 4312, 11421, 8, 989, 8374, 11421, 9, 686, 198, 692, 1032,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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 ]
tinkerinestudio/Tinkerine-Suite
TinkerineSuite/python/Lib/encodings/mac_farsi.py
593
15426
""" Python Character Mapping Codec mac_farsi generated from 'MAPPINGS/VENDORS/APPLE/FARSI.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='mac-farsi', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> CONTROL CHARACTER u'\x01' # 0x01 -> CONTROL CHARACTER u'\x02' # 0x02 -> CONTROL CHARACTER u'\x03' # 0x03 -> CONTROL CHARACTER u'\x04' # 0x04 -> CONTROL CHARACTER u'\x05' # 0x05 -> CONTROL CHARACTER u'\x06' # 0x06 -> CONTROL CHARACTER u'\x07' # 0x07 -> CONTROL CHARACTER u'\x08' # 0x08 -> CONTROL CHARACTER u'\t' # 0x09 -> CONTROL CHARACTER u'\n' # 0x0A -> CONTROL CHARACTER u'\x0b' # 0x0B -> CONTROL CHARACTER u'\x0c' # 0x0C -> CONTROL CHARACTER u'\r' # 0x0D -> CONTROL CHARACTER u'\x0e' # 0x0E -> CONTROL CHARACTER u'\x0f' # 0x0F -> CONTROL CHARACTER u'\x10' # 0x10 -> CONTROL CHARACTER u'\x11' # 0x11 -> CONTROL CHARACTER u'\x12' # 0x12 -> CONTROL CHARACTER u'\x13' # 0x13 -> CONTROL CHARACTER u'\x14' # 0x14 -> CONTROL CHARACTER u'\x15' # 0x15 -> CONTROL CHARACTER u'\x16' # 0x16 -> CONTROL CHARACTER u'\x17' # 0x17 -> CONTROL CHARACTER u'\x18' # 0x18 -> CONTROL CHARACTER u'\x19' # 0x19 -> CONTROL CHARACTER u'\x1a' # 0x1A -> CONTROL CHARACTER u'\x1b' # 0x1B -> CONTROL CHARACTER u'\x1c' # 0x1C -> CONTROL CHARACTER u'\x1d' # 0x1D -> CONTROL CHARACTER u'\x1e' # 0x1E -> CONTROL CHARACTER u'\x1f' # 0x1F -> CONTROL CHARACTER u' ' # 0x20 -> SPACE, left-right u'!' # 0x21 -> EXCLAMATION MARK, left-right u'"' # 0x22 -> QUOTATION MARK, left-right u'#' # 0x23 -> NUMBER SIGN, left-right u'$' # 0x24 -> DOLLAR SIGN, left-right u'%' # 0x25 -> PERCENT SIGN, left-right u'&' # 0x26 -> AMPERSAND, left-right u"'" # 0x27 -> APOSTROPHE, left-right u'(' # 0x28 -> LEFT PARENTHESIS, left-right u')' # 0x29 -> RIGHT PARENTHESIS, left-right u'*' # 0x2A -> ASTERISK, left-right u'+' # 0x2B -> PLUS SIGN, left-right u',' # 0x2C -> COMMA, left-right; in Arabic-script context, displayed as 0x066C ARABIC THOUSANDS SEPARATOR u'-' # 0x2D -> HYPHEN-MINUS, left-right u'.' # 0x2E -> FULL STOP, left-right; in Arabic-script context, displayed as 0x066B ARABIC DECIMAL SEPARATOR u'/' # 0x2F -> SOLIDUS, left-right u'0' # 0x30 -> DIGIT ZERO; in Arabic-script context, displayed as 0x06F0 EXTENDED ARABIC-INDIC DIGIT ZERO u'1' # 0x31 -> DIGIT ONE; in Arabic-script context, displayed as 0x06F1 EXTENDED ARABIC-INDIC DIGIT ONE u'2' # 0x32 -> DIGIT TWO; in Arabic-script context, displayed as 0x06F2 EXTENDED ARABIC-INDIC DIGIT TWO u'3' # 0x33 -> DIGIT THREE; in Arabic-script context, displayed as 0x06F3 EXTENDED ARABIC-INDIC DIGIT THREE u'4' # 0x34 -> DIGIT FOUR; in Arabic-script context, displayed as 0x06F4 EXTENDED ARABIC-INDIC DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE; in Arabic-script context, displayed as 0x06F5 EXTENDED ARABIC-INDIC DIGIT FIVE u'6' # 0x36 -> DIGIT SIX; in Arabic-script context, displayed as 0x06F6 EXTENDED ARABIC-INDIC DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN; in Arabic-script context, displayed as 0x06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT; in Arabic-script context, displayed as 0x06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE; in Arabic-script context, displayed as 0x06F9 EXTENDED ARABIC-INDIC DIGIT NINE u':' # 0x3A -> COLON, left-right u';' # 0x3B -> SEMICOLON, left-right u'<' # 0x3C -> LESS-THAN SIGN, left-right u'=' # 0x3D -> EQUALS SIGN, left-right u'>' # 0x3E -> GREATER-THAN SIGN, left-right u'?' # 0x3F -> QUESTION MARK, left-right u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET, left-right u'\\' # 0x5C -> REVERSE SOLIDUS, left-right u']' # 0x5D -> RIGHT SQUARE BRACKET, left-right u'^' # 0x5E -> CIRCUMFLEX ACCENT, left-right u'_' # 0x5F -> LOW LINE, left-right u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET, left-right u'|' # 0x7C -> VERTICAL LINE, left-right u'}' # 0x7D -> RIGHT CURLY BRACKET, left-right u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> CONTROL CHARACTER u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\xa0' # 0x81 -> NO-BREAK SPACE, right-left u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS u'\u06ba' # 0x8B -> ARABIC LETTER NOON GHUNNA u'\xab' # 0x8C -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE u'\u2026' # 0x93 -> HORIZONTAL ELLIPSIS, right-left u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE u'\xbb' # 0x98 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS u'\xf7' # 0x9B -> DIVISION SIGN, right-left u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS u' ' # 0xA0 -> SPACE, right-left u'!' # 0xA1 -> EXCLAMATION MARK, right-left u'"' # 0xA2 -> QUOTATION MARK, right-left u'#' # 0xA3 -> NUMBER SIGN, right-left u'$' # 0xA4 -> DOLLAR SIGN, right-left u'\u066a' # 0xA5 -> ARABIC PERCENT SIGN u'&' # 0xA6 -> AMPERSAND, right-left u"'" # 0xA7 -> APOSTROPHE, right-left u'(' # 0xA8 -> LEFT PARENTHESIS, right-left u')' # 0xA9 -> RIGHT PARENTHESIS, right-left u'*' # 0xAA -> ASTERISK, right-left u'+' # 0xAB -> PLUS SIGN, right-left u'\u060c' # 0xAC -> ARABIC COMMA u'-' # 0xAD -> HYPHEN-MINUS, right-left u'.' # 0xAE -> FULL STOP, right-left u'/' # 0xAF -> SOLIDUS, right-left u'\u06f0' # 0xB0 -> EXTENDED ARABIC-INDIC DIGIT ZERO, right-left (need override) u'\u06f1' # 0xB1 -> EXTENDED ARABIC-INDIC DIGIT ONE, right-left (need override) u'\u06f2' # 0xB2 -> EXTENDED ARABIC-INDIC DIGIT TWO, right-left (need override) u'\u06f3' # 0xB3 -> EXTENDED ARABIC-INDIC DIGIT THREE, right-left (need override) u'\u06f4' # 0xB4 -> EXTENDED ARABIC-INDIC DIGIT FOUR, right-left (need override) u'\u06f5' # 0xB5 -> EXTENDED ARABIC-INDIC DIGIT FIVE, right-left (need override) u'\u06f6' # 0xB6 -> EXTENDED ARABIC-INDIC DIGIT SIX, right-left (need override) u'\u06f7' # 0xB7 -> EXTENDED ARABIC-INDIC DIGIT SEVEN, right-left (need override) u'\u06f8' # 0xB8 -> EXTENDED ARABIC-INDIC DIGIT EIGHT, right-left (need override) u'\u06f9' # 0xB9 -> EXTENDED ARABIC-INDIC DIGIT NINE, right-left (need override) u':' # 0xBA -> COLON, right-left u'\u061b' # 0xBB -> ARABIC SEMICOLON u'<' # 0xBC -> LESS-THAN SIGN, right-left u'=' # 0xBD -> EQUALS SIGN, right-left u'>' # 0xBE -> GREATER-THAN SIGN, right-left u'\u061f' # 0xBF -> ARABIC QUESTION MARK u'\u274a' # 0xC0 -> EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left u'\u0621' # 0xC1 -> ARABIC LETTER HAMZA u'\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE u'\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE u'\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE u'\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW u'\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE u'\u0627' # 0xC7 -> ARABIC LETTER ALEF u'\u0628' # 0xC8 -> ARABIC LETTER BEH u'\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA u'\u062a' # 0xCA -> ARABIC LETTER TEH u'\u062b' # 0xCB -> ARABIC LETTER THEH u'\u062c' # 0xCC -> ARABIC LETTER JEEM u'\u062d' # 0xCD -> ARABIC LETTER HAH u'\u062e' # 0xCE -> ARABIC LETTER KHAH u'\u062f' # 0xCF -> ARABIC LETTER DAL u'\u0630' # 0xD0 -> ARABIC LETTER THAL u'\u0631' # 0xD1 -> ARABIC LETTER REH u'\u0632' # 0xD2 -> ARABIC LETTER ZAIN u'\u0633' # 0xD3 -> ARABIC LETTER SEEN u'\u0634' # 0xD4 -> ARABIC LETTER SHEEN u'\u0635' # 0xD5 -> ARABIC LETTER SAD u'\u0636' # 0xD6 -> ARABIC LETTER DAD u'\u0637' # 0xD7 -> ARABIC LETTER TAH u'\u0638' # 0xD8 -> ARABIC LETTER ZAH u'\u0639' # 0xD9 -> ARABIC LETTER AIN u'\u063a' # 0xDA -> ARABIC LETTER GHAIN u'[' # 0xDB -> LEFT SQUARE BRACKET, right-left u'\\' # 0xDC -> REVERSE SOLIDUS, right-left u']' # 0xDD -> RIGHT SQUARE BRACKET, right-left u'^' # 0xDE -> CIRCUMFLEX ACCENT, right-left u'_' # 0xDF -> LOW LINE, right-left u'\u0640' # 0xE0 -> ARABIC TATWEEL u'\u0641' # 0xE1 -> ARABIC LETTER FEH u'\u0642' # 0xE2 -> ARABIC LETTER QAF u'\u0643' # 0xE3 -> ARABIC LETTER KAF u'\u0644' # 0xE4 -> ARABIC LETTER LAM u'\u0645' # 0xE5 -> ARABIC LETTER MEEM u'\u0646' # 0xE6 -> ARABIC LETTER NOON u'\u0647' # 0xE7 -> ARABIC LETTER HEH u'\u0648' # 0xE8 -> ARABIC LETTER WAW u'\u0649' # 0xE9 -> ARABIC LETTER ALEF MAKSURA u'\u064a' # 0xEA -> ARABIC LETTER YEH u'\u064b' # 0xEB -> ARABIC FATHATAN u'\u064c' # 0xEC -> ARABIC DAMMATAN u'\u064d' # 0xED -> ARABIC KASRATAN u'\u064e' # 0xEE -> ARABIC FATHA u'\u064f' # 0xEF -> ARABIC DAMMA u'\u0650' # 0xF0 -> ARABIC KASRA u'\u0651' # 0xF1 -> ARABIC SHADDA u'\u0652' # 0xF2 -> ARABIC SUKUN u'\u067e' # 0xF3 -> ARABIC LETTER PEH u'\u0679' # 0xF4 -> ARABIC LETTER TTEH u'\u0686' # 0xF5 -> ARABIC LETTER TCHEH u'\u06d5' # 0xF6 -> ARABIC LETTER AE u'\u06a4' # 0xF7 -> ARABIC LETTER VEH u'\u06af' # 0xF8 -> ARABIC LETTER GAF u'\u0688' # 0xF9 -> ARABIC LETTER DDAL u'\u0691' # 0xFA -> ARABIC LETTER RREH u'{' # 0xFB -> LEFT CURLY BRACKET, right-left u'|' # 0xFC -> VERTICAL LINE, right-left u'}' # 0xFD -> RIGHT CURLY BRACKET, right-left u'\u0698' # 0xFE -> ARABIC LETTER JEH u'\u06d2' # 0xFF -> ARABIC LETTER YEH BARREE ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
agpl-3.0
[ 624, 2018, 17660, 12340, 13732, 4497, 63, 15315, 338, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 31683, 15, 38, 689, 2684, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 3088, 13, 15315, 338, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 8098, 9502, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 8098, 9502, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 8098, 9502, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 8098, 9502, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 8098, 9502, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 8098, 9502, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 8098, 9502, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 8098, 9502, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 8098, 9502, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8098, 9502, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 8098, 9502, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 8098, 9502, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 8098, 9502, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 8098, 9502, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 8098, 9502, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 8098, 9502, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 8098, 9502, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 8098, 9502, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 8098, 9502, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 8098, 9502, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 8098, 9502, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 8098, 9502, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 12, 3602, 13, 1019, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 12, 3602, 13, 1019, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 12, 3602, 13, 1019, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 12, 3602, 13, 1019, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 12, 3602, 13, 1019, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 12, 3602, 13, 1019, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 12, 3602, 13, 1019, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 12, 3602, 13, 1019, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 12, 3602, 13, 1019, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 12, 3602, 13, 1019, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 12, 3602, 13, 1019, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 12, 3602, 13, 1019, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 12, 3602, 13, 1019, 27, 315, 437, 24176, 13, 1579, 1067, 12, 9080, 465, 378, 88, 14045, 35, 9175, 377, 2979, 1668 ]
[ 2018, 17660, 12340, 13732, 4497, 63, 15315, 338, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 31683, 15, 38, 689, 2684, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 3088, 13, 15315, 338, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 8098, 9502, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 8098, 9502, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 8098, 9502, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 8098, 9502, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 8098, 9502, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 8098, 9502, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 8098, 9502, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 8098, 9502, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 8098, 9502, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8098, 9502, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 8098, 9502, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 8098, 9502, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 8098, 9502, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 8098, 9502, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 8098, 9502, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 8098, 9502, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 8098, 9502, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 8098, 9502, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 8098, 9502, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 8098, 9502, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 8098, 9502, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 8098, 9502, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 8098, 9502, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 12, 3602, 13, 1019, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 12, 3602, 13, 1019, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 12, 3602, 13, 1019, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 12, 3602, 13, 1019, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 12, 3602, 13, 1019, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 12, 3602, 13, 1019, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 12, 3602, 13, 1019, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 12, 3602, 13, 1019, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 12, 3602, 13, 1019, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 12, 3602, 13, 1019, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 12, 3602, 13, 1019, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 12, 3602, 13, 1019, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 12, 3602, 13, 1019, 27, 315, 437, 24176, 13, 1579, 1067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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
enriquesanchezb/practica_utad_2016
venv/lib/python2.7/site-packages/nltk/tokenize/stanford.py
3
3960
# -*- coding: utf-8 -*- # Natural Language Toolkit: Interface to the Stanford Tokenizer # # Copyright (C) 2001-2015 NLTK Project # Author: Steven Xu <xxu@student.unimelb.edu.au> # # URL: <http://nltk.org/> # For license information, see LICENSE.TXT from __future__ import unicode_literals, print_function import tempfile import os import json from subprocess import PIPE from nltk import compat from nltk.internals import find_jar, config_java, java, _java_options, find_jars_within_path from nltk.tokenize.api import TokenizerI _stanford_url = 'http://nlp.stanford.edu/software/tokenizer.shtml' class StanfordTokenizer(TokenizerI): r""" Interface to the Stanford Tokenizer >>> from nltk.tokenize import StanfordTokenizer >>> s = "Good muffins cost $3.88\nin New York. Please buy me\ntwo of them.\nThanks." >>> StanfordTokenizer().tokenize(s) ['Good', 'muffins', 'cost', '$', '3.88', 'in', 'New', 'York', '.', 'Please', 'buy', 'me', 'two', 'of', 'them', '.', 'Thanks', '.'] >>> s = "The colour of the wall is blue." >>> StanfordTokenizer(options={"americanize": True}).tokenize(s) ['The', 'color', 'of', 'the', 'wall', 'is', 'blue', '.'] """ _JAR = 'stanford-postagger.jar' def __init__(self, path_to_jar=None, encoding='utf8', options=None, verbose=False, java_options='-mx1000m'): self._stanford_jar = find_jar( self._JAR, path_to_jar, env_vars=('STANFORD_POSTAGGER',), searchpath=(), url=_stanford_url, verbose=verbose ) # Adding logging jar files to classpath stanford_dir = os.path.split(self._stanford_jar)[0] self._stanford_jar = tuple(find_jars_within_path(stanford_dir)) self._encoding = encoding self.java_options = java_options options = {} if options is None else options self._options_cmd = ','.join('{0}={1}'.format(key, val) for key, val in options.items()) @staticmethod def _parse_tokenized_output(s): return s.splitlines() def tokenize(self, s): """ Use stanford tokenizer's PTBTokenizer to tokenize multiple sentences. """ cmd = [ 'edu.stanford.nlp.process.PTBTokenizer', ] return self._parse_tokenized_output(self._execute(cmd, s)) def _execute(self, cmd, input_, verbose=False): encoding = self._encoding cmd.extend(['-charset', encoding]) _options_cmd = self._options_cmd if _options_cmd: cmd.extend(['-options', self._options_cmd]) default_options = ' '.join(_java_options) # Configure java. config_java(options=self.java_options, verbose=verbose) # Windows is incompatible with NamedTemporaryFile() without passing in delete=False. with tempfile.NamedTemporaryFile(mode='wb', delete=False) as input_file: # Write the actual sentences to the temporary input file if isinstance(input_, compat.text_type) and encoding: input_ = input_.encode(encoding) input_file.write(input_) input_file.flush() cmd.append(input_file.name) # Run the tagger and get the output. stdout, stderr = java(cmd, classpath=self._stanford_jar, stdout=PIPE, stderr=PIPE) stdout = stdout.decode(encoding) os.unlink(input_file.name) # Return java configurations to their default values. config_java(options=default_options, verbose=False) return stdout def setup_module(module): from nose import SkipTest try: StanfordTokenizer() except LookupError: raise SkipTest('doctests from nltk.tokenize.stanford are skipped because the stanford postagger jar doesn\'t exist')
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 653, 292, 4889, 8466, 15650, 6065, 26, 14816, 370, 314, 1933, 290, 18090, 8767, 1793, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 12521, 13, 7806, 24719, 15263, 7290, 202, 199, 3, 6529, 26, 17854, 1856, 1323, 85, 665, 2154, 85, 32, 5500, 14, 324, 1036, 6374, 14, 8654, 14, 3844, 30, 202, 199, 3, 202, 199, 3, 2851, 26, 665, 1014, 921, 7530, 2663, 14, 1308, 3133, 202, 199, 3, 2104, 4190, 2556, 12, 1937, 5113, 14, 17715, 2999, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 870, 63, 1593, 2999, 199, 646, 5549, 202, 199, 646, 747, 202, 199, 646, 2022, 202, 199, 504, 3873, 492, 22773, 2999, 199, 504, 24706, 492, 8434, 202, 199, 504, 24706, 14, 4404, 2551, 492, 2342, 63, 7338, 12, 1101, 63, 6138, 12, 12120, 12, 485, 6138, 63, 1419, 12, 2342, 63, 32262, 63, 12541, 63, 515, 2999, 199, 504, 24706, 14, 15246, 14, 1246, 492, 8767, 1793, 41, 2999, 199, 63, 9746, 18090, 63, 633, 275, 283, 1014, 921, 7530, 80, 14, 9746, 18090, 14, 8654, 15, 15619, 15, 13771, 14, 83, 1360, 7, 2999, 199, 533, 1933, 290, 18090, 21782, 8, 21782, 41, 304, 1128, 519, 624, 1128, 14816, 370, 314, 1933, 290, 18090, 8767, 1793, 2958, 1306, 687, 24706, 14, 15246, 492, 1933, 290, 18090, 21782, 1128, 1306, 308, 275, 298, 20652, 333, 3043, 3617, 7918, 2672, 19, 14, 1299, 60, 28693, 7053, 1488, 4708, 14, 221, 7754, 1032, 89, 562, 60, 343, 2027, 402, 3062, 3134, 78, 2719, 25088, 2122, 1128, 1306, 1933, 290, 18090, 21782, 1252, 15246, 8, 83, 9, 1128, 788, 20652, 297, 283, 77, 3043, 3617, 297, 283, 6336, 297, 283, 4268, 283, 19, 14, 1299, 297, 283, 262, 297, 283, 4665, 297, 283, 57, 4708, 297, 22608, 283, 8254, 297, 283, 31240, 297, 283, 278, 297, 283, 5601, 297, 283, 1618, 297, 283, 1589, 77, 297, 22608, 283, 2719, 25088, 297, 1987, 418, 1128, 1306, 308, 275, 298, 1918, 15706, 402, 314, 19882, 365, 10030, 2122, 1128, 1306, 1933, 290, 18090, 21782, 8, 1419, 8871, 313, 28775, 794, 582, 715, 21385, 15246, 8, 83, 9, 1128, 788, 1918, 297, 283, 2326, 297, 283, 1618, 297, 283, 1589, 297, 283, 7567, 297, 283, 374, 297, 283, 6304, 297, 1987, 418, 1128, 408, 2958, 485, 42, 689, 275, 283, 9746, 18090, 13, 1932, 16267, 14, 7338, 7, 2958, 347, 636, 826, 721, 277, 12, 931, 63, 475, 63, 7338, 29, 403, 12, 2644, 534, 1624, 24, 297, 1511, 29, 403, 12, 3376, 29, 797, 12, 12120, 63, 1419, 18274, 9457, 5279, 77, 735, 1039, 291, 423, 9746, 18090, 63, 7338, 275, 2342, 63, 7338, 8, 1675, 291, 423, 42, 689, 12, 931, 63, 475, 63, 7338, 12, 1675, 2589, 63, 2936, 7782, 840, 879, 2707, 36, 63, 4030, 1254, 11784, 5529, 1675, 2754, 515, 16729, 1166, 3699, 9746, 18090, 63, 633, 12, 1675, 3376, 29, 3832, 1039, 776, 13594, 327, 12934, 2050, 16290, 1584, 370, 1021, 515, 30199, 410, 290, 18090, 63, 694, 275, 747, 14, 515, 14, 1294, 8, 277, 423, 9746, 18090, 63, 7338, 2788, 16, 61, 1039, 291, 423, 9746, 18090, 63, 7338, 275, 2008, 8, 1623, 63, 32262, 63, 12541, 63, 515, 8, 9746, 18090, 63, 694, 430, 13594, 291, 423, 2991, 275, 2644, 1039, 291, 14, 6138, 63, 1419, 275, 12120, 63, 1419, 4341, 1511, 275, 1052, 340, 1511, 365, 488, 587, 1511, 1039, 291, 423, 1419, 63, 1760, 275, 12814, 904, 11117, 16, 93, 3126, 17, 5285, 908, 8, 498, 12, 1139, 9, 367, 790, 12, 1139, 315, 1511, 14, 1744, 1012, 2958, 768, 4639, 1128, 347, 485, 1122, 63, 1418, 1759, 63, 1199, 8, 83, 304, 1039, 372, 308, 14, 7644, 342, 2958, 347, 13343, 8, 277, 12, 308, 304, 1039, 408, 1039, 3645, 410, 290, 18090, 14803, 1159, 510, 20098, 21782, 370, 13343, 3663, 24256, 14, 1039, 408, 1039, 2088, 275, 359, 1675, 283, 8654, 14, 9746, 18090, 14, 7530, 80, 14, 1412, 14, 4189, 34, 21782, 297, 1039, 1622, 1039, 372, 291, 423, 1122, 63, 1418, 1759, 63, 1199, 8, 277, 423, 2526, 8, 1760, 12, 308, 430, 2958, 347, 485, 2526, 8, 277, 12, 2088, 12, 1324, 3131, 3376, 29, 797, 304, 1039, 2644, 275, 291, 423, 2991, 1039, 2088, 14, 2880, 24829, 6043, 297, 2644, 566, 1039, 485, 1419, 63, 1760, 275, 291, 423, 1419, 63, 1760, 1039, 340, 485, 1419, 63, 1760, 26, 1675, 2088, 14, 2880, 24829, 1419, 297, 291, 423, 1419, 63, 1760, 566, 4341, 849, 63, 1419, 275, 283, 1987, 904, 1547, 6138, 63, 1419, 9, 4341, 327, 15453, 12120, 14, 1039, 1101, 63, 6138, 8, 1419, 29, 277, 14, 6138, 63, 1419, 12, 3376, 29, 3832, 9, 4341, 327, 5417, 365, 18457, 543, 31825, 342, 1928, 9476, 315, 3145, 29, 797, 14, 1039, 543, 5549, 14, 19320, 8, 632, 534, 6603, 297, 3145, 29, 797, 9, 465, 1324, 63, 493, 26, 1675, 327, 6990, 314, 3503, 24256, 370, 314, 7937, 1324, 570, 1675, 340, 1228, 8, 1210, 3131, 8434, 14, 505, 63, 466, 9, 436, 2644, 26, 2628, 1324, 63, 275, 1324, 3754, 2143, 8, 2991, 9, 1675, 1324, 63, 493, 14, 952, 8, 1210, 4602, 1675, 1324, 63, 493, 14, 4939, 342, 11556, 2088, 14, 740, 8, 1210, 63, 493, 14, 354, 9, 11556, 327, 3378, 314, 1947, 836, 436, 664, 314, 1072, 14, 1675, 3839, 12, 4635, 275, 12120, 8, 1760, 12, 1021, 515, 29, 277, 423, 9746, 18090, 63, 7338, 12, 202, 3303, 3839, 29, 6089, 12, 4635, 29, 6089, 9, 1675, 3839, 275, 3839, 14, 2708, 8, 2991, 9, 4341, 747, 14, 7162, 8, 1210, 63, 493, 14, 354, 9, 4341, 327, 1432, 12120, 13422, 370, 3932, 849, 1338, 14, 1039, 1101, 63, 6138, 8, 1419, 29, 885, 63, 1419, 12, 3376, 29, 797, 9, 4341, 372, 3839, 8065, 199, 318, 3272, 63, 578, 8, 578, 304, 1128, 687, 11354, 492, 18795, 2958, 862, 26, 1039, 1933, 290, 18090, 21782, 342, 1128, 871, 19021, 26, 1039, 746, 18795, 360, 1301, 2219, 687, 24706, 14, 15246, 14, 9746, 18090, 787, 9645, 2952, 314, 410, 290, 18090 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 653, 292, 4889, 8466, 15650, 6065, 26, 14816, 370, 314, 1933, 290, 18090, 8767, 1793, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 12521, 13, 7806, 24719, 15263, 7290, 202, 199, 3, 6529, 26, 17854, 1856, 1323, 85, 665, 2154, 85, 32, 5500, 14, 324, 1036, 6374, 14, 8654, 14, 3844, 30, 202, 199, 3, 202, 199, 3, 2851, 26, 665, 1014, 921, 7530, 2663, 14, 1308, 3133, 202, 199, 3, 2104, 4190, 2556, 12, 1937, 5113, 14, 17715, 2999, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 870, 63, 1593, 2999, 199, 646, 5549, 202, 199, 646, 747, 202, 199, 646, 2022, 202, 199, 504, 3873, 492, 22773, 2999, 199, 504, 24706, 492, 8434, 202, 199, 504, 24706, 14, 4404, 2551, 492, 2342, 63, 7338, 12, 1101, 63, 6138, 12, 12120, 12, 485, 6138, 63, 1419, 12, 2342, 63, 32262, 63, 12541, 63, 515, 2999, 199, 504, 24706, 14, 15246, 14, 1246, 492, 8767, 1793, 41, 2999, 199, 63, 9746, 18090, 63, 633, 275, 283, 1014, 921, 7530, 80, 14, 9746, 18090, 14, 8654, 15, 15619, 15, 13771, 14, 83, 1360, 7, 2999, 199, 533, 1933, 290, 18090, 21782, 8, 21782, 41, 304, 1128, 519, 624, 1128, 14816, 370, 314, 1933, 290, 18090, 8767, 1793, 2958, 1306, 687, 24706, 14, 15246, 492, 1933, 290, 18090, 21782, 1128, 1306, 308, 275, 298, 20652, 333, 3043, 3617, 7918, 2672, 19, 14, 1299, 60, 28693, 7053, 1488, 4708, 14, 221, 7754, 1032, 89, 562, 60, 343, 2027, 402, 3062, 3134, 78, 2719, 25088, 2122, 1128, 1306, 1933, 290, 18090, 21782, 1252, 15246, 8, 83, 9, 1128, 788, 20652, 297, 283, 77, 3043, 3617, 297, 283, 6336, 297, 283, 4268, 283, 19, 14, 1299, 297, 283, 262, 297, 283, 4665, 297, 283, 57, 4708, 297, 22608, 283, 8254, 297, 283, 31240, 297, 283, 278, 297, 283, 5601, 297, 283, 1618, 297, 283, 1589, 77, 297, 22608, 283, 2719, 25088, 297, 1987, 418, 1128, 1306, 308, 275, 298, 1918, 15706, 402, 314, 19882, 365, 10030, 2122, 1128, 1306, 1933, 290, 18090, 21782, 8, 1419, 8871, 313, 28775, 794, 582, 715, 21385, 15246, 8, 83, 9, 1128, 788, 1918, 297, 283, 2326, 297, 283, 1618, 297, 283, 1589, 297, 283, 7567, 297, 283, 374, 297, 283, 6304, 297, 1987, 418, 1128, 408, 2958, 485, 42, 689, 275, 283, 9746, 18090, 13, 1932, 16267, 14, 7338, 7, 2958, 347, 636, 826, 721, 277, 12, 931, 63, 475, 63, 7338, 29, 403, 12, 2644, 534, 1624, 24, 297, 1511, 29, 403, 12, 3376, 29, 797, 12, 12120, 63, 1419, 18274, 9457, 5279, 77, 735, 1039, 291, 423, 9746, 18090, 63, 7338, 275, 2342, 63, 7338, 8, 1675, 291, 423, 42, 689, 12, 931, 63, 475, 63, 7338, 12, 1675, 2589, 63, 2936, 7782, 840, 879, 2707, 36, 63, 4030, 1254, 11784, 5529, 1675, 2754, 515, 16729, 1166, 3699, 9746, 18090, 63, 633, 12, 1675, 3376, 29, 3832, 1039, 776, 13594, 327, 12934, 2050, 16290, 1584, 370, 1021, 515, 30199, 410, 290, 18090, 63, 694, 275, 747, 14, 515, 14, 1294, 8, 277, 423, 9746, 18090, 63, 7338, 2788, 16, 61, 1039, 291, 423, 9746, 18090, 63, 7338, 275, 2008, 8, 1623, 63, 32262, 63, 12541, 63, 515, 8, 9746, 18090, 63, 694, 430, 13594, 291, 423, 2991, 275, 2644, 1039, 291, 14, 6138, 63, 1419, 275, 12120, 63, 1419, 4341, 1511, 275, 1052, 340, 1511, 365, 488, 587, 1511, 1039, 291, 423, 1419, 63, 1760, 275, 12814, 904, 11117, 16, 93, 3126, 17, 5285, 908, 8, 498, 12, 1139, 9, 367, 790, 12, 1139, 315, 1511, 14, 1744, 1012, 2958, 768, 4639, 1128, 347, 485, 1122, 63, 1418, 1759, 63, 1199, 8, 83, 304, 1039, 372, 308, 14, 7644, 342, 2958, 347, 13343, 8, 277, 12, 308, 304, 1039, 408, 1039, 3645, 410, 290, 18090, 14803, 1159, 510, 20098, 21782, 370, 13343, 3663, 24256, 14, 1039, 408, 1039, 2088, 275, 359, 1675, 283, 8654, 14, 9746, 18090, 14, 7530, 80, 14, 1412, 14, 4189, 34, 21782, 297, 1039, 1622, 1039, 372, 291, 423, 1122, 63, 1418, 1759, 63, 1199, 8, 277, 423, 2526, 8, 1760, 12, 308, 430, 2958, 347, 485, 2526, 8, 277, 12, 2088, 12, 1324, 3131, 3376, 29, 797, 304, 1039, 2644, 275, 291, 423, 2991, 1039, 2088, 14, 2880, 24829, 6043, 297, 2644, 566, 1039, 485, 1419, 63, 1760, 275, 291, 423, 1419, 63, 1760, 1039, 340, 485, 1419, 63, 1760, 26, 1675, 2088, 14, 2880, 24829, 1419, 297, 291, 423, 1419, 63, 1760, 566, 4341, 849, 63, 1419, 275, 283, 1987, 904, 1547, 6138, 63, 1419, 9, 4341, 327, 15453, 12120, 14, 1039, 1101, 63, 6138, 8, 1419, 29, 277, 14, 6138, 63, 1419, 12, 3376, 29, 3832, 9, 4341, 327, 5417, 365, 18457, 543, 31825, 342, 1928, 9476, 315, 3145, 29, 797, 14, 1039, 543, 5549, 14, 19320, 8, 632, 534, 6603, 297, 3145, 29, 797, 9, 465, 1324, 63, 493, 26, 1675, 327, 6990, 314, 3503, 24256, 370, 314, 7937, 1324, 570, 1675, 340, 1228, 8, 1210, 3131, 8434, 14, 505, 63, 466, 9, 436, 2644, 26, 2628, 1324, 63, 275, 1324, 3754, 2143, 8, 2991, 9, 1675, 1324, 63, 493, 14, 952, 8, 1210, 4602, 1675, 1324, 63, 493, 14, 4939, 342, 11556, 2088, 14, 740, 8, 1210, 63, 493, 14, 354, 9, 11556, 327, 3378, 314, 1947, 836, 436, 664, 314, 1072, 14, 1675, 3839, 12, 4635, 275, 12120, 8, 1760, 12, 1021, 515, 29, 277, 423, 9746, 18090, 63, 7338, 12, 202, 3303, 3839, 29, 6089, 12, 4635, 29, 6089, 9, 1675, 3839, 275, 3839, 14, 2708, 8, 2991, 9, 4341, 747, 14, 7162, 8, 1210, 63, 493, 14, 354, 9, 4341, 327, 1432, 12120, 13422, 370, 3932, 849, 1338, 14, 1039, 1101, 63, 6138, 8, 1419, 29, 885, 63, 1419, 12, 3376, 29, 797, 9, 4341, 372, 3839, 8065, 199, 318, 3272, 63, 578, 8, 578, 304, 1128, 687, 11354, 492, 18795, 2958, 862, 26, 1039, 1933, 290, 18090, 21782, 342, 1128, 871, 19021, 26, 1039, 746, 18795, 360, 1301, 2219, 687, 24706, 14, 15246, 14, 9746, 18090, 787, 9645, 2952, 314, 410, 290, 18090, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
danielpalomino/gem5
configs/common/Options.py
1
10060
# Copyright (c) 2006-2008 The Regents of The University of Michigan # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer; # redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution; # neither the name of the copyright holders nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Authors: Lisa Hsu import m5 from m5.defines import buildEnv from m5.objects import * from Benchmarks import * def addCommonOptions(parser): # system options parser.add_option("--cpu-type", type="choice", default="atomic", choices = ["atomic", "timing", "detailed", "inorder", "arm_detailed"], help = "type of cpu to run with") parser.add_option("--checker", action="store_true"); parser.add_option("-n", "--num-cpus", type="int", default=1) parser.add_option("--caches", action="store_true") parser.add_option("--l2cache", action="store_true") parser.add_option("--fastmem", action="store_true") parser.add_option("--clock", action="store", type="string", default='2GHz') parser.add_option("--num-dirs", type="int", default=1) parser.add_option("--num-l2caches", type="int", default=1) parser.add_option("--num-l3caches", type="int", default=1) parser.add_option("--l1d_size", type="string", default="64kB") parser.add_option("--l1i_size", type="string", default="32kB") parser.add_option("--l2_size", type="string", default="2MB") parser.add_option("--l3_size", type="string", default="16MB") parser.add_option("--l1d_assoc", type="int", default=2) parser.add_option("--l1i_assoc", type="int", default=2) parser.add_option("--l2_assoc", type="int", default=8) parser.add_option("--l3_assoc", type="int", default=16) parser.add_option("--cacheline_size", type="int", default=64) parser.add_option("--ruby", action="store_true") # Run duration options parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick, metavar="T", help="Stop after T ticks") parser.add_option("--maxtime", type="float") parser.add_option("-I", "--maxinsts", action="store", type="int", default=None, help="""Total number of instructions to simulate (default: run forever)""") parser.add_option("--work-item-id", action="store", type="int", help="the specific work id for exit & checkpointing") parser.add_option("--work-begin-cpu-id-exit", action="store", type="int", help="exit when work starts on the specified cpu") parser.add_option("--work-end-exit-count", action="store", type="int", help="exit at specified work end count") parser.add_option("--work-begin-exit-count", action="store", type="int", help="exit at specified work begin count") parser.add_option("--init-param", action="store", type="int", default=0, help="""Parameter available in simulation with m5 initparam""") # Checkpointing options ###Note that performing checkpointing via python script files will override ###checkpoint instructions built into binaries. parser.add_option("--take-checkpoints", action="store", type="string", help="<M,N> will take checkpoint at cycle M and every N cycles thereafter") parser.add_option("--max-checkpoints", action="store", type="int", help="the maximum number of checkpoints to drop", default=5) parser.add_option("--checkpoint-dir", action="store", type="string", help="Place all checkpoints in this absolute directory") parser.add_option("-r", "--checkpoint-restore", action="store", type="int", help="restore from checkpoint <N>") parser.add_option("--checkpoint-at-end", action="store_true", help="take a checkpoint at end of run") parser.add_option("--work-begin-checkpoint-count", action="store", type="int", help="checkpoint at specified work begin count") parser.add_option("--work-end-checkpoint-count", action="store", type="int", help="checkpoint at specified work end count") parser.add_option("--work-cpus-checkpoint-count", action="store", type="int", help="checkpoint and exit when active cpu count is reached") parser.add_option("--restore-with-cpu", action="store", type="choice", default="atomic", choices = ["atomic", "timing", "detailed", "inorder"], help = "cpu type for restoring from a checkpoint") # CPU Switching - default switch model goes from a checkpoint # to a timing simple CPU with caches to warm up, then to detailed CPU for # data measurement parser.add_option("--repeat-switch", action="store", type="int", default=None, help="switch back and forth between CPUs with period <N>") parser.add_option("-s", "--standard-switch", action="store", type="int", default=None, help="switch from timing to Detailed CPU after warmup period of <N>") parser.add_option("-p", "--prog-interval", type="int", help="CPU Progress Interval") # Fastforwarding and simpoint related materials parser.add_option("-W", "--warmup-insts", action="store", type="int", default=None, help="Warmup period in total instructions (requires --standard-switch)") parser.add_option("--bench", action="store", type="string", default=None, help="base names for --take-checkpoint and --checkpoint-restore") parser.add_option("-F", "--fast-forward", action="store", type="string", default=None, help="Number of instructions to fast forward before switching") parser.add_option("-S", "--simpoint", action="store_true", default=False, help="""Use workload simpoints as an instruction offset for --checkpoint-restore or --take-checkpoint.""") parser.add_option("--at-instruction", action="store_true", default=False, help="""Treat value of --checkpoint-restore or --take-checkpoint as a number of instructions.""") def addSEOptions(parser): # Benchmark options parser.add_option("-c", "--cmd", default="", help="The binary to run in syscall emulation mode.") parser.add_option("-o", "--options", default="", help="""The options to pass to the binary, use " " around the entire string""") parser.add_option("-i", "--input", default="", help="Read stdin from a file.") parser.add_option("--output", default="", help="Redirect stdout to a file.") parser.add_option("--errout", default="", help="Redirect stderr to a file.") def addFSOptions(parser): # Simulation options parser.add_option("--timesync", action="store_true", help="Prevent simulated time from getting ahead of real time") # System options parser.add_option("--kernel", action="store", type="string") parser.add_option("--script", action="store", type="string") parser.add_option("--frame-capture", action="store_true", help="Stores changed frame buffers from the VNC server to compressed "\ "files in the gem5 output directory") if buildEnv['TARGET_ISA'] == "arm": parser.add_option("--bare-metal", action="store_true", help="Provide the raw system without the linux specific bits") parser.add_option("--machine-type", action="store", type="choice", choices=ArmMachineType.map.keys(), default="RealView_PBX") # Benchmark options parser.add_option("--dual", action="store_true", help="Simulate two systems attached with an ethernet link") parser.add_option("-b", "--benchmark", action="store", type="string", dest="benchmark", help="Specify the benchmark to run. Available benchmarks: %s"\ % DefinedBenchmarks) # Metafile options parser.add_option("--etherdump", action="store", type="string", dest="etherdump", help="Specify the filename to dump a pcap capture of the" \ "ethernet traffic") # Disk Image Options parser.add_option("--disk-image", action="store", type="string", default=None, help="Path to the disk image to use.") # Memory Size Options parser.add_option("--mem-size", action="store", type="string", default=None, help="Specify the physical memory size (single memory)")
bsd-3-clause
[ 3, 1898, 334, 67, 9, 8315, 13, 9300, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 491, 13655, 869, 9648, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 27067, 83, 492, 627, 199, 199, 318, 1050, 7844, 4558, 8, 2087, 304, 272, 327, 2656, 1511, 272, 1798, 14, 525, 63, 1422, 6739, 3541, 13, 466, 401, 730, 628, 5095, 401, 849, 628, 10910, 401, 1993, 3415, 275, 2097, 10910, 401, 298, 14639, 401, 298, 19170, 401, 298, 262, 1648, 401, 639, 298, 5362, 63, 19170, 2255, 1993, 1720, 275, 298, 466, 402, 5033, 370, 1255, 543, 531, 272, 1798, 14, 525, 63, 1422, 6739, 6743, 401, 1595, 628, 1617, 63, 2052, 3547, 272, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 1507, 13, 8896, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 17595, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 18, 1637, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1798, 14, 525, 63, 1422, 6739, 7015, 5286, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1798, 14, 525, 63, 1422, 6739, 9597, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 849, 534, 18, 39, 13026, 358, 272, 1798, 14, 525, 63, 1422, 6739, 1507, 13, 3220, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 1507, 13, 76, 18, 17595, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 1507, 13, 76, 19, 17595, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 68, 63, 890, 401, 730, 628, 875, 401, 849, 628, 772, 75, 34, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 73, 63, 890, 401, 730, 628, 875, 401, 849, 628, 708, 75, 34, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 18, 63, 890, 401, 730, 628, 875, 401, 849, 628, 18, 4567, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 19, 63, 890, 401, 730, 628, 875, 401, 849, 628, 975, 4567, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 68, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 18, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 73, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 18, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 18, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 24, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 19, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 975, 9, 272, 1798, 14, 525, 63, 1422, 6739, 20138, 32347, 63, 890, 401, 730, 628, 442, 401, 849, 29, 772, 9, 272, 1798, 14, 525, 63, 1422, 6739, 21952, 401, 1595, 628, 1617, 63, 2052, 531, 339, 327, 3378, 7373, 1511, 272, 1798, 14, 525, 63, 1422, 6096, 77, 401, 4320, 988, 8284, 401, 730, 628, 442, 401, 849, 29, 77, 21, 14, 4261, 11763, 12, 1993, 8214, 628, 52, 401, 1720, 628, 6293, 2410, 377, 17779, 531, 272, 1798, 14, 525, 63, 1422, 6739, 988, 521, 401, 730, 628, 1609, 531, 272, 1798, 14, 525, 63, 1422, 6096, 41, 401, 4320, 988, 3615, 83, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 849, 29, 403, 12, 1720, 11916, 7316, 1329, 402, 15794, 370, 4490, 20577, 334, 885, 26, 1255, 28688, 9, 6141, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 1053, 13, 344, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 1720, 628, 1589, 2488, 1736, 1305, 367, 4458, 1253, 9997, 316, 531, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 5037, 13, 3541, 13, 344, 13, 2224, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 1720, 628, 2224, 1380, 1736, 9174, 641, 314, 2013, 5033, 531, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 500, 13, 2224, 13, 835, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 1720, 628, 2224, 737, 2013, 1736, 1284, 2338, 531, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 5037, 13, 2224, 13, 835, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993 ]
[ 1898, 334, 67, 9, 8315, 13, 9300, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 491, 13655, 869, 9648, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 27067, 83, 492, 627, 199, 199, 318, 1050, 7844, 4558, 8, 2087, 304, 272, 327, 2656, 1511, 272, 1798, 14, 525, 63, 1422, 6739, 3541, 13, 466, 401, 730, 628, 5095, 401, 849, 628, 10910, 401, 1993, 3415, 275, 2097, 10910, 401, 298, 14639, 401, 298, 19170, 401, 298, 262, 1648, 401, 639, 298, 5362, 63, 19170, 2255, 1993, 1720, 275, 298, 466, 402, 5033, 370, 1255, 543, 531, 272, 1798, 14, 525, 63, 1422, 6739, 6743, 401, 1595, 628, 1617, 63, 2052, 3547, 272, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 1507, 13, 8896, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 17595, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 18, 1637, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1798, 14, 525, 63, 1422, 6739, 7015, 5286, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1798, 14, 525, 63, 1422, 6739, 9597, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 849, 534, 18, 39, 13026, 358, 272, 1798, 14, 525, 63, 1422, 6739, 1507, 13, 3220, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 1507, 13, 76, 18, 17595, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 1507, 13, 76, 19, 17595, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 68, 63, 890, 401, 730, 628, 875, 401, 849, 628, 772, 75, 34, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 73, 63, 890, 401, 730, 628, 875, 401, 849, 628, 708, 75, 34, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 18, 63, 890, 401, 730, 628, 875, 401, 849, 628, 18, 4567, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 19, 63, 890, 401, 730, 628, 875, 401, 849, 628, 975, 4567, 531, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 68, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 18, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 17, 73, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 18, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 18, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 24, 9, 272, 1798, 14, 525, 63, 1422, 6739, 76, 19, 63, 16824, 401, 730, 628, 442, 401, 849, 29, 975, 9, 272, 1798, 14, 525, 63, 1422, 6739, 20138, 32347, 63, 890, 401, 730, 628, 442, 401, 849, 29, 772, 9, 272, 1798, 14, 525, 63, 1422, 6739, 21952, 401, 1595, 628, 1617, 63, 2052, 531, 339, 327, 3378, 7373, 1511, 272, 1798, 14, 525, 63, 1422, 6096, 77, 401, 4320, 988, 8284, 401, 730, 628, 442, 401, 849, 29, 77, 21, 14, 4261, 11763, 12, 1993, 8214, 628, 52, 401, 1720, 628, 6293, 2410, 377, 17779, 531, 272, 1798, 14, 525, 63, 1422, 6739, 988, 521, 401, 730, 628, 1609, 531, 272, 1798, 14, 525, 63, 1422, 6096, 41, 401, 4320, 988, 3615, 83, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 849, 29, 403, 12, 1720, 11916, 7316, 1329, 402, 15794, 370, 4490, 20577, 334, 885, 26, 1255, 28688, 9, 6141, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 1053, 13, 344, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 1720, 628, 1589, 2488, 1736, 1305, 367, 4458, 1253, 9997, 316, 531, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 5037, 13, 3541, 13, 344, 13, 2224, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 1720, 628, 2224, 1380, 1736, 9174, 641, 314, 2013, 5033, 531, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 500, 13, 2224, 13, 835, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 1720, 628, 2224, 737, 2013, 1736, 1284, 2338, 531, 272, 1798, 14, 525, 63, 1422, 6739, 800, 13, 5037, 13, 2224, 13, 835, 401, 1595, 628, 1617, 401, 730, 628, 442, 401, 1993, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
astrofrog/glue-3d-viewer
glue_vispy_viewers/extern/vispy/util/svg/group.py
9
1894
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2014, Nicolas P. Rougier. All rights reserved. # Distributed under the terms of the new BSD License. # ----------------------------------------------------------------------------- import copy from ...util import logger from . path import Path from . base import namespace from . transformable import Transformable class Group(Transformable): def __init__(self, content=None, parent=None): Transformable.__init__(self, content, parent) self._items = [] for element in content: if not element.tag.startswith(namespace): continue tag = element.tag[len(namespace):] if tag == "g": item = Group(element, self) elif tag == "path": item = Path(element, self) else: logger.warn("Unhandled SVG tag (%s)" % tag) continue self._items.append(item) @property def flatten(self): i = 0 L = copy.deepcopy(self._items) while i < len(L): while isinstance(L[i], Group) and len(L[i]._items): L[i:i + 1] = L[i]._items i += 1 return L @property def paths(self): return [item for item in self.flatten if isinstance(item, Path)] def __repr__(self): s = "" for item in self._items: s += repr(item) return s @property def xml(self): return self._xml() def _xml(self, prefix=""): s = prefix + "<g " s += 'id="%s" ' % self._id s += self._transform.xml s += self._style.xml s += ">\n" for item in self._items: s += item._xml(prefix=prefix + " ") s += prefix + "</g>\n" return s
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 13722, 199, 3, 1898, 334, 67, 9, 6927, 12, 30650, 761, 305, 510, 14, 19776, 71, 4446, 14, 2900, 4481, 4644, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 892, 6289, 844, 14, 199, 3, 13722, 199, 199, 646, 1331, 199, 504, 2263, 1974, 492, 2512, 199, 504, 1275, 931, 492, 6912, 199, 504, 1275, 1300, 492, 3231, 199, 504, 1275, 5793, 461, 492, 19463, 461, 421, 199, 533, 5611, 8, 6939, 461, 304, 339, 347, 636, 826, 721, 277, 12, 1564, 29, 403, 12, 1676, 29, 403, 304, 267, 19463, 461, 855, 826, 721, 277, 12, 1564, 12, 1676, 9, 398, 291, 423, 1744, 275, 942, 267, 367, 1819, 315, 1564, 26, 288, 340, 440, 1819, 14, 1450, 14, 2460, 8, 3251, 304, 355, 1980, 288, 1947, 275, 1819, 14, 1450, 59, 552, 8, 3251, 15405, 288, 340, 1947, 508, 298, 71, 582, 355, 1242, 275, 5611, 8, 2108, 12, 291, 9, 288, 916, 1947, 508, 298, 515, 582, 355, 1242, 275, 6912, 8, 2108, 12, 291, 9, 288, 587, 26, 355, 2512, 14, 4050, 480, 1358, 11217, 32062, 1947, 4366, 83, 2924, 450, 1947, 9, 355, 1980, 288, 291, 423, 1744, 14, 740, 8, 1053, 9, 339, 768, 1829, 272, 347, 9378, 8, 277, 304, 267, 284, 275, 378, 267, 491, 275, 1331, 14, 8293, 8, 277, 423, 1744, 9, 267, 1830, 284, 665, 822, 8, 44, 304, 288, 1830, 1228, 8, 44, 59, 73, 467, 5611, 9, 436, 822, 8, 44, 59, 73, 18289, 1744, 304, 355, 491, 59, 73, 26, 73, 435, 413, 61, 275, 491, 59, 73, 18289, 1744, 288, 284, 847, 413, 267, 372, 491, 339, 768, 1829, 272, 347, 3792, 8, 277, 304, 267, 372, 359, 1053, 367, 1242, 315, 291, 14, 8487, 340, 1228, 8, 1053, 12, 6912, 1874, 339, 347, 636, 2722, 721, 277, 304, 267, 308, 275, 3087, 267, 367, 1242, 315, 291, 423, 1744, 26, 288, 308, 847, 4700, 8, 1053, 9, 267, 372, 308, 339, 768, 1829, 272, 347, 2748, 8, 277, 304, 267, 372, 291, 423, 1652, 342, 339, 347, 485, 1652, 8, 277, 12, 2403, 17364, 267, 308, 275, 2403, 435, 3886, 71, 298, 267, 308, 847, 283, 344, 5961, 83, 2, 283, 450, 291, 423, 344, 267, 308, 847, 291, 423, 4711, 14, 1652, 267, 308, 847, 291, 423, 2487, 14, 1652, 267, 308, 847, 298, 3072, 78, 2, 267, 367, 1242, 315, 291, 423, 1744, 26, 288, 308, 847, 1242, 423, 1652, 8, 1861, 29, 1861, 435, 298, 257, 6099, 267, 308, 847, 2403, 435, 15683, 71, 3072, 78, 2, 267, 372, 308, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 13722, 199, 3, 1898, 334, 67, 9, 6927, 12, 30650, 761, 305, 510, 14, 19776, 71, 4446, 14, 2900, 4481, 4644, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 892, 6289, 844, 14, 199, 3, 13722, 199, 199, 646, 1331, 199, 504, 2263, 1974, 492, 2512, 199, 504, 1275, 931, 492, 6912, 199, 504, 1275, 1300, 492, 3231, 199, 504, 1275, 5793, 461, 492, 19463, 461, 421, 199, 533, 5611, 8, 6939, 461, 304, 339, 347, 636, 826, 721, 277, 12, 1564, 29, 403, 12, 1676, 29, 403, 304, 267, 19463, 461, 855, 826, 721, 277, 12, 1564, 12, 1676, 9, 398, 291, 423, 1744, 275, 942, 267, 367, 1819, 315, 1564, 26, 288, 340, 440, 1819, 14, 1450, 14, 2460, 8, 3251, 304, 355, 1980, 288, 1947, 275, 1819, 14, 1450, 59, 552, 8, 3251, 15405, 288, 340, 1947, 508, 298, 71, 582, 355, 1242, 275, 5611, 8, 2108, 12, 291, 9, 288, 916, 1947, 508, 298, 515, 582, 355, 1242, 275, 6912, 8, 2108, 12, 291, 9, 288, 587, 26, 355, 2512, 14, 4050, 480, 1358, 11217, 32062, 1947, 4366, 83, 2924, 450, 1947, 9, 355, 1980, 288, 291, 423, 1744, 14, 740, 8, 1053, 9, 339, 768, 1829, 272, 347, 9378, 8, 277, 304, 267, 284, 275, 378, 267, 491, 275, 1331, 14, 8293, 8, 277, 423, 1744, 9, 267, 1830, 284, 665, 822, 8, 44, 304, 288, 1830, 1228, 8, 44, 59, 73, 467, 5611, 9, 436, 822, 8, 44, 59, 73, 18289, 1744, 304, 355, 491, 59, 73, 26, 73, 435, 413, 61, 275, 491, 59, 73, 18289, 1744, 288, 284, 847, 413, 267, 372, 491, 339, 768, 1829, 272, 347, 3792, 8, 277, 304, 267, 372, 359, 1053, 367, 1242, 315, 291, 14, 8487, 340, 1228, 8, 1053, 12, 6912, 1874, 339, 347, 636, 2722, 721, 277, 304, 267, 308, 275, 3087, 267, 367, 1242, 315, 291, 423, 1744, 26, 288, 308, 847, 4700, 8, 1053, 9, 267, 372, 308, 339, 768, 1829, 272, 347, 2748, 8, 277, 304, 267, 372, 291, 423, 1652, 342, 339, 347, 485, 1652, 8, 277, 12, 2403, 17364, 267, 308, 275, 2403, 435, 3886, 71, 298, 267, 308, 847, 283, 344, 5961, 83, 2, 283, 450, 291, 423, 344, 267, 308, 847, 291, 423, 4711, 14, 1652, 267, 308, 847, 291, 423, 2487, 14, 1652, 267, 308, 847, 298, 3072, 78, 2, 267, 367, 1242, 315, 291, 423, 1744, 26, 288, 308, 847, 1242, 423, 1652, 8, 1861, 29, 1861, 435, 298, 257, 6099, 267, 308, 847, 2403, 435, 15683, 71, 3072, 78, 2, 267, 372, 308, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
simonlynen/or-tools
examples/python/appointments.py
32
5392
# Copyright 2010-2014 Google # 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 google.apputils import app import gflags from ortools.constraint_solver import pywrapcp from ortools.linear_solver import pywraplp FLAGS = gflags.FLAGS gflags.DEFINE_integer('load_min', 480, 'Minimum load in minutes') gflags.DEFINE_integer('load_max', 540, 'Maximum load in minutes') gflags.DEFINE_integer('commute_time', 30, 'Commute time in minutes') gflags.DEFINE_integer('num_workers', 98, 'Maximum number of workers.') def FindCombinations(durations, load_min, load_max, commute_time): """This methods find all valid combinations of appointments. This methods find all combinations of appointments such that the sum of durations + commute times is between load_min and load_max. Args: durations: The durations of all appointments. load_min: The min number of worked minutes for a valid selection. load_max: The max number of worked minutes for a valid selection. commute_time: The commute time between two appointments in minutes. Returns: A matrix where each line is a valid combinations of appointments. """ solver = pywrapcp.Solver('FindCombinations') variables = [solver.IntVar(0, load_max / (i + commute_time)) for i in durations] lengths = [i + commute_time for i in durations] solver.Add(solver.ScalProd(variables, lengths) >= load_min) solver.Add(solver.ScalProd(variables, lengths) <= load_max) db = solver.Phase(variables, solver.CHOOSE_FIRST_UNBOUND, solver.ASSIGN_MIN_VALUE) results = [] solver.NewSearch(db) while solver.NextSolution(): combination = [v.Value() for v in variables] results.append(combination) solver.EndSearch() return results def Select(combinations, loads, max_number_of_workers): """This method selects the optimal combination of appointments. This method uses Mixed Integer Programming to select the optimal mix of appointments. """ solver = pywraplp.Solver('Select', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING) num_vars = len(loads) num_combinations = len(combinations) variables = [solver.IntVar(0, max_number_of_workers, 's[%d]' % i) for i in range(num_combinations)] achieved = [solver.IntVar(0, 1000, 'achieved[%d]' % i) for i in range(num_vars)] transposed = [[combinations[type][index] for type in range(num_combinations)] for index in range(num_vars)] # Maintain the achieved variables. for i in range(len(transposed)): ct = solver.Constraint(0.0, 0.0) ct.SetCoefficient(achieved[i], -1) coefs = transposed[i] for j in range(len(coefs)): ct.SetCoefficient(variables[j], coefs[j]) # Simple bound. solver.Add(solver.Sum(variables) <= max_number_of_workers) obj_vars = [solver.IntVar(0, 1000, 'obj_vars[%d]' % i) for i in range(num_vars)] for i in range(num_vars): solver.Add(obj_vars[i] >= achieved[i] - loads[i]) solver.Add(obj_vars[i] >= loads[i] - achieved[i]) solver.Minimize(solver.Sum(obj_vars)) result_status = solver.Solve() # The problem has an optimal solution. if result_status == pywraplp.Solver.OPTIMAL: print 'Problem solved in %f milliseconds' % solver.WallTime() return solver.Objective().Value(), [int(v.SolutionValue()) for v in variables] return -1, [] def GetOptimalSchedule(demand): """Computes the optimal schedule for the appointment selection problem.""" combinations = FindCombinations([a[2] for a in demand], FLAGS.load_min, FLAGS.load_max, FLAGS.commute_time) print 'found %d possible combinations of appointements' % len(combinations) cost, selection = Select(combinations, [a[0] for a in demand], FLAGS.num_workers) output = [(selection[i], [(combinations[i][t], demand[t][1]) for t in range(len(demand)) if combinations[i][t] != 0]) for i in range(len(selection)) if selection[i] != 0] return cost, output def main(unused_argv): demand = [(40, 'A1', 90), (30, 'A2', 120), (25, 'A3', 180)] print 'appointments: ' for a in demand: print ' %d * %s : %d min' % (a[0], a[1], a[2]) print 'commute time = %d' % FLAGS.commute_time print 'accepted total duration = [%d..%d]' % (FLAGS.load_min, FLAGS.load_max) print '%d workers' % FLAGS.num_workers cost, selection = GetOptimalSchedule(demand) print 'Optimal solution as a cost of %d' % cost for template in selection: print '%d schedules with ' % template[0] for t in template[1]: print ' %d installation of type %s' % (t[0], t[1]) if __name__ == '__main__': app.run()
apache-2.0
[ 3, 1898, 7129, 13, 7280, 4475, 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, 199, 199, 504, 6233, 14, 571, 1208, 492, 1145, 199, 646, 486, 2469, 199, 504, 221, 361, 5998, 14, 5631, 63, 11263, 492, 1134, 3823, 1850, 199, 504, 221, 361, 5998, 14, 6676, 63, 11263, 492, 1134, 87, 345, 1168, 80, 199, 199, 4831, 275, 486, 2469, 14, 4831, 199, 71, 2469, 14, 14603, 63, 4115, 360, 912, 63, 827, 297, 29504, 12, 283, 12092, 2248, 315, 9395, 358, 199, 71, 2469, 14, 14603, 63, 4115, 360, 912, 63, 988, 297, 959, 2167, 12, 283, 10915, 2248, 315, 9395, 358, 199, 71, 2469, 14, 14603, 63, 4115, 360, 1404, 938, 63, 521, 297, 4233, 12, 283, 5150, 938, 900, 315, 9395, 358, 199, 71, 2469, 14, 14603, 63, 4115, 360, 1507, 63, 11009, 297, 16096, 12, 283, 10915, 1329, 402, 14123, 2659, 421, 199, 318, 6668, 17039, 1298, 8, 68, 6556, 12, 2248, 63, 827, 12, 2248, 63, 988, 12, 1923, 938, 63, 521, 304, 523, 408, 2765, 3102, 2342, 1006, 1686, 15821, 402, 2771, 1403, 1470, 14, 819, 961, 3102, 2342, 1006, 15821, 402, 2771, 1403, 1470, 4066, 626, 314, 3089, 402, 523, 366, 6556, 435, 1923, 938, 5431, 365, 3382, 2248, 63, 827, 436, 2248, 63, 988, 14, 819, 3033, 26, 272, 366, 6556, 26, 710, 366, 6556, 402, 1006, 2771, 1403, 1470, 14, 272, 2248, 63, 827, 26, 710, 1748, 1329, 402, 26731, 9395, 367, 282, 1686, 7267, 14, 272, 2248, 63, 988, 26, 710, 1390, 1329, 402, 26731, 9395, 367, 282, 1686, 7267, 14, 272, 1923, 938, 63, 521, 26, 710, 1923, 938, 900, 3382, 2877, 2771, 1403, 1470, 315, 9395, 14, 523, 1803, 26, 272, 437, 3634, 2382, 1924, 1004, 365, 282, 1686, 15821, 402, 2771, 1403, 1470, 14, 523, 408, 523, 10196, 275, 1134, 3823, 1850, 14, 24755, 360, 6591, 17039, 1298, 358, 523, 2860, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 2248, 63, 988, 1182, 334, 73, 435, 1923, 938, 63, 521, 430, 2049, 367, 284, 315, 366, 6556, 61, 523, 17464, 275, 359, 73, 435, 1923, 938, 63, 521, 367, 284, 315, 366, 6556, 61, 523, 10196, 14, 1123, 8, 11263, 14, 10249, 30966, 8, 3669, 12, 17464, 9, 2356, 2248, 63, 827, 9, 523, 10196, 14, 1123, 8, 11263, 14, 10249, 30966, 8, 3669, 12, 17464, 9, 2695, 2248, 63, 988, 9, 523, 1592, 275, 10196, 14, 10521, 8, 3669, 12, 490, 10196, 14, 1244, 5757, 899, 63, 12903, 63, 1734, 17882, 12, 490, 10196, 14, 23680, 63, 4896, 63, 7041, 9, 523, 2058, 275, 942, 523, 10196, 14, 4665, 5278, 8, 697, 9, 523, 1830, 10196, 14, 5765, 24277, 837, 272, 14665, 275, 359, 86, 14, 1110, 342, 367, 373, 315, 2860, 61, 272, 2058, 14, 740, 8, 6560, 3155, 9, 523, 10196, 14, 3005, 5278, 342, 523, 372, 2058, 421, 199, 318, 9496, 8, 18026, 12, 14404, 12, 1390, 63, 1955, 63, 1618, 63, 11009, 304, 523, 408, 2765, 1083, 24750, 314, 22081, 14665, 402, 2771, 1403, 1470, 14, 819, 961, 1083, 4440, 21203, 7225, 2165, 9258, 370, 3504, 314, 22081, 13667, 402, 523, 2771, 1403, 1470, 14, 523, 408, 523, 10196, 275, 1134, 87, 345, 1168, 80, 14, 24755, 360, 5446, 297, 2574, 1134, 87, 345, 1168, 80, 14, 24755, 14, 18255, 63, 25543, 1149, 63, 9596, 63, 15605, 45, 1206, 9, 523, 1967, 63, 2936, 275, 822, 8, 3640, 9, 523, 1967, 63, 18026, 275, 822, 8, 18026, 9, 523, 2860, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 1390, 63, 1955, 63, 1618, 63, 11009, 12, 283, 83, 9722, 68, 6616, 450, 284, 9, 2049, 367, 284, 315, 1425, 8, 1507, 63, 18026, 1874, 523, 22175, 1354, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 5198, 12, 283, 1225, 1873, 1354, 9722, 68, 6616, 450, 284, 9, 1598, 367, 284, 315, 1425, 8, 1507, 63, 2936, 1874, 523, 1752, 5824, 275, 3474, 18026, 59, 466, 1527, 1080, 61, 367, 730, 315, 1425, 8, 1507, 63, 18026, 1874, 355, 367, 1478, 315, 1425, 8, 1507, 63, 2936, 1874, 819, 327, 16593, 8368, 314, 22175, 1354, 2860, 14, 523, 367, 284, 315, 1425, 8, 552, 8, 1515, 5824, 2298, 272, 9428, 275, 10196, 14, 8463, 8, 16, 14, 16, 12, 378, 14, 16, 9, 272, 9428, 14, 1084, 967, 21069, 8, 1225, 1873, 1354, 59, 73, 467, 446, 17, 9, 272, 29879, 275, 1752, 5824, 59, 73, 61, 272, 367, 1335, 315, 1425, 8, 552, 8, 22892, 2298, 489, 9428, 14, 1084, 967, 21069, 8, 3669, 59, 74, 467, 29879, 59, 74, 566, 819, 327, 5870, 3914, 14, 523, 10196, 14, 1123, 8, 11263, 14, 6959, 8, 3669, 9, 2695, 1390, 63, 1955, 63, 1618, 63, 11009, 9, 819, 1559, 63, 2936, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 5198, 12, 283, 1113, 63, 2936, 9722, 68, 6616, 450, 284, 9, 1598, 367, 284, 315, 1425, 8, 1507, 63, 2936, 1874, 523, 367, 284, 315, 1425, 8, 1507, 63, 2936, 304, 272, 10196, 14, 1123, 8, 1113, 63, 2936, 59, 73, 61, 2356, 22175, 1354, 59, 73, 61, 446, 14404, 59, 73, 566, 272, 10196, 14, 1123, 8, 1113, 63, 2936, 59, 73, 61, 2356, 14404, 59, 73, 61, 446, 22175, 1354, 59, 73, 566, 819, 10196, 14, 4649, 11807, 8, 11263, 14, 6959, 8, 1113, 63, 2936, 430, 819, 754, 63, 1205, 275, 10196, 14, 51, 3344, 342 ]
[ 1898, 7129, 13, 7280, 4475, 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, 199, 199, 504, 6233, 14, 571, 1208, 492, 1145, 199, 646, 486, 2469, 199, 504, 221, 361, 5998, 14, 5631, 63, 11263, 492, 1134, 3823, 1850, 199, 504, 221, 361, 5998, 14, 6676, 63, 11263, 492, 1134, 87, 345, 1168, 80, 199, 199, 4831, 275, 486, 2469, 14, 4831, 199, 71, 2469, 14, 14603, 63, 4115, 360, 912, 63, 827, 297, 29504, 12, 283, 12092, 2248, 315, 9395, 358, 199, 71, 2469, 14, 14603, 63, 4115, 360, 912, 63, 988, 297, 959, 2167, 12, 283, 10915, 2248, 315, 9395, 358, 199, 71, 2469, 14, 14603, 63, 4115, 360, 1404, 938, 63, 521, 297, 4233, 12, 283, 5150, 938, 900, 315, 9395, 358, 199, 71, 2469, 14, 14603, 63, 4115, 360, 1507, 63, 11009, 297, 16096, 12, 283, 10915, 1329, 402, 14123, 2659, 421, 199, 318, 6668, 17039, 1298, 8, 68, 6556, 12, 2248, 63, 827, 12, 2248, 63, 988, 12, 1923, 938, 63, 521, 304, 523, 408, 2765, 3102, 2342, 1006, 1686, 15821, 402, 2771, 1403, 1470, 14, 819, 961, 3102, 2342, 1006, 15821, 402, 2771, 1403, 1470, 4066, 626, 314, 3089, 402, 523, 366, 6556, 435, 1923, 938, 5431, 365, 3382, 2248, 63, 827, 436, 2248, 63, 988, 14, 819, 3033, 26, 272, 366, 6556, 26, 710, 366, 6556, 402, 1006, 2771, 1403, 1470, 14, 272, 2248, 63, 827, 26, 710, 1748, 1329, 402, 26731, 9395, 367, 282, 1686, 7267, 14, 272, 2248, 63, 988, 26, 710, 1390, 1329, 402, 26731, 9395, 367, 282, 1686, 7267, 14, 272, 1923, 938, 63, 521, 26, 710, 1923, 938, 900, 3382, 2877, 2771, 1403, 1470, 315, 9395, 14, 523, 1803, 26, 272, 437, 3634, 2382, 1924, 1004, 365, 282, 1686, 15821, 402, 2771, 1403, 1470, 14, 523, 408, 523, 10196, 275, 1134, 3823, 1850, 14, 24755, 360, 6591, 17039, 1298, 358, 523, 2860, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 2248, 63, 988, 1182, 334, 73, 435, 1923, 938, 63, 521, 430, 2049, 367, 284, 315, 366, 6556, 61, 523, 17464, 275, 359, 73, 435, 1923, 938, 63, 521, 367, 284, 315, 366, 6556, 61, 523, 10196, 14, 1123, 8, 11263, 14, 10249, 30966, 8, 3669, 12, 17464, 9, 2356, 2248, 63, 827, 9, 523, 10196, 14, 1123, 8, 11263, 14, 10249, 30966, 8, 3669, 12, 17464, 9, 2695, 2248, 63, 988, 9, 523, 1592, 275, 10196, 14, 10521, 8, 3669, 12, 490, 10196, 14, 1244, 5757, 899, 63, 12903, 63, 1734, 17882, 12, 490, 10196, 14, 23680, 63, 4896, 63, 7041, 9, 523, 2058, 275, 942, 523, 10196, 14, 4665, 5278, 8, 697, 9, 523, 1830, 10196, 14, 5765, 24277, 837, 272, 14665, 275, 359, 86, 14, 1110, 342, 367, 373, 315, 2860, 61, 272, 2058, 14, 740, 8, 6560, 3155, 9, 523, 10196, 14, 3005, 5278, 342, 523, 372, 2058, 421, 199, 318, 9496, 8, 18026, 12, 14404, 12, 1390, 63, 1955, 63, 1618, 63, 11009, 304, 523, 408, 2765, 1083, 24750, 314, 22081, 14665, 402, 2771, 1403, 1470, 14, 819, 961, 1083, 4440, 21203, 7225, 2165, 9258, 370, 3504, 314, 22081, 13667, 402, 523, 2771, 1403, 1470, 14, 523, 408, 523, 10196, 275, 1134, 87, 345, 1168, 80, 14, 24755, 360, 5446, 297, 2574, 1134, 87, 345, 1168, 80, 14, 24755, 14, 18255, 63, 25543, 1149, 63, 9596, 63, 15605, 45, 1206, 9, 523, 1967, 63, 2936, 275, 822, 8, 3640, 9, 523, 1967, 63, 18026, 275, 822, 8, 18026, 9, 523, 2860, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 1390, 63, 1955, 63, 1618, 63, 11009, 12, 283, 83, 9722, 68, 6616, 450, 284, 9, 2049, 367, 284, 315, 1425, 8, 1507, 63, 18026, 1874, 523, 22175, 1354, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 5198, 12, 283, 1225, 1873, 1354, 9722, 68, 6616, 450, 284, 9, 1598, 367, 284, 315, 1425, 8, 1507, 63, 2936, 1874, 523, 1752, 5824, 275, 3474, 18026, 59, 466, 1527, 1080, 61, 367, 730, 315, 1425, 8, 1507, 63, 18026, 1874, 355, 367, 1478, 315, 1425, 8, 1507, 63, 2936, 1874, 819, 327, 16593, 8368, 314, 22175, 1354, 2860, 14, 523, 367, 284, 315, 1425, 8, 552, 8, 1515, 5824, 2298, 272, 9428, 275, 10196, 14, 8463, 8, 16, 14, 16, 12, 378, 14, 16, 9, 272, 9428, 14, 1084, 967, 21069, 8, 1225, 1873, 1354, 59, 73, 467, 446, 17, 9, 272, 29879, 275, 1752, 5824, 59, 73, 61, 272, 367, 1335, 315, 1425, 8, 552, 8, 22892, 2298, 489, 9428, 14, 1084, 967, 21069, 8, 3669, 59, 74, 467, 29879, 59, 74, 566, 819, 327, 5870, 3914, 14, 523, 10196, 14, 1123, 8, 11263, 14, 6959, 8, 3669, 9, 2695, 1390, 63, 1955, 63, 1618, 63, 11009, 9, 819, 1559, 63, 2936, 275, 359, 11263, 14, 3241, 5894, 8, 16, 12, 5198, 12, 283, 1113, 63, 2936, 9722, 68, 6616, 450, 284, 9, 1598, 367, 284, 315, 1425, 8, 1507, 63, 2936, 1874, 523, 367, 284, 315, 1425, 8, 1507, 63, 2936, 304, 272, 10196, 14, 1123, 8, 1113,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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 ]
batisteo/pasportaservo
hosting/migrations/0002_auto_20140924_0745.py
5
5088
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('hosting', '0001_initial'), ] operations = [ migrations.RemoveField( model_name='place', name='small_description', ), migrations.AddField( model_name='condition', name='abbr', field=models.CharField(max_length=20, help_text="Official abbreviation as used in the book. E.g.: 'Nef.'", default='', verbose_name='name'), preserve_default=False, ), migrations.AddField( model_name='condition', name='slug', field=models.SlugField(default=''), preserve_default=False, ), migrations.AddField( model_name='place', name='closest_city', field=models.CharField(blank=True, max_length=255, help_text='If you place is in a town near a bigger city.', default='', verbose_name='closest big city'), preserve_default=False, ), migrations.AddField( model_name='place', name='have_a_drink', field=models.BooleanField(help_text='If you are ready to have a coffee or beer with visitors.', default=False, verbose_name='have a drink'), preserve_default=True, ), migrations.AddField( model_name='place', name='short_description', field=models.CharField(blank=True, max_length=140, help_text='Used in the book, 140 character maximum.', default='', verbose_name='short description'), preserve_default=False, ), migrations.AddField( model_name='place', name='tour_guide', field=models.BooleanField(help_text='If you are ready to show your area to visitors.', default=False, verbose_name='tour guide'), preserve_default=True, ), migrations.AddField( model_name='profile', name='avatar', field=models.ImageField(blank=True, upload_to='avatars', default='', verbose_name='avatar'), preserve_default=False, ), migrations.AddField( model_name='profile', name='description', field=models.TextField(blank=True, help_text='All about yourself.', default='', verbose_name='description'), preserve_default=False, ), migrations.AddField( model_name='profile', name='first_name', field=models.CharField(blank=True, max_length=255, default='', verbose_name='first name'), preserve_default=False, ), migrations.AddField( model_name='profile', name='last_name', field=models.CharField(blank=True, max_length=255, default='', verbose_name='last name'), preserve_default=False, ), migrations.AlterField( model_name='condition', name='name', field=models.CharField(help_text="E.g.: 'Ne fumu'.", max_length=255, verbose_name='name'), ), migrations.AlterField( model_name='phone', name='type', field=models.CharField(choices=[('m', 'Mobile'), ('h', 'Home'), ('w', 'Work')], max_length=3, default='m', verbose_name='phone type'), ), migrations.AlterField( model_name='place', name='address', field=models.CharField(help_text='e.g.: Nieuwe Binnenweg 176', max_length=255, verbose_name='address'), ), migrations.AlterField( model_name='place', name='available', field=models.BooleanField(help_text='If this place is searchable. If yes, you will be considered as host.', default=True, verbose_name='available'), ), migrations.AlterField( model_name='place', name='booked', field=models.BooleanField(help_text='If the place is currently booked.', default=False, verbose_name='booked'), ), migrations.AlterField( model_name='place', name='city', field=models.CharField(help_text='e.g.: Rotterdam', max_length=255, verbose_name='city'), ), migrations.AlterField( model_name='place', name='description', field=models.TextField(blank=True, help_text='Description or remarks about your place.', verbose_name='description'), ), migrations.AlterField( model_name='place', name='in_book', field=models.BooleanField(help_text='If you want this place to be in the printed book. Must be available.', default=False, verbose_name='print in book'), ), migrations.AlterField( model_name='profile', name='title', field=models.CharField(choices=[('Mrs', 'Mrs'), ('Mr', 'Mr')], max_length=5, verbose_name='title'), ), ]
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 29138, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 5587, 792, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 7241, 63, 1802, 297, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 5394, 297, 288, 536, 534, 20787, 297, 288, 901, 29, 992, 14, 2183, 8, 988, 63, 1267, 29, 1165, 12, 1720, 63, 505, 628, 3466, 16714, 2236, 30369, 465, 1202, 315, 314, 6719, 14, 662, 14, 71, 16781, 283, 46, 2829, 26849, 849, 4581, 3376, 63, 354, 534, 354, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 5394, 297, 288, 536, 534, 5464, 297, 288, 901, 29, 992, 14, 17315, 8, 885, 534, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 22061, 63, 3690, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 1720, 63, 505, 534, 3917, 1265, 4192, 365, 315, 282, 370, 3501, 17429, 282, 29416, 14492, 3130, 849, 4581, 3376, 63, 354, 534, 22061, 7282, 14492, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 7804, 63, 65, 63, 5012, 2292, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 1265, 787, 10144, 370, 1172, 282, 512, 24715, 503, 506, 281, 543, 5684, 1384, 3130, 849, 29, 797, 12, 3376, 63, 354, 534, 7804, 282, 366, 12465, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 3612, 63, 1802, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 10037, 12, 1720, 63, 505, 534, 9167, 315, 314, 6719, 12, 22796, 4528, 5696, 3130, 849, 4581, 3376, 63, 354, 534, 3612, 1369, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 10808, 63, 17348, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 1265, 787, 10144, 370, 2498, 2195, 9150, 370, 5684, 1384, 3130, 849, 29, 797, 12, 3376, 63, 354, 534, 10808, 22885, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 14584, 297, 288, 901, 29, 992, 14, 21910, 8, 2500, 29, 549, 12, 5802, 63, 475, 534, 1214, 292, 4291, 297, 849, 4581, 3376, 63, 354, 534, 14584, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 1802, 297, 288, 901, 29, 992, 14, 6254, 8, 2500, 29, 549, 12, 1720, 63, 505, 534, 2422, 3595, 28225, 3130, 849, 4581, 3376, 63, 354, 534, 1802, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 2246, 63, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 849, 4581, 3376, 63, 354, 534, 2246, 536, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 2019, 63, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 849, 4581, 3376, 63, 354, 534, 2019, 536, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 5394, 297, 288, 536, 534, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 3437, 63, 505, 628, 37, 14, 71, 16781, 283, 4698, 289, 453, 85, 30532, 1390, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 354, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 9339, 297, 288, 536, 534, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 77, 297, 283, 27245, 659, 661, 72, 297, 283, 12054, 659, 661, 87, 297, 283, 6517, 2665, 1390, 63, 1267, 29, 19, 12, 849, 534, 77, 297, 3376, 63, 354, 534, 9339, 730, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 1562, 297, 288, 901, 29, 992, 14, 2183, 8, 3437, 63, 505, 534, 69, 14, 71, 16781, 653, 29364, 1129, 32613, 78, 287, 1129, 71, 27827, 297, 1390, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 1562, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 4561, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 642, 4192, 365, 2754, 461, 14, 982, 9456, 12, 1265, 911, 506, 8652, 465, 1591, 3130, 849, 29, 549, 12, 3376, 63, 354, 534, 4561, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 2706, 379, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 314, 4192, 365, 5544, 6719, 379, 3130, 849, 29, 797, 12, 3376, 63, 354, 534, 2706, 379, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 3690, 297, 288, 901, 29, 992, 14, 2183, 8, 3437, 63, 505, 534, 69, 14, 71, 16781, 20423, 351, 68, 455, 297, 1390, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 3690, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 1802, 297, 288, 901, 29, 992, 14, 6254, 8, 2500, 29, 549, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 29138, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 5587, 792, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 7241, 63, 1802, 297, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 5394, 297, 288, 536, 534, 20787, 297, 288, 901, 29, 992, 14, 2183, 8, 988, 63, 1267, 29, 1165, 12, 1720, 63, 505, 628, 3466, 16714, 2236, 30369, 465, 1202, 315, 314, 6719, 14, 662, 14, 71, 16781, 283, 46, 2829, 26849, 849, 4581, 3376, 63, 354, 534, 354, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 5394, 297, 288, 536, 534, 5464, 297, 288, 901, 29, 992, 14, 17315, 8, 885, 534, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 22061, 63, 3690, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 1720, 63, 505, 534, 3917, 1265, 4192, 365, 315, 282, 370, 3501, 17429, 282, 29416, 14492, 3130, 849, 4581, 3376, 63, 354, 534, 22061, 7282, 14492, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 7804, 63, 65, 63, 5012, 2292, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 1265, 787, 10144, 370, 1172, 282, 512, 24715, 503, 506, 281, 543, 5684, 1384, 3130, 849, 29, 797, 12, 3376, 63, 354, 534, 7804, 282, 366, 12465, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 3612, 63, 1802, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 10037, 12, 1720, 63, 505, 534, 9167, 315, 314, 6719, 12, 22796, 4528, 5696, 3130, 849, 4581, 3376, 63, 354, 534, 3612, 1369, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 10808, 63, 17348, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 1265, 787, 10144, 370, 2498, 2195, 9150, 370, 5684, 1384, 3130, 849, 29, 797, 12, 3376, 63, 354, 534, 10808, 22885, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 14584, 297, 288, 901, 29, 992, 14, 21910, 8, 2500, 29, 549, 12, 5802, 63, 475, 534, 1214, 292, 4291, 297, 849, 4581, 3376, 63, 354, 534, 14584, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 1802, 297, 288, 901, 29, 992, 14, 6254, 8, 2500, 29, 549, 12, 1720, 63, 505, 534, 2422, 3595, 28225, 3130, 849, 4581, 3376, 63, 354, 534, 1802, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 2246, 63, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 849, 4581, 3376, 63, 354, 534, 2246, 536, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 2913, 297, 288, 536, 534, 2019, 63, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 849, 4581, 3376, 63, 354, 534, 2019, 536, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 5394, 297, 288, 536, 534, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 3437, 63, 505, 628, 37, 14, 71, 16781, 283, 4698, 289, 453, 85, 30532, 1390, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 354, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 9339, 297, 288, 536, 534, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 77, 297, 283, 27245, 659, 661, 72, 297, 283, 12054, 659, 661, 87, 297, 283, 6517, 2665, 1390, 63, 1267, 29, 19, 12, 849, 534, 77, 297, 3376, 63, 354, 534, 9339, 730, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 1562, 297, 288, 901, 29, 992, 14, 2183, 8, 3437, 63, 505, 534, 69, 14, 71, 16781, 653, 29364, 1129, 32613, 78, 287, 1129, 71, 27827, 297, 1390, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 1562, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 4561, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 642, 4192, 365, 2754, 461, 14, 982, 9456, 12, 1265, 911, 506, 8652, 465, 1591, 3130, 849, 29, 549, 12, 3376, 63, 354, 534, 4561, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 2706, 379, 297, 288, 901, 29, 992, 14, 5036, 8, 3437, 63, 505, 534, 3917, 314, 4192, 365, 5544, 6719, 379, 3130, 849, 29, 797, 12, 3376, 63, 354, 534, 2706, 379, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 3690, 297, 288, 901, 29, 992, 14, 2183, 8, 3437, 63, 505, 534, 69, 14, 71, 16781, 20423, 351, 68, 455, 297, 1390, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 3690, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2778, 297, 288, 536, 534, 1802, 297, 288, 901, 29, 992, 14, 6254, 8, 2500, 29, 549, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kethxenn/C.B.U.L.M.S.
vendor/mockery/mockery/docs/conf.py
468
8442
# -*- coding: utf-8 -*- # # Mockery Docs documentation build configuration file, created by # sphinx-quickstart on Mon Mar 3 14:04:26 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.todo', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Mockery Docs' copyright = u'2014, Pádraic Brady, Dave Marshall, Wouter, Graham Campbell' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.9' # The full version, including alpha/beta/rc tags. release = '0.9' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'MockeryDocsdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index2', 'MockeryDocs.tex', u'Mockery Docs Documentation', u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index2', 'mockerydocs', u'Mockery Docs Documentation', [u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index2', 'MockeryDocs', u'Mockery Docs Documentation', u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell', 'MockeryDocs', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False #on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] print sphinx_rtd_theme.get_html_theme_path()
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 4420, 994, 5454, 83, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 10953, 16794, 221, 650, 4329, 26, 966, 26, 1479, 6927, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 11396, 297, 199, 61, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 3346, 994, 5454, 83, 7, 199, 7307, 275, 399, 7, 7280, 12, 510, 11302, 28385, 530, 32377, 8161, 12, 577, 811, 16794, 609, 452, 12, 644, 7837, 12, 10268, 10670, 24569, 30930, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 16, 14, 25, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 25, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 199, 3, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 11016, 10965, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 14, 199, 3, 1360, 63, 22229, 275, 488, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 4420, 994, 5454, 83, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 10953, 16794, 221, 650, 4329, 26, 966, 26, 1479, 6927, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 11396, 297, 199, 61, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 3346, 994, 5454, 83, 7, 199, 7307, 275, 399, 7, 7280, 12, 510, 11302, 28385, 530, 32377, 8161, 12, 577, 811, 16794, 609, 452, 12, 644, 7837, 12, 10268, 10670, 24569, 30930, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 16, 14, 25, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 25, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 199, 3, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 11016, 10965, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 14, 199, 3, 1360, 63, 22229, 275, 488, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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/_vendor/requests/packages/chardet/big5freq.py
3133
82594
######################## 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 ######################### # Big5 frequency table # 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 # # Ideal 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 BIG5_TYPICAL_DISTRIBUTION_RATIO = 0.75 #Char to FreqOrder table BIG5_TABLE_SIZE = 5376 Big5CharToFreqOrder = ( 1,1801,1506, 255,1431, 198, 9, 82, 6,5008, 177, 202,3681,1256,2821, 110, # 16 3814, 33,3274, 261, 76, 44,2114, 16,2946,2187,1176, 659,3971, 26,3451,2653, # 32 1198,3972,3350,4202, 410,2215, 302, 590, 361,1964, 8, 204, 58,4510,5009,1932, # 48 63,5010,5011, 317,1614, 75, 222, 159,4203,2417,1480,5012,3555,3091, 224,2822, # 64 3682, 3, 10,3973,1471, 29,2787,1135,2866,1940, 873, 130,3275,1123, 312,5013, # 80 4511,2052, 507, 252, 682,5014, 142,1915, 124, 206,2947, 34,3556,3204, 64, 604, # 96 5015,2501,1977,1978, 155,1991, 645, 641,1606,5016,3452, 337, 72, 406,5017, 80, # 112 630, 238,3205,1509, 263, 939,1092,2654, 756,1440,1094,3453, 449, 69,2987, 591, # 128 179,2096, 471, 115,2035,1844, 60, 50,2988, 134, 806,1869, 734,2036,3454, 180, # 144 995,1607, 156, 537,2907, 688,5018, 319,1305, 779,2145, 514,2379, 298,4512, 359, # 160 2502, 90,2716,1338, 663, 11, 906,1099,2553, 20,2441, 182, 532,1716,5019, 732, # 176 1376,4204,1311,1420,3206, 25,2317,1056, 113, 399, 382,1950, 242,3455,2474, 529, # 192 3276, 475,1447,3683,5020, 117, 21, 656, 810,1297,2300,2334,3557,5021, 126,4205, # 208 706, 456, 150, 613,4513, 71,1118,2037,4206, 145,3092, 85, 835, 486,2115,1246, # 224 1426, 428, 727,1285,1015, 800, 106, 623, 303,1281,5022,2128,2359, 347,3815, 221, # 240 3558,3135,5023,1956,1153,4207, 83, 296,1199,3093, 192, 624, 93,5024, 822,1898, # 256 2823,3136, 795,2065, 991,1554,1542,1592, 27, 43,2867, 859, 139,1456, 860,4514, # 272 437, 712,3974, 164,2397,3137, 695, 211,3037,2097, 195,3975,1608,3559,3560,3684, # 288 3976, 234, 811,2989,2098,3977,2233,1441,3561,1615,2380, 668,2077,1638, 305, 228, # 304 1664,4515, 467, 415,5025, 262,2099,1593, 239, 108, 300, 200,1033, 512,1247,2078, # 320 5026,5027,2176,3207,3685,2682, 593, 845,1062,3277, 88,1723,2038,3978,1951, 212, # 336 266, 152, 149, 468,1899,4208,4516, 77, 187,5028,3038, 37, 5,2990,5029,3979, # 352 5030,5031, 39,2524,4517,2908,3208,2079, 55, 148, 74,4518, 545, 483,1474,1029, # 368 1665, 217,1870,1531,3138,1104,2655,4209, 24, 172,3562, 900,3980,3563,3564,4519, # 384 32,1408,2824,1312, 329, 487,2360,2251,2717, 784,2683, 4,3039,3351,1427,1789, # 400 188, 109, 499,5032,3686,1717,1790, 888,1217,3040,4520,5033,3565,5034,3352,1520, # 416 3687,3981, 196,1034, 775,5035,5036, 929,1816, 249, 439, 38,5037,1063,5038, 794, # 432 3982,1435,2301, 46, 178,3278,2066,5039,2381,5040, 214,1709,4521, 804, 35, 707, # 448 324,3688,1601,2554, 140, 459,4210,5041,5042,1365, 839, 272, 978,2262,2580,3456, # 464 2129,1363,3689,1423, 697, 100,3094, 48, 70,1231, 495,3139,2196,5043,1294,5044, # 480 2080, 462, 586,1042,3279, 853, 256, 988, 185,2382,3457,1698, 434,1084,5045,3458, # 496 314,2625,2788,4522,2335,2336, 569,2285, 637,1817,2525, 757,1162,1879,1616,3459, # 512 287,1577,2116, 768,4523,1671,2868,3566,2526,1321,3816, 909,2418,5046,4211, 933, # 528 3817,4212,2053,2361,1222,4524, 765,2419,1322, 786,4525,5047,1920,1462,1677,2909, # 544 1699,5048,4526,1424,2442,3140,3690,2600,3353,1775,1941,3460,3983,4213, 309,1369, # 560 1130,2825, 364,2234,1653,1299,3984,3567,3985,3986,2656, 525,1085,3041, 902,2001, # 576 1475, 964,4527, 421,1845,1415,1057,2286, 940,1364,3141, 376,4528,4529,1381, 7, # 592 2527, 983,2383, 336,1710,2684,1846, 321,3461, 559,1131,3042,2752,1809,1132,1313, # 608 265,1481,1858,5049, 352,1203,2826,3280, 167,1089, 420,2827, 776, 792,1724,3568, # 624 4214,2443,3281,5050,4215,5051, 446, 229, 333,2753, 901,3818,1200,1557,4530,2657, # 640 1921, 395,2754,2685,3819,4216,1836, 125, 916,3209,2626,4531,5052,5053,3820,5054, # 656 5055,5056,4532,3142,3691,1133,2555,1757,3462,1510,2318,1409,3569,5057,2146, 438, # 672 2601,2910,2384,3354,1068, 958,3043, 461, 311,2869,2686,4217,1916,3210,4218,1979, # 688 383, 750,2755,2627,4219, 274, 539, 385,1278,1442,5058,1154,1965, 384, 561, 210, # 704 98,1295,2556,3570,5059,1711,2420,1482,3463,3987,2911,1257, 129,5060,3821, 642, # 720 523,2789,2790,2658,5061, 141,2235,1333, 68, 176, 441, 876, 907,4220, 603,2602, # 736 710, 171,3464, 404, 549, 18,3143,2398,1410,3692,1666,5062,3571,4533,2912,4534, # 752 5063,2991, 368,5064, 146, 366, 99, 871,3693,1543, 748, 807,1586,1185, 22,2263, # 768 379,3822,3211,5065,3212, 505,1942,2628,1992,1382,2319,5066, 380,2362, 218, 702, # 784 1818,1248,3465,3044,3572,3355,3282,5067,2992,3694, 930,3283,3823,5068, 59,5069, # 800 585, 601,4221, 497,3466,1112,1314,4535,1802,5070,1223,1472,2177,5071, 749,1837, # 816 690,1900,3824,1773,3988,1476, 429,1043,1791,2236,2117, 917,4222, 447,1086,1629, # 832 5072, 556,5073,5074,2021,1654, 844,1090, 105, 550, 966,1758,2828,1008,1783, 686, # 848 1095,5075,2287, 793,1602,5076,3573,2603,4536,4223,2948,2302,4537,3825, 980,2503, # 864 544, 353, 527,4538, 908,2687,2913,5077, 381,2629,1943,1348,5078,1341,1252, 560, # 880 3095,5079,3467,2870,5080,2054, 973, 886,2081, 143,4539,5081,5082, 157,3989, 496, # 896 4224, 57, 840, 540,2039,4540,4541,3468,2118,1445, 970,2264,1748,1966,2082,4225, # 912 3144,1234,1776,3284,2829,3695, 773,1206,2130,1066,2040,1326,3990,1738,1725,4226, # 928 279,3145, 51,1544,2604, 423,1578,2131,2067, 173,4542,1880,5083,5084,1583, 264, # 944 610,3696,4543,2444, 280, 154,5085,5086,5087,1739, 338,1282,3096, 693,2871,1411, # 960 1074,3826,2445,5088,4544,5089,5090,1240, 952,2399,5091,2914,1538,2688, 685,1483, # 976 4227,2475,1436, 953,4228,2055,4545, 671,2400, 79,4229,2446,3285, 608, 567,2689, # 992 3469,4230,4231,1691, 393,1261,1792,2401,5092,4546,5093,5094,5095,5096,1383,1672, # 1008 3827,3213,1464, 522,1119, 661,1150, 216, 675,4547,3991,1432,3574, 609,4548,2690, # 1024 2402,5097,5098,5099,4232,3045, 0,5100,2476, 315, 231,2447, 301,3356,4549,2385, # 1040 5101, 233,4233,3697,1819,4550,4551,5102, 96,1777,1315,2083,5103, 257,5104,1810, # 1056 3698,2718,1139,1820,4234,2022,1124,2164,2791,1778,2659,5105,3097, 363,1655,3214, # 1072 5106,2993,5107,5108,5109,3992,1567,3993, 718, 103,3215, 849,1443, 341,3357,2949, # 1088 1484,5110,1712, 127, 67, 339,4235,2403, 679,1412, 821,5111,5112, 834, 738, 351, # 1104 2994,2147, 846, 235,1497,1881, 418,1993,3828,2719, 186,1100,2148,2756,3575,1545, # 1120 1355,2950,2872,1377, 583,3994,4236,2581,2995,5113,1298,3699,1078,2557,3700,2363, # 1136 78,3829,3830, 267,1289,2100,2002,1594,4237, 348, 369,1274,2197,2178,1838,4552, # 1152 1821,2830,3701,2757,2288,2003,4553,2951,2758, 144,3358, 882,4554,3995,2759,3470, # 1168 4555,2915,5114,4238,1726, 320,5115,3996,3046, 788,2996,5116,2831,1774,1327,2873, # 1184 3997,2832,5117,1306,4556,2004,1700,3831,3576,2364,2660, 787,2023, 506, 824,3702, # 1200 534, 323,4557,1044,3359,2024,1901, 946,3471,5118,1779,1500,1678,5119,1882,4558, # 1216 165, 243,4559,3703,2528, 123, 683,4239, 764,4560, 36,3998,1793, 589,2916, 816, # 1232 626,1667,3047,2237,1639,1555,1622,3832,3999,5120,4000,2874,1370,1228,1933, 891, # 1248 2084,2917, 304,4240,5121, 292,2997,2720,3577, 691,2101,4241,1115,4561, 118, 662, # 1264 5122, 611,1156, 854,2386,1316,2875, 2, 386, 515,2918,5123,5124,3286, 868,2238, # 1280 1486, 855,2661, 785,2216,3048,5125,1040,3216,3578,5126,3146, 448,5127,1525,5128, # 1296 2165,4562,5129,3833,5130,4242,2833,3579,3147, 503, 818,4001,3148,1568, 814, 676, # 1312 1444, 306,1749,5131,3834,1416,1030, 197,1428, 805,2834,1501,4563,5132,5133,5134, # 1328 1994,5135,4564,5136,5137,2198, 13,2792,3704,2998,3149,1229,1917,5138,3835,2132, # 1344 5139,4243,4565,2404,3580,5140,2217,1511,1727,1120,5141,5142, 646,3836,2448, 307, # 1360 5143,5144,1595,3217,5145,5146,5147,3705,1113,1356,4002,1465,2529,2530,5148, 519, # 1376 5149, 128,2133, 92,2289,1980,5150,4003,1512, 342,3150,2199,5151,2793,2218,1981, # 1392 3360,4244, 290,1656,1317, 789, 827,2365,5152,3837,4566, 562, 581,4004,5153, 401, # 1408 4567,2252, 94,4568,5154,1399,2794,5155,1463,2025,4569,3218,1944,5156, 828,1105, # 1424 4245,1262,1394,5157,4246, 605,4570,5158,1784,2876,5159,2835, 819,2102, 578,2200, # 1440 2952,5160,1502, 436,3287,4247,3288,2836,4005,2919,3472,3473,5161,2721,2320,5162, # 1456 5163,2337,2068, 23,4571, 193, 826,3838,2103, 699,1630,4248,3098, 390,1794,1064, # 1472 3581,5164,1579,3099,3100,1400,5165,4249,1839,1640,2877,5166,4572,4573, 137,4250, # 1488 598,3101,1967, 780, 104, 974,2953,5167, 278, 899, 253, 402, 572, 504, 493,1339, # 1504 5168,4006,1275,4574,2582,2558,5169,3706,3049,3102,2253, 565,1334,2722, 863, 41, # 1520 5170,5171,4575,5172,1657,2338, 19, 463,2760,4251, 606,5173,2999,3289,1087,2085, # 1536 1323,2662,3000,5174,1631,1623,1750,4252,2691,5175,2878, 791,2723,2663,2339, 232, # 1552 2421,5176,3001,1498,5177,2664,2630, 755,1366,3707,3290,3151,2026,1609, 119,1918, # 1568 3474, 862,1026,4253,5178,4007,3839,4576,4008,4577,2265,1952,2477,5179,1125, 817, # 1584 4254,4255,4009,1513,1766,2041,1487,4256,3050,3291,2837,3840,3152,5180,5181,1507, # 1600 5182,2692, 733, 40,1632,1106,2879, 345,4257, 841,2531, 230,4578,3002,1847,3292, # 1616 3475,5183,1263, 986,3476,5184, 735, 879, 254,1137, 857, 622,1300,1180,1388,1562, # 1632 4010,4011,2954, 967,2761,2665,1349, 592,2134,1692,3361,3003,1995,4258,1679,4012, # 1648 1902,2188,5185, 739,3708,2724,1296,1290,5186,4259,2201,2202,1922,1563,2605,2559, # 1664 1871,2762,3004,5187, 435,5188, 343,1108, 596, 17,1751,4579,2239,3477,3709,5189, # 1680 4580, 294,3582,2955,1693, 477, 979, 281,2042,3583, 643,2043,3710,2631,2795,2266, # 1696 1031,2340,2135,2303,3584,4581, 367,1249,2560,5190,3585,5191,4582,1283,3362,2005, # 1712 240,1762,3363,4583,4584, 836,1069,3153, 474,5192,2149,2532, 268,3586,5193,3219, # 1728 1521,1284,5194,1658,1546,4260,5195,3587,3588,5196,4261,3364,2693,1685,4262, 961, # 1744 1673,2632, 190,2006,2203,3841,4585,4586,5197, 570,2504,3711,1490,5198,4587,2633, # 1760 3293,1957,4588, 584,1514, 396,1045,1945,5199,4589,1968,2449,5200,5201,4590,4013, # 1776 619,5202,3154,3294, 215,2007,2796,2561,3220,4591,3221,4592, 763,4263,3842,4593, # 1792 5203,5204,1958,1767,2956,3365,3712,1174, 452,1477,4594,3366,3155,5205,2838,1253, # 1808 2387,2189,1091,2290,4264, 492,5206, 638,1169,1825,2136,1752,4014, 648, 926,1021, # 1824 1324,4595, 520,4596, 997, 847,1007, 892,4597,3843,2267,1872,3713,2405,1785,4598, # 1840 1953,2957,3103,3222,1728,4265,2044,3714,4599,2008,1701,3156,1551, 30,2268,4266, # 1856 5207,2027,4600,3589,5208, 501,5209,4267, 594,3478,2166,1822,3590,3479,3591,3223, # 1872 829,2839,4268,5210,1680,3157,1225,4269,5211,3295,4601,4270,3158,2341,5212,4602, # 1888 4271,5213,4015,4016,5214,1848,2388,2606,3367,5215,4603, 374,4017, 652,4272,4273, # 1904 375,1140, 798,5216,5217,5218,2366,4604,2269, 546,1659, 138,3051,2450,4605,5219, # 1920 2254, 612,1849, 910, 796,3844,1740,1371, 825,3845,3846,5220,2920,2562,5221, 692, # 1936 444,3052,2634, 801,4606,4274,5222,1491, 244,1053,3053,4275,4276, 340,5223,4018, # 1952 1041,3005, 293,1168, 87,1357,5224,1539, 959,5225,2240, 721, 694,4277,3847, 219, # 1968 1478, 644,1417,3368,2666,1413,1401,1335,1389,4019,5226,5227,3006,2367,3159,1826, # 1984 730,1515, 184,2840, 66,4607,5228,1660,2958, 246,3369, 378,1457, 226,3480, 975, # 2000 4020,2959,1264,3592, 674, 696,5229, 163,5230,1141,2422,2167, 713,3593,3370,4608, # 2016 4021,5231,5232,1186, 15,5233,1079,1070,5234,1522,3224,3594, 276,1050,2725, 758, # 2032 1126, 653,2960,3296,5235,2342, 889,3595,4022,3104,3007, 903,1250,4609,4023,3481, # 2048 3596,1342,1681,1718, 766,3297, 286, 89,2961,3715,5236,1713,5237,2607,3371,3008, # 2064 5238,2962,2219,3225,2880,5239,4610,2505,2533, 181, 387,1075,4024, 731,2190,3372, # 2080 5240,3298, 310, 313,3482,2304, 770,4278, 54,3054, 189,4611,3105,3848,4025,5241, # 2096 1230,1617,1850, 355,3597,4279,4612,3373, 111,4280,3716,1350,3160,3483,3055,4281, # 2112 2150,3299,3598,5242,2797,4026,4027,3009, 722,2009,5243,1071, 247,1207,2343,2478, # 2128 1378,4613,2010, 864,1437,1214,4614, 373,3849,1142,2220, 667,4615, 442,2763,2563, # 2144 3850,4028,1969,4282,3300,1840, 837, 170,1107, 934,1336,1883,5244,5245,2119,4283, # 2160 2841, 743,1569,5246,4616,4284, 582,2389,1418,3484,5247,1803,5248, 357,1395,1729, # 2176 3717,3301,2423,1564,2241,5249,3106,3851,1633,4617,1114,2086,4285,1532,5250, 482, # 2192 2451,4618,5251,5252,1492, 833,1466,5253,2726,3599,1641,2842,5254,1526,1272,3718, # 2208 4286,1686,1795, 416,2564,1903,1954,1804,5255,3852,2798,3853,1159,2321,5256,2881, # 2224 4619,1610,1584,3056,2424,2764, 443,3302,1163,3161,5257,5258,4029,5259,4287,2506, # 2240 3057,4620,4030,3162,2104,1647,3600,2011,1873,4288,5260,4289, 431,3485,5261, 250, # 2256 97, 81,4290,5262,1648,1851,1558, 160, 848,5263, 866, 740,1694,5264,2204,2843, # 2272 3226,4291,4621,3719,1687, 950,2479, 426, 469,3227,3720,3721,4031,5265,5266,1188, # 2288 424,1996, 861,3601,4292,3854,2205,2694, 168,1235,3602,4293,5267,2087,1674,4622, # 2304 3374,3303, 220,2565,1009,5268,3855, 670,3010, 332,1208, 717,5269,5270,3603,2452, # 2320 4032,3375,5271, 513,5272,1209,2882,3376,3163,4623,1080,5273,5274,5275,5276,2534, # 2336 3722,3604, 815,1587,4033,4034,5277,3605,3486,3856,1254,4624,1328,3058,1390,4035, # 2352 1741,4036,3857,4037,5278, 236,3858,2453,3304,5279,5280,3723,3859,1273,3860,4625, # 2368 5281, 308,5282,4626, 245,4627,1852,2480,1307,2583, 430, 715,2137,2454,5283, 270, # 2384 199,2883,4038,5284,3606,2727,1753, 761,1754, 725,1661,1841,4628,3487,3724,5285, # 2400 5286, 587, 14,3305, 227,2608, 326, 480,2270, 943,2765,3607, 291, 650,1884,5287, # 2416 1702,1226, 102,1547, 62,3488, 904,4629,3489,1164,4294,5288,5289,1224,1548,2766, # 2432 391, 498,1493,5290,1386,1419,5291,2056,1177,4630, 813, 880,1081,2368, 566,1145, # 2448 4631,2291,1001,1035,2566,2609,2242, 394,1286,5292,5293,2069,5294, 86,1494,1730, # 2464 4039, 491,1588, 745, 897,2963, 843,3377,4040,2767,2884,3306,1768, 998,2221,2070, # 2480 397,1827,1195,1970,3725,3011,3378, 284,5295,3861,2507,2138,2120,1904,5296,4041, # 2496 2151,4042,4295,1036,3490,1905, 114,2567,4296, 209,1527,5297,5298,2964,2844,2635, # 2512 2390,2728,3164, 812,2568,5299,3307,5300,1559, 737,1885,3726,1210, 885, 28,2695, # 2528 3608,3862,5301,4297,1004,1780,4632,5302, 346,1982,2222,2696,4633,3863,1742, 797, # 2544 1642,4043,1934,1072,1384,2152, 896,4044,3308,3727,3228,2885,3609,5303,2569,1959, # 2560 4634,2455,1786,5304,5305,5306,4045,4298,1005,1308,3728,4299,2729,4635,4636,1528, # 2576 2610, 161,1178,4300,1983, 987,4637,1101,4301, 631,4046,1157,3229,2425,1343,1241, # 2592 1016,2243,2570, 372, 877,2344,2508,1160, 555,1935, 911,4047,5307, 466,1170, 169, # 2608 1051,2921,2697,3729,2481,3012,1182,2012,2571,1251,2636,5308, 992,2345,3491,1540, # 2624 2730,1201,2071,2406,1997,2482,5309,4638, 528,1923,2191,1503,1874,1570,2369,3379, # 2640 3309,5310, 557,1073,5311,1828,3492,2088,2271,3165,3059,3107, 767,3108,2799,4639, # 2656 1006,4302,4640,2346,1267,2179,3730,3230, 778,4048,3231,2731,1597,2667,5312,4641, # 2672 5313,3493,5314,5315,5316,3310,2698,1433,3311, 131, 95,1504,4049, 723,4303,3166, # 2688 1842,3610,2768,2192,4050,2028,2105,3731,5317,3013,4051,1218,5318,3380,3232,4052, # 2704 4304,2584, 248,1634,3864, 912,5319,2845,3732,3060,3865, 654, 53,5320,3014,5321, # 2720 1688,4642, 777,3494,1032,4053,1425,5322, 191, 820,2121,2846, 971,4643, 931,3233, # 2736 135, 664, 783,3866,1998, 772,2922,1936,4054,3867,4644,2923,3234, 282,2732, 640, # 2752 1372,3495,1127, 922, 325,3381,5323,5324, 711,2045,5325,5326,4055,2223,2800,1937, # 2768 4056,3382,2224,2255,3868,2305,5327,4645,3869,1258,3312,4057,3235,2139,2965,4058, # 2784 4059,5328,2225, 258,3236,4646, 101,1227,5329,3313,1755,5330,1391,3314,5331,2924, # 2800 2057, 893,5332,5333,5334,1402,4305,2347,5335,5336,3237,3611,5337,5338, 878,1325, # 2816 1781,2801,4647, 259,1385,2585, 744,1183,2272,4648,5339,4060,2509,5340, 684,1024, # 2832 4306,5341, 472,3612,3496,1165,3315,4061,4062, 322,2153, 881, 455,1695,1152,1340, # 2848 660, 554,2154,4649,1058,4650,4307, 830,1065,3383,4063,4651,1924,5342,1703,1919, # 2864 5343, 932,2273, 122,5344,4652, 947, 677,5345,3870,2637, 297,1906,1925,2274,4653, # 2880 2322,3316,5346,5347,4308,5348,4309, 84,4310, 112, 989,5349, 547,1059,4064, 701, # 2896 3613,1019,5350,4311,5351,3497, 942, 639, 457,2306,2456, 993,2966, 407, 851, 494, # 2912 4654,3384, 927,5352,1237,5353,2426,3385, 573,4312, 680, 921,2925,1279,1875, 285, # 2928 790,1448,1984, 719,2168,5354,5355,4655,4065,4066,1649,5356,1541, 563,5357,1077, # 2944 5358,3386,3061,3498, 511,3015,4067,4068,3733,4069,1268,2572,3387,3238,4656,4657, # 2960 5359, 535,1048,1276,1189,2926,2029,3167,1438,1373,2847,2967,1134,2013,5360,4313, # 2976 1238,2586,3109,1259,5361, 700,5362,2968,3168,3734,4314,5363,4315,1146,1876,1907, # 2992 4658,2611,4070, 781,2427, 132,1589, 203, 147, 273,2802,2407, 898,1787,2155,4071, # 3008 4072,5364,3871,2803,5365,5366,4659,4660,5367,3239,5368,1635,3872, 965,5369,1805, # 3024 2699,1516,3614,1121,1082,1329,3317,4073,1449,3873, 65,1128,2848,2927,2769,1590, # 3040 3874,5370,5371, 12,2668, 45, 976,2587,3169,4661, 517,2535,1013,1037,3240,5372, # 3056 3875,2849,5373,3876,5374,3499,5375,2612, 614,1999,2323,3877,3110,2733,2638,5376, # 3072 2588,4316, 599,1269,5377,1811,3735,5378,2700,3111, 759,1060, 489,1806,3388,3318, # 3088 1358,5379,5380,2391,1387,1215,2639,2256, 490,5381,5382,4317,1759,2392,2348,5383, # 3104 4662,3878,1908,4074,2640,1807,3241,4663,3500,3319,2770,2349, 874,5384,5385,3501, # 3120 3736,1859, 91,2928,3737,3062,3879,4664,5386,3170,4075,2669,5387,3502,1202,1403, # 3136 3880,2969,2536,1517,2510,4665,3503,2511,5388,4666,5389,2701,1886,1495,1731,4076, # 3152 2370,4667,5390,2030,5391,5392,4077,2702,1216, 237,2589,4318,2324,4078,3881,4668, # 3168 4669,2703,3615,3504, 445,4670,5393,5394,5395,5396,2771, 61,4079,3738,1823,4080, # 3184 5397, 687,2046, 935, 925, 405,2670, 703,1096,1860,2734,4671,4081,1877,1367,2704, # 3200 3389, 918,2106,1782,2483, 334,3320,1611,1093,4672, 564,3171,3505,3739,3390, 945, # 3216 2641,2058,4673,5398,1926, 872,4319,5399,3506,2705,3112, 349,4320,3740,4082,4674, # 3232 3882,4321,3741,2156,4083,4675,4676,4322,4677,2408,2047, 782,4084, 400, 251,4323, # 3248 1624,5400,5401, 277,3742, 299,1265, 476,1191,3883,2122,4324,4325,1109, 205,5402, # 3264 2590,1000,2157,3616,1861,5403,5404,5405,4678,5406,4679,2573, 107,2484,2158,4085, # 3280 3507,3172,5407,1533, 541,1301, 158, 753,4326,2886,3617,5408,1696, 370,1088,4327, # 3296 4680,3618, 579, 327, 440, 162,2244, 269,1938,1374,3508, 968,3063, 56,1396,3113, # 3312 2107,3321,3391,5409,1927,2159,4681,3016,5410,3619,5411,5412,3743,4682,2485,5413, # 3328 2804,5414,1650,4683,5415,2613,5416,5417,4086,2671,3392,1149,3393,4087,3884,4088, # 3344 5418,1076, 49,5419, 951,3242,3322,3323, 450,2850, 920,5420,1812,2805,2371,4328, # 3360 1909,1138,2372,3885,3509,5421,3243,4684,1910,1147,1518,2428,4685,3886,5422,4686, # 3376 2393,2614, 260,1796,3244,5423,5424,3887,3324, 708,5425,3620,1704,5426,3621,1351, # 3392 1618,3394,3017,1887, 944,4329,3395,4330,3064,3396,4331,5427,3744, 422, 413,1714, # 3408 3325, 500,2059,2350,4332,2486,5428,1344,1911, 954,5429,1668,5430,5431,4089,2409, # 3424 4333,3622,3888,4334,5432,2307,1318,2512,3114, 133,3115,2887,4687, 629, 31,2851, # 3440 2706,3889,4688, 850, 949,4689,4090,2970,1732,2089,4335,1496,1853,5433,4091, 620, # 3456 3245, 981,1242,3745,3397,1619,3746,1643,3326,2140,2457,1971,1719,3510,2169,5434, # 3472 3246,5435,5436,3398,1829,5437,1277,4690,1565,2048,5438,1636,3623,3116,5439, 869, # 3488 2852, 655,3890,3891,3117,4092,3018,3892,1310,3624,4691,5440,5441,5442,1733, 558, # 3504 4692,3747, 335,1549,3065,1756,4336,3748,1946,3511,1830,1291,1192, 470,2735,2108, # 3520 2806, 913,1054,4093,5443,1027,5444,3066,4094,4693, 982,2672,3399,3173,3512,3247, # 3536 3248,1947,2807,5445, 571,4694,5446,1831,5447,3625,2591,1523,2429,5448,2090, 984, # 3552 4695,3749,1960,5449,3750, 852, 923,2808,3513,3751, 969,1519, 999,2049,2325,1705, # 3568 5450,3118, 615,1662, 151, 597,4095,2410,2326,1049, 275,4696,3752,4337, 568,3753, # 3584 3626,2487,4338,3754,5451,2430,2275, 409,3249,5452,1566,2888,3514,1002, 769,2853, # 3600 194,2091,3174,3755,2226,3327,4339, 628,1505,5453,5454,1763,2180,3019,4096, 521, # 3616 1161,2592,1788,2206,2411,4697,4097,1625,4340,4341, 412, 42,3119, 464,5455,2642, # 3632 4698,3400,1760,1571,2889,3515,2537,1219,2207,3893,2643,2141,2373,4699,4700,3328, # 3648 1651,3401,3627,5456,5457,3628,2488,3516,5458,3756,5459,5460,2276,2092, 460,5461, # 3664 4701,5462,3020, 962, 588,3629, 289,3250,2644,1116, 52,5463,3067,1797,5464,5465, # 3680 5466,1467,5467,1598,1143,3757,4342,1985,1734,1067,4702,1280,3402, 465,4703,1572, # 3696 510,5468,1928,2245,1813,1644,3630,5469,4704,3758,5470,5471,2673,1573,1534,5472, # 3712 5473, 536,1808,1761,3517,3894,3175,2645,5474,5475,5476,4705,3518,2929,1912,2809, # 3728 5477,3329,1122, 377,3251,5478, 360,5479,5480,4343,1529, 551,5481,2060,3759,1769, # 3744 2431,5482,2930,4344,3330,3120,2327,2109,2031,4706,1404, 136,1468,1479, 672,1171, # 3760 3252,2308, 271,3176,5483,2772,5484,2050, 678,2736, 865,1948,4707,5485,2014,4098, # 3776 2971,5486,2737,2227,1397,3068,3760,4708,4709,1735,2931,3403,3631,5487,3895, 509, # 3792 2854,2458,2890,3896,5488,5489,3177,3178,4710,4345,2538,4711,2309,1166,1010, 552, # 3808 681,1888,5490,5491,2972,2973,4099,1287,1596,1862,3179, 358, 453, 736, 175, 478, # 3824 1117, 905,1167,1097,5492,1854,1530,5493,1706,5494,2181,3519,2292,3761,3520,3632, # 3840 4346,2093,4347,5495,3404,1193,2489,4348,1458,2193,2208,1863,1889,1421,3331,2932, # 3856 3069,2182,3521, 595,2123,5496,4100,5497,5498,4349,1707,2646, 223,3762,1359, 751, # 3872 3121, 183,3522,5499,2810,3021, 419,2374, 633, 704,3897,2394, 241,5500,5501,5502, # 3888 838,3022,3763,2277,2773,2459,3898,1939,2051,4101,1309,3122,2246,1181,5503,1136, # 3904 2209,3899,2375,1446,4350,2310,4712,5504,5505,4351,1055,2615, 484,3764,5506,4102, # 3920 625,4352,2278,3405,1499,4353,4103,5507,4104,4354,3253,2279,2280,3523,5508,5509, # 3936 2774, 808,2616,3765,3406,4105,4355,3123,2539, 526,3407,3900,4356, 955,5510,1620, # 3952 4357,2647,2432,5511,1429,3766,1669,1832, 994, 928,5512,3633,1260,5513,5514,5515, # 3968 1949,2293, 741,2933,1626,4358,2738,2460, 867,1184, 362,3408,1392,5516,5517,4106, # 3984 4359,1770,1736,3254,2934,4713,4714,1929,2707,1459,1158,5518,3070,3409,2891,1292, # 4000 1930,2513,2855,3767,1986,1187,2072,2015,2617,4360,5519,2574,2514,2170,3768,2490, # 4016 3332,5520,3769,4715,5521,5522, 666,1003,3023,1022,3634,4361,5523,4716,1814,2257, # 4032 574,3901,1603, 295,1535, 705,3902,4362, 283, 858, 417,5524,5525,3255,4717,4718, # 4048 3071,1220,1890,1046,2281,2461,4107,1393,1599, 689,2575, 388,4363,5526,2491, 802, # 4064 5527,2811,3903,2061,1405,2258,5528,4719,3904,2110,1052,1345,3256,1585,5529, 809, # 4080 5530,5531,5532, 575,2739,3524, 956,1552,1469,1144,2328,5533,2329,1560,2462,3635, # 4096 3257,4108, 616,2210,4364,3180,2183,2294,5534,1833,5535,3525,4720,5536,1319,3770, # 4112 3771,1211,3636,1023,3258,1293,2812,5537,5538,5539,3905, 607,2311,3906, 762,2892, # 4128 1439,4365,1360,4721,1485,3072,5540,4722,1038,4366,1450,2062,2648,4367,1379,4723, # 4144 2593,5541,5542,4368,1352,1414,2330,2935,1172,5543,5544,3907,3908,4724,1798,1451, # 4160 5545,5546,5547,5548,2936,4109,4110,2492,2351, 411,4111,4112,3637,3333,3124,4725, # 4176 1561,2674,1452,4113,1375,5549,5550, 47,2974, 316,5551,1406,1591,2937,3181,5552, # 4192 1025,2142,3125,3182, 354,2740, 884,2228,4369,2412, 508,3772, 726,3638, 996,2433, # 4208 3639, 729,5553, 392,2194,1453,4114,4726,3773,5554,5555,2463,3640,2618,1675,2813, # 4224 919,2352,2975,2353,1270,4727,4115, 73,5556,5557, 647,5558,3259,2856,2259,1550, # 4240 1346,3024,5559,1332, 883,3526,5560,5561,5562,5563,3334,2775,5564,1212, 831,1347, # 4256 4370,4728,2331,3909,1864,3073, 720,3910,4729,4730,3911,5565,4371,5566,5567,4731, # 4272 5568,5569,1799,4732,3774,2619,4733,3641,1645,2376,4734,5570,2938, 669,2211,2675, # 4288 2434,5571,2893,5572,5573,1028,3260,5574,4372,2413,5575,2260,1353,5576,5577,4735, # 4304 3183, 518,5578,4116,5579,4373,1961,5580,2143,4374,5581,5582,3025,2354,2355,3912, # 4320 516,1834,1454,4117,2708,4375,4736,2229,2620,1972,1129,3642,5583,2776,5584,2976, # 4336 1422, 577,1470,3026,1524,3410,5585,5586, 432,4376,3074,3527,5587,2594,1455,2515, # 4352 2230,1973,1175,5588,1020,2741,4118,3528,4737,5589,2742,5590,1743,1361,3075,3529, # 4368 2649,4119,4377,4738,2295, 895, 924,4378,2171, 331,2247,3076, 166,1627,3077,1098, # 4384 5591,1232,2894,2231,3411,4739, 657, 403,1196,2377, 542,3775,3412,1600,4379,3530, # 4400 5592,4740,2777,3261, 576, 530,1362,4741,4742,2540,2676,3776,4120,5593, 842,3913, # 4416 5594,2814,2032,1014,4121, 213,2709,3413, 665, 621,4380,5595,3777,2939,2435,5596, # 4432 2436,3335,3643,3414,4743,4381,2541,4382,4744,3644,1682,4383,3531,1380,5597, 724, # 4448 2282, 600,1670,5598,1337,1233,4745,3126,2248,5599,1621,4746,5600, 651,4384,5601, # 4464 1612,4385,2621,5602,2857,5603,2743,2312,3078,5604, 716,2464,3079, 174,1255,2710, # 4480 4122,3645, 548,1320,1398, 728,4123,1574,5605,1891,1197,3080,4124,5606,3081,3082, # 4496 3778,3646,3779, 747,5607, 635,4386,4747,5608,5609,5610,4387,5611,5612,4748,5613, # 4512 3415,4749,2437, 451,5614,3780,2542,2073,4388,2744,4389,4125,5615,1764,4750,5616, # 4528 4390, 350,4751,2283,2395,2493,5617,4391,4126,2249,1434,4127, 488,4752, 458,4392, # 4544 4128,3781, 771,1330,2396,3914,2576,3184,2160,2414,1553,2677,3185,4393,5618,2494, # 4560 2895,2622,1720,2711,4394,3416,4753,5619,2543,4395,5620,3262,4396,2778,5621,2016, # 4576 2745,5622,1155,1017,3782,3915,5623,3336,2313, 201,1865,4397,1430,5624,4129,5625, # 4592 5626,5627,5628,5629,4398,1604,5630, 414,1866, 371,2595,4754,4755,3532,2017,3127, # 4608 4756,1708, 960,4399, 887, 389,2172,1536,1663,1721,5631,2232,4130,2356,2940,1580, # 4624 5632,5633,1744,4757,2544,4758,4759,5634,4760,5635,2074,5636,4761,3647,3417,2896, # 4640 4400,5637,4401,2650,3418,2815, 673,2712,2465, 709,3533,4131,3648,4402,5638,1148, # 4656 502, 634,5639,5640,1204,4762,3649,1575,4763,2623,3783,5641,3784,3128, 948,3263, # 4672 121,1745,3916,1110,5642,4403,3083,2516,3027,4132,3785,1151,1771,3917,1488,4133, # 4688 1987,5643,2438,3534,5644,5645,2094,5646,4404,3918,1213,1407,2816, 531,2746,2545, # 4704 3264,1011,1537,4764,2779,4405,3129,1061,5647,3786,3787,1867,2897,5648,2018, 120, # 4720 4406,4407,2063,3650,3265,2314,3919,2678,3419,1955,4765,4134,5649,3535,1047,2713, # 4736 1266,5650,1368,4766,2858, 649,3420,3920,2546,2747,1102,2859,2679,5651,5652,2000, # 4752 5653,1111,3651,2977,5654,2495,3921,3652,2817,1855,3421,3788,5655,5656,3422,2415, # 4768 2898,3337,3266,3653,5657,2577,5658,3654,2818,4135,1460, 856,5659,3655,5660,2899, # 4784 2978,5661,2900,3922,5662,4408, 632,2517, 875,3923,1697,3924,2296,5663,5664,4767, # 4800 3028,1239, 580,4768,4409,5665, 914, 936,2075,1190,4136,1039,2124,5666,5667,5668, # 4816 5669,3423,1473,5670,1354,4410,3925,4769,2173,3084,4137, 915,3338,4411,4412,3339, # 4832 1605,1835,5671,2748, 398,3656,4413,3926,4138, 328,1913,2860,4139,3927,1331,4414, # 4848 3029, 937,4415,5672,3657,4140,4141,3424,2161,4770,3425, 524, 742, 538,3085,1012, # 4864 5673,5674,3928,2466,5675, 658,1103, 225,3929,5676,5677,4771,5678,4772,5679,3267, # 4880 1243,5680,4142, 963,2250,4773,5681,2714,3658,3186,5682,5683,2596,2332,5684,4774, # 4896 5685,5686,5687,3536, 957,3426,2547,2033,1931,2941,2467, 870,2019,3659,1746,2780, # 4912 2781,2439,2468,5688,3930,5689,3789,3130,3790,3537,3427,3791,5690,1179,3086,5691, # 4928 3187,2378,4416,3792,2548,3188,3131,2749,4143,5692,3428,1556,2549,2297, 977,2901, # 4944 2034,4144,1205,3429,5693,1765,3430,3189,2125,1271, 714,1689,4775,3538,5694,2333, # 4960 3931, 533,4417,3660,2184, 617,5695,2469,3340,3539,2315,5696,5697,3190,5698,5699, # 4976 3932,1988, 618, 427,2651,3540,3431,5700,5701,1244,1690,5702,2819,4418,4776,5703, # 4992 3541,4777,5704,2284,1576, 473,3661,4419,3432, 972,5705,3662,5706,3087,5707,5708, # 5008 4778,4779,5709,3793,4145,4146,5710, 153,4780, 356,5711,1892,2902,4420,2144, 408, # 5024 803,2357,5712,3933,5713,4421,1646,2578,2518,4781,4782,3934,5714,3935,4422,5715, # 5040 2416,3433, 752,5716,5717,1962,3341,2979,5718, 746,3030,2470,4783,4423,3794, 698, # 5056 4784,1893,4424,3663,2550,4785,3664,3936,5719,3191,3434,5720,1824,1302,4147,2715, # 5072 3937,1974,4425,5721,4426,3192, 823,1303,1288,1236,2861,3542,4148,3435, 774,3938, # 5088 5722,1581,4786,1304,2862,3939,4787,5723,2440,2162,1083,3268,4427,4149,4428, 344, # 5104 1173, 288,2316, 454,1683,5724,5725,1461,4788,4150,2597,5726,5727,4789, 985, 894, # 5120 5728,3436,3193,5729,1914,2942,3795,1989,5730,2111,1975,5731,4151,5732,2579,1194, # 5136 425,5733,4790,3194,1245,3796,4429,5734,5735,2863,5736, 636,4791,1856,3940, 760, # 5152 1800,5737,4430,2212,1508,4792,4152,1894,1684,2298,5738,5739,4793,4431,4432,2213, # 5168 479,5740,5741, 832,5742,4153,2496,5743,2980,2497,3797, 990,3132, 627,1815,2652, # 5184 4433,1582,4434,2126,2112,3543,4794,5744, 799,4435,3195,5745,4795,2113,1737,3031, # 5200 1018, 543, 754,4436,3342,1676,4796,4797,4154,4798,1489,5746,3544,5747,2624,2903, # 5216 4155,5748,5749,2981,5750,5751,5752,5753,3196,4799,4800,2185,1722,5754,3269,3270, # 5232 1843,3665,1715, 481, 365,1976,1857,5755,5756,1963,2498,4801,5757,2127,3666,3271, # 5248 433,1895,2064,2076,5758, 602,2750,5759,5760,5761,5762,5763,3032,1628,3437,5764, # 5264 3197,4802,4156,2904,4803,2519,5765,2551,2782,5766,5767,5768,3343,4804,2905,5769, # 5280 4805,5770,2864,4806,4807,1221,2982,4157,2520,5771,5772,5773,1868,1990,5774,5775, # 5296 5776,1896,5777,5778,4808,1897,4158, 318,5779,2095,4159,4437,5780,5781, 485,5782, # 5312 938,3941, 553,2680, 116,5783,3942,3667,5784,3545,2681,2783,3438,3344,2820,5785, # 5328 3668,2943,4160,1747,2944,2983,5786,5787, 207,5788,4809,5789,4810,2521,5790,3033, # 5344 890,3669,3943,5791,1878,3798,3439,5792,2186,2358,3440,1652,5793,5794,5795, 941, # 5360 2299, 208,3546,4161,2020, 330,4438,3944,2906,2499,3799,4439,4811,5796,5797,5798, # 5376 #last 512 #Everything below is of no interest for detection purpose 2522,1613,4812,5799,3345,3945,2523,5800,4162,5801,1637,4163,2471,4813,3946,5802, # 5392 2500,3034,3800,5803,5804,2195,4814,5805,2163,5806,5807,5808,5809,5810,5811,5812, # 5408 5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828, # 5424 5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844, # 5440 5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,5860, # 5456 5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872,5873,5874,5875,5876, # 5472 5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888,5889,5890,5891,5892, # 5488 5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904,5905,5906,5907,5908, # 5504 5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920,5921,5922,5923,5924, # 5520 5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936,5937,5938,5939,5940, # 5536 5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952,5953,5954,5955,5956, # 5552 5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5969,5970,5971,5972, # 5568 5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984,5985,5986,5987,5988, # 5584 5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004, # 5600 6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020, # 5616 6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036, # 5632 6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052, # 5648 6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068, # 5664 6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084, # 5680 6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100, # 5696 6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116, # 5712 6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132, # 5728 6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148, # 5744 6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164, # 5760 6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180, # 5776 6181,6182,6183,6184,6185,6186,6187,6188,6189,6190,6191,6192,6193,6194,6195,6196, # 5792 6197,6198,6199,6200,6201,6202,6203,6204,6205,6206,6207,6208,6209,6210,6211,6212, # 5808 6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,3670,6224,6225,6226,6227, # 5824 6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241,6242,6243, # 5840 6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6259, # 5856 6260,6261,6262,6263,6264,6265,6266,6267,6268,6269,6270,6271,6272,6273,6274,6275, # 5872 6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,4815,6286,6287,6288,6289,6290, # 5888 6291,6292,4816,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305, # 5904 6306,6307,6308,6309,6310,6311,4817,4818,6312,6313,6314,6315,6316,6317,6318,4819, # 5920 6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6330,6331,6332,6333,6334, # 5936 6335,6336,6337,4820,6338,6339,6340,6341,6342,6343,6344,6345,6346,6347,6348,6349, # 5952 6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6361,6362,6363,6364,6365, # 5968 6366,6367,6368,6369,6370,6371,6372,6373,6374,6375,6376,6377,6378,6379,6380,6381, # 5984 6382,6383,6384,6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395,6396,6397, # 6000 6398,6399,6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,3441,6411,6412, # 6016 6413,6414,6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,4440,6426,6427, # 6032 6428,6429,6430,6431,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443, # 6048 6444,6445,6446,6447,6448,6449,6450,6451,6452,6453,6454,4821,6455,6456,6457,6458, # 6064 6459,6460,6461,6462,6463,6464,6465,6466,6467,6468,6469,6470,6471,6472,6473,6474, # 6080 6475,6476,6477,3947,3948,6478,6479,6480,6481,3272,4441,6482,6483,6484,6485,4442, # 6096 6486,6487,6488,6489,6490,6491,6492,6493,6494,6495,6496,4822,6497,6498,6499,6500, # 6112 6501,6502,6503,6504,6505,6506,6507,6508,6509,6510,6511,6512,6513,6514,6515,6516, # 6128 6517,6518,6519,6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532, # 6144 6533,6534,6535,6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548, # 6160 6549,6550,6551,6552,6553,6554,6555,6556,2784,6557,4823,6558,6559,6560,6561,6562, # 6176 6563,6564,6565,6566,6567,6568,6569,3949,6570,6571,6572,4824,6573,6574,6575,6576, # 6192 6577,6578,6579,6580,6581,6582,6583,4825,6584,6585,6586,3950,2785,6587,6588,6589, # 6208 6590,6591,6592,6593,6594,6595,6596,6597,6598,6599,6600,6601,6602,6603,6604,6605, # 6224 6606,6607,6608,6609,6610,6611,6612,4826,6613,6614,6615,4827,6616,6617,6618,6619, # 6240 6620,6621,6622,6623,6624,6625,4164,6626,6627,6628,6629,6630,6631,6632,6633,6634, # 6256 3547,6635,4828,6636,6637,6638,6639,6640,6641,6642,3951,2984,6643,6644,6645,6646, # 6272 6647,6648,6649,4165,6650,4829,6651,6652,4830,6653,6654,6655,6656,6657,6658,6659, # 6288 6660,6661,6662,4831,6663,6664,6665,6666,6667,6668,6669,6670,6671,4166,6672,4832, # 6304 3952,6673,6674,6675,6676,4833,6677,6678,6679,4167,6680,6681,6682,3198,6683,6684, # 6320 6685,6686,6687,6688,6689,6690,6691,6692,6693,6694,6695,6696,6697,4834,6698,6699, # 6336 6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,6715, # 6352 6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6731, # 6368 6732,6733,6734,4443,6735,6736,6737,6738,6739,6740,6741,6742,6743,6744,6745,4444, # 6384 6746,6747,6748,6749,6750,6751,6752,6753,6754,6755,6756,6757,6758,6759,6760,6761, # 6400 6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777, # 6416 6778,6779,6780,6781,4168,6782,6783,3442,6784,6785,6786,6787,6788,6789,6790,6791, # 6432 4169,6792,6793,6794,6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,6805,6806, # 6448 6807,6808,6809,6810,6811,4835,6812,6813,6814,4445,6815,6816,4446,6817,6818,6819, # 6464 6820,6821,6822,6823,6824,6825,6826,6827,6828,6829,6830,6831,6832,6833,6834,6835, # 6480 3548,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,4836,6847,6848,6849, # 6496 6850,6851,6852,6853,6854,3953,6855,6856,6857,6858,6859,6860,6861,6862,6863,6864, # 6512 6865,6866,6867,6868,6869,6870,6871,6872,6873,6874,6875,6876,6877,3199,6878,6879, # 6528 6880,6881,6882,4447,6883,6884,6885,6886,6887,6888,6889,6890,6891,6892,6893,6894, # 6544 6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,4170,6905,6906,6907,6908,6909, # 6560 6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,6925, # 6576 6926,6927,4837,6928,6929,6930,6931,6932,6933,6934,6935,6936,3346,6937,6938,4838, # 6592 6939,6940,6941,4448,6942,6943,6944,6945,6946,4449,6947,6948,6949,6950,6951,6952, # 6608 6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968, # 6624 6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984, # 6640 6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,3671,6995,6996,6997,6998,4839, # 6656 6999,7000,7001,7002,3549,7003,7004,7005,7006,7007,7008,7009,7010,7011,7012,7013, # 6672 7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028,7029, # 6688 7030,4840,7031,7032,7033,7034,7035,7036,7037,7038,4841,7039,7040,7041,7042,7043, # 6704 7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058,7059, # 6720 7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,2985,7071,7072,7073,7074, # 6736 7075,7076,7077,7078,7079,7080,4842,7081,7082,7083,7084,7085,7086,7087,7088,7089, # 6752 7090,7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,7105, # 6768 7106,7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,4450,7119,7120, # 6784 7121,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136, # 6800 7137,7138,7139,7140,7141,7142,7143,4843,7144,7145,7146,7147,7148,7149,7150,7151, # 6816 7152,7153,7154,7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,7165,7166,7167, # 6832 7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183, # 6848 7184,7185,7186,7187,7188,4171,4172,7189,7190,7191,7192,7193,7194,7195,7196,7197, # 6864 7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213, # 6880 7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7229, # 6896 7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245, # 6912 7246,7247,7248,7249,7250,7251,7252,7253,7254,7255,7256,7257,7258,7259,7260,7261, # 6928 7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277, # 6944 7278,7279,7280,7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293, # 6960 7294,7295,7296,4844,7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308, # 6976 7309,7310,7311,7312,7313,7314,7315,7316,4451,7317,7318,7319,7320,7321,7322,7323, # 6992 7324,7325,7326,7327,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339, # 7008 7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,4173,7354, # 7024 7355,4845,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7367,7368,7369, # 7040 7370,7371,7372,7373,7374,7375,7376,7377,7378,7379,7380,7381,7382,7383,7384,7385, # 7056 7386,7387,7388,4846,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400, # 7072 7401,7402,7403,7404,7405,3672,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415, # 7088 7416,7417,7418,7419,7420,7421,7422,7423,7424,7425,7426,7427,7428,7429,7430,7431, # 7104 7432,7433,7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447, # 7120 7448,7449,7450,7451,7452,7453,4452,7454,3200,7455,7456,7457,7458,7459,7460,7461, # 7136 7462,7463,7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,4847,7475,7476, # 7152 7477,3133,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491, # 7168 7492,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,3347,7503,7504,7505,7506, # 7184 7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,4848, # 7200 7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537, # 7216 7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,3801,4849,7550,7551, # 7232 7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567, # 7248 7568,7569,3035,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582, # 7264 7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598, # 7280 7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614, # 7296 7615,7616,4850,7617,7618,3802,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628, # 7312 7629,7630,7631,7632,4851,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643, # 7328 7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659, # 7344 7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,4453,7671,7672,7673,7674, # 7360 7675,7676,7677,7678,7679,7680,7681,7682,7683,7684,7685,7686,7687,7688,7689,7690, # 7376 7691,7692,7693,7694,7695,7696,7697,3443,7698,7699,7700,7701,7702,4454,7703,7704, # 7392 7705,7706,7707,7708,7709,7710,7711,7712,7713,2472,7714,7715,7716,7717,7718,7719, # 7408 7720,7721,7722,7723,7724,7725,7726,7727,7728,7729,7730,7731,3954,7732,7733,7734, # 7424 7735,7736,7737,7738,7739,7740,7741,7742,7743,7744,7745,7746,7747,7748,7749,7750, # 7440 3134,7751,7752,4852,7753,7754,7755,4853,7756,7757,7758,7759,7760,4174,7761,7762, # 7456 7763,7764,7765,7766,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,7777,7778, # 7472 7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791,7792,7793,7794, # 7488 7795,7796,7797,7798,7799,7800,7801,7802,7803,7804,7805,4854,7806,7807,7808,7809, # 7504 7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824,7825, # 7520 4855,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840, # 7536 7841,7842,7843,7844,7845,7846,7847,3955,7848,7849,7850,7851,7852,7853,7854,7855, # 7552 7856,7857,7858,7859,7860,3444,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870, # 7568 7871,7872,7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886, # 7584 7887,7888,7889,7890,7891,4175,7892,7893,7894,7895,7896,4856,4857,7897,7898,7899, # 7600 7900,2598,7901,7902,7903,7904,7905,7906,7907,7908,4455,7909,7910,7911,7912,7913, # 7616 7914,3201,7915,7916,7917,7918,7919,7920,7921,4858,7922,7923,7924,7925,7926,7927, # 7632 7928,7929,7930,7931,7932,7933,7934,7935,7936,7937,7938,7939,7940,7941,7942,7943, # 7648 7944,7945,7946,7947,7948,7949,7950,7951,7952,7953,7954,7955,7956,7957,7958,7959, # 7664 7960,7961,7962,7963,7964,7965,7966,7967,7968,7969,7970,7971,7972,7973,7974,7975, # 7680 7976,7977,7978,7979,7980,7981,4859,7982,7983,7984,7985,7986,7987,7988,7989,7990, # 7696 7991,7992,7993,7994,7995,7996,4860,7997,7998,7999,8000,8001,8002,8003,8004,8005, # 7712 8006,8007,8008,8009,8010,8011,8012,8013,8014,8015,8016,4176,8017,8018,8019,8020, # 7728 8021,8022,8023,4861,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035, # 7744 8036,4862,4456,8037,8038,8039,8040,4863,8041,8042,8043,8044,8045,8046,8047,8048, # 7760 8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063,8064, # 7776 8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080, # 7792 8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096, # 7808 8097,8098,8099,4864,4177,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110, # 7824 8111,8112,8113,8114,8115,8116,8117,8118,8119,8120,4178,8121,8122,8123,8124,8125, # 7840 8126,8127,8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141, # 7856 8142,8143,8144,8145,4865,4866,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155, # 7872 8156,8157,8158,8159,8160,8161,8162,8163,8164,8165,4179,8166,8167,8168,8169,8170, # 7888 8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181,4457,8182,8183,8184,8185, # 7904 8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201, # 7920 8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,8213,8214,8215,8216,8217, # 7936 8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,8228,8229,8230,8231,8232,8233, # 7952 8234,8235,8236,8237,8238,8239,8240,8241,8242,8243,8244,8245,8246,8247,8248,8249, # 7968 8250,8251,8252,8253,8254,8255,8256,3445,8257,8258,8259,8260,8261,8262,4458,8263, # 7984 8264,8265,8266,8267,8268,8269,8270,8271,8272,4459,8273,8274,8275,8276,3550,8277, # 8000 8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,8288,8289,4460,8290,8291,8292, # 8016 8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,8304,8305,8306,8307,4867, # 8032 8308,8309,8310,8311,8312,3551,8313,8314,8315,8316,8317,8318,8319,8320,8321,8322, # 8048 8323,8324,8325,8326,4868,8327,8328,8329,8330,8331,8332,8333,8334,8335,8336,8337, # 8064 8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,8348,8349,8350,8351,8352,8353, # 8080 8354,8355,8356,8357,8358,8359,8360,8361,8362,8363,4869,4461,8364,8365,8366,8367, # 8096 8368,8369,8370,4870,8371,8372,8373,8374,8375,8376,8377,8378,8379,8380,8381,8382, # 8112 8383,8384,8385,8386,8387,8388,8389,8390,8391,8392,8393,8394,8395,8396,8397,8398, # 8128 8399,8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,4871,8411,8412,8413, # 8144 8414,8415,8416,8417,8418,8419,8420,8421,8422,4462,8423,8424,8425,8426,8427,8428, # 8160 8429,8430,8431,8432,8433,2986,8434,8435,8436,8437,8438,8439,8440,8441,8442,8443, # 8176 8444,8445,8446,8447,8448,8449,8450,8451,8452,8453,8454,8455,8456,8457,8458,8459, # 8192 8460,8461,8462,8463,8464,8465,8466,8467,8468,8469,8470,8471,8472,8473,8474,8475, # 8208 8476,8477,8478,4180,8479,8480,8481,8482,8483,8484,8485,8486,8487,8488,8489,8490, # 8224 8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501,8502,8503,8504,8505,8506, # 8240 8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517,8518,8519,8520,8521,8522, # 8256 8523,8524,8525,8526,8527,8528,8529,8530,8531,8532,8533,8534,8535,8536,8537,8538, # 8272 8539,8540,8541,8542,8543,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554, # 8288 8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,4872,8565,8566,8567,8568,8569, # 8304 8570,8571,8572,8573,4873,8574,8575,8576,8577,8578,8579,8580,8581,8582,8583,8584, # 8320 8585,8586,8587,8588,8589,8590,8591,8592,8593,8594,8595,8596,8597,8598,8599,8600, # 8336 8601,8602,8603,8604,8605,3803,8606,8607,8608,8609,8610,8611,8612,8613,4874,3804, # 8352 8614,8615,8616,8617,8618,8619,8620,8621,3956,8622,8623,8624,8625,8626,8627,8628, # 8368 8629,8630,8631,8632,8633,8634,8635,8636,8637,8638,2865,8639,8640,8641,8642,8643, # 8384 8644,8645,8646,8647,8648,8649,8650,8651,8652,8653,8654,8655,8656,4463,8657,8658, # 8400 8659,4875,4876,8660,8661,8662,8663,8664,8665,8666,8667,8668,8669,8670,8671,8672, # 8416 8673,8674,8675,8676,8677,8678,8679,8680,8681,4464,8682,8683,8684,8685,8686,8687, # 8432 8688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703, # 8448 8704,8705,8706,8707,8708,8709,2261,8710,8711,8712,8713,8714,8715,8716,8717,8718, # 8464 8719,8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,4181, # 8480 8734,8735,8736,8737,8738,8739,8740,8741,8742,8743,8744,8745,8746,8747,8748,8749, # 8496 8750,8751,8752,8753,8754,8755,8756,8757,8758,8759,8760,8761,8762,8763,4877,8764, # 8512 8765,8766,8767,8768,8769,8770,8771,8772,8773,8774,8775,8776,8777,8778,8779,8780, # 8528 8781,8782,8783,8784,8785,8786,8787,8788,4878,8789,4879,8790,8791,8792,4880,8793, # 8544 8794,8795,8796,8797,8798,8799,8800,8801,4881,8802,8803,8804,8805,8806,8807,8808, # 8560 8809,8810,8811,8812,8813,8814,8815,3957,8816,8817,8818,8819,8820,8821,8822,8823, # 8576 8824,8825,8826,8827,8828,8829,8830,8831,8832,8833,8834,8835,8836,8837,8838,8839, # 8592 8840,8841,8842,8843,8844,8845,8846,8847,4882,8848,8849,8850,8851,8852,8853,8854, # 8608 8855,8856,8857,8858,8859,8860,8861,8862,8863,8864,8865,8866,8867,8868,8869,8870, # 8624 8871,8872,8873,8874,8875,8876,8877,8878,8879,8880,8881,8882,8883,8884,3202,8885, # 8640 8886,8887,8888,8889,8890,8891,8892,8893,8894,8895,8896,8897,8898,8899,8900,8901, # 8656 8902,8903,8904,8905,8906,8907,8908,8909,8910,8911,8912,8913,8914,8915,8916,8917, # 8672 8918,8919,8920,8921,8922,8923,8924,4465,8925,8926,8927,8928,8929,8930,8931,8932, # 8688 4883,8933,8934,8935,8936,8937,8938,8939,8940,8941,8942,8943,2214,8944,8945,8946, # 8704 8947,8948,8949,8950,8951,8952,8953,8954,8955,8956,8957,8958,8959,8960,8961,8962, # 8720 8963,8964,8965,4884,8966,8967,8968,8969,8970,8971,8972,8973,8974,8975,8976,8977, # 8736 8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,4885, # 8752 8993,8994,8995,8996,8997,8998,8999,9000,9001,9002,9003,9004,9005,9006,9007,9008, # 8768 9009,9010,9011,9012,9013,9014,9015,9016,9017,9018,9019,9020,9021,4182,9022,9023, # 8784 9024,9025,9026,9027,9028,9029,9030,9031,9032,9033,9034,9035,9036,9037,9038,9039, # 8800 9040,9041,9042,9043,9044,9045,9046,9047,9048,9049,9050,9051,9052,9053,9054,9055, # 8816 9056,9057,9058,9059,9060,9061,9062,9063,4886,9064,9065,9066,9067,9068,9069,4887, # 8832 9070,9071,9072,9073,9074,9075,9076,9077,9078,9079,9080,9081,9082,9083,9084,9085, # 8848 9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9101, # 8864 9102,9103,9104,9105,9106,9107,9108,9109,9110,9111,9112,9113,9114,9115,9116,9117, # 8880 9118,9119,9120,9121,9122,9123,9124,9125,9126,9127,9128,9129,9130,9131,9132,9133, # 8896 9134,9135,9136,9137,9138,9139,9140,9141,3958,9142,9143,9144,9145,9146,9147,9148, # 8912 9149,9150,9151,4888,9152,9153,9154,9155,9156,9157,9158,9159,9160,9161,9162,9163, # 8928 9164,9165,9166,9167,9168,9169,9170,9171,9172,9173,9174,9175,4889,9176,9177,9178, # 8944 9179,9180,9181,9182,9183,9184,9185,9186,9187,9188,9189,9190,9191,9192,9193,9194, # 8960 9195,9196,9197,9198,9199,9200,9201,9202,9203,4890,9204,9205,9206,9207,9208,9209, # 8976 9210,9211,9212,9213,9214,9215,9216,9217,9218,9219,9220,9221,9222,4466,9223,9224, # 8992 9225,9226,9227,9228,9229,9230,9231,9232,9233,9234,9235,9236,9237,9238,9239,9240, # 9008 9241,9242,9243,9244,9245,4891,9246,9247,9248,9249,9250,9251,9252,9253,9254,9255, # 9024 9256,9257,4892,9258,9259,9260,9261,4893,4894,9262,9263,9264,9265,9266,9267,9268, # 9040 9269,9270,9271,9272,9273,4467,9274,9275,9276,9277,9278,9279,9280,9281,9282,9283, # 9056 9284,9285,3673,9286,9287,9288,9289,9290,9291,9292,9293,9294,9295,9296,9297,9298, # 9072 9299,9300,9301,9302,9303,9304,9305,9306,9307,9308,9309,9310,9311,9312,9313,9314, # 9088 9315,9316,9317,9318,9319,9320,9321,9322,4895,9323,9324,9325,9326,9327,9328,9329, # 9104 9330,9331,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345, # 9120 9346,9347,4468,9348,9349,9350,9351,9352,9353,9354,9355,9356,9357,9358,9359,9360, # 9136 9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9372,9373,4896,9374,4469, # 9152 9375,9376,9377,9378,9379,4897,9380,9381,9382,9383,9384,9385,9386,9387,9388,9389, # 9168 9390,9391,9392,9393,9394,9395,9396,9397,9398,9399,9400,9401,9402,9403,9404,9405, # 9184 9406,4470,9407,2751,9408,9409,3674,3552,9410,9411,9412,9413,9414,9415,9416,9417, # 9200 9418,9419,9420,9421,4898,9422,9423,9424,9425,9426,9427,9428,9429,3959,9430,9431, # 9216 9432,9433,9434,9435,9436,4471,9437,9438,9439,9440,9441,9442,9443,9444,9445,9446, # 9232 9447,9448,9449,9450,3348,9451,9452,9453,9454,9455,9456,9457,9458,9459,9460,9461, # 9248 9462,9463,9464,9465,9466,9467,9468,9469,9470,9471,9472,4899,9473,9474,9475,9476, # 9264 9477,4900,9478,9479,9480,9481,9482,9483,9484,9485,9486,9487,9488,3349,9489,9490, # 9280 9491,9492,9493,9494,9495,9496,9497,9498,9499,9500,9501,9502,9503,9504,9505,9506, # 9296 9507,9508,9509,9510,9511,9512,9513,9514,9515,9516,9517,9518,9519,9520,4901,9521, # 9312 9522,9523,9524,9525,9526,4902,9527,9528,9529,9530,9531,9532,9533,9534,9535,9536, # 9328 9537,9538,9539,9540,9541,9542,9543,9544,9545,9546,9547,9548,9549,9550,9551,9552, # 9344 9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568, # 9360 9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,9581,9582,9583,9584, # 9376 3805,9585,9586,9587,9588,9589,9590,9591,9592,9593,9594,9595,9596,9597,9598,9599, # 9392 9600,9601,9602,4903,9603,9604,9605,9606,9607,4904,9608,9609,9610,9611,9612,9613, # 9408 9614,4905,9615,9616,9617,9618,9619,9620,9621,9622,9623,9624,9625,9626,9627,9628, # 9424 9629,9630,9631,9632,4906,9633,9634,9635,9636,9637,9638,9639,9640,9641,9642,9643, # 9440 4907,9644,9645,9646,9647,9648,9649,9650,9651,9652,9653,9654,9655,9656,9657,9658, # 9456 9659,9660,9661,9662,9663,9664,9665,9666,9667,9668,9669,9670,9671,9672,4183,9673, # 9472 9674,9675,9676,9677,4908,9678,9679,9680,9681,4909,9682,9683,9684,9685,9686,9687, # 9488 9688,9689,9690,4910,9691,9692,9693,3675,9694,9695,9696,2945,9697,9698,9699,9700, # 9504 9701,9702,9703,9704,9705,4911,9706,9707,9708,9709,9710,9711,9712,9713,9714,9715, # 9520 9716,9717,9718,9719,9720,9721,9722,9723,9724,9725,9726,9727,9728,9729,9730,9731, # 9536 9732,9733,9734,9735,4912,9736,9737,9738,9739,9740,4913,9741,9742,9743,9744,9745, # 9552 9746,9747,9748,9749,9750,9751,9752,9753,9754,9755,9756,9757,9758,4914,9759,9760, # 9568 9761,9762,9763,9764,9765,9766,9767,9768,9769,9770,9771,9772,9773,9774,9775,9776, # 9584 9777,9778,9779,9780,9781,9782,4915,9783,9784,9785,9786,9787,9788,9789,9790,9791, # 9600 9792,9793,4916,9794,9795,9796,9797,9798,9799,9800,9801,9802,9803,9804,9805,9806, # 9616 9807,9808,9809,9810,9811,9812,9813,9814,9815,9816,9817,9818,9819,9820,9821,9822, # 9632 9823,9824,9825,9826,9827,9828,9829,9830,9831,9832,9833,9834,9835,9836,9837,9838, # 9648 9839,9840,9841,9842,9843,9844,9845,9846,9847,9848,9849,9850,9851,9852,9853,9854, # 9664 9855,9856,9857,9858,9859,9860,9861,9862,9863,9864,9865,9866,9867,9868,4917,9869, # 9680 9870,9871,9872,9873,9874,9875,9876,9877,9878,9879,9880,9881,9882,9883,9884,9885, # 9696 9886,9887,9888,9889,9890,9891,9892,4472,9893,9894,9895,9896,9897,3806,9898,9899, # 9712 9900,9901,9902,9903,9904,9905,9906,9907,9908,9909,9910,9911,9912,9913,9914,4918, # 9728 9915,9916,9917,4919,9918,9919,9920,9921,4184,9922,9923,9924,9925,9926,9927,9928, # 9744 9929,9930,9931,9932,9933,9934,9935,9936,9937,9938,9939,9940,9941,9942,9943,9944, # 9760 9945,9946,4920,9947,9948,9949,9950,9951,9952,9953,9954,9955,4185,9956,9957,9958, # 9776 9959,9960,9961,9962,9963,9964,9965,4921,9966,9967,9968,4473,9969,9970,9971,9972, # 9792 9973,9974,9975,9976,9977,4474,9978,9979,9980,9981,9982,9983,9984,9985,9986,9987, # 9808 9988,9989,9990,9991,9992,9993,9994,9995,9996,9997,9998,9999,10000,10001,10002,10003, # 9824 10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,10016,10017,10018,10019, # 9840 10020,10021,4922,10022,4923,10023,10024,10025,10026,10027,10028,10029,10030,10031,10032,10033, # 9856 10034,10035,10036,10037,10038,10039,10040,10041,10042,10043,10044,10045,10046,10047,10048,4924, # 9872 10049,10050,10051,10052,10053,10054,10055,10056,10057,10058,10059,10060,10061,10062,10063,10064, # 9888 10065,10066,10067,10068,10069,10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080, # 9904 10081,10082,10083,10084,10085,10086,10087,4475,10088,10089,10090,10091,10092,10093,10094,10095, # 9920 10096,10097,4476,10098,10099,10100,10101,10102,10103,10104,10105,10106,10107,10108,10109,10110, # 9936 10111,2174,10112,10113,10114,10115,10116,10117,10118,10119,10120,10121,10122,10123,10124,10125, # 9952 10126,10127,10128,10129,10130,10131,10132,10133,10134,10135,10136,10137,10138,10139,10140,3807, # 9968 4186,4925,10141,10142,10143,10144,10145,10146,10147,4477,4187,10148,10149,10150,10151,10152, # 9984 10153,4188,10154,10155,10156,10157,10158,10159,10160,10161,4926,10162,10163,10164,10165,10166, #10000 10167,10168,10169,10170,10171,10172,10173,10174,10175,10176,10177,10178,10179,10180,10181,10182, #10016 10183,10184,10185,10186,10187,10188,10189,10190,10191,10192,3203,10193,10194,10195,10196,10197, #10032 10198,10199,10200,4478,10201,10202,10203,10204,4479,10205,10206,10207,10208,10209,10210,10211, #10048 10212,10213,10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10224,10225,10226,10227, #10064 10228,10229,10230,10231,10232,10233,10234,4927,10235,10236,10237,10238,10239,10240,10241,10242, #10080 10243,10244,10245,10246,10247,10248,10249,10250,10251,10252,10253,10254,10255,10256,10257,10258, #10096 10259,10260,10261,10262,10263,10264,10265,10266,10267,10268,10269,10270,10271,10272,10273,4480, #10112 4928,4929,10274,10275,10276,10277,10278,10279,10280,10281,10282,10283,10284,10285,10286,10287, #10128 10288,10289,10290,10291,10292,10293,10294,10295,10296,10297,10298,10299,10300,10301,10302,10303, #10144 10304,10305,10306,10307,10308,10309,10310,10311,10312,10313,10314,10315,10316,10317,10318,10319, #10160 10320,10321,10322,10323,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334,4930, #10176 10335,10336,10337,10338,10339,10340,10341,10342,4931,10343,10344,10345,10346,10347,10348,10349, #10192 10350,10351,10352,10353,10354,10355,3088,10356,2786,10357,10358,10359,10360,4189,10361,10362, #10208 10363,10364,10365,10366,10367,10368,10369,10370,10371,10372,10373,10374,10375,4932,10376,10377, #10224 10378,10379,10380,10381,10382,10383,10384,10385,10386,10387,10388,10389,10390,10391,10392,4933, #10240 10393,10394,10395,4934,10396,10397,10398,10399,10400,10401,10402,10403,10404,10405,10406,10407, #10256 10408,10409,10410,10411,10412,3446,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422, #10272 10423,4935,10424,10425,10426,10427,10428,10429,10430,4936,10431,10432,10433,10434,10435,10436, #10288 10437,10438,10439,10440,10441,10442,10443,4937,10444,10445,10446,10447,4481,10448,10449,10450, #10304 10451,10452,10453,10454,10455,10456,10457,10458,10459,10460,10461,10462,10463,10464,10465,10466, #10320 10467,10468,10469,10470,10471,10472,10473,10474,10475,10476,10477,10478,10479,10480,10481,10482, #10336 10483,10484,10485,10486,10487,10488,10489,10490,10491,10492,10493,10494,10495,10496,10497,10498, #10352 10499,10500,10501,10502,10503,10504,10505,4938,10506,10507,10508,10509,10510,2552,10511,10512, #10368 10513,10514,10515,10516,3447,10517,10518,10519,10520,10521,10522,10523,10524,10525,10526,10527, #10384 10528,10529,10530,10531,10532,10533,10534,10535,10536,10537,10538,10539,10540,10541,10542,10543, #10400 4482,10544,4939,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557, #10416 10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,3676,4483,10568,10569,10570,10571, #10432 10572,3448,10573,10574,10575,10576,10577,10578,10579,10580,10581,10582,10583,10584,10585,10586, #10448 10587,10588,10589,10590,10591,10592,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602, #10464 10603,10604,10605,10606,10607,10608,10609,10610,10611,10612,10613,10614,10615,10616,10617,10618, #10480 10619,10620,10621,10622,10623,10624,10625,10626,10627,4484,10628,10629,10630,10631,10632,4940, #10496 10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646,10647,10648, #10512 10649,10650,10651,10652,10653,10654,10655,10656,4941,10657,10658,10659,2599,10660,10661,10662, #10528 10663,10664,10665,10666,3089,10667,10668,10669,10670,10671,10672,10673,10674,10675,10676,10677, #10544 10678,10679,10680,4942,10681,10682,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692, #10560 10693,10694,10695,10696,10697,4485,10698,10699,10700,10701,10702,10703,10704,4943,10705,3677, #10576 10706,10707,10708,10709,10710,10711,10712,4944,10713,10714,10715,10716,10717,10718,10719,10720, #10592 10721,10722,10723,10724,10725,10726,10727,10728,4945,10729,10730,10731,10732,10733,10734,10735, #10608 10736,10737,10738,10739,10740,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751, #10624 10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,4946,10762,10763,10764,10765,10766, #10640 10767,4947,4948,10768,10769,10770,10771,10772,10773,10774,10775,10776,10777,10778,10779,10780, #10656 10781,10782,10783,10784,10785,10786,10787,10788,10789,10790,10791,10792,10793,10794,10795,10796, #10672 10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812, #10688 10813,10814,10815,10816,10817,10818,10819,10820,10821,10822,10823,10824,10825,10826,10827,10828, #10704 10829,10830,10831,10832,10833,10834,10835,10836,10837,10838,10839,10840,10841,10842,10843,10844, #10720 10845,10846,10847,10848,10849,10850,10851,10852,10853,10854,10855,10856,10857,10858,10859,10860, #10736 10861,10862,10863,10864,10865,10866,10867,10868,10869,10870,10871,10872,10873,10874,10875,10876, #10752 10877,10878,4486,10879,10880,10881,10882,10883,10884,10885,4949,10886,10887,10888,10889,10890, #10768 10891,10892,10893,10894,10895,10896,10897,10898,10899,10900,10901,10902,10903,10904,10905,10906, #10784 10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,4487,10920,10921, #10800 10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,4950,10933,10934,10935,10936, #10816 10937,10938,10939,10940,10941,10942,10943,10944,10945,10946,10947,10948,10949,4488,10950,10951, #10832 10952,10953,10954,10955,10956,10957,10958,10959,4190,10960,10961,10962,10963,10964,10965,10966, #10848 10967,10968,10969,10970,10971,10972,10973,10974,10975,10976,10977,10978,10979,10980,10981,10982, #10864 10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993,10994,10995,10996,10997,10998, #10880 10999,11000,11001,11002,11003,11004,11005,11006,3960,11007,11008,11009,11010,11011,11012,11013, #10896 11014,11015,11016,11017,11018,11019,11020,11021,11022,11023,11024,11025,11026,11027,11028,11029, #10912 11030,11031,11032,4951,11033,11034,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044, #10928 11045,11046,11047,4489,11048,11049,11050,11051,4952,11052,11053,11054,11055,11056,11057,11058, #10944 4953,11059,11060,11061,11062,11063,11064,11065,11066,11067,11068,11069,11070,11071,4954,11072, #10960 11073,11074,11075,11076,11077,11078,11079,11080,11081,11082,11083,11084,11085,11086,11087,11088, #10976 11089,11090,11091,11092,11093,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104, #10992 11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,3808,11116,11117,11118,11119, #11008 11120,11121,11122,11123,11124,11125,11126,11127,11128,11129,11130,11131,11132,11133,11134,4955, #11024 11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150, #11040 11151,11152,11153,11154,11155,11156,11157,11158,11159,11160,11161,4956,11162,11163,11164,11165, #11056 11166,11167,11168,11169,11170,11171,11172,11173,11174,11175,11176,11177,11178,11179,11180,4957, #11072 11181,11182,11183,11184,11185,11186,4958,11187,11188,11189,11190,11191,11192,11193,11194,11195, #11088 11196,11197,11198,11199,11200,3678,11201,11202,11203,11204,11205,11206,4191,11207,11208,11209, #11104 11210,11211,11212,11213,11214,11215,11216,11217,11218,11219,11220,11221,11222,11223,11224,11225, #11120 11226,11227,11228,11229,11230,11231,11232,11233,11234,11235,11236,11237,11238,11239,11240,11241, #11136 11242,11243,11244,11245,11246,11247,11248,11249,11250,11251,4959,11252,11253,11254,11255,11256, #11152 11257,11258,11259,11260,11261,11262,11263,11264,11265,11266,11267,11268,11269,11270,11271,11272, #11168 11273,11274,11275,11276,11277,11278,11279,11280,11281,11282,11283,11284,11285,11286,11287,11288, #11184 11289,11290,11291,11292,11293,11294,11295,11296,11297,11298,11299,11300,11301,11302,11303,11304, #11200 11305,11306,11307,11308,11309,11310,11311,11312,11313,11314,3679,11315,11316,11317,11318,4490, #11216 11319,11320,11321,11322,11323,11324,11325,11326,11327,11328,11329,11330,11331,11332,11333,11334, #11232 11335,11336,11337,11338,11339,11340,11341,11342,11343,11344,11345,11346,11347,4960,11348,11349, #11248 11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365, #11264 11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,3961,4961,11378,11379, #11280 11380,11381,11382,11383,11384,11385,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395, #11296 11396,11397,4192,11398,11399,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410, #11312 11411,4962,11412,11413,11414,11415,11416,11417,11418,11419,11420,11421,11422,11423,11424,11425, #11328 11426,11427,11428,11429,11430,11431,11432,11433,11434,11435,11436,11437,11438,11439,11440,11441, #11344 11442,11443,11444,11445,11446,11447,11448,11449,11450,11451,11452,11453,11454,11455,11456,11457, #11360 11458,11459,11460,11461,11462,11463,11464,11465,11466,11467,11468,11469,4963,11470,11471,4491, #11376 11472,11473,11474,11475,4964,11476,11477,11478,11479,11480,11481,11482,11483,11484,11485,11486, #11392 11487,11488,11489,11490,11491,11492,4965,11493,11494,11495,11496,11497,11498,11499,11500,11501, #11408 11502,11503,11504,11505,11506,11507,11508,11509,11510,11511,11512,11513,11514,11515,11516,11517, #11424 11518,11519,11520,11521,11522,11523,11524,11525,11526,11527,11528,11529,3962,11530,11531,11532, #11440 11533,11534,11535,11536,11537,11538,11539,11540,11541,11542,11543,11544,11545,11546,11547,11548, #11456 11549,11550,11551,11552,11553,11554,11555,11556,11557,11558,11559,11560,11561,11562,11563,11564, #11472 4193,4194,11565,11566,11567,11568,11569,11570,11571,11572,11573,11574,11575,11576,11577,11578, #11488 11579,11580,11581,11582,11583,11584,11585,11586,11587,11588,11589,11590,11591,4966,4195,11592, #11504 11593,11594,11595,11596,11597,11598,11599,11600,11601,11602,11603,11604,3090,11605,11606,11607, #11520 11608,11609,11610,4967,11611,11612,11613,11614,11615,11616,11617,11618,11619,11620,11621,11622, #11536 11623,11624,11625,11626,11627,11628,11629,11630,11631,11632,11633,11634,11635,11636,11637,11638, #11552 11639,11640,11641,11642,11643,11644,11645,11646,11647,11648,11649,11650,11651,11652,11653,11654, #11568 11655,11656,11657,11658,11659,11660,11661,11662,11663,11664,11665,11666,11667,11668,11669,11670, #11584 11671,11672,11673,11674,4968,11675,11676,11677,11678,11679,11680,11681,11682,11683,11684,11685, #11600 11686,11687,11688,11689,11690,11691,11692,11693,3809,11694,11695,11696,11697,11698,11699,11700, #11616 11701,11702,11703,11704,11705,11706,11707,11708,11709,11710,11711,11712,11713,11714,11715,11716, #11632 11717,11718,3553,11719,11720,11721,11722,11723,11724,11725,11726,11727,11728,11729,11730,4969, #11648 11731,11732,11733,11734,11735,11736,11737,11738,11739,11740,4492,11741,11742,11743,11744,11745, #11664 11746,11747,11748,11749,11750,11751,11752,4970,11753,11754,11755,11756,11757,11758,11759,11760, #11680 11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,11776, #11696 11777,11778,11779,11780,11781,11782,11783,11784,11785,11786,11787,11788,11789,11790,4971,11791, #11712 11792,11793,11794,11795,11796,11797,4972,11798,11799,11800,11801,11802,11803,11804,11805,11806, #11728 11807,11808,11809,11810,4973,11811,11812,11813,11814,11815,11816,11817,11818,11819,11820,11821, #11744 11822,11823,11824,11825,11826,11827,11828,11829,11830,11831,11832,11833,11834,3680,3810,11835, #11760 11836,4974,11837,11838,11839,11840,11841,11842,11843,11844,11845,11846,11847,11848,11849,11850, #11776 11851,11852,11853,11854,11855,11856,11857,11858,11859,11860,11861,11862,11863,11864,11865,11866, #11792 11867,11868,11869,11870,11871,11872,11873,11874,11875,11876,11877,11878,11879,11880,11881,11882, #11808 11883,11884,4493,11885,11886,11887,11888,11889,11890,11891,11892,11893,11894,11895,11896,11897, #11824 11898,11899,11900,11901,11902,11903,11904,11905,11906,11907,11908,11909,11910,11911,11912,11913, #11840 11914,11915,4975,11916,11917,11918,11919,11920,11921,11922,11923,11924,11925,11926,11927,11928, #11856 11929,11930,11931,11932,11933,11934,11935,11936,11937,11938,11939,11940,11941,11942,11943,11944, #11872 11945,11946,11947,11948,11949,4976,11950,11951,11952,11953,11954,11955,11956,11957,11958,11959, #11888 11960,11961,11962,11963,11964,11965,11966,11967,11968,11969,11970,11971,11972,11973,11974,11975, #11904 11976,11977,11978,11979,11980,11981,11982,11983,11984,11985,11986,11987,4196,11988,11989,11990, #11920 11991,11992,4977,11993,11994,11995,11996,11997,11998,11999,12000,12001,12002,12003,12004,12005, #11936 12006,12007,12008,12009,12010,12011,12012,12013,12014,12015,12016,12017,12018,12019,12020,12021, #11952 12022,12023,12024,12025,12026,12027,12028,12029,12030,12031,12032,12033,12034,12035,12036,12037, #11968 12038,12039,12040,12041,12042,12043,12044,12045,12046,12047,12048,12049,12050,12051,12052,12053, #11984 12054,12055,12056,12057,12058,12059,12060,12061,4978,12062,12063,12064,12065,12066,12067,12068, #12000 12069,12070,12071,12072,12073,12074,12075,12076,12077,12078,12079,12080,12081,12082,12083,12084, #12016 12085,12086,12087,12088,12089,12090,12091,12092,12093,12094,12095,12096,12097,12098,12099,12100, #12032 12101,12102,12103,12104,12105,12106,12107,12108,12109,12110,12111,12112,12113,12114,12115,12116, #12048 12117,12118,12119,12120,12121,12122,12123,4979,12124,12125,12126,12127,12128,4197,12129,12130, #12064 12131,12132,12133,12134,12135,12136,12137,12138,12139,12140,12141,12142,12143,12144,12145,12146, #12080 12147,12148,12149,12150,12151,12152,12153,12154,4980,12155,12156,12157,12158,12159,12160,4494, #12096 12161,12162,12163,12164,3811,12165,12166,12167,12168,12169,4495,12170,12171,4496,12172,12173, #12112 12174,12175,12176,3812,12177,12178,12179,12180,12181,12182,12183,12184,12185,12186,12187,12188, #12128 12189,12190,12191,12192,12193,12194,12195,12196,12197,12198,12199,12200,12201,12202,12203,12204, #12144 12205,12206,12207,12208,12209,12210,12211,12212,12213,12214,12215,12216,12217,12218,12219,12220, #12160 12221,4981,12222,12223,12224,12225,12226,12227,12228,12229,12230,12231,12232,12233,12234,12235, #12176 4982,12236,12237,12238,12239,12240,12241,12242,12243,12244,12245,4983,12246,12247,12248,12249, #12192 4984,12250,12251,12252,12253,12254,12255,12256,12257,12258,12259,12260,12261,12262,12263,12264, #12208 4985,12265,4497,12266,12267,12268,12269,12270,12271,12272,12273,12274,12275,12276,12277,12278, #12224 12279,12280,12281,12282,12283,12284,12285,12286,12287,4986,12288,12289,12290,12291,12292,12293, #12240 12294,12295,12296,2473,12297,12298,12299,12300,12301,12302,12303,12304,12305,12306,12307,12308, #12256 12309,12310,12311,12312,12313,12314,12315,12316,12317,12318,12319,3963,12320,12321,12322,12323, #12272 12324,12325,12326,12327,12328,12329,12330,12331,12332,4987,12333,12334,12335,12336,12337,12338, #12288 12339,12340,12341,12342,12343,12344,12345,12346,12347,12348,12349,12350,12351,12352,12353,12354, #12304 12355,12356,12357,12358,12359,3964,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369, #12320 12370,3965,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384, #12336 12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400, #12352 12401,12402,12403,12404,12405,12406,12407,12408,4988,12409,12410,12411,12412,12413,12414,12415, #12368 12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431, #12384 12432,12433,12434,12435,12436,12437,12438,3554,12439,12440,12441,12442,12443,12444,12445,12446, #12400 12447,12448,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462, #12416 12463,12464,4989,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477, #12432 12478,12479,12480,4990,12481,12482,12483,12484,12485,12486,12487,12488,12489,4498,12490,12491, #12448 12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507, #12464 12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523, #12480 12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,12535,12536,12537,12538,12539, #12496 12540,12541,12542,12543,12544,12545,12546,12547,12548,12549,12550,12551,4991,12552,12553,12554, #12512 12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,12570, #12528 12571,12572,12573,12574,12575,12576,12577,12578,3036,12579,12580,12581,12582,12583,3966,12584, #12544 12585,12586,12587,12588,12589,12590,12591,12592,12593,12594,12595,12596,12597,12598,12599,12600, #12560 12601,12602,12603,12604,12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616, #12576 12617,12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,12631,12632, #12592 12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,4499,12647, #12608 12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,12659,12660,12661,12662,12663, #12624 12664,12665,12666,12667,12668,12669,12670,12671,12672,12673,12674,12675,12676,12677,12678,12679, #12640 12680,12681,12682,12683,12684,12685,12686,12687,12688,12689,12690,12691,12692,12693,12694,12695, #12656 12696,12697,12698,4992,12699,12700,12701,12702,12703,12704,12705,12706,12707,12708,12709,12710, #12672 12711,12712,12713,12714,12715,12716,12717,12718,12719,12720,12721,12722,12723,12724,12725,12726, #12688 12727,12728,12729,12730,12731,12732,12733,12734,12735,12736,12737,12738,12739,12740,12741,12742, #12704 12743,12744,12745,12746,12747,12748,12749,12750,12751,12752,12753,12754,12755,12756,12757,12758, #12720 12759,12760,12761,12762,12763,12764,12765,12766,12767,12768,12769,12770,12771,12772,12773,12774, #12736 12775,12776,12777,12778,4993,2175,12779,12780,12781,12782,12783,12784,12785,12786,4500,12787, #12752 12788,12789,12790,12791,12792,12793,12794,12795,12796,12797,12798,12799,12800,12801,12802,12803, #12768 12804,12805,12806,12807,12808,12809,12810,12811,12812,12813,12814,12815,12816,12817,12818,12819, #12784 12820,12821,12822,12823,12824,12825,12826,4198,3967,12827,12828,12829,12830,12831,12832,12833, #12800 12834,12835,12836,12837,12838,12839,12840,12841,12842,12843,12844,12845,12846,12847,12848,12849, #12816 12850,12851,12852,12853,12854,12855,12856,12857,12858,12859,12860,12861,4199,12862,12863,12864, #12832 12865,12866,12867,12868,12869,12870,12871,12872,12873,12874,12875,12876,12877,12878,12879,12880, #12848 12881,12882,12883,12884,12885,12886,12887,4501,12888,12889,12890,12891,12892,12893,12894,12895, #12864 12896,12897,12898,12899,12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,12911, #12880 12912,4994,12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,12923,12924,12925,12926, #12896 12927,12928,12929,12930,12931,12932,12933,12934,12935,12936,12937,12938,12939,12940,12941,12942, #12912 12943,12944,12945,12946,12947,12948,12949,12950,12951,12952,12953,12954,12955,12956,1772,12957, #12928 12958,12959,12960,12961,12962,12963,12964,12965,12966,12967,12968,12969,12970,12971,12972,12973, #12944 12974,12975,12976,12977,12978,12979,12980,12981,12982,12983,12984,12985,12986,12987,12988,12989, #12960 12990,12991,12992,12993,12994,12995,12996,12997,4502,12998,4503,12999,13000,13001,13002,13003, #12976 4504,13004,13005,13006,13007,13008,13009,13010,13011,13012,13013,13014,13015,13016,13017,13018, #12992 13019,13020,13021,13022,13023,13024,13025,13026,13027,13028,13029,3449,13030,13031,13032,13033, #13008 13034,13035,13036,13037,13038,13039,13040,13041,13042,13043,13044,13045,13046,13047,13048,13049, #13024 13050,13051,13052,13053,13054,13055,13056,13057,13058,13059,13060,13061,13062,13063,13064,13065, #13040 13066,13067,13068,13069,13070,13071,13072,13073,13074,13075,13076,13077,13078,13079,13080,13081, #13056 13082,13083,13084,13085,13086,13087,13088,13089,13090,13091,13092,13093,13094,13095,13096,13097, #13072 13098,13099,13100,13101,13102,13103,13104,13105,13106,13107,13108,13109,13110,13111,13112,13113, #13088 13114,13115,13116,13117,13118,3968,13119,4995,13120,13121,13122,13123,13124,13125,13126,13127, #13104 4505,13128,13129,13130,13131,13132,13133,13134,4996,4506,13135,13136,13137,13138,13139,4997, #13120 13140,13141,13142,13143,13144,13145,13146,13147,13148,13149,13150,13151,13152,13153,13154,13155, #13136 13156,13157,13158,13159,4998,13160,13161,13162,13163,13164,13165,13166,13167,13168,13169,13170, #13152 13171,13172,13173,13174,13175,13176,4999,13177,13178,13179,13180,13181,13182,13183,13184,13185, #13168 13186,13187,13188,13189,13190,13191,13192,13193,13194,13195,13196,13197,13198,13199,13200,13201, #13184 13202,13203,13204,13205,13206,5000,13207,13208,13209,13210,13211,13212,13213,13214,13215,13216, #13200 13217,13218,13219,13220,13221,13222,13223,13224,13225,13226,13227,4200,5001,13228,13229,13230, #13216 13231,13232,13233,13234,13235,13236,13237,13238,13239,13240,3969,13241,13242,13243,13244,3970, #13232 13245,13246,13247,13248,13249,13250,13251,13252,13253,13254,13255,13256,13257,13258,13259,13260, #13248 13261,13262,13263,13264,13265,13266,13267,13268,3450,13269,13270,13271,13272,13273,13274,13275, #13264 13276,5002,13277,13278,13279,13280,13281,13282,13283,13284,13285,13286,13287,13288,13289,13290, #13280 13291,13292,13293,13294,13295,13296,13297,13298,13299,13300,13301,13302,3813,13303,13304,13305, #13296 13306,13307,13308,13309,13310,13311,13312,13313,13314,13315,13316,13317,13318,13319,13320,13321, #13312 13322,13323,13324,13325,13326,13327,13328,4507,13329,13330,13331,13332,13333,13334,13335,13336, #13328 13337,13338,13339,13340,13341,5003,13342,13343,13344,13345,13346,13347,13348,13349,13350,13351, #13344 13352,13353,13354,13355,13356,13357,13358,13359,13360,13361,13362,13363,13364,13365,13366,13367, #13360 5004,13368,13369,13370,13371,13372,13373,13374,13375,13376,13377,13378,13379,13380,13381,13382, #13376 13383,13384,13385,13386,13387,13388,13389,13390,13391,13392,13393,13394,13395,13396,13397,13398, #13392 13399,13400,13401,13402,13403,13404,13405,13406,13407,13408,13409,13410,13411,13412,13413,13414, #13408 13415,13416,13417,13418,13419,13420,13421,13422,13423,13424,13425,13426,13427,13428,13429,13430, #13424 13431,13432,4508,13433,13434,13435,4201,13436,13437,13438,13439,13440,13441,13442,13443,13444, #13440 13445,13446,13447,13448,13449,13450,13451,13452,13453,13454,13455,13456,13457,5005,13458,13459, #13456 13460,13461,13462,13463,13464,13465,13466,13467,13468,13469,13470,4509,13471,13472,13473,13474, #13472 13475,13476,13477,13478,13479,13480,13481,13482,13483,13484,13485,13486,13487,13488,13489,13490, #13488 13491,13492,13493,13494,13495,13496,13497,13498,13499,13500,13501,13502,13503,13504,13505,13506, #13504 13507,13508,13509,13510,13511,13512,13513,13514,13515,13516,13517,13518,13519,13520,13521,13522, #13520 13523,13524,13525,13526,13527,13528,13529,13530,13531,13532,13533,13534,13535,13536,13537,13538, #13536 13539,13540,13541,13542,13543,13544,13545,13546,13547,13548,13549,13550,13551,13552,13553,13554, #13552 13555,13556,13557,13558,13559,13560,13561,13562,13563,13564,13565,13566,13567,13568,13569,13570, #13568 13571,13572,13573,13574,13575,13576,13577,13578,13579,13580,13581,13582,13583,13584,13585,13586, #13584 13587,13588,13589,13590,13591,13592,13593,13594,13595,13596,13597,13598,13599,13600,13601,13602, #13600 13603,13604,13605,13606,13607,13608,13609,13610,13611,13612,13613,13614,13615,13616,13617,13618, #13616 13619,13620,13621,13622,13623,13624,13625,13626,13627,13628,13629,13630,13631,13632,13633,13634, #13632 13635,13636,13637,13638,13639,13640,13641,13642,5006,13643,13644,13645,13646,13647,13648,13649, #13648 13650,13651,5007,13652,13653,13654,13655,13656,13657,13658,13659,13660,13661,13662,13663,13664, #13664 13665,13666,13667,13668,13669,13670,13671,13672,13673,13674,13675,13676,13677,13678,13679,13680, #13680 13681,13682,13683,13684,13685,13686,13687,13688,13689,13690,13691,13692,13693,13694,13695,13696, #13696 13697,13698,13699,13700,13701,13702,13703,13704,13705,13706,13707,13708,13709,13710,13711,13712, #13712 13713,13714,13715,13716,13717,13718,13719,13720,13721,13722,13723,13724,13725,13726,13727,13728, #13728 13729,13730,13731,13732,13733,13734,13735,13736,13737,13738,13739,13740,13741,13742,13743,13744, #13744 13745,13746,13747,13748,13749,13750,13751,13752,13753,13754,13755,13756,13757,13758,13759,13760, #13760 13761,13762,13763,13764,13765,13766,13767,13768,13769,13770,13771,13772,13773,13774,3273,13775, #13776 13776,13777,13778,13779,13780,13781,13782,13783,13784,13785,13786,13787,13788,13789,13790,13791, #13792 13792,13793,13794,13795,13796,13797,13798,13799,13800,13801,13802,13803,13804,13805,13806,13807, #13808 13808,13809,13810,13811,13812,13813,13814,13815,13816,13817,13818,13819,13820,13821,13822,13823, #13824 13824,13825,13826,13827,13828,13829,13830,13831,13832,13833,13834,13835,13836,13837,13838,13839, #13840 13840,13841,13842,13843,13844,13845,13846,13847,13848,13849,13850,13851,13852,13853,13854,13855, #13856 13856,13857,13858,13859,13860,13861,13862,13863,13864,13865,13866,13867,13868,13869,13870,13871, #13872 13872,13873,13874,13875,13876,13877,13878,13879,13880,13881,13882,13883,13884,13885,13886,13887, #13888 13888,13889,13890,13891,13892,13893,13894,13895,13896,13897,13898,13899,13900,13901,13902,13903, #13904 13904,13905,13906,13907,13908,13909,13910,13911,13912,13913,13914,13915,13916,13917,13918,13919, #13920 13920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,13931,13932,13933,13934,13935, #13936 13936,13937,13938,13939,13940,13941,13942,13943,13944,13945,13946,13947,13948,13949,13950,13951, #13952 13952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,13967, #13968 13968,13969,13970,13971,13972) #13973 # 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, 13123, 21, 9857, 1817, 199, 3, 701, 377, 5789, 20444, 1159, 603, 460, 285, 262, 27724, 23193, 1849, 1097, 382, 199, 3, 665, 1014, 921, 1544, 14, 8654, 14, 8122, 26, 2835, 15, 10333, 82, 3133, 199, 3, 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, 21245, 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, 18643, 21, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 378, 14, 2194, 199, 199, 3, 1610, 370, 481, 2103, 4738, 1817, 199, 18643, 21, 63, 8723, 63, 4305, 275, 959, 11452, 199, 199, 7279, 21, 18139, 13875, 4738, 275, 334, 2043, 413, 12, 1085, 614, 12, 1046, 1690, 12, 5450, 12, 1079, 2192, 12, 413, 2905, 12, 257, 1749, 12, 221, 18051, 12, 257, 1227, 12, 5783, 24, 12, 413, 1138, 12, 19328, 12, 1344, 2835, 12, 713, 1367, 12, 1651, 2025, 12, 16814, 12, 327, 257, 3193, 199, 1703, 1079, 12, 221, 9404, 12, 708, 1342, 12, 499, 2976, 12, 221, 14646, 12, 221, 10868, 12, 18, 7636, 12, 221, 3193, 12, 1398, 2466, 12, 9252, 23, 12, 31989, 12, 1227, 1427, 12, 1355, 3172, 12, 221, 7875, 12, 1082, 2869, 12, 1479, 2481, 12, 327, 257, 4337, 199, 845, 2905, 12, 1355, 2819, 12, 1153, 1400, 12, 2260, 996, 12, 32321, 12, 1081, 1046, 12, 11485, 12, 959, 2710, 12, 650, 2976, 12, 1167, 772, 12, 257, 1695, 12, 14785, 12, 221, 13713, 12, 2322, 709, 12, 5783, 25, 12, 1167, 708, 12, 327, 257, 9615, 523, 13668, 12, 8216, 16, 12, 8216, 17, 12, 650, 1196, 12, 975, 1079, 12, 221, 13098, 12, 26485, 12, 413, 1427, 12, 20, 11341, 12, 1194, 1196, 12, 1079, 1257, 12, 8216, 18, 12, 10156, 21, 12, 1216, 3328, 12, 18565, 12, 29736, 12, 327, 257, 5049, 199, 1344, 2564, 12, 257, 650, 12, 221, 1616, 12, 1355, 2898, 12, 1079, 3172, 12, 221, 7349, 12, 1465, 1555, 12, 845, 1276, 12, 11125, 22, 12, 30614, 12, 10513, 19, 12, 21334, 12, 708, 2194, 12, 17, 4288, 12, 650, 713, 12, 8216, 19, 12, 327, 257, 5939, 199, 2322, 845, 12, 1165, 2528, 12, 959, 1780, 12, 27210, 12, 1227, 2564, 12, 8216, 20, 12, 31308, 12, 1167, 1046, 12, 25442, 12, 26761, 12, 1398, 2417, 12, 221, 8177, 12, 10156, 22, 12, 708, 966, 12, 221, 5049, 12, 1227, 966, 12, 327, 257, 15580, 199, 8216, 21, 12, 821, 614, 12, 1167, 1138, 12, 1167, 2277, 12, 29710, 12, 7155, 17, 12, 5049, 21, 12, 5049, 17, 12, 975, 1690, 12, 8216, 22, 12, 1082, 2528, 12, 650, 1401, 12, 221, 15323, 12, 841, 1690, 12, 8216, 23, 12, 221, 5939, 12, 327, 221, 20240, 199, 1227, 1216, 12, 27077, 12, 708, 1717, 12, 1046, 1643, 12, 499, 2766, 12, 1749, 1355, 12, 709, 2942, 12, 1479, 1477, 12, 1520, 1367, 12, 1079, 2167, 12, 709, 2635, 12, 1082, 2481, 12, 841, 1887, 12, 221, 14610, 12, 1398, 1555, 12, 959, 3328, 12, 327, 221, 7960, 199, 31420, 12, 1165, 2534, 12, 841, 3172, 12, 22560, 12, 1165, 1276, 12, 1085, 1602, 12, 221, 5212, 12, 221, 5238, 12, 1398, 1299, 12, 25956, 12, 5939, 22, 12, 1085, 1876, 12, 1520, 1082, 12, 1165, 1344, 12, 1082, 1477, 12, 13576, 12, 327, 221, 21771, 199, 8806, 21, 12, 975, 1780, 12, 32609, 12, 959, 1401, 12, 1398, 1780, 12, 1227, 1299, 12, 8216, 24, 12, 650, 1167, 12, 969, 1717, 12, 8375, 25, 12, 6886, 21, 12, 959, 1079, 12, 10638, 25, 12, 499, 2905, 12, 2322, 713, 12, 650, 1427, 12, 327, 221, 21235, 199, 27874, 12, 221, 9137, 12, 1465, 975, 12, 969, 1703, 12, 1227, 2766, 12, 221, 4119, 12, 1749, 1690, 12, 709, 1020, 12, 2299, 19, 12, 221, 3388, 12, 1194, 2953, 12, 413, 2564, 12, 959, 708, 12, 1196, 975, 12, 8216, 25, 12, 1520, 708, 12, 327, 221, 27827, 199, 969, 2114, 12, 2260, 966, 12, 969, 845, 12, 1079, 1165, 12, 708, 1690, 12, 221, 5661, 12, 1789, 1196, 12, 709, 1367, 12, 24073, 12, 650, 1020, 12, 650, 2564 ]
[ 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, 13123, 21, 9857, 1817, 199, 3, 701, 377, 5789, 20444, 1159, 603, 460, 285, 262, 27724, 23193, 1849, 1097, 382, 199, 3, 665, 1014, 921, 1544, 14, 8654, 14, 8122, 26, 2835, 15, 10333, 82, 3133, 199, 3, 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, 21245, 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, 18643, 21, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 378, 14, 2194, 199, 199, 3, 1610, 370, 481, 2103, 4738, 1817, 199, 18643, 21, 63, 8723, 63, 4305, 275, 959, 11452, 199, 199, 7279, 21, 18139, 13875, 4738, 275, 334, 2043, 413, 12, 1085, 614, 12, 1046, 1690, 12, 5450, 12, 1079, 2192, 12, 413, 2905, 12, 257, 1749, 12, 221, 18051, 12, 257, 1227, 12, 5783, 24, 12, 413, 1138, 12, 19328, 12, 1344, 2835, 12, 713, 1367, 12, 1651, 2025, 12, 16814, 12, 327, 257, 3193, 199, 1703, 1079, 12, 221, 9404, 12, 708, 1342, 12, 499, 2976, 12, 221, 14646, 12, 221, 10868, 12, 18, 7636, 12, 221, 3193, 12, 1398, 2466, 12, 9252, 23, 12, 31989, 12, 1227, 1427, 12, 1355, 3172, 12, 221, 7875, 12, 1082, 2869, 12, 1479, 2481, 12, 327, 257, 4337, 199, 845, 2905, 12, 1355, 2819, 12, 1153, 1400, 12, 2260, 996, 12, 32321, 12, 1081, 1046, 12, 11485, 12, 959, 2710, 12, 650, 2976, 12, 1167, 772, 12, 257, 1695, 12, 14785, 12, 221, 13713, 12, 2322, 709, 12, 5783, 25, 12, 1167, 708, 12, 327, 257, 9615, 523, 13668, 12, 8216, 16, 12, 8216, 17, 12, 650, 1196, 12, 975, 1079, 12, 221, 13098, 12, 26485, 12, 413, 1427, 12, 20, 11341, 12, 1194, 1196, 12, 1079, 1257, 12, 8216, 18, 12, 10156, 21, 12, 1216, 3328, 12, 18565, 12, 29736, 12, 327, 257, 5049, 199, 1344, 2564, 12, 257, 650, 12, 221, 1616, 12, 1355, 2898, 12, 1079, 3172, 12, 221, 7349, 12, 1465, 1555, 12, 845, 1276, 12, 11125, 22, 12, 30614, 12, 10513, 19, 12, 21334, 12, 708, 2194, 12, 17, 4288, 12, 650, 713, 12, 8216, 19, 12, 327, 257, 5939, 199, 2322, 845, 12, 1165, 2528, 12, 959, 1780, 12, 27210, 12, 1227, 2564, 12, 8216, 20, 12, 31308, 12, 1167, 1046, 12, 25442, 12, 26761, 12, 1398, 2417, 12, 221, 8177, 12, 10156, 22, 12, 708, 966, 12, 221, 5049, 12, 1227, 966, 12, 327, 257, 15580, 199, 8216, 21, 12, 821, 614, 12, 1167, 1138, 12, 1167, 2277, 12, 29710, 12, 7155, 17, 12, 5049, 21, 12, 5049, 17, 12, 975, 1690, 12, 8216, 22, 12, 1082, 2528, 12, 650, 1401, 12, 221, 15323, 12, 841, 1690, 12, 8216, 23, 12, 221, 5939, 12, 327, 221, 20240, 199, 1227, 1216, 12, 27077, 12, 708, 1717, 12, 1046, 1643, 12, 499, 2766, 12, 1749, 1355, 12, 709, 2942, 12, 1479, 1477, 12, 1520, 1367, 12, 1079, 2167, 12, 709, 2635, 12, 1082, 2481, 12, 841, 1887, 12, 221, 14610, 12, 1398, 1555, 12, 959, 3328, 12, 327, 221, 7960, 199, 31420, 12, 1165, 2534, 12, 841, 3172, 12, 22560, 12, 1165, 1276, 12, 1085, 1602, 12, 221, 5212, 12, 221, 5238, 12, 1398, 1299, 12, 25956, 12, 5939, 22, 12, 1085, 1876, 12, 1520, 1082, 12, 1165, 1344, 12, 1082, 1477, 12, 13576, 12, 327, 221, 21771, 199, 8806, 21, 12, 975, 1780, 12, 32609, 12, 959, 1401, 12, 1398, 1780, 12, 1227, 1299, 12, 8216, 24, 12, 650, 1167, 12, 969, 1717, 12, 8375, 25, 12, 6886, 21, 12, 959, 1079, 12, 10638, 25, 12, 499, 2905, 12, 2322, 713, 12, 650, 1427, 12, 327, 221, 21235, 199, 27874, 12, 221, 9137, 12, 1465, 975, 12, 969, 1703, 12, 1227, 2766, 12, 221, 4119, 12, 1749, 1690, 12, 709, 1020, 12, 2299, 19, 12, 221, 3388, 12, 1194, 2953, 12, 413, 2564, 12, 959, 708, 12, 1196, 975, 12, 8216, 25, 12, 1520, 708, 12, 327, 221, 27827, 199, 969, 2114, 12, 2260, 966, 12, 969, 845, 12, 1079, 1165, 12, 708, 1690, 12, 221, 5661, 12, 1789, 1196, 12, 709, 1367, 12, 24073, 12, 650, 1020, 12, 650, 2564, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
freakboy3742/django
django/conf/locale/fr/formats.py
35
1286
# This file is distributed under the same license as the Django package. # # The *_FORMAT strings use the Django date format syntax, # see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j F Y' TIME_FORMAT = 'H:i' DATETIME_FORMAT = 'j F Y H:i' YEAR_MONTH_FORMAT = 'F Y' MONTH_DAY_FORMAT = 'j F' SHORT_DATE_FORMAT = 'j N Y' SHORT_DATETIME_FORMAT = 'j N Y H:i' FIRST_DAY_OF_WEEK = 1 # Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see https://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = [ '%d/%m/%Y', '%d/%m/%y', # '25/10/2006', '25/10/06' '%d.%m.%Y', '%d.%m.%y', # Swiss [fr_CH), '25.10.2006', '25.10.06' # '%d %B %Y', '%d %b %Y', # '25 octobre 2006', '25 oct. 2006' ] DATETIME_INPUT_FORMATS = [ '%d/%m/%Y %H:%M:%S', # '25/10/2006 14:30:59' '%d/%m/%Y %H:%M:%S.%f', # '25/10/2006 14:30:59.000200' '%d/%m/%Y %H:%M', # '25/10/2006 14:30' '%d.%m.%Y %H:%M:%S', # Swiss [fr_CH), '25.10.2006 14:30:59' '%d.%m.%Y %H:%M:%S.%f', # Swiss (fr_CH), '25.10.2006 14:30:59.000200' '%d.%m.%Y %H:%M', # Swiss (fr_CH), '25.10.2006 14:30' ] DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '\xa0' # non-breaking space NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 481, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 481, 1488, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 653, 1488, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 653, 1488, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 3149, 77, 3149, 57, 297, 1543, 68, 3149, 77, 3149, 89, 297, 221, 327, 283, 821, 15, 709, 15, 7968, 297, 283, 821, 15, 709, 15, 1690, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 16666, 19857, 359, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 327, 1543, 68, 450, 34, 450, 57, 297, 1543, 68, 450, 66, 450, 57, 297, 327, 283, 821, 17162, 2873, 264, 8315, 297, 283, 821, 17162, 14, 8315, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 15, 709, 15, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 15, 709, 15, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 15, 709, 15, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 16666, 19857, 359, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 16666, 19857, 334, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 16666, 19857, 334, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 481, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 481, 1488, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 653, 1488, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 653, 1488, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 3149, 77, 3149, 57, 297, 1543, 68, 3149, 77, 3149, 89, 297, 221, 327, 283, 821, 15, 709, 15, 7968, 297, 283, 821, 15, 709, 15, 1690, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 16666, 19857, 359, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 327, 1543, 68, 450, 34, 450, 57, 297, 1543, 68, 450, 66, 450, 57, 297, 327, 283, 821, 17162, 2873, 264, 8315, 297, 283, 821, 17162, 14, 8315, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 15, 709, 15, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 15, 709, 15, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 15, 709, 15, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 16666, 19857, 359, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 16666, 19857, 334, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 16666, 19857, 334, 4391, 63, 1244, 395, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
byoungm/linux-kernel-test
scripts/gdb/linux/utils.py
630
4267
# # gdb helper commands and functions for Linux kernel debugging # # common utilities # # Copyright (c) Siemens AG, 2011-2013 # # Authors: # Jan Kiszka <jan.kiszka@siemens.com> # # This work is licensed under the terms of the GNU GPL version 2. # import gdb class CachedType: def __init__(self, name): self._type = None self._name = name def _new_objfile_handler(self, event): self._type = None gdb.events.new_objfile.disconnect(self._new_objfile_handler) def get_type(self): if self._type is None: self._type = gdb.lookup_type(self._name) if self._type is None: raise gdb.GdbError( "cannot resolve type '{0}'".format(self._name)) if hasattr(gdb, 'events') and hasattr(gdb.events, 'new_objfile'): gdb.events.new_objfile.connect(self._new_objfile_handler) return self._type long_type = CachedType("long") def get_long_type(): global long_type return long_type.get_type() def offset_of(typeobj, field): element = gdb.Value(0).cast(typeobj) return int(str(element[field].address).split()[0], 16) def container_of(ptr, typeobj, member): return (ptr.cast(get_long_type()) - offset_of(typeobj, member)).cast(typeobj) class ContainerOf(gdb.Function): """Return pointer to containing data structure. $container_of(PTR, "TYPE", "ELEMENT"): Given PTR, return a pointer to the data structure of the type TYPE in which PTR is the address of ELEMENT. Note that TYPE and ELEMENT have to be quoted as strings.""" def __init__(self): super(ContainerOf, self).__init__("container_of") def invoke(self, ptr, typename, elementname): return container_of(ptr, gdb.lookup_type(typename.string()).pointer(), elementname.string()) ContainerOf() BIG_ENDIAN = 0 LITTLE_ENDIAN = 1 target_endianness = None def get_target_endianness(): global target_endianness if target_endianness is None: endian = gdb.execute("show endian", to_string=True) if "little endian" in endian: target_endianness = LITTLE_ENDIAN elif "big endian" in endian: target_endianness = BIG_ENDIAN else: raise gdb.GdbError("unknown endianness '{0}'".format(str(endian))) return target_endianness def read_u16(buffer): if get_target_endianness() == LITTLE_ENDIAN: return ord(buffer[0]) + (ord(buffer[1]) << 8) else: return ord(buffer[1]) + (ord(buffer[0]) << 8) def read_u32(buffer): if get_target_endianness() == LITTLE_ENDIAN: return read_u16(buffer[0:2]) + (read_u16(buffer[2:4]) << 16) else: return read_u16(buffer[2:4]) + (read_u16(buffer[0:2]) << 16) def read_u64(buffer): if get_target_endianness() == LITTLE_ENDIAN: return read_u32(buffer[0:4]) + (read_u32(buffer[4:8]) << 32) else: return read_u32(buffer[4:8]) + (read_u32(buffer[0:4]) << 32) target_arch = None def is_target_arch(arch): if hasattr(gdb.Frame, 'architecture'): return arch in gdb.newest_frame().architecture().name() else: global target_arch if target_arch is None: target_arch = gdb.execute("show architecture", to_string=True) return arch in target_arch GDBSERVER_QEMU = 0 GDBSERVER_KGDB = 1 gdbserver_type = None def get_gdbserver_type(): def exit_handler(event): global gdbserver_type gdbserver_type = None gdb.events.exited.disconnect(exit_handler) def probe_qemu(): try: return gdb.execute("monitor info version", to_string=True) != "" except: return False def probe_kgdb(): try: thread_info = gdb.execute("info thread 2", to_string=True) return "shadowCPU0" in thread_info except: return False global gdbserver_type if gdbserver_type is None: if probe_qemu(): gdbserver_type = GDBSERVER_QEMU elif probe_kgdb(): gdbserver_type = GDBSERVER_KGDB if gdbserver_type is not None and hasattr(gdb, 'events'): gdb.events.exited.connect(exit_handler) return gdbserver_type
gpl-2.0
[ 3, 199, 3, 12124, 5922, 3718, 436, 3423, 367, 10130, 5114, 10201, 199, 3, 199, 3, 221, 2863, 15841, 199, 3, 199, 3, 1898, 334, 67, 9, 428, 1873, 278, 561, 26787, 12, 7760, 13, 6965, 199, 3, 199, 3, 6642, 26, 199, 3, 221, 17474, 1804, 374, 90, 7351, 665, 24418, 14, 75, 374, 90, 7351, 32, 23994, 278, 561, 14, 957, 30, 199, 3, 199, 3, 961, 1736, 365, 18233, 1334, 314, 2895, 402, 314, 1664, 14629, 1015, 499, 14, 199, 3, 199, 199, 646, 12124, 421, 199, 533, 445, 4583, 804, 26, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 423, 466, 275, 488, 267, 291, 423, 354, 275, 536, 339, 347, 485, 1222, 63, 1113, 493, 63, 2232, 8, 277, 12, 1566, 304, 267, 291, 423, 466, 275, 488, 267, 12124, 14, 4368, 14, 1222, 63, 1113, 493, 14, 10673, 8, 277, 423, 1222, 63, 1113, 493, 63, 2232, 9, 339, 347, 664, 63, 466, 8, 277, 304, 267, 340, 291, 423, 466, 365, 488, 26, 288, 291, 423, 466, 275, 12124, 14, 3892, 63, 466, 8, 277, 423, 354, 9, 288, 340, 291, 423, 466, 365, 488, 26, 355, 746, 12124, 14, 39, 697, 547, 8, 490, 298, 11250, 7512, 730, 5041, 16, 30366, 908, 8, 277, 423, 354, 430, 288, 340, 2688, 8, 17119, 12, 283, 4368, 358, 436, 2688, 8, 17119, 14, 4368, 12, 283, 1222, 63, 1113, 493, 735, 355, 12124, 14, 4368, 14, 1222, 63, 1113, 493, 14, 2242, 8, 277, 423, 1222, 63, 1113, 493, 63, 2232, 9, 267, 372, 291, 423, 466, 421, 199, 2809, 63, 466, 275, 445, 4583, 804, 480, 2809, 531, 421, 199, 318, 664, 63, 2809, 63, 466, 837, 272, 2288, 1846, 63, 466, 272, 372, 1846, 63, 466, 14, 362, 63, 466, 342, 421, 199, 318, 3268, 63, 1618, 8, 466, 1113, 12, 901, 304, 272, 1819, 275, 12124, 14, 1110, 8, 16, 680, 2931, 8, 466, 1113, 9, 272, 372, 1109, 8, 495, 8, 2108, 59, 698, 1055, 1562, 680, 1294, 3430, 16, 467, 3193, 9, 421, 199, 318, 3970, 63, 1618, 8, 4695, 12, 730, 1113, 12, 3653, 304, 272, 372, 334, 4695, 14, 2931, 8, 362, 63, 2809, 63, 466, 1012, 446, 288, 3268, 63, 1618, 8, 466, 1113, 12, 3653, 4992, 2931, 8, 466, 1113, 9, 421, 199, 533, 15395, 3466, 8, 17119, 14, 3481, 304, 272, 408, 1767, 7849, 370, 3035, 666, 5523, 14, 199, 199, 4, 3600, 63, 1618, 8, 14528, 12, 298, 2711, 401, 298, 12535, 2349, 9138, 510, 1766, 12, 372, 282, 7849, 370, 314, 199, 576, 5523, 402, 314, 730, 11511, 315, 1314, 510, 1766, 365, 314, 2287, 402, 662, 10320, 14, 199, 7443, 626, 11511, 436, 662, 10320, 1172, 370, 506, 10999, 465, 3326, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 4076, 3466, 12, 291, 2843, 826, 29093, 3600, 63, 1618, 531, 339, 347, 12677, 8, 277, 12, 12448, 12, 19151, 12, 1819, 354, 304, 267, 372, 3970, 63, 1618, 8, 4695, 12, 12124, 14, 3892, 63, 466, 8, 18596, 14, 875, 8801, 3929, 1062, 1169, 1819, 354, 14, 875, 1012, 199, 199, 4076, 3466, 342, 421, 199, 18643, 63, 21046, 275, 378, 199, 44, 31783, 63, 21046, 275, 413, 199, 1375, 63, 15009, 4171, 275, 488, 421, 199, 318, 664, 63, 1375, 63, 15009, 4171, 837, 272, 2288, 1347, 63, 15009, 4171, 272, 340, 1347, 63, 15009, 4171, 365, 488, 26, 267, 17638, 275, 12124, 14, 2526, 480, 2384, 17638, 401, 370, 63, 875, 29, 549, 9, 267, 340, 298, 10182, 17638, 2, 315, 17638, 26, 288, 1347, 63, 15009, 4171, 275, 491, 31783, 63, 21046, 267, 916, 298, 5076, 17638, 2, 315, 17638, 26, 288, 1347, 63, 15009, 4171, 275, 16524, 63, 21046, 267, 587, 26, 288, 746, 12124, 14, 39, 697, 547, 480, 5187, 17638, 4171, 5041, 16, 30366, 908, 8, 495, 8, 15009, 1724, 272, 372, 1347, 63, 15009, 4171, 421, 199, 318, 1586, 63, 85, 975, 8, 2738, 304, 272, 340, 664, 63, 1375, 63, 15009, 4171, 342, 508, 491, 31783, 63, 21046, 26, 267, 372, 6206, 8, 2738, 59, 16, 566, 435, 334, 2181, 8, 2738, 59, 17, 566, 5213, 1695, 9, 272, 587, 26, 267, 372, 6206, 8, 2738, 59, 17, 566, 435, 334, 2181, 8, 2738, 59, 16, 566, 5213, 1695, 9, 421, 199, 318, 1586, 63, 85, 708, 8, 2738, 304, 272, 340, 664, 63, 1375, 63, 15009, 4171, 342, 508, 491, 31783, 63, 21046, 26, 267, 372, 1586, 63, 85, 975, 8, 2738, 59, 16, 26, 18, 566, 435, 334, 739, 63, 85, 975, 8, 2738, 59, 18, 26, 20, 566, 5213, 3193, 9, 272, 587, 26, 267, 372, 1586, 63, 85, 975, 8, 2738, 59, 18, 26, 20, 566, 435, 334, 739, 63, 85, 975, 8, 2738, 59, 16, 26, 18, 566, 5213, 3193, 9, 421, 199, 318, 1586, 63, 85, 772, 8, 2738, 304, 272, 340, 664, 63, 1375, 63, 15009, 4171, 342, 508, 491, 31783, 63, 21046, 26, 267, 372, 1586, 63, 85, 708, 8, 2738, 59, 16, 26, 20, 566, 435, 334, 739, 63, 85, 708, 8, 2738, 59, 20, 26, 24, 566, 5213, 4337, 9, 272, 587, 26, 267, 372, 1586, 63, 85, 708, 8, 2738, 59, 20, 26, 24, 566, 435, 334, 739, 63, 85, 708, 8, 2738, 59, 16, 26, 20, 566, 5213, 4337, 9, 421, 199, 1375, 63, 1047, 275, 488, 421, 199, 318, 365, 63, 1375, 63, 1047, 8, 1047, 304, 272, 340, 2688, 8, 17119, 14, 3160, 12, 283, 19134, 735, 267, 372, 3819, 315, 12124, 14, 1222, 597, 63, 1943, 1252, 19134, 1252, 354, 342, 272, 587, 26, 267, 2288, 1347, 63, 1047, 267, 340, 1347, 63, 1047, 365, 488, 26, 288, 1347, 63, 1047, 275, 12124, 14, 2526, 480, 2384, 15931, 401, 370, 63, 875, 29, 549, 9, 267, 372, 3819, 315, 1347, 63, 1047, 421, 199, 39, 2846, 6613, 63, 49, 2769, 53, 275, 378, 199, 39, 2846, 6613, 63, 14634, 2846, 275, 413, 199, 17119, 1000, 63, 466, 275, 488, 421, 199, 318, 664, 63, 17119, 1000, 63, 466, 837, 272, 347, 4458, 63, 2232, 8, 1430 ]
[ 199, 3, 12124, 5922, 3718, 436, 3423, 367, 10130, 5114, 10201, 199, 3, 199, 3, 221, 2863, 15841, 199, 3, 199, 3, 1898, 334, 67, 9, 428, 1873, 278, 561, 26787, 12, 7760, 13, 6965, 199, 3, 199, 3, 6642, 26, 199, 3, 221, 17474, 1804, 374, 90, 7351, 665, 24418, 14, 75, 374, 90, 7351, 32, 23994, 278, 561, 14, 957, 30, 199, 3, 199, 3, 961, 1736, 365, 18233, 1334, 314, 2895, 402, 314, 1664, 14629, 1015, 499, 14, 199, 3, 199, 199, 646, 12124, 421, 199, 533, 445, 4583, 804, 26, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 423, 466, 275, 488, 267, 291, 423, 354, 275, 536, 339, 347, 485, 1222, 63, 1113, 493, 63, 2232, 8, 277, 12, 1566, 304, 267, 291, 423, 466, 275, 488, 267, 12124, 14, 4368, 14, 1222, 63, 1113, 493, 14, 10673, 8, 277, 423, 1222, 63, 1113, 493, 63, 2232, 9, 339, 347, 664, 63, 466, 8, 277, 304, 267, 340, 291, 423, 466, 365, 488, 26, 288, 291, 423, 466, 275, 12124, 14, 3892, 63, 466, 8, 277, 423, 354, 9, 288, 340, 291, 423, 466, 365, 488, 26, 355, 746, 12124, 14, 39, 697, 547, 8, 490, 298, 11250, 7512, 730, 5041, 16, 30366, 908, 8, 277, 423, 354, 430, 288, 340, 2688, 8, 17119, 12, 283, 4368, 358, 436, 2688, 8, 17119, 14, 4368, 12, 283, 1222, 63, 1113, 493, 735, 355, 12124, 14, 4368, 14, 1222, 63, 1113, 493, 14, 2242, 8, 277, 423, 1222, 63, 1113, 493, 63, 2232, 9, 267, 372, 291, 423, 466, 421, 199, 2809, 63, 466, 275, 445, 4583, 804, 480, 2809, 531, 421, 199, 318, 664, 63, 2809, 63, 466, 837, 272, 2288, 1846, 63, 466, 272, 372, 1846, 63, 466, 14, 362, 63, 466, 342, 421, 199, 318, 3268, 63, 1618, 8, 466, 1113, 12, 901, 304, 272, 1819, 275, 12124, 14, 1110, 8, 16, 680, 2931, 8, 466, 1113, 9, 272, 372, 1109, 8, 495, 8, 2108, 59, 698, 1055, 1562, 680, 1294, 3430, 16, 467, 3193, 9, 421, 199, 318, 3970, 63, 1618, 8, 4695, 12, 730, 1113, 12, 3653, 304, 272, 372, 334, 4695, 14, 2931, 8, 362, 63, 2809, 63, 466, 1012, 446, 288, 3268, 63, 1618, 8, 466, 1113, 12, 3653, 4992, 2931, 8, 466, 1113, 9, 421, 199, 533, 15395, 3466, 8, 17119, 14, 3481, 304, 272, 408, 1767, 7849, 370, 3035, 666, 5523, 14, 199, 199, 4, 3600, 63, 1618, 8, 14528, 12, 298, 2711, 401, 298, 12535, 2349, 9138, 510, 1766, 12, 372, 282, 7849, 370, 314, 199, 576, 5523, 402, 314, 730, 11511, 315, 1314, 510, 1766, 365, 314, 2287, 402, 662, 10320, 14, 199, 7443, 626, 11511, 436, 662, 10320, 1172, 370, 506, 10999, 465, 3326, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 4076, 3466, 12, 291, 2843, 826, 29093, 3600, 63, 1618, 531, 339, 347, 12677, 8, 277, 12, 12448, 12, 19151, 12, 1819, 354, 304, 267, 372, 3970, 63, 1618, 8, 4695, 12, 12124, 14, 3892, 63, 466, 8, 18596, 14, 875, 8801, 3929, 1062, 1169, 1819, 354, 14, 875, 1012, 199, 199, 4076, 3466, 342, 421, 199, 18643, 63, 21046, 275, 378, 199, 44, 31783, 63, 21046, 275, 413, 199, 1375, 63, 15009, 4171, 275, 488, 421, 199, 318, 664, 63, 1375, 63, 15009, 4171, 837, 272, 2288, 1347, 63, 15009, 4171, 272, 340, 1347, 63, 15009, 4171, 365, 488, 26, 267, 17638, 275, 12124, 14, 2526, 480, 2384, 17638, 401, 370, 63, 875, 29, 549, 9, 267, 340, 298, 10182, 17638, 2, 315, 17638, 26, 288, 1347, 63, 15009, 4171, 275, 491, 31783, 63, 21046, 267, 916, 298, 5076, 17638, 2, 315, 17638, 26, 288, 1347, 63, 15009, 4171, 275, 16524, 63, 21046, 267, 587, 26, 288, 746, 12124, 14, 39, 697, 547, 480, 5187, 17638, 4171, 5041, 16, 30366, 908, 8, 495, 8, 15009, 1724, 272, 372, 1347, 63, 15009, 4171, 421, 199, 318, 1586, 63, 85, 975, 8, 2738, 304, 272, 340, 664, 63, 1375, 63, 15009, 4171, 342, 508, 491, 31783, 63, 21046, 26, 267, 372, 6206, 8, 2738, 59, 16, 566, 435, 334, 2181, 8, 2738, 59, 17, 566, 5213, 1695, 9, 272, 587, 26, 267, 372, 6206, 8, 2738, 59, 17, 566, 435, 334, 2181, 8, 2738, 59, 16, 566, 5213, 1695, 9, 421, 199, 318, 1586, 63, 85, 708, 8, 2738, 304, 272, 340, 664, 63, 1375, 63, 15009, 4171, 342, 508, 491, 31783, 63, 21046, 26, 267, 372, 1586, 63, 85, 975, 8, 2738, 59, 16, 26, 18, 566, 435, 334, 739, 63, 85, 975, 8, 2738, 59, 18, 26, 20, 566, 5213, 3193, 9, 272, 587, 26, 267, 372, 1586, 63, 85, 975, 8, 2738, 59, 18, 26, 20, 566, 435, 334, 739, 63, 85, 975, 8, 2738, 59, 16, 26, 18, 566, 5213, 3193, 9, 421, 199, 318, 1586, 63, 85, 772, 8, 2738, 304, 272, 340, 664, 63, 1375, 63, 15009, 4171, 342, 508, 491, 31783, 63, 21046, 26, 267, 372, 1586, 63, 85, 708, 8, 2738, 59, 16, 26, 20, 566, 435, 334, 739, 63, 85, 708, 8, 2738, 59, 20, 26, 24, 566, 5213, 4337, 9, 272, 587, 26, 267, 372, 1586, 63, 85, 708, 8, 2738, 59, 20, 26, 24, 566, 435, 334, 739, 63, 85, 708, 8, 2738, 59, 16, 26, 20, 566, 5213, 4337, 9, 421, 199, 1375, 63, 1047, 275, 488, 421, 199, 318, 365, 63, 1375, 63, 1047, 8, 1047, 304, 272, 340, 2688, 8, 17119, 14, 3160, 12, 283, 19134, 735, 267, 372, 3819, 315, 12124, 14, 1222, 597, 63, 1943, 1252, 19134, 1252, 354, 342, 272, 587, 26, 267, 2288, 1347, 63, 1047, 267, 340, 1347, 63, 1047, 365, 488, 26, 288, 1347, 63, 1047, 275, 12124, 14, 2526, 480, 2384, 15931, 401, 370, 63, 875, 29, 549, 9, 267, 372, 3819, 315, 1347, 63, 1047, 421, 199, 39, 2846, 6613, 63, 49, 2769, 53, 275, 378, 199, 39, 2846, 6613, 63, 14634, 2846, 275, 413, 199, 17119, 1000, 63, 466, 275, 488, 421, 199, 318, 664, 63, 17119, 1000, 63, 466, 837, 272, 347, 4458, 63, 2232, 8, 1430, 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, 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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 ]
BILS/agda
agda/species_geo_coder/views.py
1
2551
import time #from django.shortcuts import render from django.views.generic import TemplateView, FormView from django.shortcuts import redirect, render from django.db import transaction from agda.views import package_template_dict from jobs.models import (JOB_STATUS_LEVEL_ACCEPTED, JOB_STATUS_LEVEL_FINISHED, get_job_or_404) from species_geo_coder.models import app_package, SpeciesGeoCoderJob from species_geo_coder.forms import SpeciesGeoCoderForm from species_geo_coder.models import tool_1 # Create your views here. class IndexView(TemplateView): template_name = 'species_geo_coder/index.html' def get_context_data(self, *args, **kw): context = super(IndexView, self).get_context_data(**kw) return package_template_dict(self.request, app_package, *args, **kw) class ToolView(FormView): template_name = 'species_geo_coder/speciesgeocoder.html' form_class = SpeciesGeoCoderForm @transaction.atomic def form_valid(self, form): request = self.request ## These are all generic, should be extracted to a main class job = SpeciesGeoCoderJob(status=JOB_STATUS_LEVEL_ACCEPTED) job.save() job = SpeciesGeoCoderJob.objects.select_for_update().get(pk=job.id) job.log_create(request.user, 'Created in web interface.') verbose = form.cleaned_data['verbose'] occurences = form.cleaned_data['occurences'] plot = form.cleaned_data['plot'] job.submit(request.user, request.META['REMOTE_ADDR'], form.cleaned_data['name'], self.request.FILES, occurences, verbose, plot) return redirect('jobs.views.show_results', job.slug) @transaction.atomic def tool_1_results(request, slug): job = get_job_or_404(slug=slug, select_for_update=True) job.update_status(request.user) params = dict(job=job, tool=tool_1) if job.is_alive: reload_time, interval = request.session.setdefault('mdrscan', dict()).pop(job.slug, (0, 5)) if reload_time <= time.time(): reload_time = max(time.time() + 5, reload_time + interval) interval *= 2 request.session['mdrscan'][job.slug] = (reload_time, interval) request.session.modified = True params.update(timeout=reload_time - time.time()) params.update(reload_time=reload_time, interval=interval) return render(request, 'species_geo_coder/results.html', params) #class ToolResultView(TemplateView): # template_name = '<app>/tool_result.html'
mit
[ 646, 900, 199, 3, 504, 1639, 14, 17469, 492, 3795, 199, 199, 504, 1639, 14, 4196, 14, 6767, 492, 5458, 2768, 12, 8204, 2768, 199, 504, 1639, 14, 17469, 492, 4660, 12, 3795, 199, 504, 1639, 14, 697, 492, 6008, 199, 199, 504, 1839, 983, 14, 4196, 492, 2559, 63, 1160, 63, 807, 199, 504, 9643, 14, 992, 492, 334, 14879, 63, 6305, 63, 11817, 63, 13089, 1149, 12, 586, 1603, 5488, 63, 6305, 63, 11817, 63, 17383, 20450, 12, 586, 664, 63, 2423, 63, 269, 63, 5188, 9, 199, 199, 504, 20340, 63, 6721, 63, 2693, 14, 992, 492, 1145, 63, 2491, 12, 5367, 397, 10748, 3034, 82, 6694, 199, 504, 20340, 63, 6721, 63, 2693, 14, 3351, 492, 5367, 397, 10748, 3034, 82, 2821, 199, 199, 504, 20340, 63, 6721, 63, 2693, 14, 992, 492, 4744, 63, 17, 199, 3, 2790, 2195, 6858, 2348, 14, 199, 199, 533, 5499, 2768, 8, 4231, 2768, 304, 272, 1978, 63, 354, 275, 283, 17168, 63, 6721, 63, 2693, 15, 1080, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1067, 275, 1613, 8, 2681, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 829, 9, 267, 372, 2559, 63, 1160, 63, 807, 8, 277, 14, 1069, 12, 1145, 63, 2491, 12, 627, 589, 12, 1011, 829, 9, 199, 199, 533, 15650, 2768, 8, 2821, 2768, 304, 272, 1978, 63, 354, 275, 283, 17168, 63, 6721, 63, 2693, 15, 17168, 6721, 2693, 14, 1360, 7, 272, 1824, 63, 533, 259, 275, 5367, 397, 10748, 3034, 82, 2821, 339, 768, 5945, 14, 10910, 272, 347, 1824, 63, 1078, 8, 277, 12, 1824, 304, 267, 1056, 275, 291, 14, 1069, 398, 925, 5723, 787, 1006, 7809, 12, 1077, 506, 12509, 370, 282, 2446, 1021, 267, 3906, 275, 5367, 397, 10748, 3034, 82, 6694, 8, 1205, 29, 14879, 63, 6305, 63, 11817, 63, 13089, 1149, 9, 267, 3906, 14, 2117, 342, 267, 3906, 275, 5367, 397, 10748, 3034, 82, 6694, 14, 1462, 14, 2416, 63, 509, 63, 873, 1252, 362, 8, 2051, 29, 2423, 14, 344, 9, 267, 3906, 14, 793, 63, 981, 8, 1069, 14, 751, 12, 283, 10502, 315, 3330, 3217, 2659, 398, 3376, 275, 1824, 14, 8275, 63, 576, 459, 3832, 418, 267, 14706, 608, 78, 823, 275, 1824, 14, 8275, 63, 576, 459, 679, 67, 608, 78, 823, 418, 267, 5137, 275, 1824, 14, 8275, 63, 576, 459, 2798, 418, 267, 3906, 14, 7275, 8, 1069, 14, 751, 12, 1056, 14, 10614, 459, 16058, 63, 7803, 995, 1824, 14, 8275, 63, 576, 459, 354, 995, 355, 291, 14, 1069, 14, 9472, 12, 14706, 608, 78, 823, 12, 3376, 12, 5137, 9, 398, 372, 4660, 360, 6920, 14, 4196, 14, 2384, 63, 2604, 297, 3906, 14, 5464, 9, 199, 199, 32, 5945, 14, 10910, 199, 318, 4744, 63, 17, 63, 2604, 8, 1069, 12, 8889, 304, 272, 3906, 275, 664, 63, 2423, 63, 269, 63, 5188, 8, 5464, 29, 5464, 12, 3504, 63, 509, 63, 873, 29, 549, 9, 272, 3906, 14, 873, 63, 1205, 8, 1069, 14, 751, 9, 272, 1862, 275, 1211, 8, 2423, 29, 2423, 12, 4744, 29, 3557, 63, 17, 9, 272, 340, 3906, 14, 374, 63, 9631, 26, 267, 13101, 63, 521, 12, 6252, 275, 1056, 14, 1730, 14, 5486, 360, 1064, 82, 6282, 297, 1211, 8801, 1935, 8, 2423, 14, 5464, 12, 334, 16, 12, 959, 430, 267, 340, 13101, 63, 521, 2695, 900, 14, 521, 837, 288, 13101, 63, 521, 275, 1390, 8, 521, 14, 521, 342, 435, 959, 12, 13101, 63, 521, 435, 6252, 9, 288, 6252, 9000, 499, 267, 1056, 14, 1730, 459, 1064, 82, 6282, 3488, 2423, 14, 5464, 61, 275, 334, 9233, 63, 521, 12, 6252, 9, 267, 1056, 14, 1730, 14, 5540, 275, 715, 267, 1862, 14, 873, 8, 2593, 29, 9233, 63, 521, 446, 900, 14, 521, 1012, 267, 1862, 14, 873, 8, 9233, 63, 521, 29, 9233, 63, 521, 12, 6252, 29, 4284, 9, 272, 372, 3795, 8, 1069, 12, 283, 17168, 63, 6721, 63, 2693, 15, 2604, 14, 1360, 297, 1862, 9, 199, 199, 3, 533, 15650, 2889, 2768, 8, 4231, 2768, 304, 199, 3, 259, 1978, 63, 354, 275, 2650, 571, 12202, 3557, 63, 1099, 14, 1360, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 900, 199, 3, 504, 1639, 14, 17469, 492, 3795, 199, 199, 504, 1639, 14, 4196, 14, 6767, 492, 5458, 2768, 12, 8204, 2768, 199, 504, 1639, 14, 17469, 492, 4660, 12, 3795, 199, 504, 1639, 14, 697, 492, 6008, 199, 199, 504, 1839, 983, 14, 4196, 492, 2559, 63, 1160, 63, 807, 199, 504, 9643, 14, 992, 492, 334, 14879, 63, 6305, 63, 11817, 63, 13089, 1149, 12, 586, 1603, 5488, 63, 6305, 63, 11817, 63, 17383, 20450, 12, 586, 664, 63, 2423, 63, 269, 63, 5188, 9, 199, 199, 504, 20340, 63, 6721, 63, 2693, 14, 992, 492, 1145, 63, 2491, 12, 5367, 397, 10748, 3034, 82, 6694, 199, 504, 20340, 63, 6721, 63, 2693, 14, 3351, 492, 5367, 397, 10748, 3034, 82, 2821, 199, 199, 504, 20340, 63, 6721, 63, 2693, 14, 992, 492, 4744, 63, 17, 199, 3, 2790, 2195, 6858, 2348, 14, 199, 199, 533, 5499, 2768, 8, 4231, 2768, 304, 272, 1978, 63, 354, 275, 283, 17168, 63, 6721, 63, 2693, 15, 1080, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1067, 275, 1613, 8, 2681, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 829, 9, 267, 372, 2559, 63, 1160, 63, 807, 8, 277, 14, 1069, 12, 1145, 63, 2491, 12, 627, 589, 12, 1011, 829, 9, 199, 199, 533, 15650, 2768, 8, 2821, 2768, 304, 272, 1978, 63, 354, 275, 283, 17168, 63, 6721, 63, 2693, 15, 17168, 6721, 2693, 14, 1360, 7, 272, 1824, 63, 533, 259, 275, 5367, 397, 10748, 3034, 82, 2821, 339, 768, 5945, 14, 10910, 272, 347, 1824, 63, 1078, 8, 277, 12, 1824, 304, 267, 1056, 275, 291, 14, 1069, 398, 925, 5723, 787, 1006, 7809, 12, 1077, 506, 12509, 370, 282, 2446, 1021, 267, 3906, 275, 5367, 397, 10748, 3034, 82, 6694, 8, 1205, 29, 14879, 63, 6305, 63, 11817, 63, 13089, 1149, 9, 267, 3906, 14, 2117, 342, 267, 3906, 275, 5367, 397, 10748, 3034, 82, 6694, 14, 1462, 14, 2416, 63, 509, 63, 873, 1252, 362, 8, 2051, 29, 2423, 14, 344, 9, 267, 3906, 14, 793, 63, 981, 8, 1069, 14, 751, 12, 283, 10502, 315, 3330, 3217, 2659, 398, 3376, 275, 1824, 14, 8275, 63, 576, 459, 3832, 418, 267, 14706, 608, 78, 823, 275, 1824, 14, 8275, 63, 576, 459, 679, 67, 608, 78, 823, 418, 267, 5137, 275, 1824, 14, 8275, 63, 576, 459, 2798, 418, 267, 3906, 14, 7275, 8, 1069, 14, 751, 12, 1056, 14, 10614, 459, 16058, 63, 7803, 995, 1824, 14, 8275, 63, 576, 459, 354, 995, 355, 291, 14, 1069, 14, 9472, 12, 14706, 608, 78, 823, 12, 3376, 12, 5137, 9, 398, 372, 4660, 360, 6920, 14, 4196, 14, 2384, 63, 2604, 297, 3906, 14, 5464, 9, 199, 199, 32, 5945, 14, 10910, 199, 318, 4744, 63, 17, 63, 2604, 8, 1069, 12, 8889, 304, 272, 3906, 275, 664, 63, 2423, 63, 269, 63, 5188, 8, 5464, 29, 5464, 12, 3504, 63, 509, 63, 873, 29, 549, 9, 272, 3906, 14, 873, 63, 1205, 8, 1069, 14, 751, 9, 272, 1862, 275, 1211, 8, 2423, 29, 2423, 12, 4744, 29, 3557, 63, 17, 9, 272, 340, 3906, 14, 374, 63, 9631, 26, 267, 13101, 63, 521, 12, 6252, 275, 1056, 14, 1730, 14, 5486, 360, 1064, 82, 6282, 297, 1211, 8801, 1935, 8, 2423, 14, 5464, 12, 334, 16, 12, 959, 430, 267, 340, 13101, 63, 521, 2695, 900, 14, 521, 837, 288, 13101, 63, 521, 275, 1390, 8, 521, 14, 521, 342, 435, 959, 12, 13101, 63, 521, 435, 6252, 9, 288, 6252, 9000, 499, 267, 1056, 14, 1730, 459, 1064, 82, 6282, 3488, 2423, 14, 5464, 61, 275, 334, 9233, 63, 521, 12, 6252, 9, 267, 1056, 14, 1730, 14, 5540, 275, 715, 267, 1862, 14, 873, 8, 2593, 29, 9233, 63, 521, 446, 900, 14, 521, 1012, 267, 1862, 14, 873, 8, 9233, 63, 521, 29, 9233, 63, 521, 12, 6252, 29, 4284, 9, 272, 372, 3795, 8, 1069, 12, 283, 17168, 63, 6721, 63, 2693, 15, 2604, 14, 1360, 297, 1862, 9, 199, 199, 3, 533, 15650, 2889, 2768, 8, 4231, 2768, 304, 199, 3, 259, 1978, 63, 354, 275, 2650, 571, 12202, 3557, 63, 1099, 14, 1360, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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