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
kevalds51/sympy
sympy/concrete/delta.py
66
9727
from __future__ import print_function, division from sympy.core import Add, Mul, S, Dummy from sympy.core.cache import cacheit from sympy.core.compatibility import default_sort_key, range from sympy.functions import KroneckerDelta, Piecewise, piecewise_fold from sympy.sets import Interval @cacheit def _expand_delta(expr, index): """ Expand the first Add containing a simple KroneckerDelta. """ if not expr.is_Mul: return expr delta = None func = Add terms = [S(1)] for h in expr.args: if delta is None and h.is_Add and _has_simple_delta(h, index): delta = True func = h.func terms = [terms[0]*t for t in h.args] else: terms = [t*h for t in terms] return func(*terms) @cacheit def _extract_delta(expr, index): """ Extract a simple KroneckerDelta from the expression. Returns the tuple ``(delta, newexpr)`` where: - ``delta`` is a simple KroneckerDelta expression if one was found, or ``None`` if no simple KroneckerDelta expression was found. - ``newexpr`` is a Mul containing the remaining terms; ``expr`` is returned unchanged if no simple KroneckerDelta expression was found. Examples ======== >>> from sympy import KroneckerDelta >>> from sympy.concrete.delta import _extract_delta >>> from sympy.abc import x, y, i, j, k >>> _extract_delta(4*x*y*KroneckerDelta(i, j), i) (KroneckerDelta(i, j), 4*x*y) >>> _extract_delta(4*x*y*KroneckerDelta(i, j), k) (None, 4*x*y*KroneckerDelta(i, j)) See Also ======== sympy.functions.special.tensor_functions.KroneckerDelta deltaproduct deltasummation """ if not _has_simple_delta(expr, index): return (None, expr) if isinstance(expr, KroneckerDelta): return (expr, S(1)) if not expr.is_Mul: raise ValueError("Incorrect expr") delta = None terms = [] for arg in expr.args: if delta is None and _is_simple_delta(arg, index): delta = arg else: terms.append(arg) return (delta, expr.func(*terms)) @cacheit def _has_simple_delta(expr, index): """ Returns True if ``expr`` is an expression that contains a KroneckerDelta that is simple in the index ``index``, meaning that this KroneckerDelta is nonzero for a single value of the index ``index``. """ if expr.has(KroneckerDelta): if _is_simple_delta(expr, index): return True if expr.is_Add or expr.is_Mul: for arg in expr.args: if _has_simple_delta(arg, index): return True return False @cacheit def _is_simple_delta(delta, index): """ Returns True if ``delta`` is a KroneckerDelta and is nonzero for a single value of the index ``index``. """ if isinstance(delta, KroneckerDelta) and delta.has(index): p = (delta.args[0] - delta.args[1]).as_poly(index) if p: return p.degree() == 1 return False @cacheit def _remove_multiple_delta(expr): """ Evaluate products of KroneckerDelta's. """ from sympy.solvers import solve if expr.is_Add: return expr.func(*list(map(_remove_multiple_delta, expr.args))) if not expr.is_Mul: return expr eqs = [] newargs = [] for arg in expr.args: if isinstance(arg, KroneckerDelta): eqs.append(arg.args[0] - arg.args[1]) else: newargs.append(arg) if not eqs: return expr solns = solve(eqs, dict=True) if len(solns) == 0: return S.Zero elif len(solns) == 1: for key in solns[0].keys(): newargs.append(KroneckerDelta(key, solns[0][key])) expr2 = expr.func(*newargs) if expr != expr2: return _remove_multiple_delta(expr2) return expr @cacheit def _simplify_delta(expr): """ Rewrite a KroneckerDelta's indices in its simplest form. """ from sympy.solvers import solve if isinstance(expr, KroneckerDelta): try: slns = solve(expr.args[0] - expr.args[1], dict=True) if slns and len(slns) == 1: return Mul(*[KroneckerDelta(*(key, value)) for key, value in slns[0].items()]) except NotImplementedError: pass return expr @cacheit def deltaproduct(f, limit): """ Handle products containing a KroneckerDelta. See Also ======== deltasummation sympy.functions.special.tensor_functions.KroneckerDelta sympy.concrete.products.product """ from sympy.concrete.products import product if ((limit[2] - limit[1]) < 0) == True: return S.One if not f.has(KroneckerDelta): return product(f, limit) if f.is_Add: # Identify the term in the Add that has a simple KroneckerDelta delta = None terms = [] for arg in sorted(f.args, key=default_sort_key): if delta is None and _has_simple_delta(arg, limit[0]): delta = arg else: terms.append(arg) newexpr = f.func(*terms) k = Dummy("kprime", integer=True) if isinstance(limit[1], int) and isinstance(limit[2], int): result = deltaproduct(newexpr, limit) + sum([ deltaproduct(newexpr, (limit[0], limit[1], ik - 1)) * delta.subs(limit[0], ik) * deltaproduct(newexpr, (limit[0], ik + 1, limit[2])) for ik in range(int(limit[1]), int(limit[2] + 1))] ) else: result = deltaproduct(newexpr, limit) + deltasummation( deltaproduct(newexpr, (limit[0], limit[1], k - 1)) * delta.subs(limit[0], k) * deltaproduct(newexpr, (limit[0], k + 1, limit[2])), (k, limit[1], limit[2]), no_piecewise=_has_simple_delta(newexpr, limit[0]) ) return _remove_multiple_delta(result) delta, _ = _extract_delta(f, limit[0]) if not delta: g = _expand_delta(f, limit[0]) if f != g: from sympy import factor try: return factor(deltaproduct(g, limit)) except AssertionError: return deltaproduct(g, limit) return product(f, limit) from sympy import Eq c = Eq(limit[2], limit[1] - 1) return _remove_multiple_delta(f.subs(limit[0], limit[1])*KroneckerDelta(limit[2], limit[1])) + \ S.One*_simplify_delta(KroneckerDelta(limit[2], limit[1] - 1)) @cacheit def deltasummation(f, limit, no_piecewise=False): """ Handle summations containing a KroneckerDelta. The idea for summation is the following: - If we are dealing with a KroneckerDelta expression, i.e. KroneckerDelta(g(x), j), we try to simplify it. If we could simplify it, then we sum the resulting expression. We already know we can sum a simplified expression, because only simple KroneckerDelta expressions are involved. If we couldn't simplify it, there are two cases: 1) The expression is a simple expression: we return the summation, taking care if we are dealing with a Derivative or with a proper KroneckerDelta. 2) The expression is not simple (i.e. KroneckerDelta(cos(x))): we can do nothing at all. - If the expr is a multiplication expr having a KroneckerDelta term: First we expand it. If the expansion did work, then we try to sum the expansion. If not, we try to extract a simple KroneckerDelta term, then we have two cases: 1) We have a simple KroneckerDelta term, so we return the summation. 2) We didn't have a simple term, but we do have an expression with simplified KroneckerDelta terms, so we sum this expression. Examples ======== >>> from sympy import oo, symbols >>> from sympy.abc import k >>> i, j = symbols('i, j', integer=True, finite=True) >>> from sympy.concrete.delta import deltasummation >>> from sympy import KroneckerDelta, Piecewise >>> deltasummation(KroneckerDelta(i, k), (k, -oo, oo)) 1 >>> deltasummation(KroneckerDelta(i, k), (k, 0, oo)) Piecewise((1, 0 <= i), (0, True)) >>> deltasummation(KroneckerDelta(i, k), (k, 1, 3)) Piecewise((1, And(1 <= i, i <= 3)), (0, True)) >>> deltasummation(k*KroneckerDelta(i, j)*KroneckerDelta(j, k), (k, -oo, oo)) j*KroneckerDelta(i, j) >>> deltasummation(j*KroneckerDelta(i, j), (j, -oo, oo)) i >>> deltasummation(i*KroneckerDelta(i, j), (i, -oo, oo)) j See Also ======== deltaproduct sympy.functions.special.tensor_functions.KroneckerDelta sympy.concrete.sums.summation """ from sympy.concrete.summations import summation from sympy.solvers import solve if ((limit[2] - limit[1]) < 0) == True: return S.Zero if not f.has(KroneckerDelta): return summation(f, limit) x = limit[0] g = _expand_delta(f, x) if g.is_Add: return piecewise_fold( g.func(*[deltasummation(h, limit, no_piecewise) for h in g.args])) # try to extract a simple KroneckerDelta term delta, expr = _extract_delta(g, x) if not delta: return summation(f, limit) solns = solve(delta.args[0] - delta.args[1], x) if len(solns) == 0: return S.Zero elif len(solns) != 1: return Sum(f, limit) value = solns[0] if no_piecewise: return expr.subs(x, value) return Piecewise( (expr.subs(x, value), Interval(*limit[1:3]).as_relational(value)), (S.Zero, True) )
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 1018, 492, 2654, 12, 22578, 12, 428, 12, 9762, 199, 504, 5840, 14, 1018, 14, 1637, 492, 2581, 390, 199, 504, 5840, 14, 1018, 14, 15390, 492, 849, 63, 3191, 63, 498, 12, 1425, 199, 504, 5840, 14, 5777, 492, 1804, 82, 368, 22043, 13411, 12, 31362, 12, 14854, 2605, 63, 14011, 199, 504, 5840, 14, 2193, 492, 18766, 421, 199, 32, 1637, 390, 199, 318, 485, 4441, 63, 3136, 8, 3684, 12, 1478, 304, 272, 408, 272, 18890, 314, 1642, 2654, 3035, 282, 3486, 1804, 82, 368, 22043, 13411, 14, 272, 408, 272, 340, 440, 5348, 14, 374, 63, 16867, 26, 267, 372, 5348, 272, 5762, 275, 488, 272, 2562, 275, 2654, 272, 2895, 275, 359, 51, 8, 17, 1874, 272, 367, 394, 315, 5348, 14, 589, 26, 267, 340, 5762, 365, 488, 436, 394, 14, 374, 63, 1123, 436, 485, 1989, 63, 4129, 63, 3136, 8, 72, 12, 1478, 304, 288, 5762, 275, 715, 288, 2562, 275, 394, 14, 1532, 288, 2895, 275, 359, 9187, 59, 16, 3672, 84, 367, 307, 315, 394, 14, 589, 61, 267, 587, 26, 288, 2895, 275, 359, 84, 10, 72, 367, 307, 315, 2895, 61, 272, 372, 2562, 2031, 9187, 9, 421, 199, 32, 1637, 390, 199, 318, 485, 5005, 63, 3136, 8, 3684, 12, 1478, 304, 272, 408, 272, 12892, 282, 3486, 1804, 82, 368, 22043, 13411, 687, 314, 3965, 14, 339, 1803, 314, 2008, 15475, 3136, 12, 892, 3684, 9719, 2382, 26, 2541, 446, 1124, 3136, 1040, 365, 282, 3486, 1804, 82, 368, 22043, 13411, 3965, 340, 1373, 1990, 1911, 12, 267, 503, 1124, 403, 1040, 340, 949, 3486, 1804, 82, 368, 22043, 13411, 3965, 1990, 1911, 14, 2541, 446, 1124, 1222, 3684, 1040, 365, 282, 22578, 3035, 314, 7971, 2895, 27, 1124, 3684, 1040, 365, 267, 2138, 14874, 340, 949, 3486, 1804, 82, 368, 22043, 13411, 3965, 1990, 1911, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 1804, 82, 368, 22043, 13411, 272, 1306, 687, 5840, 14, 13455, 14, 3136, 492, 485, 5005, 63, 3136, 272, 1306, 687, 5840, 14, 3175, 492, 671, 12, 612, 12, 284, 12, 1335, 12, 1022, 272, 1306, 485, 5005, 63, 3136, 8, 20, 10, 88, 10, 89, 10, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 395, 284, 9, 272, 334, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 395, 841, 10, 88, 10, 89, 9, 272, 1306, 485, 5005, 63, 3136, 8, 20, 10, 88, 10, 89, 10, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 395, 1022, 9, 272, 334, 403, 12, 841, 10, 88, 10, 89, 10, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 430, 339, 1666, 6121, 272, 12655, 339, 5840, 14, 5777, 14, 6664, 14, 3128, 63, 5777, 14, 27399, 368, 22043, 13411, 272, 2150, 16609, 293, 1601, 272, 27446, 453, 1615, 272, 408, 272, 340, 440, 485, 1989, 63, 4129, 63, 3136, 8, 3684, 12, 1478, 304, 267, 372, 334, 403, 12, 5348, 9, 272, 340, 1228, 8, 3684, 12, 1804, 82, 368, 22043, 13411, 304, 267, 372, 334, 3684, 12, 428, 8, 17, 430, 272, 340, 440, 5348, 14, 374, 63, 16867, 26, 267, 746, 1722, 480, 18298, 5348, 531, 272, 5762, 275, 488, 272, 2895, 275, 942, 339, 367, 1680, 315, 5348, 14, 589, 26, 267, 340, 5762, 365, 488, 436, 485, 374, 63, 4129, 63, 3136, 8, 1273, 12, 1478, 304, 288, 5762, 275, 1680, 267, 587, 26, 288, 2895, 14, 740, 8, 1273, 9, 272, 372, 334, 3136, 12, 5348, 14, 1532, 2031, 9187, 430, 421, 199, 32, 1637, 390, 199, 318, 485, 1989, 63, 4129, 63, 3136, 8, 3684, 12, 1478, 304, 272, 408, 272, 1803, 715, 340, 1124, 3684, 1040, 365, 376, 3965, 626, 3509, 282, 1804, 82, 368, 22043, 13411, 272, 626, 365, 3486, 315, 314, 1478, 1124, 1080, 4542, 11150, 626, 642, 1804, 82, 368, 22043, 13411, 272, 365, 23338, 367, 282, 2849, 574, 402, 314, 1478, 1124, 1080, 4345, 272, 408, 272, 340, 5348, 14, 1989, 8, 27399, 368, 22043, 13411, 304, 267, 340, 485, 374, 63, 4129, 63, 3136, 8, 3684, 12, 1478, 304, 288, 372, 715, 267, 340, 5348, 14, 374, 63, 1123, 503, 5348, 14, 374, 63, 16867, 26, 288, 367, 1680, 315, 5348, 14, 589, 26, 355, 340, 485, 1989, 63, 4129, 63, 3136, 8, 1273, 12, 1478, 304, 490, 372, 715, 272, 372, 756, 421, 199, 32, 1637, 390, 199, 318, 485, 374, 63, 4129, 63, 3136, 8, 3136, 12, 1478, 304, 272, 408, 272, 1803, 715, 340, 1124, 3136, 1040, 365, 282, 1804, 82, 368, 22043, 13411, 436, 365, 23338, 367, 282, 2849, 272, 574, 402, 314, 1478, 1124, 1080, 4345, 272, 408, 272, 340, 1228, 8, 3136, 12, 1804, 82, 368, 22043, 13411, 9, 436, 5762, 14, 1989, 8, 1080, 304, 267, 299, 275, 334, 3136, 14, 589, 59, 16, 61, 446, 5762, 14, 589, 59, 17, 6575, 305, 63, 6023, 8, 1080, 9, 267, 340, 299, 26, 288, 372, 299, 14, 10956, 342, 508, 413, 272, 372, 756, 421, 199, 32, 1637, 390, 199, 318, 485, 2168, 63, 6048, 63, 3136, 8, 3684, 304, 272, 408, 272, 27450, 7585, 402, 1804, 82, 368, 22043, 13411, 1159, 14, 272, 408, 272, 687, 5840, 14, 11263, 83, 492, 14241, 272, 340, 5348, 14, 374, 63, 1123, 26, 267, 372, 5348, 14, 1532, 2031, 513, 8, 1130, 1547, 2168, 63, 6048, 63, 3136, 12, 5348, 14, 589, 1724, 272, 340, 440, 5348, 14, 374, 63, 16867, 26, 267, 372, 5348, 272, 3850, 83, 275, 942, 272, 892, 589, 275, 942, 272, 367, 1680, 315, 5348, 14, 589, 26, 267, 340, 1228, 8, 1273, 12, 1804, 82, 368, 22043, 13411, 304, 288, 3850, 83, 14, 740, 8, 1273, 14, 589, 59, 16, 61, 446, 1680, 14, 589, 59, 17, 566, 267, 587, 26, 288, 892, 589, 14, 740, 8, 1273, 9, 272, 340, 440, 3850, 83, 26, 267, 372, 5348, 272, 8597, 561, 275, 14241, 8, 4077, 83, 12, 1211, 29, 549, 9, 272, 340, 822, 8, 7873, 561, 9, 508, 378, 26, 267, 372, 428, 14, 8681, 272, 916 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 1018, 492, 2654, 12, 22578, 12, 428, 12, 9762, 199, 504, 5840, 14, 1018, 14, 1637, 492, 2581, 390, 199, 504, 5840, 14, 1018, 14, 15390, 492, 849, 63, 3191, 63, 498, 12, 1425, 199, 504, 5840, 14, 5777, 492, 1804, 82, 368, 22043, 13411, 12, 31362, 12, 14854, 2605, 63, 14011, 199, 504, 5840, 14, 2193, 492, 18766, 421, 199, 32, 1637, 390, 199, 318, 485, 4441, 63, 3136, 8, 3684, 12, 1478, 304, 272, 408, 272, 18890, 314, 1642, 2654, 3035, 282, 3486, 1804, 82, 368, 22043, 13411, 14, 272, 408, 272, 340, 440, 5348, 14, 374, 63, 16867, 26, 267, 372, 5348, 272, 5762, 275, 488, 272, 2562, 275, 2654, 272, 2895, 275, 359, 51, 8, 17, 1874, 272, 367, 394, 315, 5348, 14, 589, 26, 267, 340, 5762, 365, 488, 436, 394, 14, 374, 63, 1123, 436, 485, 1989, 63, 4129, 63, 3136, 8, 72, 12, 1478, 304, 288, 5762, 275, 715, 288, 2562, 275, 394, 14, 1532, 288, 2895, 275, 359, 9187, 59, 16, 3672, 84, 367, 307, 315, 394, 14, 589, 61, 267, 587, 26, 288, 2895, 275, 359, 84, 10, 72, 367, 307, 315, 2895, 61, 272, 372, 2562, 2031, 9187, 9, 421, 199, 32, 1637, 390, 199, 318, 485, 5005, 63, 3136, 8, 3684, 12, 1478, 304, 272, 408, 272, 12892, 282, 3486, 1804, 82, 368, 22043, 13411, 687, 314, 3965, 14, 339, 1803, 314, 2008, 15475, 3136, 12, 892, 3684, 9719, 2382, 26, 2541, 446, 1124, 3136, 1040, 365, 282, 3486, 1804, 82, 368, 22043, 13411, 3965, 340, 1373, 1990, 1911, 12, 267, 503, 1124, 403, 1040, 340, 949, 3486, 1804, 82, 368, 22043, 13411, 3965, 1990, 1911, 14, 2541, 446, 1124, 1222, 3684, 1040, 365, 282, 22578, 3035, 314, 7971, 2895, 27, 1124, 3684, 1040, 365, 267, 2138, 14874, 340, 949, 3486, 1804, 82, 368, 22043, 13411, 3965, 1990, 1911, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 1804, 82, 368, 22043, 13411, 272, 1306, 687, 5840, 14, 13455, 14, 3136, 492, 485, 5005, 63, 3136, 272, 1306, 687, 5840, 14, 3175, 492, 671, 12, 612, 12, 284, 12, 1335, 12, 1022, 272, 1306, 485, 5005, 63, 3136, 8, 20, 10, 88, 10, 89, 10, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 395, 284, 9, 272, 334, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 395, 841, 10, 88, 10, 89, 9, 272, 1306, 485, 5005, 63, 3136, 8, 20, 10, 88, 10, 89, 10, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 395, 1022, 9, 272, 334, 403, 12, 841, 10, 88, 10, 89, 10, 27399, 368, 22043, 13411, 8, 73, 12, 1335, 430, 339, 1666, 6121, 272, 12655, 339, 5840, 14, 5777, 14, 6664, 14, 3128, 63, 5777, 14, 27399, 368, 22043, 13411, 272, 2150, 16609, 293, 1601, 272, 27446, 453, 1615, 272, 408, 272, 340, 440, 485, 1989, 63, 4129, 63, 3136, 8, 3684, 12, 1478, 304, 267, 372, 334, 403, 12, 5348, 9, 272, 340, 1228, 8, 3684, 12, 1804, 82, 368, 22043, 13411, 304, 267, 372, 334, 3684, 12, 428, 8, 17, 430, 272, 340, 440, 5348, 14, 374, 63, 16867, 26, 267, 746, 1722, 480, 18298, 5348, 531, 272, 5762, 275, 488, 272, 2895, 275, 942, 339, 367, 1680, 315, 5348, 14, 589, 26, 267, 340, 5762, 365, 488, 436, 485, 374, 63, 4129, 63, 3136, 8, 1273, 12, 1478, 304, 288, 5762, 275, 1680, 267, 587, 26, 288, 2895, 14, 740, 8, 1273, 9, 272, 372, 334, 3136, 12, 5348, 14, 1532, 2031, 9187, 430, 421, 199, 32, 1637, 390, 199, 318, 485, 1989, 63, 4129, 63, 3136, 8, 3684, 12, 1478, 304, 272, 408, 272, 1803, 715, 340, 1124, 3684, 1040, 365, 376, 3965, 626, 3509, 282, 1804, 82, 368, 22043, 13411, 272, 626, 365, 3486, 315, 314, 1478, 1124, 1080, 4542, 11150, 626, 642, 1804, 82, 368, 22043, 13411, 272, 365, 23338, 367, 282, 2849, 574, 402, 314, 1478, 1124, 1080, 4345, 272, 408, 272, 340, 5348, 14, 1989, 8, 27399, 368, 22043, 13411, 304, 267, 340, 485, 374, 63, 4129, 63, 3136, 8, 3684, 12, 1478, 304, 288, 372, 715, 267, 340, 5348, 14, 374, 63, 1123, 503, 5348, 14, 374, 63, 16867, 26, 288, 367, 1680, 315, 5348, 14, 589, 26, 355, 340, 485, 1989, 63, 4129, 63, 3136, 8, 1273, 12, 1478, 304, 490, 372, 715, 272, 372, 756, 421, 199, 32, 1637, 390, 199, 318, 485, 374, 63, 4129, 63, 3136, 8, 3136, 12, 1478, 304, 272, 408, 272, 1803, 715, 340, 1124, 3136, 1040, 365, 282, 1804, 82, 368, 22043, 13411, 436, 365, 23338, 367, 282, 2849, 272, 574, 402, 314, 1478, 1124, 1080, 4345, 272, 408, 272, 340, 1228, 8, 3136, 12, 1804, 82, 368, 22043, 13411, 9, 436, 5762, 14, 1989, 8, 1080, 304, 267, 299, 275, 334, 3136, 14, 589, 59, 16, 61, 446, 5762, 14, 589, 59, 17, 6575, 305, 63, 6023, 8, 1080, 9, 267, 340, 299, 26, 288, 372, 299, 14, 10956, 342, 508, 413, 272, 372, 756, 421, 199, 32, 1637, 390, 199, 318, 485, 2168, 63, 6048, 63, 3136, 8, 3684, 304, 272, 408, 272, 27450, 7585, 402, 1804, 82, 368, 22043, 13411, 1159, 14, 272, 408, 272, 687, 5840, 14, 11263, 83, 492, 14241, 272, 340, 5348, 14, 374, 63, 1123, 26, 267, 372, 5348, 14, 1532, 2031, 513, 8, 1130, 1547, 2168, 63, 6048, 63, 3136, 12, 5348, 14, 589, 1724, 272, 340, 440, 5348, 14, 374, 63, 16867, 26, 267, 372, 5348, 272, 3850, 83, 275, 942, 272, 892, 589, 275, 942, 272, 367, 1680, 315, 5348, 14, 589, 26, 267, 340, 1228, 8, 1273, 12, 1804, 82, 368, 22043, 13411, 304, 288, 3850, 83, 14, 740, 8, 1273, 14, 589, 59, 16, 61, 446, 1680, 14, 589, 59, 17, 566, 267, 587, 26, 288, 892, 589, 14, 740, 8, 1273, 9, 272, 340, 440, 3850, 83, 26, 267, 372, 5348, 272, 8597, 561, 275, 14241, 8, 4077, 83, 12, 1211, 29, 549, 9, 272, 340, 822, 8, 7873, 561, 9, 508, 378, 26, 267, 372, 428, 14, 8681, 272, 916, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
todddeluca/diabric
diabric/files.py
1
11396
''' Fabric utilities for working with files. ''' import StringIO import contextlib import os import shutil import subprocess import uuid from fabric.api import sudo, run, settings, hide, put, local from fabric.contrib.files import exists ################## # HELPER FUNCTIONS # These functions are reusable snippets meant to improve the consistency # and modularity of files.py code def set_mode(path, mode, remote=True, use_sudo=False): ''' To improve code consistency and composition, this function changes the mode of `path` to `mode`. path: the path to the file or directory whose mode is being set. remote: indicates that filename is a located on a remote host and `run` or `sudo` should be used to set the mode. use_sudo: only applies when remote is True. Use `sudo` instead of `run`. ''' func = local if not remote else sudo if use_sudo else run func('chmod {} {}'.format(oct(mode), path)) def backup_file(filename, remote=True, use_sudo=False, extension='.bak'): ''' filename: path to a local or remote file If filename exists, copy filename to filename.bak ''' func = local if not remote else sudo if use_sudo else run if exists(filename): func("cp %s %s.bak" % (filename, filename)) def normalize_dest(src, dest, remote=True, use_sudo=False): ''' src: a file path dest: a file or directory path If dest is an existing directory, this returns a path to the basename of src within the directory dest. Otherwise, if dest is returned unchanged. This is useful for getting an actual filename when destination can be a file or a directory. ''' func = local if not remote else sudo if use_sudo else run # Normalize dest to be an actual filename, due to using StringIO with settings(hide('everything'), warn_only=True): if func('test -d %s' % dest).succeeded: dest = os.path.join(dest, os.path.basename(src)) return dest ################ # FILE FUNCTIONS def file_template(filename, destination, context=None, use_jinja=False, template_dir=None, backup=True, mirror_local_mode=False, mode=None): """ This is the local version of upload_template. Render and copy a template text file to a local destination. ``filename`` should be the path to a text file, which may contain `Python string interpolation formatting <http://docs.python.org/release/2.5.4/lib/typesseq-strings.html>`_ and will be rendered with the given context dictionary ``context`` (if given.) Alternately, if ``use_jinja`` is set to True and you have the Jinja2 templating library available, Jinja will be used to render the template instead. Templates will be loaded from the invoking user's current working directory by default, or from ``template_dir`` if given. The resulting rendered file will be written to the local file path ``destination``. If the destination file already exists, it will be renamed with a ``.bak`` extension unless ``backup=False`` is specified. The ``mirror_local_mode`` and ``mode`` kwargs are used in a similar manner as in `~fabric.operations.put`; please see its documentation for details on these two options. """ func = local # make sure destination is a file name, not a directory name. destination = normalize_dest(filename, destination, remote=False) # grab mode before writing destination, in case filename and destination # are the same. if mirror_local_mode and mode is None: # mode is numeric. See os.chmod or os.stat. mode = os.stat(src).st_mode # Process template text = None if use_jinja: try: from jinja2 import Environment, FileSystemLoader jenv = Environment(loader=FileSystemLoader(template_dir or '.')) text = jenv.get_template(filename).render(**context or {}) except ImportError: import traceback tb = traceback.format_exc() abort(tb + "\nUnable to import Jinja2 -- see above.") else: with open(filename) as inputfile: text = inputfile.read() if context: text = text % context if backup: backup_file(destination, remote=False) # write the processed text with open(destination, 'w') as fh: fh.write(text) if mode: set_mode(destination, mode, remote=False) def fix_shebang(shebang, handle): ''' shebang: a shebang line, e.g. #!/usr/bin/env python or #!/bin/sh. If shebang does not start with '#!', then '#!' will be prepended to it. If shebang does not end with a newline, a newline will be appended. handle: a iterable of lines, presumably the contents of a file that needs a shebang line or a new shebang line. Yield shebang and then the lines in handle except the first line in handle if it is a shebang line. ''' # make sure shebang is starts with '#!' and ends with a newline. if not shebang.startswith('#!'): shebang = '#!' + shebang if not shebang.endswith('\n'): shebang += '\n' for i, line in enumerate(handle): if i == 0: yield shebang if not line.startswith('#!'): yield line else: yield line def upload_shebang(filename, destination, shebang, use_sudo=False, backup=True, mirror_local_mode=False, mode=None): """ Upload a text file to a remote host, adding or updating the shebang line. ``filename`` should be the path to a text file. ``shebang`` should be a string containing a shebang line. E.g. "#!/usr/bin/python\n". If shebang does not start with '#!' or end with a newline, these will be added. If the first line in filename starts with '#!' it will be replaced with shebang. If the first line does not start with #!, shebang will be prepended to the contents of filename. The resulting file will be uploaded to the remote file path ``destination``. If the destination file already exists, it will be renamed with a ``.bak`` extension unless ``backup=False`` is specified. By default, the file will be copied to ``destination`` as the logged-in user; specify ``use_sudo=True`` to use `sudo` instead. The ``mirror_local_mode`` and ``mode`` kwargs are passed directly to an internal `~fabric.operations.put` call; please see its documentation for details on these two options. """ func = use_sudo and sudo or run # Normalize destination to be an actual filename, due to using StringIO with settings(hide('everything'), warn_only=True): if func('test -d %s' % destination).succeeded: sep = "" if destination.endswith('/') else "/" destination += sep + os.path.basename(filename) # Use mode kwarg to implement mirror_local_mode, again due to using # StringIO if mirror_local_mode and mode is None: mode = os.stat(filename).st_mode # To prevent put() from trying to do this # logic itself mirror_local_mode = False # process filename text = None with open(filename) as inputfile: text = ''.join(fix_shebang(shebang, inputfile)) # Back up original file if backup and exists(destination): func("cp %s{,.bak}" % destination) # Upload the file. put( local_path=StringIO.StringIO(text), remote_path=destination, use_sudo=use_sudo, mirror_local_mode=mirror_local_mode, mode=mode ) def upload_format(filename, destination, args=None, kws=None, use_sudo=False, backup=True, mirror_local_mode=False, mode=None): """ Read in the contents of filename, format the contents via contents.format(*args, **kws), and upload the results to the destination on the remote host. ``filename`` should be the path to a text file. The contents of ``filename`` will be read in. Format the contents, using contents.format(*args, **kws). If args is None, it will not be included in the format() call. Likewise for kws. The resulting contents will be uploaded to the remote file path ``destination``. If the destination file already exists, it will be renamed with a ``.bak`` extension unless ``backup=False`` is specified. By default, the file will be copied to ``destination`` as the logged-in user; specify ``use_sudo=True`` to use `sudo` instead. The ``mirror_local_mode`` and ``mode`` kwargs are passed directly to an internal `~fabric.operations.put` call; please see its documentation for details on these two options. """ func = use_sudo and sudo or run # Normalize destination to be an actual filename, due to using StringIO with settings(hide('everything'), warn_only=True): if func('test -d %s' % destination).succeeded: sep = "" if destination.endswith('/') else "/" destination += sep + os.path.basename(filename) # Use mode kwarg to implement mirror_local_mode, again due to using # StringIO if mirror_local_mode and mode is None: mode = os.stat(filename).st_mode # To prevent put() from trying to do this # logic itself mirror_local_mode = False # process filename text = None with open(filename) as inputfile: if not args: args = [] if not kws: kws = {} text = inputfile.read().format(*args, **kws) # Back up original file if backup and exists(destination): func("cp %s{,.bak}" % destination) # Upload the file. put( local_path=StringIO.StringIO(text), remote_path=destination, use_sudo=use_sudo, mirror_local_mode=mirror_local_mode, mode=mode ) def file_format(infile, outfile, args=None, kws=None): ''' Consider using fabric.contrib.files.upload_template or upload_format infile: a local file path outfile: a local file path. Read the contents of infile as a string, ''.format() the string using args and kws, and write the formatted string to outfile. This is useful if infile is a "template" and args and kws contain the concrete values for the template. ''' if args is None: args = [] if kws is None: kws is {} with open(infile) as fh: text = fh.read() new_text = text.format(*args, **kws) with open(outfile, 'w') as fh2: fh2.write(new_text) def rsync(options, src, dest, user=None, host=None, cwd=None): ''' Consider using fabric.contrib.project.rsync_project. options: list of rsync options, e.g. ['--delete', '-avz'] src: source directory (or files). Note: rsync behavior varies depending on whether or not src dir ends in '/'. dest: destination directory. cwd: change (using subprocess) to cwd before running rsync. This is a helper function for running rsync locally, via subprocess. Note: shell=False. ''' # if remote user and host specified, copy there instead of locally. if user and host: destStr = '{}@{}:{}'.format(user, host, dest) else: destStr = dest args = ['rsync'] + options + [src, destStr] print args subprocess.check_call(args, cwd=cwd)
mit
[ 199, 2344, 199, 38, 2129, 15841, 367, 6449, 543, 1584, 14, 199, 2344, 199, 199, 646, 5228, 199, 646, 15502, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 5377, 199, 199, 504, 2630, 14, 1246, 492, 14682, 12, 1255, 12, 2202, 12, 13714, 12, 5324, 12, 2257, 199, 504, 2630, 14, 2828, 14, 1725, 492, 3495, 421, 199, 749, 309, 199, 3, 25734, 4227, 21498, 19560, 199, 3, 5723, 3423, 787, 295, 14418, 19484, 18329, 370, 19053, 314, 17754, 221, 199, 3, 436, 3413, 22504, 402, 1584, 14, 647, 1233, 199, 199, 318, 663, 63, 632, 8, 515, 12, 818, 12, 3982, 29, 549, 12, 675, 63, 12095, 29, 797, 304, 272, 1449, 272, 4005, 19053, 1233, 17754, 436, 31586, 12, 642, 805, 272, 4493, 314, 818, 402, 658, 515, 64, 370, 658, 632, 2313, 339, 931, 26, 314, 931, 370, 314, 570, 503, 2082, 7447, 818, 365, 3769, 663, 14, 272, 3982, 26, 9126, 626, 1788, 365, 282, 16180, 641, 282, 3982, 1591, 436, 658, 1065, 64, 272, 503, 658, 12095, 64, 1077, 506, 1202, 370, 663, 314, 818, 14, 272, 675, 63, 12095, 26, 1454, 12966, 1380, 3982, 365, 715, 14, 221, 3645, 658, 12095, 64, 3140, 402, 658, 1065, 2313, 272, 1449, 272, 2562, 275, 2257, 340, 440, 3982, 587, 14682, 340, 675, 63, 12095, 587, 1255, 272, 2562, 360, 11693, 1052, 9499, 908, 8, 15560, 8, 632, 395, 931, 430, 421, 199, 318, 6902, 63, 493, 8, 1501, 12, 3982, 29, 549, 12, 675, 63, 12095, 29, 797, 12, 3329, 15637, 27162, 735, 272, 1449, 272, 1788, 26, 931, 370, 282, 2257, 503, 3982, 570, 339, 982, 1788, 3495, 12, 1331, 1788, 370, 1788, 14, 27162, 272, 1449, 272, 2562, 275, 2257, 340, 440, 3982, 587, 14682, 340, 675, 63, 12095, 587, 1255, 272, 340, 3495, 8, 1501, 304, 267, 2562, 480, 1850, 450, 83, 450, 83, 14, 27162, 2, 450, 334, 1501, 12, 1788, 430, 421, 199, 318, 7666, 63, 2614, 8, 2164, 12, 2053, 12, 3982, 29, 549, 12, 675, 63, 12095, 29, 797, 304, 272, 1449, 272, 2928, 26, 282, 570, 931, 272, 2053, 26, 282, 570, 503, 2082, 931, 339, 982, 2053, 365, 376, 3411, 2082, 12, 642, 2529, 282, 931, 370, 314, 9593, 402, 2928, 4453, 314, 2082, 2053, 14, 272, 6630, 12, 340, 2053, 365, 2138, 14874, 14, 272, 961, 365, 2997, 367, 10232, 376, 3503, 1788, 1380, 5724, 883, 506, 272, 282, 570, 503, 282, 2082, 14, 272, 1449, 272, 2562, 275, 2257, 340, 440, 3982, 587, 14682, 340, 675, 63, 12095, 587, 1255, 272, 327, 21017, 2053, 370, 506, 376, 3503, 1788, 12, 7037, 370, 1808, 5228, 272, 543, 2202, 8, 8191, 360, 14287, 2127, 659, 7987, 63, 2118, 29, 549, 304, 267, 340, 2562, 360, 396, 446, 68, 450, 83, 7, 450, 2053, 680, 20003, 26, 288, 2053, 275, 747, 14, 515, 14, 904, 8, 2614, 12, 747, 14, 515, 14, 4846, 8, 2164, 430, 339, 372, 2053, 421, 199, 749, 199, 3, 13024, 21498, 19560, 421, 199, 318, 570, 63, 1160, 8, 1501, 12, 5724, 12, 1067, 29, 403, 12, 675, 63, 12264, 29, 797, 12, 272, 1978, 63, 694, 29, 403, 12, 6902, 29, 549, 12, 15216, 63, 1832, 63, 632, 29, 797, 12, 818, 29, 403, 304, 272, 408, 272, 961, 365, 314, 2257, 1015, 402, 5802, 63, 1160, 14, 339, 17769, 436, 1331, 282, 1978, 1318, 570, 370, 282, 2257, 5724, 14, 339, 1124, 1501, 1040, 1077, 506, 314, 931, 370, 282, 1318, 570, 12, 1314, 1443, 1395, 658, 4718, 272, 1059, 14046, 10803, 272, 665, 1014, 921, 4757, 14, 1548, 14, 1308, 15, 3221, 15, 18, 14, 21, 14, 20, 15, 773, 15, 1313, 3610, 13, 5465, 14, 1360, 18740, 436, 911, 272, 506, 8018, 543, 314, 1627, 1067, 2600, 1124, 1100, 1040, 334, 692, 1627, 4959, 339, 17669, 13824, 12, 340, 1124, 1180, 63, 12264, 1040, 365, 663, 370, 715, 436, 1265, 1172, 314, 17300, 18, 272, 2388, 24615, 3555, 2808, 12, 17300, 911, 506, 1202, 370, 3795, 314, 1978, 272, 3140, 14, 31273, 911, 506, 6511, 687, 314, 26750, 922, 1159, 1453, 6449, 272, 2082, 701, 849, 12, 503, 687, 1124, 1160, 63, 694, 1040, 340, 1627, 14, 339, 710, 9183, 8018, 570, 911, 506, 5313, 370, 314, 2257, 570, 931, 272, 1124, 6881, 4345, 221, 982, 314, 5724, 570, 2575, 3495, 12, 652, 911, 506, 272, 17864, 543, 282, 21502, 27162, 1040, 3329, 7444, 1124, 5751, 29, 797, 1040, 365, 2013, 14, 339, 710, 1124, 12324, 63, 1832, 63, 632, 1040, 436, 1124, 632, 1040, 2074, 787, 1202, 315, 282, 8545, 272, 30800, 465, 315, 28157, 4991, 14, 8170, 14, 524, 64, 27, 8749, 1937, 2399, 3794, 367, 272, 2436, 641, 3520, 2877, 1511, 14, 272, 408, 272, 2562, 275, 2257, 339, 327, 1852, 3238, 5724, 365, 282, 570, 536, 12, 440, 282, 2082, 536, 14, 272, 5724, 275, 7666, 63, 2614, 8, 1501, 12, 5724, 12, 3982, 29, 797, 9, 339, 327, 18200, 818, 2544, 3575, 5724, 12, 315, 1930, 1788, 436, 5724, 272, 327, 787, 314, 2011, 14, 272, 340, 15216, 63, 1832, 63, 632, 436, 818, 365, 488, 26, 267, 327, 818, 365, 8950, 14, 221, 1666, 747, 14, 11693, 503, 747, 14, 3736, 14, 267, 818, 275, 747, 14, 3736, 8, 2164, 680, 270, 63, 632, 339, 327, 7132, 1978, 272, 1318, 275, 488, 272, 340, 675, 63, 12264, 26, 267, 862, 26, 288, 687, 10321, 18, 492, 9711, 12, 23754, 5455, 288, 1335, 1813, 275, 9711, 8, 3422, 29, 17521, 5455, 8, 1160, 63, 694, 503, 1987, 1333, 288, 1318, 275, 1335, 1813, 14, 362, 63, 1160, 8, 1501, 680, 3352, 3682, 1100, 503, 5009, 267, 871, 3545, 26, 288, 492, 5190, 288, 7070, 275, 5190, 14, 908, 63, 2804, 342, 288, 12004, 8, 5842, 435, 1867, 78, 6005, 370, 492, 17300, 18, 1553, 1937, 3432, 2685, 272, 587, 26, 267, 543, 1551, 8, 1501, 9, 465, 1324, 493, 26, 288, 1318, 275, 1324, 493, 14, 739, 342, 267, 340, 1067, 26, 288, 1318, 275, 1318, 450, 1067, 339, 340, 6902, 26, 267, 6902, 63, 493, 8, 6881, 12, 3982, 29, 797, 9, 339, 327 ]
[ 2344, 199, 38, 2129, 15841, 367, 6449, 543, 1584, 14, 199, 2344, 199, 199, 646, 5228, 199, 646, 15502, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 5377, 199, 199, 504, 2630, 14, 1246, 492, 14682, 12, 1255, 12, 2202, 12, 13714, 12, 5324, 12, 2257, 199, 504, 2630, 14, 2828, 14, 1725, 492, 3495, 421, 199, 749, 309, 199, 3, 25734, 4227, 21498, 19560, 199, 3, 5723, 3423, 787, 295, 14418, 19484, 18329, 370, 19053, 314, 17754, 221, 199, 3, 436, 3413, 22504, 402, 1584, 14, 647, 1233, 199, 199, 318, 663, 63, 632, 8, 515, 12, 818, 12, 3982, 29, 549, 12, 675, 63, 12095, 29, 797, 304, 272, 1449, 272, 4005, 19053, 1233, 17754, 436, 31586, 12, 642, 805, 272, 4493, 314, 818, 402, 658, 515, 64, 370, 658, 632, 2313, 339, 931, 26, 314, 931, 370, 314, 570, 503, 2082, 7447, 818, 365, 3769, 663, 14, 272, 3982, 26, 9126, 626, 1788, 365, 282, 16180, 641, 282, 3982, 1591, 436, 658, 1065, 64, 272, 503, 658, 12095, 64, 1077, 506, 1202, 370, 663, 314, 818, 14, 272, 675, 63, 12095, 26, 1454, 12966, 1380, 3982, 365, 715, 14, 221, 3645, 658, 12095, 64, 3140, 402, 658, 1065, 2313, 272, 1449, 272, 2562, 275, 2257, 340, 440, 3982, 587, 14682, 340, 675, 63, 12095, 587, 1255, 272, 2562, 360, 11693, 1052, 9499, 908, 8, 15560, 8, 632, 395, 931, 430, 421, 199, 318, 6902, 63, 493, 8, 1501, 12, 3982, 29, 549, 12, 675, 63, 12095, 29, 797, 12, 3329, 15637, 27162, 735, 272, 1449, 272, 1788, 26, 931, 370, 282, 2257, 503, 3982, 570, 339, 982, 1788, 3495, 12, 1331, 1788, 370, 1788, 14, 27162, 272, 1449, 272, 2562, 275, 2257, 340, 440, 3982, 587, 14682, 340, 675, 63, 12095, 587, 1255, 272, 340, 3495, 8, 1501, 304, 267, 2562, 480, 1850, 450, 83, 450, 83, 14, 27162, 2, 450, 334, 1501, 12, 1788, 430, 421, 199, 318, 7666, 63, 2614, 8, 2164, 12, 2053, 12, 3982, 29, 549, 12, 675, 63, 12095, 29, 797, 304, 272, 1449, 272, 2928, 26, 282, 570, 931, 272, 2053, 26, 282, 570, 503, 2082, 931, 339, 982, 2053, 365, 376, 3411, 2082, 12, 642, 2529, 282, 931, 370, 314, 9593, 402, 2928, 4453, 314, 2082, 2053, 14, 272, 6630, 12, 340, 2053, 365, 2138, 14874, 14, 272, 961, 365, 2997, 367, 10232, 376, 3503, 1788, 1380, 5724, 883, 506, 272, 282, 570, 503, 282, 2082, 14, 272, 1449, 272, 2562, 275, 2257, 340, 440, 3982, 587, 14682, 340, 675, 63, 12095, 587, 1255, 272, 327, 21017, 2053, 370, 506, 376, 3503, 1788, 12, 7037, 370, 1808, 5228, 272, 543, 2202, 8, 8191, 360, 14287, 2127, 659, 7987, 63, 2118, 29, 549, 304, 267, 340, 2562, 360, 396, 446, 68, 450, 83, 7, 450, 2053, 680, 20003, 26, 288, 2053, 275, 747, 14, 515, 14, 904, 8, 2614, 12, 747, 14, 515, 14, 4846, 8, 2164, 430, 339, 372, 2053, 421, 199, 749, 199, 3, 13024, 21498, 19560, 421, 199, 318, 570, 63, 1160, 8, 1501, 12, 5724, 12, 1067, 29, 403, 12, 675, 63, 12264, 29, 797, 12, 272, 1978, 63, 694, 29, 403, 12, 6902, 29, 549, 12, 15216, 63, 1832, 63, 632, 29, 797, 12, 818, 29, 403, 304, 272, 408, 272, 961, 365, 314, 2257, 1015, 402, 5802, 63, 1160, 14, 339, 17769, 436, 1331, 282, 1978, 1318, 570, 370, 282, 2257, 5724, 14, 339, 1124, 1501, 1040, 1077, 506, 314, 931, 370, 282, 1318, 570, 12, 1314, 1443, 1395, 658, 4718, 272, 1059, 14046, 10803, 272, 665, 1014, 921, 4757, 14, 1548, 14, 1308, 15, 3221, 15, 18, 14, 21, 14, 20, 15, 773, 15, 1313, 3610, 13, 5465, 14, 1360, 18740, 436, 911, 272, 506, 8018, 543, 314, 1627, 1067, 2600, 1124, 1100, 1040, 334, 692, 1627, 4959, 339, 17669, 13824, 12, 340, 1124, 1180, 63, 12264, 1040, 365, 663, 370, 715, 436, 1265, 1172, 314, 17300, 18, 272, 2388, 24615, 3555, 2808, 12, 17300, 911, 506, 1202, 370, 3795, 314, 1978, 272, 3140, 14, 31273, 911, 506, 6511, 687, 314, 26750, 922, 1159, 1453, 6449, 272, 2082, 701, 849, 12, 503, 687, 1124, 1160, 63, 694, 1040, 340, 1627, 14, 339, 710, 9183, 8018, 570, 911, 506, 5313, 370, 314, 2257, 570, 931, 272, 1124, 6881, 4345, 221, 982, 314, 5724, 570, 2575, 3495, 12, 652, 911, 506, 272, 17864, 543, 282, 21502, 27162, 1040, 3329, 7444, 1124, 5751, 29, 797, 1040, 365, 2013, 14, 339, 710, 1124, 12324, 63, 1832, 63, 632, 1040, 436, 1124, 632, 1040, 2074, 787, 1202, 315, 282, 8545, 272, 30800, 465, 315, 28157, 4991, 14, 8170, 14, 524, 64, 27, 8749, 1937, 2399, 3794, 367, 272, 2436, 641, 3520, 2877, 1511, 14, 272, 408, 272, 2562, 275, 2257, 339, 327, 1852, 3238, 5724, 365, 282, 570, 536, 12, 440, 282, 2082, 536, 14, 272, 5724, 275, 7666, 63, 2614, 8, 1501, 12, 5724, 12, 3982, 29, 797, 9, 339, 327, 18200, 818, 2544, 3575, 5724, 12, 315, 1930, 1788, 436, 5724, 272, 327, 787, 314, 2011, 14, 272, 340, 15216, 63, 1832, 63, 632, 436, 818, 365, 488, 26, 267, 327, 818, 365, 8950, 14, 221, 1666, 747, 14, 11693, 503, 747, 14, 3736, 14, 267, 818, 275, 747, 14, 3736, 8, 2164, 680, 270, 63, 632, 339, 327, 7132, 1978, 272, 1318, 275, 488, 272, 340, 675, 63, 12264, 26, 267, 862, 26, 288, 687, 10321, 18, 492, 9711, 12, 23754, 5455, 288, 1335, 1813, 275, 9711, 8, 3422, 29, 17521, 5455, 8, 1160, 63, 694, 503, 1987, 1333, 288, 1318, 275, 1335, 1813, 14, 362, 63, 1160, 8, 1501, 680, 3352, 3682, 1100, 503, 5009, 267, 871, 3545, 26, 288, 492, 5190, 288, 7070, 275, 5190, 14, 908, 63, 2804, 342, 288, 12004, 8, 5842, 435, 1867, 78, 6005, 370, 492, 17300, 18, 1553, 1937, 3432, 2685, 272, 587, 26, 267, 543, 1551, 8, 1501, 9, 465, 1324, 493, 26, 288, 1318, 275, 1324, 493, 14, 739, 342, 267, 340, 1067, 26, 288, 1318, 275, 1318, 450, 1067, 339, 340, 6902, 26, 267, 6902, 63, 493, 8, 6881, 12, 3982, 29, 797, 9, 339, 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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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 ]
mlavin/django
tests/queries/tests.py
4
160528
import datetime import pickle import unittest from collections import OrderedDict from operator import attrgetter from django.core.exceptions import EmptyResultSet, FieldError from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import Count, F, Q from django.db.models.sql.constants import LOUTER from django.db.models.sql.where import NothingNode, WhereNode from django.test import TestCase, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext from .models import ( FK1, Annotation, Article, Author, BaseA, Book, CategoryItem, CategoryRelationship, Celebrity, Channel, Chapter, Child, ChildObjectA, Classroom, Company, Cover, CustomPk, CustomPkTag, Detail, DumbCategory, Eaten, Employment, ExtraInfo, Fan, Food, Identifier, Individual, Item, Job, JobResponsibilities, Join, LeafA, LeafB, LoopX, LoopZ, ManagedModel, Member, ModelA, ModelB, ModelC, ModelD, MyObject, NamedCategory, Node, Note, NullableName, Number, ObjectA, ObjectB, ObjectC, OneToOneCategory, Order, OrderItem, Page, Paragraph, Person, Plaything, PointerA, Program, ProxyCategory, ProxyObjectA, ProxyObjectB, Ranking, Related, RelatedIndividual, RelatedObject, Report, ReportComment, ReservedName, Responsibility, School, SharedConnection, SimpleCategory, SingleObject, SpecialCategory, Staff, StaffUser, Student, Tag, Task, Teacher, Ticket21203Child, Ticket21203Parent, Ticket23605A, Ticket23605B, Ticket23605C, TvChef, Valid, X, ) class Queries1Tests(TestCase): @classmethod def setUpTestData(cls): generic = NamedCategory.objects.create(name="Generic") cls.t1 = Tag.objects.create(name='t1', category=generic) cls.t2 = Tag.objects.create(name='t2', parent=cls.t1, category=generic) cls.t3 = Tag.objects.create(name='t3', parent=cls.t1) t4 = Tag.objects.create(name='t4', parent=cls.t3) cls.t5 = Tag.objects.create(name='t5', parent=cls.t3) cls.n1 = Note.objects.create(note='n1', misc='foo', id=1) n2 = Note.objects.create(note='n2', misc='bar', id=2) cls.n3 = Note.objects.create(note='n3', misc='foo', id=3) ann1 = Annotation.objects.create(name='a1', tag=cls.t1) ann1.notes.add(cls.n1) ann2 = Annotation.objects.create(name='a2', tag=t4) ann2.notes.add(n2, cls.n3) # Create these out of order so that sorting by 'id' will be different to sorting # by 'info'. Helps detect some problems later. cls.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41) e1 = ExtraInfo.objects.create(info='e1', note=cls.n1, value=42) cls.a1 = Author.objects.create(name='a1', num=1001, extra=e1) cls.a2 = Author.objects.create(name='a2', num=2002, extra=e1) a3 = Author.objects.create(name='a3', num=3003, extra=cls.e2) cls.a4 = Author.objects.create(name='a4', num=4004, extra=cls.e2) cls.time1 = datetime.datetime(2007, 12, 19, 22, 25, 0) cls.time2 = datetime.datetime(2007, 12, 19, 21, 0, 0) time3 = datetime.datetime(2007, 12, 20, 22, 25, 0) time4 = datetime.datetime(2007, 12, 20, 21, 0, 0) cls.i1 = Item.objects.create(name='one', created=cls.time1, modified=cls.time1, creator=cls.a1, note=cls.n3) cls.i1.tags.set([cls.t1, cls.t2]) cls.i2 = Item.objects.create(name='two', created=cls.time2, creator=cls.a2, note=n2) cls.i2.tags.set([cls.t1, cls.t3]) cls.i3 = Item.objects.create(name='three', created=time3, creator=cls.a2, note=cls.n3) i4 = Item.objects.create(name='four', created=time4, creator=cls.a4, note=cls.n3) i4.tags.set([t4]) cls.r1 = Report.objects.create(name='r1', creator=cls.a1) Report.objects.create(name='r2', creator=a3) Report.objects.create(name='r3') # Ordering by 'rank' gives us rank2, rank1, rank3. Ordering by the Meta.ordering # will be rank3, rank2, rank1. cls.rank1 = Ranking.objects.create(rank=2, author=cls.a2) Cover.objects.create(title="first", item=i4) Cover.objects.create(title="second", item=cls.i2) def test_subquery_condition(self): qs1 = Tag.objects.filter(pk__lte=0) qs2 = Tag.objects.filter(parent__in=qs1) qs3 = Tag.objects.filter(parent__in=qs2) self.assertEqual(qs3.query.subq_aliases, {'T', 'U', 'V'}) self.assertIn('v0', str(qs3.query).lower()) qs4 = qs3.filter(parent__in=qs1) self.assertEqual(qs4.query.subq_aliases, {'T', 'U', 'V'}) # It is possible to reuse U for the second subquery, no need to use W. self.assertNotIn('w0', str(qs4.query).lower()) # So, 'U0."id"' is referenced twice. self.assertTrue(str(qs4.query).lower().count('u0'), 2) def test_ticket1050(self): self.assertQuerysetEqual( Item.objects.filter(tags__isnull=True), ['<Item: three>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__id__isnull=True), ['<Item: three>'] ) def test_ticket1801(self): self.assertQuerysetEqual( Author.objects.filter(item=self.i2), ['<Author: a2>'] ) self.assertQuerysetEqual( Author.objects.filter(item=self.i3), ['<Author: a2>'] ) self.assertQuerysetEqual( Author.objects.filter(item=self.i2) & Author.objects.filter(item=self.i3), ['<Author: a2>'] ) def test_ticket2306(self): # Checking that no join types are "left outer" joins. query = Item.objects.filter(tags=self.t2).query self.assertNotIn(LOUTER, [x.join_type for x in query.alias_map.values()]) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1)).order_by('name'), ['<Item: one>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1)).filter(Q(tags=self.t2)), ['<Item: one>'] ) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1)).filter(Q(creator__name='fred') | Q(tags=self.t2)), ['<Item: one>'] ) # Each filter call is processed "at once" against a single table, so this is # different from the previous example as it tries to find tags that are two # things at once (rather than two tags). self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1) & Q(tags=self.t2)), [] ) self.assertQuerysetEqual( Item.objects.filter(Q(tags=self.t1), Q(creator__name='fred') | Q(tags=self.t2)), [] ) qs = Author.objects.filter(ranking__rank=2, ranking__id=self.rank1.id) self.assertQuerysetEqual(list(qs), ['<Author: a2>']) self.assertEqual(2, qs.query.count_active_tables(), 2) qs = Author.objects.filter(ranking__rank=2).filter(ranking__id=self.rank1.id) self.assertEqual(qs.query.count_active_tables(), 3) def test_ticket4464(self): self.assertQuerysetEqual( Item.objects.filter(tags=self.t1).filter(tags=self.t2), ['<Item: one>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).distinct().order_by('name'), ['<Item: one>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).filter(tags=self.t3), ['<Item: two>'] ) # Make sure .distinct() works with slicing (this was broken in Oracle). self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).order_by('name')[:3], ['<Item: one>', '<Item: one>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(tags__in=[self.t1, self.t2]).distinct().order_by('name')[:3], ['<Item: one>', '<Item: two>'] ) def test_tickets_2080_3592(self): self.assertQuerysetEqual( Author.objects.filter(item__name='one') | Author.objects.filter(name='a3'), ['<Author: a1>', '<Author: a3>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(item__name='one') | Q(name='a3')), ['<Author: a1>', '<Author: a3>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(name='a3') | Q(item__name='one')), ['<Author: a1>', '<Author: a3>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(item__name='three') | Q(report__name='r3')), ['<Author: a2>'] ) def test_ticket6074(self): # Merging two empty result sets shouldn't leave a queryset with no constraints # (which would match everything). self.assertQuerysetEqual(Author.objects.filter(Q(id__in=[])), []) self.assertQuerysetEqual( Author.objects.filter(Q(id__in=[]) | Q(id__in=[])), [] ) def test_tickets_1878_2939(self): self.assertEqual(Item.objects.values('creator').distinct().count(), 3) # Create something with a duplicate 'name' so that we can test multi-column # cases (which require some tricky SQL transformations under the covers). xx = Item(name='four', created=self.time1, creator=self.a2, note=self.n1) xx.save() self.assertEqual( Item.objects.exclude(name='two').values('creator', 'name').distinct().count(), 4 ) self.assertEqual( ( Item.objects .exclude(name='two') .extra(select={'foo': '%s'}, select_params=(1,)) .values('creator', 'name', 'foo') .distinct() .count() ), 4 ) self.assertEqual( ( Item.objects .exclude(name='two') .extra(select={'foo': '%s'}, select_params=(1,)) .values('creator', 'name') .distinct() .count() ), 4 ) xx.delete() def test_ticket7323(self): self.assertEqual(Item.objects.values('creator', 'name').count(), 4) def test_ticket2253(self): q1 = Item.objects.order_by('name') q2 = Item.objects.filter(id=self.i1.id) self.assertQuerysetEqual( q1, ['<Item: four>', '<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual(q2, ['<Item: one>']) self.assertQuerysetEqual( (q1 | q2).order_by('name'), ['<Item: four>', '<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual((q1 & q2).order_by('name'), ['<Item: one>']) q1 = Item.objects.filter(tags=self.t1) q2 = Item.objects.filter(note=self.n3, tags=self.t2) q3 = Item.objects.filter(creator=self.a4) self.assertQuerysetEqual( ((q1 & q2) | q3).order_by('name'), ['<Item: four>', '<Item: one>'] ) def test_order_by_tables(self): q1 = Item.objects.order_by('name') q2 = Item.objects.filter(id=self.i1.id) list(q2) combined_query = (q1 & q2).order_by('name').query self.assertEqual(len([ t for t in combined_query.alias_map if combined_query.alias_refcount[t] ]), 1) def test_order_by_join_unref(self): """ This test is related to the above one, testing that there aren't old JOINs in the query. """ qs = Celebrity.objects.order_by('greatest_fan__fan_of') self.assertIn('OUTER JOIN', str(qs.query)) qs = qs.order_by('id') self.assertNotIn('OUTER JOIN', str(qs.query)) def test_get_clears_ordering(self): """ get() should clear ordering for optimization purposes. """ with CaptureQueriesContext(connection) as captured_queries: Author.objects.order_by('name').get(pk=self.a1.pk) self.assertNotIn('order by', captured_queries[0]['sql'].lower()) def test_tickets_4088_4306(self): self.assertQuerysetEqual( Report.objects.filter(creator=1001), ['<Report: r1>'] ) self.assertQuerysetEqual( Report.objects.filter(creator__num=1001), ['<Report: r1>'] ) self.assertQuerysetEqual(Report.objects.filter(creator__id=1001), []) self.assertQuerysetEqual( Report.objects.filter(creator__id=self.a1.id), ['<Report: r1>'] ) self.assertQuerysetEqual( Report.objects.filter(creator__name='a1'), ['<Report: r1>'] ) def test_ticket4510(self): self.assertQuerysetEqual( Author.objects.filter(report__name='r1'), ['<Author: a1>'] ) def test_ticket7378(self): self.assertQuerysetEqual(self.a1.report_set.all(), ['<Report: r1>']) def test_tickets_5324_6704(self): self.assertQuerysetEqual( Item.objects.filter(tags__name='t4'), ['<Item: four>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t4').order_by('name').distinct(), ['<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t4').order_by('name').distinct().reverse(), ['<Item: two>', '<Item: three>', '<Item: one>'] ) self.assertQuerysetEqual( Author.objects.exclude(item__name='one').distinct().order_by('name'), ['<Author: a2>', '<Author: a3>', '<Author: a4>'] ) # Excluding across a m2m relation when there is more than one related # object associated was problematic. self.assertQuerysetEqual( Item.objects.exclude(tags__name='t1').order_by('name'), ['<Item: four>', '<Item: three>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t1').exclude(tags__name='t4'), ['<Item: three>'] ) # Excluding from a relation that cannot be NULL should not use outer joins. query = Item.objects.exclude(creator__in=[self.a1, self.a2]).query self.assertNotIn(LOUTER, [x.join_type for x in query.alias_map.values()]) # Similarly, when one of the joins cannot possibly, ever, involve NULL # values (Author -> ExtraInfo, in the following), it should never be # promoted to a left outer join. So the following query should only # involve one "left outer" join (Author -> Item is 0-to-many). qs = Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3)) self.assertEqual( len([ x for x in qs.query.alias_map.values() if x.join_type == LOUTER and qs.query.alias_refcount[x.table_alias] ]), 1 ) # The previous changes shouldn't affect nullable foreign key joins. self.assertQuerysetEqual( Tag.objects.filter(parent__isnull=True).order_by('name'), ['<Tag: t1>'] ) self.assertQuerysetEqual( Tag.objects.exclude(parent__isnull=True).order_by('name'), ['<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.exclude(Q(parent__name='t1') | Q(parent__isnull=True)).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.exclude(Q(parent__isnull=True) | Q(parent__name='t1')).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.exclude(Q(parent__parent__isnull=True)).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.filter(~Q(parent__parent__isnull=True)).order_by('name'), ['<Tag: t4>', '<Tag: t5>'] ) def test_ticket2091(self): t = Tag.objects.get(name='t4') self.assertQuerysetEqual( Item.objects.filter(tags__in=[t]), ['<Item: four>'] ) def test_avoid_infinite_loop_on_too_many_subqueries(self): x = Tag.objects.filter(pk=1) local_recursion_limit = 127 msg = 'Maximum recursion depth exceeded: too many subqueries.' with self.assertRaisesMessage(RuntimeError, msg): for i in range(local_recursion_limit * 2): x = Tag.objects.filter(pk__in=x) def test_reasonable_number_of_subq_aliases(self): x = Tag.objects.filter(pk=1) for _ in range(20): x = Tag.objects.filter(pk__in=x) self.assertEqual( x.query.subq_aliases, { 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', } ) def test_heterogeneous_qs_combination(self): # Combining querysets built on different models should behave in a well-defined # fashion. We raise an error. with self.assertRaisesMessage(AssertionError, 'Cannot combine queries on two different base models.'): Author.objects.all() & Tag.objects.all() with self.assertRaisesMessage(AssertionError, 'Cannot combine queries on two different base models.'): Author.objects.all() | Tag.objects.all() def test_ticket3141(self): self.assertEqual(Author.objects.extra(select={'foo': '1'}).count(), 4) self.assertEqual( Author.objects.extra(select={'foo': '%s'}, select_params=(1,)).count(), 4 ) def test_ticket2400(self): self.assertQuerysetEqual( Author.objects.filter(item__isnull=True), ['<Author: a3>'] ) self.assertQuerysetEqual( Tag.objects.filter(item__isnull=True), ['<Tag: t5>'] ) def test_ticket2496(self): self.assertQuerysetEqual( Item.objects.extra(tables=['queries_author']).select_related().order_by('name')[:1], ['<Item: four>'] ) def test_error_raised_on_filter_with_dictionary(self): with self.assertRaisesMessage(FieldError, 'Cannot parse keyword query as dict'): Note.objects.filter({'note': 'n1', 'misc': 'foo'}) def test_tickets_2076_7256(self): # Ordering on related tables should be possible, even if the table is # not otherwise involved. self.assertQuerysetEqual( Item.objects.order_by('note__note', 'name'), ['<Item: two>', '<Item: four>', '<Item: one>', '<Item: three>'] ) # Ordering on a related field should use the remote model's default # ordering as a final step. self.assertQuerysetEqual( Author.objects.order_by('extra', '-name'), ['<Author: a2>', '<Author: a1>', '<Author: a4>', '<Author: a3>'] ) # Using remote model default ordering can span multiple models (in this # case, Cover is ordered by Item's default, which uses Note's default). self.assertQuerysetEqual( Cover.objects.all(), ['<Cover: first>', '<Cover: second>'] ) # If the remote model does not have a default ordering, we order by its 'id' # field. self.assertQuerysetEqual( Item.objects.order_by('creator', 'name'), ['<Item: one>', '<Item: three>', '<Item: two>', '<Item: four>'] ) # Ordering by a many-valued attribute (e.g. a many-to-many or reverse # ForeignKey) is legal, but the results might not make sense. That # isn't Django's problem. Garbage in, garbage out. self.assertQuerysetEqual( Item.objects.filter(tags__isnull=False).order_by('tags', 'id'), ['<Item: one>', '<Item: two>', '<Item: one>', '<Item: two>', '<Item: four>'] ) # If we replace the default ordering, Django adjusts the required # tables automatically. Item normally requires a join with Note to do # the default ordering, but that isn't needed here. qs = Item.objects.order_by('name') self.assertQuerysetEqual( qs, ['<Item: four>', '<Item: one>', '<Item: three>', '<Item: two>'] ) self.assertEqual(len(qs.query.alias_map), 1) def test_tickets_2874_3002(self): qs = Item.objects.select_related().order_by('note__note', 'name') self.assertQuerysetEqual( qs, ['<Item: two>', '<Item: four>', '<Item: one>', '<Item: three>'] ) # This is also a good select_related() test because there are multiple # Note entries in the SQL. The two Note items should be different. self.assertTrue(repr(qs[0].note), '<Note: n2>') self.assertEqual(repr(qs[0].creator.extra.note), '<Note: n1>') def test_ticket3037(self): self.assertQuerysetEqual( Item.objects.filter(Q(creator__name='a3', name='two') | Q(creator__name='a4', name='four')), ['<Item: four>'] ) def test_tickets_5321_7070(self): # Ordering columns must be included in the output columns. Note that # this means results that might otherwise be distinct are not (if there # are multiple values in the ordering cols), as in this example. This # isn't a bug; it's a warning to be careful with the selection of # ordering columns. self.assertSequenceEqual( Note.objects.values('misc').distinct().order_by('note', '-misc'), [{'misc': 'foo'}, {'misc': 'bar'}, {'misc': 'foo'}] ) def test_ticket4358(self): # If you don't pass any fields to values(), relation fields are # returned as "foo_id" keys, not "foo". For consistency, you should be # able to pass "foo_id" in the fields list and have it work, too. We # actually allow both "foo" and "foo_id". # The *_id version is returned by default. self.assertIn('note_id', ExtraInfo.objects.values()[0]) # You can also pass it in explicitly. self.assertSequenceEqual(ExtraInfo.objects.values('note_id'), [{'note_id': 1}, {'note_id': 2}]) # ...or use the field name. self.assertSequenceEqual(ExtraInfo.objects.values('note'), [{'note': 1}, {'note': 2}]) def test_ticket2902(self): # Parameters can be given to extra_select, *if* you use an OrderedDict. # (First we need to know which order the keys fall in "naturally" on # your system, so we can put things in the wrong way around from # normal. A normal dict would thus fail.) s = [('a', '%s'), ('b', '%s')] params = ['one', 'two'] if list({'a': 1, 'b': 2}) == ['a', 'b']: s.reverse() params.reverse() d = Item.objects.extra(select=OrderedDict(s), select_params=params).values('a', 'b')[0] self.assertEqual(d, {'a': 'one', 'b': 'two'}) # Order by the number of tags attached to an item. qs = ( Item.objects .extra(select={ 'count': 'select count(*) from queries_item_tags where queries_item_tags.item_id = queries_item.id' }) .order_by('-count') ) self.assertEqual([o.count for o in qs], [2, 2, 1, 0]) def test_ticket6154(self): # Multiple filter statements are joined using "AND" all the time. self.assertQuerysetEqual( Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3)), ['<Author: a1>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(extra__note=self.n1) | Q(item__note=self.n3)).filter(id=self.a1.id), ['<Author: a1>'] ) def test_ticket6981(self): self.assertQuerysetEqual( Tag.objects.select_related('parent').order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) def test_ticket9926(self): self.assertQuerysetEqual( Tag.objects.select_related("parent", "category").order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Tag.objects.select_related('parent', "parent__category").order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'] ) def test_tickets_6180_6203(self): # Dates with limits and/or counts self.assertEqual(Item.objects.count(), 4) self.assertEqual(Item.objects.datetimes('created', 'month').count(), 1) self.assertEqual(Item.objects.datetimes('created', 'day').count(), 2) self.assertEqual(len(Item.objects.datetimes('created', 'day')), 2) self.assertEqual(Item.objects.datetimes('created', 'day')[0], datetime.datetime(2007, 12, 19, 0, 0)) def test_tickets_7087_12242(self): # Dates with extra select columns self.assertQuerysetEqual( Item.objects.datetimes('created', 'day').extra(select={'a': 1}), ['datetime.datetime(2007, 12, 19, 0, 0)', 'datetime.datetime(2007, 12, 20, 0, 0)'] ) self.assertQuerysetEqual( Item.objects.extra(select={'a': 1}).datetimes('created', 'day'), ['datetime.datetime(2007, 12, 19, 0, 0)', 'datetime.datetime(2007, 12, 20, 0, 0)'] ) name = "one" self.assertQuerysetEqual( Item.objects.datetimes('created', 'day').extra(where=['name=%s'], params=[name]), ['datetime.datetime(2007, 12, 19, 0, 0)'] ) self.assertQuerysetEqual( Item.objects.extra(where=['name=%s'], params=[name]).datetimes('created', 'day'), ['datetime.datetime(2007, 12, 19, 0, 0)'] ) def test_ticket7155(self): # Nullable dates self.assertQuerysetEqual( Item.objects.datetimes('modified', 'day'), ['datetime.datetime(2007, 12, 19, 0, 0)'] ) def test_ticket7098(self): # Make sure semi-deprecated ordering by related models syntax still # works. self.assertSequenceEqual( Item.objects.values('note__note').order_by('queries_note.note', 'id'), [{'note__note': 'n2'}, {'note__note': 'n3'}, {'note__note': 'n3'}, {'note__note': 'n3'}] ) def test_ticket7096(self): # Make sure exclude() with multiple conditions continues to work. self.assertQuerysetEqual( Tag.objects.filter(parent=self.t1, name='t3').order_by('name'), ['<Tag: t3>'] ) self.assertQuerysetEqual( Tag.objects.exclude(parent=self.t1, name='t3').order_by('name'), ['<Tag: t1>', '<Tag: t2>', '<Tag: t4>', '<Tag: t5>'] ) self.assertQuerysetEqual( Item.objects.exclude(tags__name='t1', name='one').order_by('name').distinct(), ['<Item: four>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual( Item.objects.filter(name__in=['three', 'four']).exclude(tags__name='t1').order_by('name'), ['<Item: four>', '<Item: three>'] ) # More twisted cases, involving nested negations. self.assertQuerysetEqual( Item.objects.exclude(~Q(tags__name='t1', name='one')), ['<Item: one>'] ) self.assertQuerysetEqual( Item.objects.filter(~Q(tags__name='t1', name='one'), name='two'), ['<Item: two>'] ) self.assertQuerysetEqual( Item.objects.exclude(~Q(tags__name='t1', name='one'), name='two'), ['<Item: four>', '<Item: one>', '<Item: three>'] ) def test_tickets_7204_7506(self): # Make sure querysets with related fields can be pickled. If this # doesn't crash, it's a Good Thing. pickle.dumps(Item.objects.all()) def test_ticket7813(self): # We should also be able to pickle things that use select_related(). # The only tricky thing here is to ensure that we do the related # selections properly after unpickling. qs = Item.objects.select_related() query = qs.query.get_compiler(qs.db).as_sql()[0] query2 = pickle.loads(pickle.dumps(qs.query)) self.assertEqual( query2.get_compiler(qs.db).as_sql()[0], query ) def test_deferred_load_qs_pickling(self): # Check pickling of deferred-loading querysets qs = Item.objects.defer('name', 'creator') q2 = pickle.loads(pickle.dumps(qs)) self.assertEqual(list(qs), list(q2)) q3 = pickle.loads(pickle.dumps(qs, pickle.HIGHEST_PROTOCOL)) self.assertEqual(list(qs), list(q3)) def test_ticket7277(self): self.assertQuerysetEqual( self.n1.annotation_set.filter( Q(tag=self.t5) | Q(tag__children=self.t5) | Q(tag__children__children=self.t5) ), ['<Annotation: a1>'] ) def test_tickets_7448_7707(self): # Complex objects should be converted to strings before being used in # lookups. self.assertQuerysetEqual( Item.objects.filter(created__in=[self.time1, self.time2]), ['<Item: one>', '<Item: two>'] ) def test_ticket7235(self): # An EmptyQuerySet should not raise exceptions if it is filtered. Eaten.objects.create(meal='m') q = Eaten.objects.none() with self.assertNumQueries(0): self.assertQuerysetEqual(q.all(), []) self.assertQuerysetEqual(q.filter(meal='m'), []) self.assertQuerysetEqual(q.exclude(meal='m'), []) self.assertQuerysetEqual(q.complex_filter({'pk': 1}), []) self.assertQuerysetEqual(q.select_related('food'), []) self.assertQuerysetEqual(q.annotate(Count('food')), []) self.assertQuerysetEqual(q.order_by('meal', 'food'), []) self.assertQuerysetEqual(q.distinct(), []) self.assertQuerysetEqual( q.extra(select={'foo': "1"}), [] ) self.assertQuerysetEqual(q.reverse(), []) q.query.low_mark = 1 with self.assertRaisesMessage(AssertionError, 'Cannot change a query once a slice has been taken'): q.extra(select={'foo': "1"}) self.assertQuerysetEqual(q.defer('meal'), []) self.assertQuerysetEqual(q.only('meal'), []) def test_ticket7791(self): # There were "issues" when ordering and distinct-ing on fields related # via ForeignKeys. self.assertEqual( len(Note.objects.order_by('extrainfo__info').distinct()), 3 ) # Pickling of QuerySets using datetimes() should work. qs = Item.objects.datetimes('created', 'month') pickle.loads(pickle.dumps(qs)) def test_ticket9997(self): # If a ValuesList or Values queryset is passed as an inner query, we # make sure it's only requesting a single value and use that as the # thing to select. self.assertQuerysetEqual( Tag.objects.filter(name__in=Tag.objects.filter(parent=self.t1).values('name')), ['<Tag: t2>', '<Tag: t3>'] ) # Multi-valued values() and values_list() querysets should raise errors. with self.assertRaisesMessage(TypeError, 'Cannot use multi-field values as a filter value.'): Tag.objects.filter(name__in=Tag.objects.filter(parent=self.t1).values('name', 'id')) with self.assertRaisesMessage(TypeError, 'Cannot use multi-field values as a filter value.'): Tag.objects.filter(name__in=Tag.objects.filter(parent=self.t1).values_list('name', 'id')) def test_ticket9985(self): # qs.values_list(...).values(...) combinations should work. self.assertSequenceEqual( Note.objects.values_list("note", flat=True).values("id").order_by("id"), [{'id': 1}, {'id': 2}, {'id': 3}] ) self.assertQuerysetEqual( Annotation.objects.filter(notes__in=Note.objects.filter(note="n1").values_list('note').values('id')), ['<Annotation: a1>'] ) def test_ticket10205(self): # When bailing out early because of an empty "__in" filter, we need # to set things up correctly internally so that subqueries can continue properly. self.assertEqual(Tag.objects.filter(name__in=()).update(name="foo"), 0) def test_ticket10432(self): # Testing an empty "__in" filter with a generator as the value. def f(): return iter([]) n_obj = Note.objects.all()[0] def g(): yield n_obj.pk self.assertQuerysetEqual(Note.objects.filter(pk__in=f()), []) self.assertEqual(list(Note.objects.filter(pk__in=g())), [n_obj]) def test_ticket10742(self): # Queries used in an __in clause don't execute subqueries subq = Author.objects.filter(num__lt=3000) qs = Author.objects.filter(pk__in=subq) self.assertQuerysetEqual(qs, ['<Author: a1>', '<Author: a2>']) # The subquery result cache should not be populated self.assertIsNone(subq._result_cache) subq = Author.objects.filter(num__lt=3000) qs = Author.objects.exclude(pk__in=subq) self.assertQuerysetEqual(qs, ['<Author: a3>', '<Author: a4>']) # The subquery result cache should not be populated self.assertIsNone(subq._result_cache) subq = Author.objects.filter(num__lt=3000) self.assertQuerysetEqual( Author.objects.filter(Q(pk__in=subq) & Q(name='a1')), ['<Author: a1>'] ) # The subquery result cache should not be populated self.assertIsNone(subq._result_cache) def test_ticket7076(self): # Excluding shouldn't eliminate NULL entries. self.assertQuerysetEqual( Item.objects.exclude(modified=self.time1).order_by('name'), ['<Item: four>', '<Item: three>', '<Item: two>'] ) self.assertQuerysetEqual( Tag.objects.exclude(parent__name=self.t1.name), ['<Tag: t1>', '<Tag: t4>', '<Tag: t5>'] ) def test_ticket7181(self): # Ordering by related tables should accommodate nullable fields (this # test is a little tricky, since NULL ordering is database dependent. # Instead, we just count the number of results). self.assertEqual(len(Tag.objects.order_by('parent__name')), 5) # Empty querysets can be merged with others. self.assertQuerysetEqual( Note.objects.none() | Note.objects.all(), ['<Note: n1>', '<Note: n2>', '<Note: n3>'] ) self.assertQuerysetEqual( Note.objects.all() | Note.objects.none(), ['<Note: n1>', '<Note: n2>', '<Note: n3>'] ) self.assertQuerysetEqual(Note.objects.none() & Note.objects.all(), []) self.assertQuerysetEqual(Note.objects.all() & Note.objects.none(), []) def test_ticket9411(self): # Make sure bump_prefix() (an internal Query method) doesn't (re-)break. It's # sufficient that this query runs without error. qs = Tag.objects.values_list('id', flat=True).order_by('id') qs.query.bump_prefix(qs.query) first = qs[0] self.assertEqual(list(qs), list(range(first, first + 5))) def test_ticket8439(self): # Complex combinations of conjunctions, disjunctions and nullable # relations. self.assertQuerysetEqual( Author.objects.filter(Q(item__note__extrainfo=self.e2) | Q(report=self.r1, name='xyz')), ['<Author: a2>'] ) self.assertQuerysetEqual( Author.objects.filter(Q(report=self.r1, name='xyz') | Q(item__note__extrainfo=self.e2)), ['<Author: a2>'] ) self.assertQuerysetEqual( Annotation.objects.filter(Q(tag__parent=self.t1) | Q(notes__note='n1', name='a1')), ['<Annotation: a1>'] ) xx = ExtraInfo.objects.create(info='xx', note=self.n3) self.assertQuerysetEqual( Note.objects.filter(Q(extrainfo__author=self.a1) | Q(extrainfo=xx)), ['<Note: n1>', '<Note: n3>'] ) q = Note.objects.filter(Q(extrainfo__author=self.a1) | Q(extrainfo=xx)).query self.assertEqual( len([x for x in q.alias_map.values() if x.join_type == LOUTER and q.alias_refcount[x.table_alias]]), 1 ) def test_ticket17429(self): """ Meta.ordering=None works the same as Meta.ordering=[] """ original_ordering = Tag._meta.ordering Tag._meta.ordering = None try: self.assertQuerysetEqual( Tag.objects.all(), ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ordered=False ) finally: Tag._meta.ordering = original_ordering def test_exclude(self): self.assertQuerysetEqual( Item.objects.exclude(tags__name='t4'), [repr(i) for i in Item.objects.filter(~Q(tags__name='t4'))]) self.assertQuerysetEqual( Item.objects.exclude(Q(tags__name='t4') | Q(tags__name='t3')), [repr(i) for i in Item.objects.filter(~(Q(tags__name='t4') | Q(tags__name='t3')))]) self.assertQuerysetEqual( Item.objects.exclude(Q(tags__name='t4') | ~Q(tags__name='t3')), [repr(i) for i in Item.objects.filter(~(Q(tags__name='t4') | ~Q(tags__name='t3')))]) def test_nested_exclude(self): self.assertQuerysetEqual( Item.objects.exclude(~Q(tags__name='t4')), [repr(i) for i in Item.objects.filter(~~Q(tags__name='t4'))]) def test_double_exclude(self): self.assertQuerysetEqual( Item.objects.filter(Q(tags__name='t4')), [repr(i) for i in Item.objects.filter(~~Q(tags__name='t4'))]) self.assertQuerysetEqual( Item.objects.filter(Q(tags__name='t4')), [repr(i) for i in Item.objects.filter(~Q(~Q(tags__name='t4')))]) def test_exclude_in(self): self.assertQuerysetEqual( Item.objects.exclude(Q(tags__name__in=['t4', 't3'])), [repr(i) for i in Item.objects.filter(~Q(tags__name__in=['t4', 't3']))]) self.assertQuerysetEqual( Item.objects.filter(Q(tags__name__in=['t4', 't3'])), [repr(i) for i in Item.objects.filter(~~Q(tags__name__in=['t4', 't3']))]) def test_ticket_10790_1(self): # Querying direct fields with isnull should trim the left outer join. # It also should not create INNER JOIN. q = Tag.objects.filter(parent__isnull=True) self.assertQuerysetEqual(q, ['<Tag: t1>']) self.assertNotIn('JOIN', str(q.query)) q = Tag.objects.filter(parent__isnull=False) self.assertQuerysetEqual( q, ['<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ) self.assertNotIn('JOIN', str(q.query)) q = Tag.objects.exclude(parent__isnull=True) self.assertQuerysetEqual( q, ['<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ) self.assertNotIn('JOIN', str(q.query)) q = Tag.objects.exclude(parent__isnull=False) self.assertQuerysetEqual(q, ['<Tag: t1>']) self.assertNotIn('JOIN', str(q.query)) q = Tag.objects.exclude(parent__parent__isnull=False) self.assertQuerysetEqual( q, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'], ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 1) self.assertNotIn('INNER JOIN', str(q.query)) def test_ticket_10790_2(self): # Querying across several tables should strip only the last outer join, # while preserving the preceding inner joins. q = Tag.objects.filter(parent__parent__isnull=False) self.assertQuerysetEqual( q, ['<Tag: t4>', '<Tag: t5>'], ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 1) # Querying without isnull should not convert anything to left outer join. q = Tag.objects.filter(parent__parent=self.t1) self.assertQuerysetEqual( q, ['<Tag: t4>', '<Tag: t5>'], ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 1) def test_ticket_10790_3(self): # Querying via indirect fields should populate the left outer join q = NamedCategory.objects.filter(tag__isnull=True) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 1) # join to dumbcategory ptr_id self.assertEqual(str(q.query).count('INNER JOIN'), 1) self.assertQuerysetEqual(q, []) # Querying across several tables should strip only the last join, while # preserving the preceding left outer joins. q = NamedCategory.objects.filter(tag__parent__isnull=True) self.assertEqual(str(q.query).count('INNER JOIN'), 1) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 1) self.assertQuerysetEqual(q, ['<NamedCategory: Generic>']) def test_ticket_10790_4(self): # Querying across m2m field should not strip the m2m table from join. q = Author.objects.filter(item__tags__isnull=True) self.assertQuerysetEqual( q, ['<Author: a2>', '<Author: a3>'], ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 2) self.assertNotIn('INNER JOIN', str(q.query)) q = Author.objects.filter(item__tags__parent__isnull=True) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a3>'], ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 3) self.assertNotIn('INNER JOIN', str(q.query)) def test_ticket_10790_5(self): # Querying with isnull=False across m2m field should not create outer joins q = Author.objects.filter(item__tags__isnull=False) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a4>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 2) q = Author.objects.filter(item__tags__parent__isnull=False) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a4>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 3) q = Author.objects.filter(item__tags__parent__parent__isnull=False) self.assertQuerysetEqual( q, ['<Author: a4>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 4) def test_ticket_10790_6(self): # Querying with isnull=True across m2m field should not create inner joins # and strip last outer join q = Author.objects.filter(item__tags__parent__parent__isnull=True) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a2>', '<Author: a3>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 4) self.assertEqual(str(q.query).count('INNER JOIN'), 0) q = Author.objects.filter(item__tags__parent__isnull=True) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a3>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 3) self.assertEqual(str(q.query).count('INNER JOIN'), 0) def test_ticket_10790_7(self): # Reverse querying with isnull should not strip the join q = Author.objects.filter(item__isnull=True) self.assertQuerysetEqual( q, ['<Author: a3>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 1) self.assertEqual(str(q.query).count('INNER JOIN'), 0) q = Author.objects.filter(item__isnull=False) self.assertQuerysetEqual( q, ['<Author: a1>', '<Author: a2>', '<Author: a2>', '<Author: a4>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 1) def test_ticket_10790_8(self): # Querying with combined q-objects should also strip the left outer join q = Tag.objects.filter(Q(parent__isnull=True) | Q(parent=self.t1)) self.assertQuerysetEqual( q, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertEqual(str(q.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q.query).count('INNER JOIN'), 0) def test_ticket_10790_combine(self): # Combining queries should not re-populate the left outer join q1 = Tag.objects.filter(parent__isnull=True) q2 = Tag.objects.filter(parent__isnull=False) q3 = q1 | q2 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'], ) self.assertEqual(str(q3.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q3.query).count('INNER JOIN'), 0) q3 = q1 & q2 self.assertQuerysetEqual(q3, []) self.assertEqual(str(q3.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q3.query).count('INNER JOIN'), 0) q2 = Tag.objects.filter(parent=self.t1) q3 = q1 | q2 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertEqual(str(q3.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q3.query).count('INNER JOIN'), 0) q3 = q2 | q1 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertEqual(str(q3.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(q3.query).count('INNER JOIN'), 0) q1 = Tag.objects.filter(parent__isnull=True) q2 = Tag.objects.filter(parent__parent__isnull=True) q3 = q1 | q2 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertEqual(str(q3.query).count('LEFT OUTER JOIN'), 1) self.assertEqual(str(q3.query).count('INNER JOIN'), 0) q3 = q2 | q1 self.assertQuerysetEqual( q3, ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>'] ) self.assertEqual(str(q3.query).count('LEFT OUTER JOIN'), 1) self.assertEqual(str(q3.query).count('INNER JOIN'), 0) def test_ticket19672(self): self.assertQuerysetEqual( Report.objects.filter(Q(creator__isnull=False) & ~Q(creator__extra__value=41)), ['<Report: r1>'] ) def test_ticket_20250(self): # A negated Q along with an annotated queryset failed in Django 1.4 qs = Author.objects.annotate(Count('item')) qs = qs.filter(~Q(extra__value=0)) self.assertIn('SELECT', str(qs.query)) self.assertQuerysetEqual( qs, ['<Author: a1>', '<Author: a2>', '<Author: a3>', '<Author: a4>'] ) def test_lookup_constraint_fielderror(self): msg = ( "Cannot resolve keyword 'unknown_field' into field. Choices are: " "annotation, category, category_id, children, id, item, " "managedmodel, name, note, parent, parent_id" ) with self.assertRaisesMessage(FieldError, msg): Tag.objects.filter(unknown_field__name='generic') class Queries2Tests(TestCase): @classmethod def setUpTestData(cls): Number.objects.create(num=4) Number.objects.create(num=8) Number.objects.create(num=12) def test_ticket4289(self): # A slight variation on the restricting the filtering choices by the # lookup constraints. self.assertQuerysetEqual(Number.objects.filter(num__lt=4), []) self.assertQuerysetEqual(Number.objects.filter(num__gt=8, num__lt=12), []) self.assertQuerysetEqual( Number.objects.filter(num__gt=8, num__lt=13), ['<Number: 12>'] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__lt=4) | Q(num__gt=8, num__lt=12)), [] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__gt=8, num__lt=12) | Q(num__lt=4)), [] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__gt=8) & Q(num__lt=12) | Q(num__lt=4)), [] ) self.assertQuerysetEqual( Number.objects.filter(Q(num__gt=7) & Q(num__lt=12) | Q(num__lt=4)), ['<Number: 8>'] ) def test_ticket12239(self): # Custom lookups are registered to round float values correctly on gte # and lt IntegerField queries. self.assertQuerysetEqual( Number.objects.filter(num__gt=11.9), ['<Number: 12>'] ) self.assertQuerysetEqual(Number.objects.filter(num__gt=12), []) self.assertQuerysetEqual(Number.objects.filter(num__gt=12.0), []) self.assertQuerysetEqual(Number.objects.filter(num__gt=12.1), []) self.assertQuerysetEqual( Number.objects.filter(num__lt=12), ['<Number: 4>', '<Number: 8>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lt=12.0), ['<Number: 4>', '<Number: 8>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lt=12.1), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__gte=11.9), ['<Number: 12>'] ) self.assertQuerysetEqual( Number.objects.filter(num__gte=12), ['<Number: 12>'] ) self.assertQuerysetEqual( Number.objects.filter(num__gte=12.0), ['<Number: 12>'] ) self.assertQuerysetEqual(Number.objects.filter(num__gte=12.1), []) self.assertQuerysetEqual(Number.objects.filter(num__gte=12.9), []) self.assertQuerysetEqual( Number.objects.filter(num__lte=11.9), ['<Number: 4>', '<Number: 8>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12.0), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12.1), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) self.assertQuerysetEqual( Number.objects.filter(num__lte=12.9), ['<Number: 4>', '<Number: 8>', '<Number: 12>'], ordered=False ) def test_ticket7759(self): # Count should work with a partially read result set. count = Number.objects.count() qs = Number.objects.all() def run(): for obj in qs: return qs.count() == count self.assertTrue(run()) class Queries3Tests(TestCase): def test_ticket7107(self): # This shouldn't create an infinite loop. self.assertQuerysetEqual(Valid.objects.all(), []) def test_ticket8683(self): # An error should be raised when QuerySet.datetimes() is passed the # wrong type of field. with self.assertRaisesMessage(AssertionError, "'name' isn't a DateField, TimeField, or DateTimeField."): Item.objects.datetimes('name', 'month') def test_ticket22023(self): with self.assertRaisesMessage(TypeError, "Cannot call only() after .values() or .values_list()"): Valid.objects.values().only() with self.assertRaisesMessage(TypeError, "Cannot call defer() after .values() or .values_list()"): Valid.objects.values().defer() class Queries4Tests(TestCase): @classmethod def setUpTestData(cls): generic = NamedCategory.objects.create(name="Generic") cls.t1 = Tag.objects.create(name='t1', category=generic) n1 = Note.objects.create(note='n1', misc='foo') n2 = Note.objects.create(note='n2', misc='bar') e1 = ExtraInfo.objects.create(info='e1', note=n1) e2 = ExtraInfo.objects.create(info='e2', note=n2) cls.a1 = Author.objects.create(name='a1', num=1001, extra=e1) cls.a3 = Author.objects.create(name='a3', num=3003, extra=e2) cls.r1 = Report.objects.create(name='r1', creator=cls.a1) cls.r2 = Report.objects.create(name='r2', creator=cls.a3) cls.r3 = Report.objects.create(name='r3') Item.objects.create(name='i1', created=datetime.datetime.now(), note=n1, creator=cls.a1) Item.objects.create(name='i2', created=datetime.datetime.now(), note=n1, creator=cls.a3) def test_ticket24525(self): tag = Tag.objects.create() anth100 = tag.note_set.create(note='ANTH', misc='100') math101 = tag.note_set.create(note='MATH', misc='101') s1 = tag.annotation_set.create(name='1') s2 = tag.annotation_set.create(name='2') s1.notes.set([math101, anth100]) s2.notes.set([math101]) result = math101.annotation_set.all() & tag.annotation_set.exclude(notes__in=[anth100]) self.assertEqual(list(result), [s2]) def test_ticket11811(self): unsaved_category = NamedCategory(name="Other") msg = 'Unsaved model instance <NamedCategory: Other> cannot be used in an ORM query.' with self.assertRaisesMessage(ValueError, msg): Tag.objects.filter(pk=self.t1.pk).update(category=unsaved_category) def test_ticket14876(self): # Note: when combining the query we need to have information available # about the join type of the trimmed "creator__isnull" join. If we # don't have that information, then the join is created as INNER JOIN # and results will be incorrect. q1 = Report.objects.filter(Q(creator__isnull=True) | Q(creator__extra__info='e1')) q2 = Report.objects.filter(Q(creator__isnull=True)) | Report.objects.filter(Q(creator__extra__info='e1')) self.assertQuerysetEqual(q1, ["<Report: r1>", "<Report: r3>"], ordered=False) self.assertEqual(str(q1.query), str(q2.query)) q1 = Report.objects.filter(Q(creator__extra__info='e1') | Q(creator__isnull=True)) q2 = Report.objects.filter(Q(creator__extra__info='e1')) | Report.objects.filter(Q(creator__isnull=True)) self.assertQuerysetEqual(q1, ["<Report: r1>", "<Report: r3>"], ordered=False) self.assertEqual(str(q1.query), str(q2.query)) q1 = Item.objects.filter(Q(creator=self.a1) | Q(creator__report__name='r1')).order_by() q2 = ( Item.objects .filter(Q(creator=self.a1)).order_by() | Item.objects.filter(Q(creator__report__name='r1')) .order_by() ) self.assertQuerysetEqual(q1, ["<Item: i1>"]) self.assertEqual(str(q1.query), str(q2.query)) q1 = Item.objects.filter(Q(creator__report__name='e1') | Q(creator=self.a1)).order_by() q2 = ( Item.objects.filter(Q(creator__report__name='e1')).order_by() | Item.objects.filter(Q(creator=self.a1)).order_by() ) self.assertQuerysetEqual(q1, ["<Item: i1>"]) self.assertEqual(str(q1.query), str(q2.query)) def test_combine_join_reuse(self): # Joins having identical connections are correctly recreated in the # rhs query, in case the query is ORed together (#18748). Report.objects.create(name='r4', creator=self.a1) q1 = Author.objects.filter(report__name='r5') q2 = Author.objects.filter(report__name='r4').filter(report__name='r1') combined = q1 | q2 self.assertEqual(str(combined.query).count('JOIN'), 2) self.assertEqual(len(combined), 1) self.assertEqual(combined[0].name, 'a1') def test_join_reuse_order(self): # Join aliases are reused in order. This shouldn't raise AssertionError # because change_map contains a circular reference (#26522). s1 = School.objects.create() s2 = School.objects.create() s3 = School.objects.create() t1 = Teacher.objects.create() otherteachers = Teacher.objects.exclude(pk=t1.pk).exclude(friends=t1) qs1 = otherteachers.filter(schools=s1).filter(schools=s2) qs2 = otherteachers.filter(schools=s1).filter(schools=s3) self.assertQuerysetEqual(qs1 | qs2, []) def test_ticket7095(self): # Updates that are filtered on the model being updated are somewhat # tricky in MySQL. ManagedModel.objects.create(data='mm1', tag=self.t1, public=True) self.assertEqual(ManagedModel.objects.update(data='mm'), 1) # A values() or values_list() query across joined models must use outer # joins appropriately. # Note: In Oracle, we expect a null CharField to return '' instead of # None. if connection.features.interprets_empty_strings_as_nulls: expected_null_charfield_repr = '' else: expected_null_charfield_repr = None self.assertSequenceEqual( Report.objects.values_list("creator__extra__info", flat=True).order_by("name"), ['e1', 'e2', expected_null_charfield_repr], ) # Similarly for select_related(), joins beyond an initial nullable join # must use outer joins so that all results are included. self.assertQuerysetEqual( Report.objects.select_related("creator", "creator__extra").order_by("name"), ['<Report: r1>', '<Report: r2>', '<Report: r3>'] ) # When there are multiple paths to a table from another table, we have # to be careful not to accidentally reuse an inappropriate join when # using select_related(). We used to return the parent's Detail record # here by mistake. d1 = Detail.objects.create(data="d1") d2 = Detail.objects.create(data="d2") m1 = Member.objects.create(name="m1", details=d1) m2 = Member.objects.create(name="m2", details=d2) Child.objects.create(person=m2, parent=m1) obj = m1.children.select_related("person__details")[0] self.assertEqual(obj.person.details.data, 'd2') def test_order_by_resetting(self): # Calling order_by() with no parameters removes any existing ordering on the # model. But it should still be possible to add new ordering after that. qs = Author.objects.order_by().order_by('name') self.assertIn('ORDER BY', qs.query.get_compiler(qs.db).as_sql()[0]) def test_order_by_reverse_fk(self): # It is possible to order by reverse of foreign key, although that can lead # to duplicate results. c1 = SimpleCategory.objects.create(name="category1") c2 = SimpleCategory.objects.create(name="category2") CategoryItem.objects.create(category=c1) CategoryItem.objects.create(category=c2) CategoryItem.objects.create(category=c1) self.assertSequenceEqual(SimpleCategory.objects.order_by('categoryitem', 'pk'), [c1, c2, c1]) def test_ticket10181(self): # Avoid raising an EmptyResultSet if an inner query is probably # empty (and hence, not executed). self.assertQuerysetEqual( Tag.objects.filter(id__in=Tag.objects.filter(id__in=[])), [] ) def test_ticket15316_filter_false(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") CategoryItem.objects.create(category=c1) ci2 = CategoryItem.objects.create(category=c2) ci3 = CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.filter(category__specialcategory__isnull=False) self.assertEqual(qs.count(), 2) self.assertSequenceEqual(qs, [ci2, ci3]) def test_ticket15316_exclude_false(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") ci1 = CategoryItem.objects.create(category=c1) CategoryItem.objects.create(category=c2) CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.exclude(category__specialcategory__isnull=False) self.assertEqual(qs.count(), 1) self.assertSequenceEqual(qs, [ci1]) def test_ticket15316_filter_true(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") ci1 = CategoryItem.objects.create(category=c1) CategoryItem.objects.create(category=c2) CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.filter(category__specialcategory__isnull=True) self.assertEqual(qs.count(), 1) self.assertSequenceEqual(qs, [ci1]) def test_ticket15316_exclude_true(self): c1 = SimpleCategory.objects.create(name="category1") c2 = SpecialCategory.objects.create(name="named category1", special_name="special1") c3 = SpecialCategory.objects.create(name="named category2", special_name="special2") CategoryItem.objects.create(category=c1) ci2 = CategoryItem.objects.create(category=c2) ci3 = CategoryItem.objects.create(category=c3) qs = CategoryItem.objects.exclude(category__specialcategory__isnull=True) self.assertEqual(qs.count(), 2) self.assertSequenceEqual(qs, [ci2, ci3]) def test_ticket15316_one2one_filter_false(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") CategoryItem.objects.create(category=c) ci2 = CategoryItem.objects.create(category=c0) ci3 = CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.filter(category__onetoonecategory__isnull=False).order_by('pk') self.assertEqual(qs.count(), 2) self.assertSequenceEqual(qs, [ci2, ci3]) def test_ticket15316_one2one_exclude_false(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") ci1 = CategoryItem.objects.create(category=c) CategoryItem.objects.create(category=c0) CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.exclude(category__onetoonecategory__isnull=False) self.assertEqual(qs.count(), 1) self.assertSequenceEqual(qs, [ci1]) def test_ticket15316_one2one_filter_true(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") ci1 = CategoryItem.objects.create(category=c) CategoryItem.objects.create(category=c0) CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.filter(category__onetoonecategory__isnull=True) self.assertEqual(qs.count(), 1) self.assertSequenceEqual(qs, [ci1]) def test_ticket15316_one2one_exclude_true(self): c = SimpleCategory.objects.create(name="cat") c0 = SimpleCategory.objects.create(name="cat0") c1 = SimpleCategory.objects.create(name="category1") OneToOneCategory.objects.create(category=c1, new_name="new1") OneToOneCategory.objects.create(category=c0, new_name="new2") CategoryItem.objects.create(category=c) ci2 = CategoryItem.objects.create(category=c0) ci3 = CategoryItem.objects.create(category=c1) qs = CategoryItem.objects.exclude(category__onetoonecategory__isnull=True).order_by('pk') self.assertEqual(qs.count(), 2) self.assertSequenceEqual(qs, [ci2, ci3]) class Queries5Tests(TestCase): @classmethod def setUpTestData(cls): # Ordering by 'rank' gives us rank2, rank1, rank3. Ordering by the # Meta.ordering will be rank3, rank2, rank1. n1 = Note.objects.create(note='n1', misc='foo', id=1) n2 = Note.objects.create(note='n2', misc='bar', id=2) e1 = ExtraInfo.objects.create(info='e1', note=n1) e2 = ExtraInfo.objects.create(info='e2', note=n2) a1 = Author.objects.create(name='a1', num=1001, extra=e1) a2 = Author.objects.create(name='a2', num=2002, extra=e1) a3 = Author.objects.create(name='a3', num=3003, extra=e2) cls.rank1 = Ranking.objects.create(rank=2, author=a2) Ranking.objects.create(rank=1, author=a3) Ranking.objects.create(rank=3, author=a1) def test_ordering(self): # Cross model ordering is possible in Meta, too. self.assertQuerysetEqual( Ranking.objects.all(), ['<Ranking: 3: a1>', '<Ranking: 2: a2>', '<Ranking: 1: a3>'] ) self.assertQuerysetEqual( Ranking.objects.all().order_by('rank'), ['<Ranking: 1: a3>', '<Ranking: 2: a2>', '<Ranking: 3: a1>'] ) # Ordering of extra() pieces is possible, too and you can mix extra # fields and model fields in the ordering. self.assertQuerysetEqual( Ranking.objects.extra(tables=['django_site'], order_by=['-django_site.id', 'rank']), ['<Ranking: 1: a3>', '<Ranking: 2: a2>', '<Ranking: 3: a1>'] ) qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'}) self.assertEqual( [o.good for o in qs.extra(order_by=('-good',))], [True, False, False] ) self.assertQuerysetEqual( qs.extra(order_by=('-good', 'id')), ['<Ranking: 3: a1>', '<Ranking: 2: a2>', '<Ranking: 1: a3>'] ) # Despite having some extra aliases in the query, we can still omit # them in a values() query. dicts = qs.values('id', 'rank').order_by('id') self.assertEqual( [d['rank'] for d in dicts], [2, 1, 3] ) def test_ticket7256(self): # An empty values() call includes all aliases, including those from an # extra() qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'}) dicts = qs.values().order_by('id') for d in dicts: del d['id'] del d['author_id'] self.assertEqual( [sorted(d.items()) for d in dicts], [[('good', 0), ('rank', 2)], [('good', 0), ('rank', 1)], [('good', 1), ('rank', 3)]] ) def test_ticket7045(self): # Extra tables used to crash SQL construction on the second use. qs = Ranking.objects.extra(tables=['django_site']) qs.query.get_compiler(qs.db).as_sql() # test passes if this doesn't raise an exception. qs.query.get_compiler(qs.db).as_sql() def test_ticket9848(self): # Make sure that updates which only filter on sub-tables don't # inadvertently update the wrong records (bug #9848). author_start = Author.objects.get(name='a1') ranking_start = Ranking.objects.get(author__name='a1') # Make sure that the IDs from different tables don't happen to match. self.assertQuerysetEqual( Ranking.objects.filter(author__name='a1'), ['<Ranking: 3: a1>'] ) self.assertEqual( Ranking.objects.filter(author__name='a1').update(rank=4636), 1 ) r = Ranking.objects.get(author__name='a1') self.assertEqual(r.id, ranking_start.id) self.assertEqual(r.author.id, author_start.id) self.assertEqual(r.rank, 4636) r.rank = 3 r.save() self.assertQuerysetEqual( Ranking.objects.all(), ['<Ranking: 3: a1>', '<Ranking: 2: a2>', '<Ranking: 1: a3>'] ) def test_ticket5261(self): # Test different empty excludes. self.assertQuerysetEqual( Note.objects.exclude(Q()), ['<Note: n1>', '<Note: n2>'] ) self.assertQuerysetEqual( Note.objects.filter(~Q()), ['<Note: n1>', '<Note: n2>'] ) self.assertQuerysetEqual( Note.objects.filter(~Q() | ~Q()), ['<Note: n1>', '<Note: n2>'] ) self.assertQuerysetEqual( Note.objects.exclude(~Q() & ~Q()), ['<Note: n1>', '<Note: n2>'] ) def test_extra_select_literal_percent_s(self): # Allow %%s to escape select clauses self.assertEqual( Note.objects.extra(select={'foo': "'%%s'"})[0].foo, '%s' ) self.assertEqual( Note.objects.extra(select={'foo': "'%%s bar %%s'"})[0].foo, '%s bar %s' ) self.assertEqual( Note.objects.extra(select={'foo': "'bar %%s'"})[0].foo, 'bar %s' ) class SelectRelatedTests(TestCase): def test_tickets_3045_3288(self): # Once upon a time, select_related() with circular relations would loop # infinitely if you forgot to specify "depth". Now we set an arbitrary # default upper bound. self.assertQuerysetEqual(X.objects.all(), []) self.assertQuerysetEqual(X.objects.select_related(), []) class SubclassFKTests(TestCase): def test_ticket7778(self): # Model subclasses could not be deleted if a nullable foreign key # relates to a model that relates back. num_celebs = Celebrity.objects.count() tvc = TvChef.objects.create(name="Huey") self.assertEqual(Celebrity.objects.count(), num_celebs + 1) Fan.objects.create(fan_of=tvc) Fan.objects.create(fan_of=tvc) tvc.delete() # The parent object should have been deleted as well. self.assertEqual(Celebrity.objects.count(), num_celebs) class CustomPkTests(TestCase): def test_ticket7371(self): self.assertQuerysetEqual(Related.objects.order_by('custom'), []) class NullableRelOrderingTests(TestCase): def test_ticket10028(self): # Ordering by model related to nullable relations(!) should use outer # joins, so that all results are included. Plaything.objects.create(name="p1") self.assertQuerysetEqual( Plaything.objects.all(), ['<Plaything: p1>'] ) def test_join_already_in_query(self): # Ordering by model related to nullable relations should not change # the join type of already existing joins. Plaything.objects.create(name="p1") s = SingleObject.objects.create(name='s') r = RelatedObject.objects.create(single=s, f=1) Plaything.objects.create(name="p2", others=r) qs = Plaything.objects.all().filter(others__isnull=False).order_by('pk') self.assertNotIn('JOIN', str(qs.query)) qs = Plaything.objects.all().filter(others__f__isnull=False).order_by('pk') self.assertIn('INNER', str(qs.query)) qs = qs.order_by('others__single__name') # The ordering by others__single__pk will add one new join (to single) # and that join must be LEFT join. The already existing join to related # objects must be kept INNER. So, we have both an INNER and a LEFT join # in the query. self.assertEqual(str(qs.query).count('LEFT'), 1) self.assertEqual(str(qs.query).count('INNER'), 1) self.assertQuerysetEqual( qs, ['<Plaything: p2>'] ) class DisjunctiveFilterTests(TestCase): @classmethod def setUpTestData(cls): cls.n1 = Note.objects.create(note='n1', misc='foo', id=1) ExtraInfo.objects.create(info='e1', note=cls.n1) def test_ticket7872(self): # Another variation on the disjunctive filtering theme. # For the purposes of this regression test, it's important that there is no # Join object related to the LeafA we create. LeafA.objects.create(data='first') self.assertQuerysetEqual(LeafA.objects.all(), ['<LeafA: first>']) self.assertQuerysetEqual( LeafA.objects.filter(Q(data='first') | Q(join__b__data='second')), ['<LeafA: first>'] ) def test_ticket8283(self): # Checking that applying filters after a disjunction works correctly. self.assertQuerysetEqual( (ExtraInfo.objects.filter(note=self.n1) | ExtraInfo.objects.filter(info='e2')).filter(note=self.n1), ['<ExtraInfo: e1>'] ) self.assertQuerysetEqual( (ExtraInfo.objects.filter(info='e2') | ExtraInfo.objects.filter(note=self.n1)).filter(note=self.n1), ['<ExtraInfo: e1>'] ) class Queries6Tests(TestCase): @classmethod def setUpTestData(cls): generic = NamedCategory.objects.create(name="Generic") t1 = Tag.objects.create(name='t1', category=generic) Tag.objects.create(name='t2', parent=t1, category=generic) t3 = Tag.objects.create(name='t3', parent=t1) t4 = Tag.objects.create(name='t4', parent=t3) Tag.objects.create(name='t5', parent=t3) n1 = Note.objects.create(note='n1', misc='foo', id=1) ann1 = Annotation.objects.create(name='a1', tag=t1) ann1.notes.add(n1) Annotation.objects.create(name='a2', tag=t4) def test_parallel_iterators(self): # Parallel iterators work. qs = Tag.objects.all() i1, i2 = iter(qs), iter(qs) self.assertEqual(repr(next(i1)), '<Tag: t1>') self.assertEqual(repr(next(i1)), '<Tag: t2>') self.assertEqual(repr(next(i2)), '<Tag: t1>') self.assertEqual(repr(next(i2)), '<Tag: t2>') self.assertEqual(repr(next(i2)), '<Tag: t3>') self.assertEqual(repr(next(i1)), '<Tag: t3>') qs = X.objects.all() self.assertFalse(qs) self.assertFalse(qs) def test_nested_queries_sql(self): # Nested queries should not evaluate the inner query as part of constructing the # SQL (so we should see a nested query here, indicated by two "SELECT" calls). qs = Annotation.objects.filter(notes__in=Note.objects.filter(note="xyzzy")) self.assertEqual( qs.query.get_compiler(qs.db).as_sql()[0].count('SELECT'), 2 ) def test_tickets_8921_9188(self): # Incorrect SQL was being generated for certain types of exclude() # queries that crossed multi-valued relations (#8921, #9188 and some # preemptively discovered cases). self.assertQuerysetEqual( PointerA.objects.filter(connection__pointerb__id=1), [] ) self.assertQuerysetEqual( PointerA.objects.exclude(connection__pointerb__id=1), [] ) self.assertQuerysetEqual( Tag.objects.exclude(children=None), ['<Tag: t1>', '<Tag: t3>'] ) # This example is tricky because the parent could be NULL, so only checking # parents with annotations omits some results (tag t1, in this case). self.assertQuerysetEqual( Tag.objects.exclude(parent__annotation__name="a1"), ['<Tag: t1>', '<Tag: t4>', '<Tag: t5>'] ) # The annotation->tag link is single values and tag->children links is # multi-valued. So we have to split the exclude filter in the middle # and then optimize the inner query without losing results. self.assertQuerysetEqual( Annotation.objects.exclude(tag__children__name="t2"), ['<Annotation: a2>'] ) # Nested queries are possible (although should be used with care, since # they have performance problems on backends like MySQL. self.assertQuerysetEqual( Annotation.objects.filter(notes__in=Note.objects.filter(note="n1")), ['<Annotation: a1>'] ) def test_ticket3739(self): # The all() method on querysets returns a copy of the queryset. q1 = Tag.objects.order_by('name') self.assertIsNot(q1, q1.all()) def test_ticket_11320(self): qs = Tag.objects.exclude(category=None).exclude(category__name='foo') self.assertEqual(str(qs.query).count(' INNER JOIN '), 1) class RawQueriesTests(TestCase): def setUp(self): Note.objects.create(note='n1', misc='foo', id=1) def test_ticket14729(self): # Test representation of raw query with one or few parameters passed as list query = "SELECT * FROM queries_note WHERE note = %s" params = ['n1'] qs = Note.objects.raw(query, params=params) self.assertEqual(repr(qs), "<RawQuerySet: SELECT * FROM queries_note WHERE note = n1>") query = "SELECT * FROM queries_note WHERE note = %s and misc = %s" params = ['n1', 'foo'] qs = Note.objects.raw(query, params=params) self.assertEqual(repr(qs), "<RawQuerySet: SELECT * FROM queries_note WHERE note = n1 and misc = foo>") class GeneratorExpressionTests(TestCase): def test_ticket10432(self): # Using an empty generator expression as the rvalue for an "__in" # lookup is legal. self.assertQuerysetEqual( Note.objects.filter(pk__in=(x for x in ())), [] ) class ComparisonTests(TestCase): def setUp(self): self.n1 = Note.objects.create(note='n1', misc='foo', id=1) e1 = ExtraInfo.objects.create(info='e1', note=self.n1) self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) def test_ticket8597(self): # Regression tests for case-insensitive comparisons Item.objects.create(name="a_b", created=datetime.datetime.now(), creator=self.a2, note=self.n1) Item.objects.create(name="x%y", created=datetime.datetime.now(), creator=self.a2, note=self.n1) self.assertQuerysetEqual( Item.objects.filter(name__iexact="A_b"), ['<Item: a_b>'] ) self.assertQuerysetEqual( Item.objects.filter(name__iexact="x%Y"), ['<Item: x%y>'] ) self.assertQuerysetEqual( Item.objects.filter(name__istartswith="A_b"), ['<Item: a_b>'] ) self.assertQuerysetEqual( Item.objects.filter(name__iendswith="A_b"), ['<Item: a_b>'] ) class ExistsSql(TestCase): def test_exists(self): with CaptureQueriesContext(connection) as captured_queries: self.assertFalse(Tag.objects.exists()) # Ok - so the exist query worked - but did it include too many columns? self.assertEqual(len(captured_queries), 1) qstr = captured_queries[0]['sql'] id, name = connection.ops.quote_name('id'), connection.ops.quote_name('name') self.assertNotIn(id, qstr) self.assertNotIn(name, qstr) def test_ticket_18414(self): Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='two', created=datetime.datetime.now()) self.assertTrue(Article.objects.exists()) self.assertTrue(Article.objects.distinct().exists()) self.assertTrue(Article.objects.distinct()[1:3].exists()) self.assertFalse(Article.objects.distinct()[1:1].exists()) @skipUnlessDBFeature('can_distinct_on_fields') def test_ticket_18414_distinct_on(self): Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='two', created=datetime.datetime.now()) self.assertTrue(Article.objects.distinct('name').exists()) self.assertTrue(Article.objects.distinct('name')[1:2].exists()) self.assertFalse(Article.objects.distinct('name')[2:3].exists()) class QuerysetOrderedTests(unittest.TestCase): """ Tests for the Queryset.ordered attribute. """ def test_no_default_or_explicit_ordering(self): self.assertIs(Annotation.objects.all().ordered, False) def test_cleared_default_ordering(self): self.assertIs(Tag.objects.all().ordered, True) self.assertIs(Tag.objects.all().order_by().ordered, False) def test_explicit_ordering(self): self.assertIs(Annotation.objects.all().order_by('id').ordered, True) def test_order_by_extra(self): self.assertIs(Annotation.objects.all().extra(order_by=['id']).ordered, True) def test_annotated_ordering(self): qs = Annotation.objects.annotate(num_notes=Count('notes')) self.assertIs(qs.ordered, False) self.assertIs(qs.order_by('num_notes').ordered, True) @skipUnlessDBFeature('allow_sliced_subqueries') class SubqueryTests(TestCase): @classmethod def setUpTestData(cls): NamedCategory.objects.create(id=1, name='first') NamedCategory.objects.create(id=2, name='second') NamedCategory.objects.create(id=3, name='third') NamedCategory.objects.create(id=4, name='fourth') def test_ordered_subselect(self): "Subselects honor any manual ordering" query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:2]) self.assertEqual(set(query.values_list('id', flat=True)), {3, 4}) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[:2]) self.assertEqual(set(query.values_list('id', flat=True)), {3, 4}) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:2]) self.assertEqual(set(query.values_list('id', flat=True)), {3}) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[2:]) self.assertEqual(set(query.values_list('id', flat=True)), {1, 2}) def test_slice_subquery_and_query(self): """ Slice a query that has a sliced subquery """ query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:2])[0:2] self.assertEqual({x.id for x in query}, {3, 4}) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:3])[1:3] self.assertEqual({x.id for x in query}, {3}) query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[2:])[1:] self.assertEqual({x.id for x in query}, {2}) def test_related_sliced_subquery(self): """ Related objects constraints can safely contain sliced subqueries. refs #22434 """ generic = NamedCategory.objects.create(id=5, name="Generic") t1 = Tag.objects.create(name='t1', category=generic) t2 = Tag.objects.create(name='t2', category=generic) ManagedModel.objects.create(data='mm1', tag=t1, public=True) mm2 = ManagedModel.objects.create(data='mm2', tag=t2, public=True) query = ManagedModel.normal_manager.filter( tag__in=Tag.objects.order_by('-id')[:1] ) self.assertEqual({x.id for x in query}, {mm2.id}) def test_sliced_delete(self): "Delete queries can safely contain sliced subqueries" DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:1]).delete() self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), {1, 2, 3}) DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:2]).delete() self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), {1, 3}) DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:]).delete() self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), {3}) def test_distinct_ordered_sliced_subquery(self): # Implicit values('id'). self.assertSequenceEqual( NamedCategory.objects.filter( id__in=NamedCategory.objects.distinct().order_by('name')[0:2], ).order_by('name').values_list('name', flat=True), ['first', 'fourth'] ) # Explicit values('id'). self.assertSequenceEqual( NamedCategory.objects.filter( id__in=NamedCategory.objects.distinct().order_by('-name').values('id')[0:2], ).order_by('name').values_list('name', flat=True), ['second', 'third'] ) # Annotated value. self.assertSequenceEqual( DumbCategory.objects.filter( id__in=DumbCategory.objects.annotate( double_id=F('id') * 2 ).order_by('id').distinct().values('double_id')[0:2], ).order_by('id').values_list('id', flat=True), [2, 4] ) class CloneTests(TestCase): def test_evaluated_queryset_as_argument(self): "#13227 -- If a queryset is already evaluated, it can still be used as a query arg" n = Note(note='Test1', misc='misc') n.save() e = ExtraInfo(info='good', note=n) e.save() n_list = Note.objects.all() # Evaluate the Note queryset, populating the query cache list(n_list) # Use the note queryset in a query, and evaluate # that query in a way that involves cloning. self.assertEqual(ExtraInfo.objects.filter(note__in=n_list)[0].info, 'good') def test_no_model_options_cloning(self): """ Cloning a queryset does not get out of hand. While complete testing is impossible, this is a sanity check against invalid use of deepcopy. refs #16759. """ opts_class = type(Note._meta) note_deepcopy = getattr(opts_class, "__deepcopy__", None) opts_class.__deepcopy__ = lambda obj, memo: self.fail("Model options shouldn't be cloned.") try: Note.objects.filter(pk__lte=F('pk') + 1).all() finally: if note_deepcopy is None: delattr(opts_class, "__deepcopy__") else: opts_class.__deepcopy__ = note_deepcopy def test_no_fields_cloning(self): """ Cloning a queryset does not get out of hand. While complete testing is impossible, this is a sanity check against invalid use of deepcopy. refs #16759. """ opts_class = type(Note._meta.get_field("misc")) note_deepcopy = getattr(opts_class, "__deepcopy__", None) opts_class.__deepcopy__ = lambda obj, memo: self.fail("Model fields shouldn't be cloned") try: Note.objects.filter(note=F('misc')).all() finally: if note_deepcopy is None: delattr(opts_class, "__deepcopy__") else: opts_class.__deepcopy__ = note_deepcopy class EmptyQuerySetTests(TestCase): def test_emptyqueryset_values(self): # #14366 -- Calling .values() on an empty QuerySet and then cloning # that should not cause an error self.assertQuerysetEqual( Number.objects.none().values('num').order_by('num'), [] ) def test_values_subquery(self): self.assertQuerysetEqual( Number.objects.filter(pk__in=Number.objects.none().values("pk")), [] ) self.assertQuerysetEqual( Number.objects.filter(pk__in=Number.objects.none().values_list("pk")), [] ) def test_ticket_19151(self): # #19151 -- Calling .values() or .values_list() on an empty QuerySet # should return an empty QuerySet and not cause an error. q = Author.objects.none() self.assertQuerysetEqual(q.values(), []) self.assertQuerysetEqual(q.values_list(), []) class ValuesQuerysetTests(TestCase): @classmethod def setUpTestData(cls): Number.objects.create(num=72) def test_flat_values_list(self): qs = Number.objects.values_list("num") qs = qs.values_list("num", flat=True) self.assertSequenceEqual(qs, [72]) def test_extra_values(self): # testing for ticket 14930 issues qs = Number.objects.extra(select=OrderedDict([('value_plus_x', 'num+%s'), ('value_minus_x', 'num-%s')]), select_params=(1, 2)) qs = qs.order_by('value_minus_x') qs = qs.values('num') self.assertSequenceEqual(qs, [{'num': 72}]) def test_extra_values_order_twice(self): # testing for ticket 14930 issues qs = Number.objects.extra(select={'value_plus_one': 'num+1', 'value_minus_one': 'num-1'}) qs = qs.order_by('value_minus_one').order_by('value_plus_one') qs = qs.values('num') self.assertSequenceEqual(qs, [{'num': 72}]) def test_extra_values_order_multiple(self): # Postgres doesn't allow constants in order by, so check for that. qs = Number.objects.extra(select={ 'value_plus_one': 'num+1', 'value_minus_one': 'num-1', 'constant_value': '1' }) qs = qs.order_by('value_plus_one', 'value_minus_one', 'constant_value') qs = qs.values('num') self.assertSequenceEqual(qs, [{'num': 72}]) def test_extra_values_order_in_extra(self): # testing for ticket 14930 issues qs = Number.objects.extra( select={'value_plus_one': 'num+1', 'value_minus_one': 'num-1'}, order_by=['value_minus_one']) qs = qs.values('num') def test_extra_select_params_values_order_in_extra(self): # testing for 23259 issue qs = Number.objects.extra( select={'value_plus_x': 'num+%s'}, select_params=[1], order_by=['value_plus_x']) qs = qs.filter(num=72) qs = qs.values('num') self.assertSequenceEqual(qs, [{'num': 72}]) def test_extra_multiple_select_params_values_order_by(self): # testing for 23259 issue qs = Number.objects.extra(select=OrderedDict([('value_plus_x', 'num+%s'), ('value_minus_x', 'num-%s')]), select_params=(72, 72)) qs = qs.order_by('value_minus_x') qs = qs.filter(num=1) qs = qs.values('num') self.assertSequenceEqual(qs, []) def test_extra_values_list(self): # testing for ticket 14930 issues qs = Number.objects.extra(select={'value_plus_one': 'num+1'}) qs = qs.order_by('value_plus_one') qs = qs.values_list('num') self.assertSequenceEqual(qs, [(72,)]) def test_flat_extra_values_list(self): # testing for ticket 14930 issues qs = Number.objects.extra(select={'value_plus_one': 'num+1'}) qs = qs.order_by('value_plus_one') qs = qs.values_list('num', flat=True) self.assertSequenceEqual(qs, [72]) def test_field_error_values_list(self): # see #23443 msg = "Cannot resolve keyword %r into field. Join on 'name' not permitted." % 'foo' with self.assertRaisesMessage(FieldError, msg): Tag.objects.values_list('name__foo') class QuerySetSupportsPythonIdioms(TestCase): @classmethod def setUpTestData(cls): some_date = datetime.datetime(2014, 5, 16, 12, 1) for i in range(1, 8): Article.objects.create( name="Article {}".format(i), created=some_date) def get_ordered_articles(self): return Article.objects.all().order_by('name') def test_can_get_items_using_index_and_slice_notation(self): self.assertEqual(self.get_ordered_articles()[0].name, 'Article 1') self.assertQuerysetEqual( self.get_ordered_articles()[1:3], ["<Article: Article 2>", "<Article: Article 3>"] ) def test_slicing_with_steps_can_be_used(self): self.assertQuerysetEqual( self.get_ordered_articles()[::2], [ "<Article: Article 1>", "<Article: Article 3>", "<Article: Article 5>", "<Article: Article 7>" ] ) def test_slicing_without_step_is_lazy(self): with self.assertNumQueries(0): self.get_ordered_articles()[0:5] def test_slicing_with_tests_is_not_lazy(self): with self.assertNumQueries(1): self.get_ordered_articles()[0:5:3] def test_slicing_can_slice_again_after_slicing(self): self.assertQuerysetEqual( self.get_ordered_articles()[0:5][0:2], ["<Article: Article 1>", "<Article: Article 2>"] ) self.assertQuerysetEqual(self.get_ordered_articles()[0:5][4:], ["<Article: Article 5>"]) self.assertQuerysetEqual(self.get_ordered_articles()[0:5][5:], []) # Some more tests! self.assertQuerysetEqual( self.get_ordered_articles()[2:][0:2], ["<Article: Article 3>", "<Article: Article 4>"] ) self.assertQuerysetEqual( self.get_ordered_articles()[2:][:2], ["<Article: Article 3>", "<Article: Article 4>"] ) self.assertQuerysetEqual(self.get_ordered_articles()[2:][2:3], ["<Article: Article 5>"]) # Using an offset without a limit is also possible. self.assertQuerysetEqual( self.get_ordered_articles()[5:], ["<Article: Article 6>", "<Article: Article 7>"] ) def test_slicing_cannot_filter_queryset_once_sliced(self): with self.assertRaisesMessage(AssertionError, "Cannot filter a query once a slice has been taken."): Article.objects.all()[0:5].filter(id=1, ) def test_slicing_cannot_reorder_queryset_once_sliced(self): with self.assertRaisesMessage(AssertionError, "Cannot reorder a query once a slice has been taken."): Article.objects.all()[0:5].order_by('id', ) def test_slicing_cannot_combine_queries_once_sliced(self): with self.assertRaisesMessage(AssertionError, "Cannot combine queries once a slice has been taken."): Article.objects.all()[0:1] & Article.objects.all()[4:5] def test_slicing_negative_indexing_not_supported_for_single_element(self): """hint: inverting your ordering might do what you need""" with self.assertRaisesMessage(AssertionError, "Negative indexing is not supported."): Article.objects.all()[-1] def test_slicing_negative_indexing_not_supported_for_range(self): """hint: inverting your ordering might do what you need""" with self.assertRaisesMessage(AssertionError, "Negative indexing is not supported."): Article.objects.all()[0:-5] def test_can_get_number_of_items_in_queryset_using_standard_len(self): self.assertEqual(len(Article.objects.filter(name__exact='Article 1')), 1) def test_can_combine_queries_using_and_and_or_operators(self): s1 = Article.objects.filter(name__exact='Article 1') s2 = Article.objects.filter(name__exact='Article 2') self.assertQuerysetEqual( (s1 | s2).order_by('name'), ["<Article: Article 1>", "<Article: Article 2>"] ) self.assertQuerysetEqual(s1 & s2, []) class WeirdQuerysetSlicingTests(TestCase): @classmethod def setUpTestData(cls): Number.objects.create(num=1) Number.objects.create(num=2) Article.objects.create(name='one', created=datetime.datetime.now()) Article.objects.create(name='two', created=datetime.datetime.now()) Article.objects.create(name='three', created=datetime.datetime.now()) Article.objects.create(name='four', created=datetime.datetime.now()) food = Food.objects.create(name='spam') Eaten.objects.create(meal='spam with eggs', food=food) def test_tickets_7698_10202(self): # People like to slice with '0' as the high-water mark. self.assertQuerysetEqual(Article.objects.all()[0:0], []) self.assertQuerysetEqual(Article.objects.all()[0:0][:10], []) self.assertEqual(Article.objects.all()[:0].count(), 0) with self.assertRaisesMessage(AssertionError, 'Cannot change a query once a slice has been taken.'): Article.objects.all()[:0].latest('created') def test_empty_resultset_sql(self): # ticket #12192 self.assertNumQueries(0, lambda: list(Number.objects.all()[1:1])) def test_empty_sliced_subquery(self): self.assertEqual(Eaten.objects.filter(food__in=Food.objects.all()[0:0]).count(), 0) def test_empty_sliced_subquery_exclude(self): self.assertEqual(Eaten.objects.exclude(food__in=Food.objects.all()[0:0]).count(), 1) def test_zero_length_values_slicing(self): n = 42 with self.assertNumQueries(0): self.assertQuerysetEqual(Article.objects.values()[n:n], []) self.assertQuerysetEqual(Article.objects.values_list()[n:n], []) class EscapingTests(TestCase): def test_ticket_7302(self): # Reserved names are appropriately escaped ReservedName.objects.create(name='a', order=42) ReservedName.objects.create(name='b', order=37) self.assertQuerysetEqual( ReservedName.objects.all().order_by('order'), ['<ReservedName: b>', '<ReservedName: a>'] ) self.assertQuerysetEqual( ReservedName.objects.extra(select={'stuff': 'name'}, order_by=('order', 'stuff')), ['<ReservedName: b>', '<ReservedName: a>'] ) class ToFieldTests(TestCase): def test_in_query(self): apple = Food.objects.create(name="apple") pear = Food.objects.create(name="pear") lunch = Eaten.objects.create(food=apple, meal="lunch") dinner = Eaten.objects.create(food=pear, meal="dinner") self.assertEqual( set(Eaten.objects.filter(food__in=[apple, pear])), {lunch, dinner}, ) def test_in_subquery(self): apple = Food.objects.create(name="apple") lunch = Eaten.objects.create(food=apple, meal="lunch") self.assertEqual( set(Eaten.objects.filter(food__in=Food.objects.filter(name='apple'))), {lunch} ) self.assertEqual( set(Eaten.objects.filter(food__in=Food.objects.filter(name='apple').values('eaten__meal'))), set() ) self.assertEqual( set(Food.objects.filter(eaten__in=Eaten.objects.filter(meal='lunch'))), {apple} ) def test_nested_in_subquery(self): extra = ExtraInfo.objects.create() author = Author.objects.create(num=42, extra=extra) report = Report.objects.create(creator=author) comment = ReportComment.objects.create(report=report) comments = ReportComment.objects.filter( report__in=Report.objects.filter( creator__in=extra.author_set.all(), ), ) self.assertSequenceEqual(comments, [comment]) def test_reverse_in(self): apple = Food.objects.create(name="apple") pear = Food.objects.create(name="pear") lunch_apple = Eaten.objects.create(food=apple, meal="lunch") lunch_pear = Eaten.objects.create(food=pear, meal="dinner") self.assertEqual( set(Food.objects.filter(eaten__in=[lunch_apple, lunch_pear])), {apple, pear} ) def test_single_object(self): apple = Food.objects.create(name="apple") lunch = Eaten.objects.create(food=apple, meal="lunch") dinner = Eaten.objects.create(food=apple, meal="dinner") self.assertEqual( set(Eaten.objects.filter(food=apple)), {lunch, dinner} ) def test_single_object_reverse(self): apple = Food.objects.create(name="apple") lunch = Eaten.objects.create(food=apple, meal="lunch") self.assertEqual( set(Food.objects.filter(eaten=lunch)), {apple} ) def test_recursive_fk(self): node1 = Node.objects.create(num=42) node2 = Node.objects.create(num=1, parent=node1) self.assertEqual( list(Node.objects.filter(parent=node1)), [node2] ) def test_recursive_fk_reverse(self): node1 = Node.objects.create(num=42) node2 = Node.objects.create(num=1, parent=node1) self.assertEqual( list(Node.objects.filter(node=node2)), [node1] ) class IsNullTests(TestCase): def test_primary_key(self): custom = CustomPk.objects.create(name='pk') null = Related.objects.create() notnull = Related.objects.create(custom=custom) self.assertSequenceEqual(Related.objects.filter(custom__isnull=False), [notnull]) self.assertSequenceEqual(Related.objects.filter(custom__isnull=True), [null]) def test_to_field(self): apple = Food.objects.create(name="apple") Eaten.objects.create(food=apple, meal="lunch") Eaten.objects.create(meal="lunch") self.assertQuerysetEqual( Eaten.objects.filter(food__isnull=False), ['<Eaten: apple at lunch>'] ) self.assertQuerysetEqual( Eaten.objects.filter(food__isnull=True), ['<Eaten: None at lunch>'] ) class ConditionalTests(TestCase): """Tests whose execution depend on different environment conditions like Python version or DB backend features""" @classmethod def setUpTestData(cls): generic = NamedCategory.objects.create(name="Generic") t1 = Tag.objects.create(name='t1', category=generic) Tag.objects.create(name='t2', parent=t1, category=generic) t3 = Tag.objects.create(name='t3', parent=t1) Tag.objects.create(name='t4', parent=t3) Tag.objects.create(name='t5', parent=t3) def test_infinite_loop(self): # If you're not careful, it's possible to introduce infinite loops via # default ordering on foreign keys in a cycle. We detect that. with self.assertRaisesMessage(FieldError, 'Infinite loop caused by ordering.'): list(LoopX.objects.all()) # Force queryset evaluation with list() with self.assertRaisesMessage(FieldError, 'Infinite loop caused by ordering.'): list(LoopZ.objects.all()) # Force queryset evaluation with list() # Note that this doesn't cause an infinite loop, since the default # ordering on the Tag model is empty (and thus defaults to using "id" # for the related field). self.assertEqual(len(Tag.objects.order_by('parent')), 5) # ... but you can still order in a non-recursive fashion among linked # fields (the previous test failed because the default ordering was # recursive). self.assertQuerysetEqual( LoopX.objects.all().order_by('y__x__y__x__id'), [] ) # When grouping without specifying ordering, we add an explicit "ORDER BY NULL" # portion in MySQL to prevent unnecessary sorting. @skipUnlessDBFeature('requires_explicit_null_ordering_when_grouping') def test_null_ordering_added(self): query = Tag.objects.values_list('parent_id', flat=True).order_by().query query.group_by = ['parent_id'] sql = query.get_compiler(DEFAULT_DB_ALIAS).as_sql()[0] fragment = "ORDER BY " pos = sql.find(fragment) self.assertEqual(sql.find(fragment, pos + 1), -1) self.assertEqual(sql.find("NULL", pos + len(fragment)), pos + len(fragment)) def test_in_list_limit(self): # The "in" lookup works with lists of 1000 items or more. # The numbers amount is picked to force three different IN batches # for Oracle, yet to be less than 2100 parameter limit for MSSQL. numbers = list(range(2050)) max_query_params = connection.features.max_query_params if max_query_params is None or max_query_params >= len(numbers): Number.objects.bulk_create(Number(num=num) for num in numbers) for number in [1000, 1001, 2000, len(numbers)]: with self.subTest(number=number): self.assertEqual(Number.objects.filter(num__in=numbers[:number]).count(), number) class UnionTests(unittest.TestCase): """ Tests for the union of two querysets. Bug #12252. """ @classmethod def setUpTestData(cls): objectas = [] objectbs = [] objectcs = [] a_info = ['one', 'two', 'three'] for name in a_info: o = ObjectA(name=name) o.save() objectas.append(o) b_info = [('un', 1, objectas[0]), ('deux', 2, objectas[0]), ('trois', 3, objectas[2])] for name, number, objecta in b_info: o = ObjectB(name=name, num=number, objecta=objecta) o.save() objectbs.append(o) c_info = [('ein', objectas[2], objectbs[2]), ('zwei', objectas[1], objectbs[1])] for name, objecta, objectb in c_info: o = ObjectC(name=name, objecta=objecta, objectb=objectb) o.save() objectcs.append(o) def check_union(self, model, Q1, Q2): filter = model.objects.filter self.assertEqual(set(filter(Q1) | filter(Q2)), set(filter(Q1 | Q2))) self.assertEqual(set(filter(Q2) | filter(Q1)), set(filter(Q1 | Q2))) def test_A_AB(self): Q1 = Q(name='two') Q2 = Q(objectb__name='deux') self.check_union(ObjectA, Q1, Q2) def test_A_AB2(self): Q1 = Q(name='two') Q2 = Q(objectb__name='deux', objectb__num=2) self.check_union(ObjectA, Q1, Q2) def test_AB_ACB(self): Q1 = Q(objectb__name='deux') Q2 = Q(objectc__objectb__name='deux') self.check_union(ObjectA, Q1, Q2) def test_BAB_BAC(self): Q1 = Q(objecta__objectb__name='deux') Q2 = Q(objecta__objectc__name='ein') self.check_union(ObjectB, Q1, Q2) def test_BAB_BACB(self): Q1 = Q(objecta__objectb__name='deux') Q2 = Q(objecta__objectc__objectb__name='trois') self.check_union(ObjectB, Q1, Q2) def test_BA_BCA__BAB_BAC_BCA(self): Q1 = Q(objecta__name='one', objectc__objecta__name='two') Q2 = Q(objecta__objectc__name='ein', objectc__objecta__name='three', objecta__objectb__name='trois') self.check_union(ObjectB, Q1, Q2) class DefaultValuesInsertTest(TestCase): def test_no_extra_params(self): """ Can create an instance of a model with only the PK field (#17056)." """ DumbCategory.objects.create() class ExcludeTests(TestCase): @classmethod def setUpTestData(cls): f1 = Food.objects.create(name='apples') Food.objects.create(name='oranges') Eaten.objects.create(food=f1, meal='dinner') j1 = Job.objects.create(name='Manager') r1 = Responsibility.objects.create(description='Playing golf') j2 = Job.objects.create(name='Programmer') r2 = Responsibility.objects.create(description='Programming') JobResponsibilities.objects.create(job=j1, responsibility=r1) JobResponsibilities.objects.create(job=j2, responsibility=r2) def test_to_field(self): self.assertQuerysetEqual( Food.objects.exclude(eaten__meal='dinner'), ['<Food: oranges>']) self.assertQuerysetEqual( Job.objects.exclude(responsibilities__description='Playing golf'), ['<Job: Programmer>']) self.assertQuerysetEqual( Responsibility.objects.exclude(jobs__name='Manager'), ['<Responsibility: Programming>']) def test_ticket14511(self): alex = Person.objects.get_or_create(name='Alex')[0] jane = Person.objects.get_or_create(name='Jane')[0] oracle = Company.objects.get_or_create(name='Oracle')[0] google = Company.objects.get_or_create(name='Google')[0] microsoft = Company.objects.get_or_create(name='Microsoft')[0] intel = Company.objects.get_or_create(name='Intel')[0] def employ(employer, employee, title): Employment.objects.get_or_create(employee=employee, employer=employer, title=title) employ(oracle, alex, 'Engineer') employ(oracle, alex, 'Developer') employ(google, alex, 'Engineer') employ(google, alex, 'Manager') employ(microsoft, alex, 'Manager') employ(intel, alex, 'Manager') employ(microsoft, jane, 'Developer') employ(intel, jane, 'Manager') alex_tech_employers = alex.employers.filter( employment__title__in=('Engineer', 'Developer')).distinct().order_by('name') self.assertSequenceEqual(alex_tech_employers, [google, oracle]) alex_nontech_employers = alex.employers.exclude( employment__title__in=('Engineer', 'Developer')).distinct().order_by('name') self.assertSequenceEqual(alex_nontech_employers, [google, intel, microsoft]) class ExcludeTest17600(TestCase): """ Some regressiontests for ticket #17600. Some of these likely duplicate other existing tests. """ @classmethod def setUpTestData(cls): # Create a few Orders. cls.o1 = Order.objects.create(pk=1) cls.o2 = Order.objects.create(pk=2) cls.o3 = Order.objects.create(pk=3) # Create some OrderItems for the first order with homogeneous # status_id values cls.oi1 = OrderItem.objects.create(order=cls.o1, status=1) cls.oi2 = OrderItem.objects.create(order=cls.o1, status=1) cls.oi3 = OrderItem.objects.create(order=cls.o1, status=1) # Create some OrderItems for the second order with heterogeneous # status_id values cls.oi4 = OrderItem.objects.create(order=cls.o2, status=1) cls.oi5 = OrderItem.objects.create(order=cls.o2, status=2) cls.oi6 = OrderItem.objects.create(order=cls.o2, status=3) # Create some OrderItems for the second order with heterogeneous # status_id values cls.oi7 = OrderItem.objects.create(order=cls.o3, status=2) cls.oi8 = OrderItem.objects.create(order=cls.o3, status=3) cls.oi9 = OrderItem.objects.create(order=cls.o3, status=4) def test_exclude_plain(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(items__status=1), ['<Order: 3>']) def test_exclude_plain_distinct(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(items__status=1).distinct(), ['<Order: 3>']) def test_exclude_with_q_object_distinct(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(Q(items__status=1)).distinct(), ['<Order: 3>']) def test_exclude_with_q_object_no_distinct(self): """ This should exclude Orders which have some items with status 1 """ self.assertQuerysetEqual( Order.objects.exclude(Q(items__status=1)), ['<Order: 3>']) def test_exclude_with_q_is_equal_to_plain_exclude(self): """ Using exclude(condition) and exclude(Q(condition)) should yield the same QuerySet """ self.assertEqual( list(Order.objects.exclude(items__status=1).distinct()), list(Order.objects.exclude(Q(items__status=1)).distinct())) def test_exclude_with_q_is_equal_to_plain_exclude_variation(self): """ Using exclude(condition) and exclude(Q(condition)) should yield the same QuerySet """ self.assertEqual( list(Order.objects.exclude(items__status=1)), list(Order.objects.exclude(Q(items__status=1)).distinct())) @unittest.expectedFailure def test_only_orders_with_all_items_having_status_1(self): """ This should only return orders having ALL items set to status 1, or those items not having any orders at all. The correct way to write this query in SQL seems to be using two nested subqueries. """ self.assertQuerysetEqual( Order.objects.exclude(~Q(items__status=1)).distinct(), ['<Order: 1>']) class Exclude15786(TestCase): """Regression test for #15786""" def test_ticket15786(self): c1 = SimpleCategory.objects.create(name='c1') c2 = SimpleCategory.objects.create(name='c2') OneToOneCategory.objects.create(category=c1) OneToOneCategory.objects.create(category=c2) rel = CategoryRelationship.objects.create(first=c1, second=c2) self.assertEqual( CategoryRelationship.objects.exclude( first__onetoonecategory=F('second__onetoonecategory') ).get(), rel ) class NullInExcludeTest(TestCase): @classmethod def setUpTestData(cls): NullableName.objects.create(name='i1') NullableName.objects.create() def test_null_in_exclude_qs(self): none_val = '' if connection.features.interprets_empty_strings_as_nulls else None self.assertQuerysetEqual( NullableName.objects.exclude(name__in=[]), ['i1', none_val], attrgetter('name')) self.assertQuerysetEqual( NullableName.objects.exclude(name__in=['i1']), [none_val], attrgetter('name')) self.assertQuerysetEqual( NullableName.objects.exclude(name__in=['i3']), ['i1', none_val], attrgetter('name')) inner_qs = NullableName.objects.filter(name='i1').values_list('name') self.assertQuerysetEqual( NullableName.objects.exclude(name__in=inner_qs), [none_val], attrgetter('name')) # The inner queryset wasn't executed - it should be turned # into subquery above self.assertIs(inner_qs._result_cache, None) @unittest.expectedFailure def test_col_not_in_list_containing_null(self): """ The following case is not handled properly because SQL's COL NOT IN (list containing null) handling is too weird to abstract away. """ self.assertQuerysetEqual( NullableName.objects.exclude(name__in=[None]), ['i1'], attrgetter('name')) def test_double_exclude(self): self.assertEqual( list(NullableName.objects.filter(~~Q(name='i1'))), list(NullableName.objects.filter(Q(name='i1')))) self.assertNotIn( 'IS NOT NULL', str(NullableName.objects.filter(~~Q(name='i1')).query)) class EmptyStringsAsNullTest(TestCase): """ Filtering on non-null character fields works as expected. The reason for these tests is that Oracle treats '' as NULL, and this can cause problems in query construction. Refs #17957. """ @classmethod def setUpTestData(cls): cls.nc = NamedCategory.objects.create(name='') def test_direct_exclude(self): self.assertQuerysetEqual( NamedCategory.objects.exclude(name__in=['nonexistent']), [self.nc.pk], attrgetter('pk') ) def test_joined_exclude(self): self.assertQuerysetEqual( DumbCategory.objects.exclude(namedcategory__name__in=['nonexistent']), [self.nc.pk], attrgetter('pk') ) def test_21001(self): foo = NamedCategory.objects.create(name='foo') self.assertQuerysetEqual( NamedCategory.objects.exclude(name=''), [foo.pk], attrgetter('pk') ) class ProxyQueryCleanupTest(TestCase): def test_evaluated_proxy_count(self): """ Generating the query string doesn't alter the query's state in irreversible ways. Refs #18248. """ ProxyCategory.objects.create() qs = ProxyCategory.objects.all() self.assertEqual(qs.count(), 1) str(qs.query) self.assertEqual(qs.count(), 1) class WhereNodeTest(TestCase): class DummyNode: def as_sql(self, compiler, connection): return 'dummy', [] class MockCompiler: def compile(self, node): return node.as_sql(self, connection) def __call__(self, name): return connection.ops.quote_name(name) def test_empty_full_handling_conjunction(self): compiler = WhereNodeTest.MockCompiler() w = WhereNode(children=[NothingNode()]) with self.assertRaises(EmptyResultSet): w.as_sql(compiler, connection) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('', [])) w = WhereNode(children=[self.DummyNode(), self.DummyNode()]) self.assertEqual(w.as_sql(compiler, connection), ('(dummy AND dummy)', [])) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('NOT (dummy AND dummy)', [])) w = WhereNode(children=[NothingNode(), self.DummyNode()]) with self.assertRaises(EmptyResultSet): w.as_sql(compiler, connection) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('', [])) def test_empty_full_handling_disjunction(self): compiler = WhereNodeTest.MockCompiler() w = WhereNode(children=[NothingNode()], connector='OR') with self.assertRaises(EmptyResultSet): w.as_sql(compiler, connection) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('', [])) w = WhereNode(children=[self.DummyNode(), self.DummyNode()], connector='OR') self.assertEqual(w.as_sql(compiler, connection), ('(dummy OR dummy)', [])) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('NOT (dummy OR dummy)', [])) w = WhereNode(children=[NothingNode(), self.DummyNode()], connector='OR') self.assertEqual(w.as_sql(compiler, connection), ('dummy', [])) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('NOT (dummy)', [])) def test_empty_nodes(self): compiler = WhereNodeTest.MockCompiler() empty_w = WhereNode() w = WhereNode(children=[empty_w, empty_w]) self.assertEqual(w.as_sql(compiler, connection), ('', [])) w.negate() with self.assertRaises(EmptyResultSet): w.as_sql(compiler, connection) w.connector = 'OR' with self.assertRaises(EmptyResultSet): w.as_sql(compiler, connection) w.negate() self.assertEqual(w.as_sql(compiler, connection), ('', [])) w = WhereNode(children=[empty_w, NothingNode()], connector='OR') self.assertEqual(w.as_sql(compiler, connection), ('', [])) w = WhereNode(children=[empty_w, NothingNode()], connector='AND') with self.assertRaises(EmptyResultSet): w.as_sql(compiler, connection) class QuerySetExceptionTests(TestCase): def test_iter_exceptions(self): qs = ExtraInfo.objects.only('author') msg = "'ManyToOneRel' object has no attribute 'attname'" with self.assertRaisesMessage(AttributeError, msg): list(qs) def test_invalid_qs_list(self): # Test for #19895 - second iteration over invalid queryset # raises errors. qs = Article.objects.order_by('invalid_column') msg = "Cannot resolve keyword 'invalid_column' into field." with self.assertRaisesMessage(FieldError, msg): list(qs) with self.assertRaisesMessage(FieldError, msg): list(qs) def test_invalid_order_by(self): msg = "Invalid order_by arguments: ['*']" with self.assertRaisesMessage(FieldError, msg): list(Article.objects.order_by('*')) def test_invalid_queryset_model(self): msg = 'Cannot use QuerySet for "Article": Use a QuerySet for "ExtraInfo".' with self.assertRaisesMessage(ValueError, msg): list(Author.objects.filter(extra=Article.objects.all())) class NullJoinPromotionOrTest(TestCase): @classmethod def setUpTestData(cls): cls.d1 = ModelD.objects.create(name='foo') d2 = ModelD.objects.create(name='bar') cls.a1 = ModelA.objects.create(name='a1', d=cls.d1) c = ModelC.objects.create(name='c') b = ModelB.objects.create(name='b', c=c) cls.a2 = ModelA.objects.create(name='a2', b=b, d=d2) def test_ticket_17886(self): # The first Q-object is generating the match, the rest of the filters # should not remove the match even if they do not match anything. The # problem here was that b__name generates a LOUTER JOIN, then # b__c__name generates join to c, which the ORM tried to promote but # failed as that join isn't nullable. q_obj = ( Q(d__name='foo') | Q(b__name='foo') | Q(b__c__name='foo') ) qset = ModelA.objects.filter(q_obj) self.assertEqual(list(qset), [self.a1]) # We generate one INNER JOIN to D. The join is direct and not nullable # so we can use INNER JOIN for it. However, we can NOT use INNER JOIN # for the b->c join, as a->b is nullable. self.assertEqual(str(qset.query).count('INNER JOIN'), 1) def test_isnull_filter_promotion(self): qs = ModelA.objects.filter(Q(b__name__isnull=True)) self.assertEqual(str(qs.query).count('LEFT OUTER'), 1) self.assertEqual(list(qs), [self.a1]) qs = ModelA.objects.filter(~Q(b__name__isnull=True)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(list(qs), [self.a2]) qs = ModelA.objects.filter(~~Q(b__name__isnull=True)) self.assertEqual(str(qs.query).count('LEFT OUTER'), 1) self.assertEqual(list(qs), [self.a1]) qs = ModelA.objects.filter(Q(b__name__isnull=False)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(list(qs), [self.a2]) qs = ModelA.objects.filter(~Q(b__name__isnull=False)) self.assertEqual(str(qs.query).count('LEFT OUTER'), 1) self.assertEqual(list(qs), [self.a1]) qs = ModelA.objects.filter(~~Q(b__name__isnull=False)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(list(qs), [self.a2]) def test_null_join_demotion(self): qs = ModelA.objects.filter(Q(b__name__isnull=False) & Q(b__name__isnull=True)) self.assertIn(' INNER JOIN ', str(qs.query)) qs = ModelA.objects.filter(Q(b__name__isnull=True) & Q(b__name__isnull=False)) self.assertIn(' INNER JOIN ', str(qs.query)) qs = ModelA.objects.filter(Q(b__name__isnull=False) | Q(b__name__isnull=True)) self.assertIn(' LEFT OUTER JOIN ', str(qs.query)) qs = ModelA.objects.filter(Q(b__name__isnull=True) | Q(b__name__isnull=False)) self.assertIn(' LEFT OUTER JOIN ', str(qs.query)) def test_ticket_21366(self): n = Note.objects.create(note='n', misc='m') e = ExtraInfo.objects.create(info='info', note=n) a = Author.objects.create(name='Author1', num=1, extra=e) Ranking.objects.create(rank=1, author=a) r1 = Report.objects.create(name='Foo', creator=a) r2 = Report.objects.create(name='Bar') Report.objects.create(name='Bar', creator=a) qs = Report.objects.filter( Q(creator__ranking__isnull=True) | Q(creator__ranking__rank=1, name='Foo') ) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) self.assertEqual(str(qs.query).count(' JOIN '), 2) self.assertSequenceEqual(qs.order_by('name'), [r2, r1]) def test_ticket_21748(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') i3 = Identifier.objects.create(name='i3') Program.objects.create(identifier=i1) Channel.objects.create(identifier=i1) Program.objects.create(identifier=i2) self.assertSequenceEqual(Identifier.objects.filter(program=None, channel=None), [i3]) self.assertSequenceEqual(Identifier.objects.exclude(program=None, channel=None).order_by('name'), [i1, i2]) def test_ticket_21748_double_negated_and(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') Identifier.objects.create(name='i3') p1 = Program.objects.create(identifier=i1) c1 = Channel.objects.create(identifier=i1) Program.objects.create(identifier=i2) # Check the ~~Q() (or equivalently .exclude(~Q)) works like Q() for # join promotion. qs1_doubleneg = Identifier.objects.exclude(~Q(program__id=p1.id, channel__id=c1.id)).order_by('pk') qs1_filter = Identifier.objects.filter(program__id=p1.id, channel__id=c1.id).order_by('pk') self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x) self.assertEqual(str(qs1_filter.query).count('JOIN'), str(qs1_doubleneg.query).count('JOIN')) self.assertEqual(2, str(qs1_doubleneg.query).count('INNER JOIN')) self.assertEqual(str(qs1_filter.query).count('INNER JOIN'), str(qs1_doubleneg.query).count('INNER JOIN')) def test_ticket_21748_double_negated_or(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') Identifier.objects.create(name='i3') p1 = Program.objects.create(identifier=i1) c1 = Channel.objects.create(identifier=i1) p2 = Program.objects.create(identifier=i2) # Test OR + doubleneg. The expected result is that channel is LOUTER # joined, program INNER joined qs1_filter = Identifier.objects.filter( Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id) ).order_by('pk') qs1_doubleneg = Identifier.objects.exclude( ~Q(Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id)) ).order_by('pk') self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x) self.assertEqual(str(qs1_filter.query).count('JOIN'), str(qs1_doubleneg.query).count('JOIN')) self.assertEqual(1, str(qs1_doubleneg.query).count('INNER JOIN')) self.assertEqual(str(qs1_filter.query).count('INNER JOIN'), str(qs1_doubleneg.query).count('INNER JOIN')) def test_ticket_21748_complex_filter(self): i1 = Identifier.objects.create(name='i1') i2 = Identifier.objects.create(name='i2') Identifier.objects.create(name='i3') p1 = Program.objects.create(identifier=i1) c1 = Channel.objects.create(identifier=i1) p2 = Program.objects.create(identifier=i2) # Finally, a more complex case, one time in a way where each # NOT is pushed to lowest level in the boolean tree, and # another query where this isn't done. qs1 = Identifier.objects.filter( ~Q(~Q(program__id=p2.id, channel__id=c1.id) & Q(program__id=p1.id)) ).order_by('pk') qs2 = Identifier.objects.filter( Q(Q(program__id=p2.id, channel__id=c1.id) | ~Q(program__id=p1.id)) ).order_by('pk') self.assertQuerysetEqual(qs1, qs2, lambda x: x) self.assertEqual(str(qs1.query).count('JOIN'), str(qs2.query).count('JOIN')) self.assertEqual(0, str(qs1.query).count('INNER JOIN')) self.assertEqual(str(qs1.query).count('INNER JOIN'), str(qs2.query).count('INNER JOIN')) class ReverseJoinTrimmingTest(TestCase): def test_reverse_trimming(self): # We don't accidentally trim reverse joins - we can't know if there is # anything on the other side of the join, so trimming reverse joins # can't be done, ever. t = Tag.objects.create() qs = Tag.objects.filter(annotation__tag=t.pk) self.assertIn('INNER JOIN', str(qs.query)) self.assertEqual(list(qs), []) class JoinReuseTest(TestCase): """ The queries reuse joins sensibly (for example, direct joins are always reused). """ def test_fk_reuse(self): qs = Annotation.objects.filter(tag__name='foo').filter(tag__name='bar') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_select_related(self): qs = Annotation.objects.filter(tag__name='foo').select_related('tag') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_annotation(self): qs = Annotation.objects.filter(tag__name='foo').annotate(cnt=Count('tag__name')) self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_disjunction(self): qs = Annotation.objects.filter(Q(tag__name='foo') | Q(tag__name='bar')) self.assertEqual(str(qs.query).count('JOIN'), 1) def test_fk_reuse_order_by(self): qs = Annotation.objects.filter(tag__name='foo').order_by('tag__name') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_revo2o_reuse(self): qs = Detail.objects.filter(member__name='foo').filter(member__name='foo') self.assertEqual(str(qs.query).count('JOIN'), 1) def test_revfk_noreuse(self): qs = Author.objects.filter(report__name='r4').filter(report__name='r1') self.assertEqual(str(qs.query).count('JOIN'), 2) def test_inverted_q_across_relations(self): """ When a trimmable join is specified in the query (here school__), the ORM detects it and removes unnecessary joins. The set of reusable joins are updated after trimming the query so that other lookups don't consider that the outer query's filters are in effect for the subquery (#26551). """ springfield_elementary = School.objects.create() hogward = School.objects.create() Student.objects.create(school=springfield_elementary) hp = Student.objects.create(school=hogward) Classroom.objects.create(school=hogward, name='Potion') Classroom.objects.create(school=springfield_elementary, name='Main') qs = Student.objects.filter( ~(Q(school__classroom__name='Main') & Q(school__classroom__has_blackboard=None)) ) self.assertSequenceEqual(qs, [hp]) class DisjunctionPromotionTests(TestCase): def test_disjunction_promotion_select_related(self): fk1 = FK1.objects.create(f1='f1', f2='f2') basea = BaseA.objects.create(a=fk1) qs = BaseA.objects.filter(Q(a=fk1) | Q(b=2)) self.assertEqual(str(qs.query).count(' JOIN '), 0) qs = qs.select_related('a', 'b') self.assertEqual(str(qs.query).count(' INNER JOIN '), 0) self.assertEqual(str(qs.query).count(' LEFT OUTER JOIN '), 2) with self.assertNumQueries(1): self.assertSequenceEqual(qs, [basea]) self.assertEqual(qs[0].a, fk1) self.assertIs(qs[0].b, None) def test_disjunction_promotion1(self): # Pre-existing join, add two ORed filters to the same join, # all joins can be INNER JOINS. qs = BaseA.objects.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = qs.filter(Q(b__f1='foo') | Q(b__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) # Reverse the order of AND and OR filters. qs = BaseA.objects.filter(Q(b__f1='foo') | Q(b__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = qs.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 2) def test_disjunction_promotion2(self): qs = BaseA.objects.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) # Now we have two different joins in an ORed condition, these # must be OUTER joins. The pre-existing join should remain INNER. qs = qs.filter(Q(b__f1='foo') | Q(c__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) # Reverse case. qs = BaseA.objects.filter(Q(b__f1='foo') | Q(c__f2='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) qs = qs.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) def test_disjunction_promotion3(self): qs = BaseA.objects.filter(a__f2='bar') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) # The ANDed a__f2 filter allows us to use keep using INNER JOIN # even inside the ORed case. If the join to a__ returns nothing, # the ANDed filter for a__f2 can't be true. qs = qs.filter(Q(a__f1='foo') | Q(b__f2='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) def test_disjunction_promotion3_demote(self): # This one needs demotion logic: the first filter causes a to be # outer joined, the second filter makes it inner join again. qs = BaseA.objects.filter( Q(a__f1='foo') | Q(b__f2='foo')).filter(a__f2='bar') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) def test_disjunction_promotion4_demote(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('JOIN'), 0) # Demote needed for the "a" join. It is marked as outer join by # above filter (even if it is trimmed away). qs = qs.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) def test_disjunction_promotion4(self): qs = BaseA.objects.filter(a__f1='foo') self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = qs.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) def test_disjunction_promotion5_demote(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) # Note that the above filters on a force the join to an # inner join even if it is trimmed. self.assertEqual(str(qs.query).count('JOIN'), 0) qs = qs.filter(Q(a__f1='foo') | Q(b__f1='foo')) # So, now the a__f1 join doesn't need promotion. self.assertEqual(str(qs.query).count('INNER JOIN'), 1) # But b__f1 does. self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) qs = BaseA.objects.filter(Q(a__f1='foo') | Q(b__f1='foo')) # Now the join to a is created as LOUTER self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) qs = qs.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) def test_disjunction_promotion6(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('JOIN'), 0) qs = BaseA.objects.filter(Q(a__f1='foo') & Q(b__f1='foo')) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 0) qs = BaseA.objects.filter(Q(a__f1='foo') & Q(b__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 0) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) qs = qs.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('INNER JOIN'), 2) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 0) def test_disjunction_promotion7(self): qs = BaseA.objects.filter(Q(a=1) | Q(a=2)) self.assertEqual(str(qs.query).count('JOIN'), 0) qs = BaseA.objects.filter(Q(a__f1='foo') | (Q(b__f1='foo') & Q(a__f1='bar'))) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) qs = BaseA.objects.filter( (Q(a__f1='foo') | Q(b__f1='foo')) & (Q(a__f1='bar') | Q(c__f1='foo')) ) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 3) self.assertEqual(str(qs.query).count('INNER JOIN'), 0) qs = BaseA.objects.filter( (Q(a__f1='foo') | (Q(a__f1='bar')) & (Q(b__f1='bar') | Q(c__f1='foo'))) ) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) def test_disjunction_promotion_fexpression(self): qs = BaseA.objects.filter(Q(a__f1=F('b__f1')) | Q(b__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 1) self.assertEqual(str(qs.query).count('INNER JOIN'), 1) qs = BaseA.objects.filter(Q(a__f1=F('c__f1')) | Q(b__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 3) qs = BaseA.objects.filter(Q(a__f1=F('b__f1')) | Q(a__f2=F('b__f2')) | Q(c__f1='foo')) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 3) qs = BaseA.objects.filter(Q(a__f1=F('c__f1')) | (Q(pk=1) & Q(pk=2))) self.assertEqual(str(qs.query).count('LEFT OUTER JOIN'), 2) self.assertEqual(str(qs.query).count('INNER JOIN'), 0) class ManyToManyExcludeTest(TestCase): def test_exclude_many_to_many(self): Identifier.objects.create(name='extra') program = Program.objects.create(identifier=Identifier.objects.create(name='program')) channel = Channel.objects.create(identifier=Identifier.objects.create(name='channel')) channel.programs.add(program) # channel contains 'program1', so all Identifiers except that one # should be returned self.assertQuerysetEqual( Identifier.objects.exclude(program__channel=channel).order_by('name'), ['<Identifier: channel>', '<Identifier: extra>'] ) self.assertQuerysetEqual( Identifier.objects.exclude(program__channel=None).order_by('name'), ['<Identifier: program>'] ) def test_ticket_12823(self): pg3 = Page.objects.create(text='pg3') pg2 = Page.objects.create(text='pg2') pg1 = Page.objects.create(text='pg1') pa1 = Paragraph.objects.create(text='pa1') pa1.page.set([pg1, pg2]) pa2 = Paragraph.objects.create(text='pa2') pa2.page.set([pg2, pg3]) pa3 = Paragraph.objects.create(text='pa3') ch1 = Chapter.objects.create(title='ch1', paragraph=pa1) ch2 = Chapter.objects.create(title='ch2', paragraph=pa2) ch3 = Chapter.objects.create(title='ch3', paragraph=pa3) b1 = Book.objects.create(title='b1', chapter=ch1) b2 = Book.objects.create(title='b2', chapter=ch2) b3 = Book.objects.create(title='b3', chapter=ch3) q = Book.objects.exclude(chapter__paragraph__page__text='pg1') self.assertNotIn('IS NOT NULL', str(q.query)) self.assertEqual(len(q), 2) self.assertNotIn(b1, q) self.assertIn(b2, q) self.assertIn(b3, q) class RelabelCloneTest(TestCase): def test_ticket_19964(self): my1 = MyObject.objects.create(data='foo') my1.parent = my1 my1.save() my2 = MyObject.objects.create(data='bar', parent=my1) parents = MyObject.objects.filter(parent=F('id')) children = MyObject.objects.filter(parent__in=parents).exclude(parent=F('id')) self.assertEqual(list(parents), [my1]) # Evaluating the children query (which has parents as part of it) does # not change results for the parents query. self.assertEqual(list(children), [my2]) self.assertEqual(list(parents), [my1]) class Ticket20101Tests(TestCase): def test_ticket_20101(self): """ Tests QuerySet ORed combining in exclude subquery case. """ t = Tag.objects.create(name='foo') a1 = Annotation.objects.create(tag=t, name='a1') a2 = Annotation.objects.create(tag=t, name='a2') a3 = Annotation.objects.create(tag=t, name='a3') n = Note.objects.create(note='foo', misc='bar') qs1 = Note.objects.exclude(annotation__in=[a1, a2]) qs2 = Note.objects.filter(annotation__in=[a3]) self.assertIn(n, qs1) self.assertNotIn(n, qs2) self.assertIn(n, (qs1 | qs2)) class EmptyStringPromotionTests(TestCase): def test_empty_string_promotion(self): qs = RelatedObject.objects.filter(single__name='') if connection.features.interprets_empty_strings_as_nulls: self.assertIn('LEFT OUTER JOIN', str(qs.query)) else: self.assertNotIn('LEFT OUTER JOIN', str(qs.query)) class ValuesSubqueryTests(TestCase): def test_values_in_subquery(self): # If a values() queryset is used, then the given values # will be used instead of forcing use of the relation's field. o1 = Order.objects.create(id=-2) o2 = Order.objects.create(id=-1) oi1 = OrderItem.objects.create(order=o1, status=0) oi1.status = oi1.pk oi1.save() OrderItem.objects.create(order=o2, status=0) # The query below should match o1 as it has related order_item # with id == status. self.assertSequenceEqual(Order.objects.filter(items__in=OrderItem.objects.values_list('status')), [o1]) class DoubleInSubqueryTests(TestCase): def test_double_subquery_in(self): lfa1 = LeafA.objects.create(data='foo') lfa2 = LeafA.objects.create(data='bar') lfb1 = LeafB.objects.create(data='lfb1') lfb2 = LeafB.objects.create(data='lfb2') Join.objects.create(a=lfa1, b=lfb1) Join.objects.create(a=lfa2, b=lfb2) leaf_as = LeafA.objects.filter(data='foo').values_list('pk', flat=True) joins = Join.objects.filter(a__in=leaf_as).values_list('b__id', flat=True) qs = LeafB.objects.filter(pk__in=joins) self.assertSequenceEqual(qs, [lfb1]) class Ticket18785Tests(TestCase): def test_ticket_18785(self): # Test join trimming from ticket18785 qs = Item.objects.exclude( note__isnull=False ).filter( name='something', creator__extra__isnull=True ).order_by() self.assertEqual(1, str(qs.query).count('INNER JOIN')) self.assertEqual(0, str(qs.query).count('OUTER JOIN')) class Ticket20788Tests(TestCase): def test_ticket_20788(self): Paragraph.objects.create() paragraph = Paragraph.objects.create() page = paragraph.page.create() chapter = Chapter.objects.create(paragraph=paragraph) Book.objects.create(chapter=chapter) paragraph2 = Paragraph.objects.create() Page.objects.create() chapter2 = Chapter.objects.create(paragraph=paragraph2) book2 = Book.objects.create(chapter=chapter2) sentences_not_in_pub = Book.objects.exclude(chapter__paragraph__page=page) self.assertSequenceEqual(sentences_not_in_pub, [book2]) class Ticket12807Tests(TestCase): def test_ticket_12807(self): p1 = Paragraph.objects.create() p2 = Paragraph.objects.create() # The ORed condition below should have no effect on the query - the # ~Q(pk__in=[]) will always be True. qs = Paragraph.objects.filter((Q(pk=p2.pk) | ~Q(pk__in=[])) & Q(pk=p1.pk)) self.assertSequenceEqual(qs, [p1]) class RelatedLookupTypeTests(TestCase): error = 'Cannot query "%s": Must be "%s" instance.' @classmethod def setUpTestData(cls): cls.oa = ObjectA.objects.create(name="oa") cls.poa = ProxyObjectA.objects.get(name="oa") cls.coa = ChildObjectA.objects.create(name="coa") cls.wrong_type = Order.objects.create(id=cls.oa.pk) cls.ob = ObjectB.objects.create(name="ob", objecta=cls.oa, num=1) ProxyObjectB.objects.create(name="pob", objecta=cls.oa, num=2) cls.pob = ProxyObjectB.objects.all() ObjectC.objects.create(childobjecta=cls.coa) def test_wrong_type_lookup(self): """ A ValueError is raised when the incorrect object type is passed to a query lookup. """ # Passing incorrect object type with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectA._meta.object_name)): ObjectB.objects.get(objecta=self.wrong_type) with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectA._meta.object_name)): ObjectB.objects.filter(objecta__in=[self.wrong_type]) with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectA._meta.object_name)): ObjectB.objects.filter(objecta=self.wrong_type) with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectB._meta.object_name)): ObjectA.objects.filter(objectb__in=[self.wrong_type, self.ob]) # Passing an object of the class on which query is done. with self.assertRaisesMessage(ValueError, self.error % (self.ob, ObjectA._meta.object_name)): ObjectB.objects.filter(objecta__in=[self.poa, self.ob]) with self.assertRaisesMessage(ValueError, self.error % (self.ob, ChildObjectA._meta.object_name)): ObjectC.objects.exclude(childobjecta__in=[self.coa, self.ob]) def test_wrong_backward_lookup(self): """ A ValueError is raised when the incorrect object type is passed to a query lookup for backward relations. """ with self.assertRaisesMessage(ValueError, self.error % (self.oa, ObjectB._meta.object_name)): ObjectA.objects.filter(objectb__in=[self.oa, self.ob]) with self.assertRaisesMessage(ValueError, self.error % (self.oa, ObjectB._meta.object_name)): ObjectA.objects.exclude(objectb=self.oa) with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectB._meta.object_name)): ObjectA.objects.get(objectb=self.wrong_type) def test_correct_lookup(self): """ When passing proxy model objects, child objects, or parent objects, lookups work fine. """ out_a = ['<ObjectA: oa>', ] out_b = ['<ObjectB: ob>', '<ObjectB: pob>'] out_c = ['<ObjectC: >'] # proxy model objects self.assertQuerysetEqual(ObjectB.objects.filter(objecta=self.poa).order_by('name'), out_b) self.assertQuerysetEqual(ObjectA.objects.filter(objectb__in=self.pob).order_by('pk'), out_a * 2) # child objects self.assertQuerysetEqual(ObjectB.objects.filter(objecta__in=[self.coa]), []) self.assertQuerysetEqual(ObjectB.objects.filter(objecta__in=[self.poa, self.coa]).order_by('name'), out_b) self.assertQuerysetEqual( ObjectB.objects.filter(objecta__in=iter([self.poa, self.coa])).order_by('name'), out_b ) # parent objects self.assertQuerysetEqual(ObjectC.objects.exclude(childobjecta=self.oa), out_c) # QuerySet related object type checking shouldn't issue queries # (the querysets aren't evaluated here, hence zero queries) (#23266). with self.assertNumQueries(0): ObjectB.objects.filter(objecta__in=ObjectA.objects.all()) def test_values_queryset_lookup(self): """ #23396 - Ensure ValueQuerySets are not checked for compatibility with the lookup field """ # Make sure the num and objecta field values match. ob = ObjectB.objects.get(name='ob') ob.num = ob.objecta.pk ob.save() pob = ObjectB.objects.get(name='pob') pob.num = pob.objecta.pk pob.save() self.assertQuerysetEqual(ObjectB.objects.filter( objecta__in=ObjectB.objects.all().values_list('num') ).order_by('pk'), ['<ObjectB: ob>', '<ObjectB: pob>']) class Ticket14056Tests(TestCase): def test_ticket_14056(self): s1 = SharedConnection.objects.create(data='s1') s2 = SharedConnection.objects.create(data='s2') s3 = SharedConnection.objects.create(data='s3') PointerA.objects.create(connection=s2) expected_ordering = ( [s1, s3, s2] if connection.features.nulls_order_largest else [s2, s1, s3] ) self.assertSequenceEqual(SharedConnection.objects.order_by('-pointera__connection', 'pk'), expected_ordering) class Ticket20955Tests(TestCase): def test_ticket_20955(self): jack = Staff.objects.create(name='jackstaff') jackstaff = StaffUser.objects.create(staff=jack) jill = Staff.objects.create(name='jillstaff') jillstaff = StaffUser.objects.create(staff=jill) task = Task.objects.create(creator=jackstaff, owner=jillstaff, title="task") task_get = Task.objects.get(pk=task.pk) # Load data so that assertNumQueries doesn't complain about the get # version's queries. task_get.creator.staffuser.staff task_get.owner.staffuser.staff qs = Task.objects.select_related( 'creator__staffuser__staff', 'owner__staffuser__staff') self.assertEqual(str(qs.query).count(' JOIN '), 6) task_select_related = qs.get(pk=task.pk) with self.assertNumQueries(0): self.assertEqual(task_select_related.creator.staffuser.staff, task_get.creator.staffuser.staff) self.assertEqual(task_select_related.owner.staffuser.staff, task_get.owner.staffuser.staff) class Ticket21203Tests(TestCase): def test_ticket_21203(self): p = Ticket21203Parent.objects.create(parent_bool=True) c = Ticket21203Child.objects.create(parent=p) qs = Ticket21203Child.objects.select_related('parent').defer('parent__created') self.assertSequenceEqual(qs, [c]) self.assertIs(qs[0].parent.parent_bool, True) class ValuesJoinPromotionTests(TestCase): def test_values_no_promotion_for_existing(self): qs = Node.objects.filter(parent__parent__isnull=False) self.assertIn(' INNER JOIN ', str(qs.query)) qs = qs.values('parent__parent__id') self.assertIn(' INNER JOIN ', str(qs.query)) # Make sure there is a left outer join without the filter. qs = Node.objects.values('parent__parent__id') self.assertIn(' LEFT OUTER JOIN ', str(qs.query)) def test_non_nullable_fk_not_promoted(self): qs = ObjectB.objects.values('objecta__name') self.assertIn(' INNER JOIN ', str(qs.query)) def test_ticket_21376(self): a = ObjectA.objects.create() ObjectC.objects.create(objecta=a) qs = ObjectC.objects.filter( Q(objecta=a) | Q(objectb__objecta=a), ) qs = qs.filter( Q(objectb=1) | Q(objecta=a), ) self.assertEqual(qs.count(), 1) tblname = connection.ops.quote_name(ObjectB._meta.db_table) self.assertIn(' LEFT OUTER JOIN %s' % tblname, str(qs.query)) class ForeignKeyToBaseExcludeTests(TestCase): def test_ticket_21787(self): sc1 = SpecialCategory.objects.create(special_name='sc1', name='sc1') sc2 = SpecialCategory.objects.create(special_name='sc2', name='sc2') sc3 = SpecialCategory.objects.create(special_name='sc3', name='sc3') c1 = CategoryItem.objects.create(category=sc1) CategoryItem.objects.create(category=sc2) self.assertSequenceEqual(SpecialCategory.objects.exclude(categoryitem__id=c1.pk).order_by('name'), [sc2, sc3]) self.assertSequenceEqual(SpecialCategory.objects.filter(categoryitem__id=c1.pk), [sc1]) class ReverseM2MCustomPkTests(TestCase): def test_ticket_21879(self): cpt1 = CustomPkTag.objects.create(id='cpt1', tag='cpt1') cp1 = CustomPk.objects.create(name='cp1', extra='extra') cp1.custompktag_set.add(cpt1) self.assertSequenceEqual(CustomPk.objects.filter(custompktag=cpt1), [cp1]) self.assertSequenceEqual(CustomPkTag.objects.filter(custom_pk=cp1), [cpt1]) class Ticket22429Tests(TestCase): def test_ticket_22429(self): sc1 = School.objects.create() st1 = Student.objects.create(school=sc1) sc2 = School.objects.create() st2 = Student.objects.create(school=sc2) cr = Classroom.objects.create(school=sc1) cr.students.add(st1) queryset = Student.objects.filter(~Q(classroom__school=F('school'))) self.assertSequenceEqual(queryset, [st2]) class Ticket23605Tests(TestCase): def test_ticket_23605(self): # Test filtering on a complicated q-object from ticket's report. # The query structure is such that we have multiple nested subqueries. # The original problem was that the inner queries weren't relabeled # correctly. # See also #24090. a1 = Ticket23605A.objects.create() a2 = Ticket23605A.objects.create() c1 = Ticket23605C.objects.create(field_c0=10000.0) Ticket23605B.objects.create( field_b0=10000.0, field_b1=True, modelc_fk=c1, modela_fk=a1) complex_q = Q(pk__in=Ticket23605A.objects.filter( Q( # True for a1 as field_b0 = 10000, field_c0=10000 # False for a2 as no ticket23605b found ticket23605b__field_b0__gte=1000000 / F("ticket23605b__modelc_fk__field_c0") ) & # True for a1 (field_b1=True) Q(ticket23605b__field_b1=True) & ~Q(ticket23605b__pk__in=Ticket23605B.objects.filter( ~( # Same filters as above commented filters, but # double-negated (one for Q() above, one for # parentheses). So, again a1 match, a2 not. Q(field_b1=True) & Q(field_b0__gte=1000000 / F("modelc_fk__field_c0")) ) ))).filter(ticket23605b__field_b1=True)) qs1 = Ticket23605A.objects.filter(complex_q) self.assertSequenceEqual(qs1, [a1]) qs2 = Ticket23605A.objects.exclude(complex_q) self.assertSequenceEqual(qs2, [a2]) class TestTicket24279(TestCase): def test_ticket_24278(self): School.objects.create() qs = School.objects.filter(Q(pk__in=()) | Q()) self.assertQuerysetEqual(qs, []) class TestInvalidValuesRelation(TestCase): def test_invalid_values(self): msg = "invalid literal for int() with base 10: 'abc'" with self.assertRaisesMessage(ValueError, msg): Annotation.objects.filter(tag='abc') with self.assertRaisesMessage(ValueError, msg): Annotation.objects.filter(tag__in=[123, 'abc']) class TestTicket24605(TestCase): def test_ticket_24605(self): """ Subquery table names should be quoted. """ i1 = Individual.objects.create(alive=True) RelatedIndividual.objects.create(related=i1) i2 = Individual.objects.create(alive=False) RelatedIndividual.objects.create(related=i2) i3 = Individual.objects.create(alive=True) i4 = Individual.objects.create(alive=False) self.assertSequenceEqual(Individual.objects.filter(Q(alive=False), Q(related_individual__isnull=True)), [i4]) self.assertSequenceEqual( Individual.objects.exclude(Q(alive=False), Q(related_individual__isnull=True)).order_by('pk'), [i1, i2, i3] ) class Ticket23622Tests(TestCase): @skipUnlessDBFeature('can_distinct_on_fields') def test_ticket_23622(self): """ Make sure __pk__in and __in work the same for related fields when using a distinct on subquery. """ a1 = Ticket23605A.objects.create() a2 = Ticket23605A.objects.create() c1 = Ticket23605C.objects.create(field_c0=0.0) Ticket23605B.objects.create( modela_fk=a1, field_b0=123, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a1, field_b0=23, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a1, field_b0=234, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a1, field_b0=12, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a2, field_b0=567, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a2, field_b0=76, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a2, field_b0=7, field_b1=True, modelc_fk=c1, ) Ticket23605B.objects.create( modela_fk=a2, field_b0=56, field_b1=True, modelc_fk=c1, ) qx = ( Q(ticket23605b__pk__in=Ticket23605B.objects.order_by('modela_fk', '-field_b1').distinct('modela_fk')) & Q(ticket23605b__field_b0__gte=300) ) qy = ( Q(ticket23605b__in=Ticket23605B.objects.order_by('modela_fk', '-field_b1').distinct('modela_fk')) & Q(ticket23605b__field_b0__gte=300) ) self.assertEqual( set(Ticket23605A.objects.filter(qx).values_list('pk', flat=True)), set(Ticket23605A.objects.filter(qy).values_list('pk', flat=True)) ) self.assertSequenceEqual(Ticket23605A.objects.filter(qx), [a2])
bsd-3-clause
[ 646, 2197, 199, 646, 5927, 199, 646, 2882, 199, 504, 5055, 492, 8773, 199, 504, 4182, 492, 21829, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 9630, 21722, 12, 27691, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 14826, 12, 481, 12, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 491, 1877, 540, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 4509, 492, 20550, 1716, 12, 17685, 1716, 199, 504, 1639, 14, 396, 492, 7640, 12, 3372, 5524, 18093, 199, 504, 1639, 14, 396, 14, 1208, 492, 29828, 13611, 2998, 199, 199, 504, 1275, 992, 492, 334, 272, 18821, 17, 12, 30793, 12, 8281, 12, 6529, 12, 3523, 33, 12, 8944, 12, 13573, 2081, 12, 272, 13573, 21096, 12, 445, 8081, 9660, 369, 12, 17270, 12, 2799, 4185, 12, 12988, 12, 12988, 1692, 33, 12, 272, 8089, 11245, 12, 15878, 12, 1849, 422, 12, 8388, 29619, 12, 8388, 29619, 1931, 12, 13302, 12, 577, 4295, 7841, 12, 272, 662, 323, 78, 12, 662, 311, 7775, 12, 11177, 2354, 12, 481, 290, 12, 481, 23521, 12, 23285, 12, 1010, 15067, 12, 7020, 12, 15057, 12, 272, 15057, 1322, 678, 23422, 12, 25733, 12, 27836, 33, 12, 27836, 34, 12, 18175, 56, 12, 18175, 58, 12, 4688, 6028, 1685, 12, 272, 14409, 12, 5822, 33, 12, 5822, 34, 12, 5822, 35, 12, 5822, 36, 12, 4932, 1692, 12, 16198, 7841, 12, 5013, 12, 272, 3390, 12, 12119, 461, 985, 12, 4860, 12, 6935, 33, 12, 6935, 34, 12, 6935, 35, 12, 7309, 10939, 7841, 12, 272, 9240, 12, 9240, 2081, 12, 10331, 12, 2235, 7109, 12, 8028, 12, 16527, 2127, 12, 28833, 33, 12, 18841, 12, 272, 12373, 7841, 12, 12373, 1692, 33, 12, 12373, 1692, 34, 12, 31536, 316, 12, 20116, 12, 272, 20116, 28604, 12, 20116, 1692, 12, 11774, 12, 11774, 7488, 12, 5702, 985, 12, 272, 3591, 678, 4783, 12, 428, 15089, 12, 23752, 3225, 12, 5870, 7841, 12, 13050, 1692, 12, 272, 12568, 7841, 12, 25910, 12, 25910, 1899, 12, 17246, 12, 8053, 12, 8495, 12, 5773, 19728, 12, 272, 21932, 11722, 1644, 3493, 12, 21932, 11722, 1644, 6652, 12, 21932, 10008, 1717, 33, 12, 21932, 10008, 1717, 34, 12, 272, 21932, 10008, 1717, 35, 12, 377, 86, 20335, 70, 12, 4821, 12, 1323, 12, 199, 9, 421, 199, 533, 5843, 5460, 17, 2925, 8, 1746, 304, 272, 768, 3744, 272, 347, 3613, 16550, 8, 1886, 304, 267, 7809, 275, 16198, 7841, 14, 1462, 14, 981, 8, 354, 628, 9417, 531, 267, 843, 14, 84, 17, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 17, 297, 4637, 29, 6767, 9, 267, 843, 14, 84, 18, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 18, 297, 1676, 29, 1886, 14, 84, 17, 12, 4637, 29, 6767, 9, 267, 843, 14, 84, 19, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 19, 297, 1676, 29, 1886, 14, 84, 17, 9, 267, 307, 20, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 20, 297, 1676, 29, 1886, 14, 84, 19, 9, 267, 843, 14, 84, 21, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 21, 297, 1676, 29, 1886, 14, 84, 19, 9, 398, 843, 14, 78, 17, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 17, 297, 18576, 534, 1421, 297, 1305, 29, 17, 9, 267, 302, 18, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 18, 297, 18576, 534, 1700, 297, 1305, 29, 18, 9, 267, 843, 14, 78, 19, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 19, 297, 18576, 534, 1421, 297, 1305, 29, 19, 9, 398, 21172, 17, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1947, 29, 1886, 14, 84, 17, 9, 267, 21172, 17, 14, 5983, 14, 525, 8, 1886, 14, 78, 17, 9, 267, 21172, 18, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1947, 29, 84, 20, 9, 267, 21172, 18, 14, 5983, 14, 525, 8, 78, 18, 12, 843, 14, 78, 19, 9, 398, 327, 2790, 3520, 734, 402, 1865, 880, 626, 13351, 701, 283, 344, 7, 911, 506, 3365, 370, 13351, 267, 327, 701, 283, 815, 1370, 869, 352, 1190, 9696, 2005, 8826, 2945, 14, 267, 843, 14, 69, 18, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 18, 297, 5317, 29, 78, 18, 12, 574, 29, 2953, 9, 267, 325, 17, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 17, 297, 5317, 29, 1886, 14, 78, 17, 12, 574, 29, 2260, 9, 398, 843, 14, 65, 17, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1967, 29, 22167, 12, 2402, 29, 69, 17, 9, 267, 843, 14, 65, 18, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1967, 29, 15135, 12, 2402, 29, 69, 17, 9, 267, 282, 19, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 19, 297, 1967, 29, 5863, 19, 12, 2402, 29, 1886, 14, 69, 18, 9, 267, 843, 14, 65, 20, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 20, 297, 1967, 29, 5303, 20, 12, 2402, 29, 1886, 14, 69, 18, 9, 398, 843, 14, 521, 17, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 6928, 12, 5661, 12, 378, 9, 267, 843, 14, 521, 18, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 7829, 12, 378, 12, 378, 9, 267, 900, 19, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 6928, 12, 5661, 12, 378, 9, 267, 900, 20, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 7829, 12, 378, 12, 378, 9, 267, 843, 14, 73, 17, 275, 7020, 14, 1462, 14, 981, 8, 354, 534, 368, 297, 2737, 29, 1886, 14, 521, 17, 12, 6042, 29, 1886, 14, 521, 17, 12, 14875, 29, 1886, 14, 65, 17, 12, 5317, 29, 1886, 14, 78, 19, 9, 267, 843, 14, 73 ]
[ 2197, 199, 646, 5927, 199, 646, 2882, 199, 504, 5055, 492, 8773, 199, 504, 4182, 492, 21829, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 9630, 21722, 12, 27691, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 14826, 12, 481, 12, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 491, 1877, 540, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 4509, 492, 20550, 1716, 12, 17685, 1716, 199, 504, 1639, 14, 396, 492, 7640, 12, 3372, 5524, 18093, 199, 504, 1639, 14, 396, 14, 1208, 492, 29828, 13611, 2998, 199, 199, 504, 1275, 992, 492, 334, 272, 18821, 17, 12, 30793, 12, 8281, 12, 6529, 12, 3523, 33, 12, 8944, 12, 13573, 2081, 12, 272, 13573, 21096, 12, 445, 8081, 9660, 369, 12, 17270, 12, 2799, 4185, 12, 12988, 12, 12988, 1692, 33, 12, 272, 8089, 11245, 12, 15878, 12, 1849, 422, 12, 8388, 29619, 12, 8388, 29619, 1931, 12, 13302, 12, 577, 4295, 7841, 12, 272, 662, 323, 78, 12, 662, 311, 7775, 12, 11177, 2354, 12, 481, 290, 12, 481, 23521, 12, 23285, 12, 1010, 15067, 12, 7020, 12, 15057, 12, 272, 15057, 1322, 678, 23422, 12, 25733, 12, 27836, 33, 12, 27836, 34, 12, 18175, 56, 12, 18175, 58, 12, 4688, 6028, 1685, 12, 272, 14409, 12, 5822, 33, 12, 5822, 34, 12, 5822, 35, 12, 5822, 36, 12, 4932, 1692, 12, 16198, 7841, 12, 5013, 12, 272, 3390, 12, 12119, 461, 985, 12, 4860, 12, 6935, 33, 12, 6935, 34, 12, 6935, 35, 12, 7309, 10939, 7841, 12, 272, 9240, 12, 9240, 2081, 12, 10331, 12, 2235, 7109, 12, 8028, 12, 16527, 2127, 12, 28833, 33, 12, 18841, 12, 272, 12373, 7841, 12, 12373, 1692, 33, 12, 12373, 1692, 34, 12, 31536, 316, 12, 20116, 12, 272, 20116, 28604, 12, 20116, 1692, 12, 11774, 12, 11774, 7488, 12, 5702, 985, 12, 272, 3591, 678, 4783, 12, 428, 15089, 12, 23752, 3225, 12, 5870, 7841, 12, 13050, 1692, 12, 272, 12568, 7841, 12, 25910, 12, 25910, 1899, 12, 17246, 12, 8053, 12, 8495, 12, 5773, 19728, 12, 272, 21932, 11722, 1644, 3493, 12, 21932, 11722, 1644, 6652, 12, 21932, 10008, 1717, 33, 12, 21932, 10008, 1717, 34, 12, 272, 21932, 10008, 1717, 35, 12, 377, 86, 20335, 70, 12, 4821, 12, 1323, 12, 199, 9, 421, 199, 533, 5843, 5460, 17, 2925, 8, 1746, 304, 272, 768, 3744, 272, 347, 3613, 16550, 8, 1886, 304, 267, 7809, 275, 16198, 7841, 14, 1462, 14, 981, 8, 354, 628, 9417, 531, 267, 843, 14, 84, 17, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 17, 297, 4637, 29, 6767, 9, 267, 843, 14, 84, 18, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 18, 297, 1676, 29, 1886, 14, 84, 17, 12, 4637, 29, 6767, 9, 267, 843, 14, 84, 19, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 19, 297, 1676, 29, 1886, 14, 84, 17, 9, 267, 307, 20, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 20, 297, 1676, 29, 1886, 14, 84, 19, 9, 267, 843, 14, 84, 21, 275, 8053, 14, 1462, 14, 981, 8, 354, 534, 84, 21, 297, 1676, 29, 1886, 14, 84, 19, 9, 398, 843, 14, 78, 17, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 17, 297, 18576, 534, 1421, 297, 1305, 29, 17, 9, 267, 302, 18, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 18, 297, 18576, 534, 1700, 297, 1305, 29, 18, 9, 267, 843, 14, 78, 19, 275, 3390, 14, 1462, 14, 981, 8, 4610, 534, 78, 19, 297, 18576, 534, 1421, 297, 1305, 29, 19, 9, 398, 21172, 17, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1947, 29, 1886, 14, 84, 17, 9, 267, 21172, 17, 14, 5983, 14, 525, 8, 1886, 14, 78, 17, 9, 267, 21172, 18, 275, 30793, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1947, 29, 84, 20, 9, 267, 21172, 18, 14, 5983, 14, 525, 8, 78, 18, 12, 843, 14, 78, 19, 9, 398, 327, 2790, 3520, 734, 402, 1865, 880, 626, 13351, 701, 283, 344, 7, 911, 506, 3365, 370, 13351, 267, 327, 701, 283, 815, 1370, 869, 352, 1190, 9696, 2005, 8826, 2945, 14, 267, 843, 14, 69, 18, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 18, 297, 5317, 29, 78, 18, 12, 574, 29, 2953, 9, 267, 325, 17, 275, 11177, 2354, 14, 1462, 14, 981, 8, 815, 534, 69, 17, 297, 5317, 29, 1886, 14, 78, 17, 12, 574, 29, 2260, 9, 398, 843, 14, 65, 17, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 17, 297, 1967, 29, 22167, 12, 2402, 29, 69, 17, 9, 267, 843, 14, 65, 18, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 18, 297, 1967, 29, 15135, 12, 2402, 29, 69, 17, 9, 267, 282, 19, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 19, 297, 1967, 29, 5863, 19, 12, 2402, 29, 1886, 14, 69, 18, 9, 267, 843, 14, 65, 20, 275, 6529, 14, 1462, 14, 981, 8, 354, 534, 65, 20, 297, 1967, 29, 5303, 20, 12, 2402, 29, 1886, 14, 69, 18, 9, 398, 843, 14, 521, 17, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 6928, 12, 5661, 12, 378, 9, 267, 843, 14, 521, 18, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 5851, 12, 7829, 12, 378, 12, 378, 9, 267, 900, 19, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 6928, 12, 5661, 12, 378, 9, 267, 900, 20, 275, 2197, 14, 2083, 8, 9488, 12, 3144, 12, 3388, 12, 7829, 12, 378, 12, 378, 9, 267, 843, 14, 73, 17, 275, 7020, 14, 1462, 14, 981, 8, 354, 534, 368, 297, 2737, 29, 1886, 14, 521, 17, 12, 6042, 29, 1886, 14, 521, 17, 12, 14875, 29, 1886, 14, 65, 17, 12, 5317, 29, 1886, 14, 78, 19, 9, 267, 843, 14, 73, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wizardxbl/rtt-stm32f10x
bsp/upd70f3454/rtconfig.py
36
2949
import os # toolchains options ARCH = 'v850' CPU = '70f34' CROSS_TOOL = 'iar' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if CROSS_TOOL == 'gcc': print '================ERROR============================' print 'Not support gcc yet!' print '=================================================' exit(0) elif CROSS_TOOL == 'iar': PLATFORM = 'iar' IAR_PATH = 'C:/Program Files/IAR Systems/Embedded Workbench 6.0 Evaluation_0' elif CROSS_TOOL == 'keil': print '================ERROR============================' print 'Not support keil yet!' print '=================================================' exit(0) if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') BUILD = 'debug' if PLATFORM == 'gcc': # toolchains PREFIX = 'm32c-elf-' CC = PREFIX + 'gcc' AS = PREFIX + 'gcc' AR = PREFIX + 'ar' LINK = PREFIX + 'gcc' TARGET_EXT = 'out' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=m16c' CFLAGS = DEVICE AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' LFLAGS = DEVICE + ' -nostartfiles' + ' -Wl,--gc-sections,-Map=rtthread_m16c.map,-cref,-u,_start -T m16c62p.ld' CPATH = '' LPATH = '' if BUILD == 'debug': CFLAGS += ' -O0 -gdwarf-2' AFLAGS += ' -gdwarf-2' else: CFLAGS += ' -O2' POST_ACTION = OBJCPY + ' -O srec $TARGET rtthread.mot\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'iar': # toolchains CC = 'iccv850' AS = 'av850' AR = 'xar' LINK = 'xlink' TARGET_EXT = 'hex' DEVICE = '--cpu V850' EXEC_PATH = IAR_PATH + '/v850/bin' AFLAGS = '-s+' AFLAGS = ' -v1' # AFLAGS += ' -M<>' AFLAGS += ' -s+' AFLAGS += ' -DCODE_MODEL_NORMAL' AFLAGS += ' -DDATA_MODEL_TINY' AFLAGS += ' -w+' AFLAGS += ' -r' AFLAGS += ' -I"' + IAR_PATH + '/v850/INC"' LFLAGS = '-xms' LFLAGS += ' -I"' + IAR_PATH + '/v850/LIB"' LFLAGS += ' -rt' LFLAGS += ' -s __program_start' LFLAGS += ' -D_CSTACK_SIZE=1000' LFLAGS += ' "' + IAR_PATH + '/v850/LIB/dl85nn1.r85"' LFLAGS += ' -D_HEAP_SIZE=0' # LFLAGS += ' "' + IAR_PATH + '/v850/lib/CLIB/clm16cfnffwc.r34"' # LFLAGS += ' -e_small_write=_formatted_write' # LFLAGS += ' -e_medium_read=_formatted_read' # CFLAGS = DEVICE CFLAGS = '--diag_suppress Pa050' CFLAGS += ' -v1' CFLAGS += ' -mt' CFLAGS += ' --code_model normal' CFLAGS += ' --no_cse' CFLAGS += ' --no_unroll' CFLAGS += ' --no_inline' CFLAGS += ' --no_code_motion' CFLAGS += ' --dlib_config "' + IAR_PATH + '/v850/LIB/dl85nn1.h"' CFLAGS += ' -I"' + IAR_PATH + '/v850/INC"' CFLAGS += ' --no_tbaa' CFLAGS += ' --debug' CFLAGS += ' --lock_regs 0' CFLAGS += ' --migration_preprocessor_extensions' CFLAGS += ' -e' CFLAGS += ' -Ol' POST_ACTION = ''
gpl-2.0
[ 646, 747, 199, 199, 3, 4744, 17419, 1511, 199, 7762, 258, 275, 283, 86, 21419, 7, 199, 11011, 420, 275, 283, 2760, 70, 1082, 7, 199, 199, 28368, 63, 9731, 221, 198, 29, 283, 73, 285, 7, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 2571, 735, 199, 198, 28368, 63, 9731, 275, 747, 14, 12959, 360, 50, 1481, 63, 2571, 358, 199, 199, 692, 221, 445, 23264, 63, 9731, 508, 283, 13112, 356, 272, 870, 283, 1280, 3170, 1280, 5769, 7, 272, 870, 283, 1763, 2291, 19443, 5966, 11213, 272, 870, 283, 12813, 534, 272, 4458, 8, 16, 9, 199, 4164, 445, 23264, 63, 9731, 508, 283, 73, 285, 356, 199, 198, 17805, 221, 198, 29, 283, 73, 285, 7, 199, 198, 41, 689, 63, 3243, 275, 283, 35, 11254, 9184, 16920, 15, 41, 689, 15285, 15, 27395, 9361, 16571, 1227, 14, 16, 16494, 4086, 63, 16, 7, 199, 4164, 445, 23264, 63, 9731, 508, 283, 415, 382, 356, 272, 870, 283, 1280, 3170, 1280, 5769, 7, 272, 870, 283, 1763, 2291, 10074, 382, 5966, 11213, 272, 870, 283, 12813, 534, 272, 4458, 8, 16, 9, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 735, 199, 198, 10276, 63, 3243, 275, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 358, 199, 199, 8248, 275, 283, 1757, 7, 199, 199, 692, 21966, 508, 283, 13112, 356, 272, 327, 4744, 17419, 272, 27884, 275, 283, 77, 708, 67, 13, 25371, 15668, 272, 17586, 275, 27884, 435, 283, 13112, 7, 272, 4319, 275, 27884, 435, 283, 13112, 7, 272, 4160, 275, 27884, 435, 283, 285, 7, 272, 19774, 275, 27884, 435, 283, 13112, 7, 272, 26134, 63, 2472, 275, 283, 548, 7, 272, 32289, 275, 27884, 435, 283, 890, 7, 272, 593, 16262, 26406, 275, 27884, 435, 283, 1113, 2724, 7, 272, 593, 16262, 2890, 57, 275, 27884, 435, 283, 1113, 1574, 7, 339, 11643, 275, 283, 446, 77, 3541, 29, 77, 975, 67, 7, 272, 25149, 275, 11643, 272, 437, 4831, 275, 283, 446, 67, 7, 435, 11643, 435, 283, 446, 88, 22931, 82, 13, 1045, 13, 5910, 7, 272, 491, 4831, 275, 11643, 435, 283, 446, 889, 928, 1725, 7, 435, 283, 446, 16239, 28925, 9493, 13, 7786, 3057, 2956, 29, 2591, 2671, 63, 77, 975, 67, 14, 1130, 3057, 67, 1121, 3057, 85, 16987, 928, 446, 52, 333, 975, 67, 2789, 80, 14, 1447, 7, 339, 445, 3243, 275, 2125, 272, 491, 3243, 275, 2125, 339, 340, 22974, 508, 283, 1757, 356, 267, 25149, 847, 283, 446, 47, 16, 446, 7136, 3281, 70, 13, 18, 7, 267, 437, 4831, 847, 283, 446, 7136, 3281, 70, 13, 18, 7, 272, 587, 26, 267, 25149, 847, 283, 446, 47, 18, 7, 339, 8761, 63, 10052, 275, 593, 16262, 2890, 57, 435, 283, 446, 47, 308, 2761, 2672, 9268, 14059, 2671, 14, 30034, 60, 78, 7, 435, 32289, 435, 283, 2672, 9268, 971, 78, 7, 199, 199, 4164, 21966, 508, 283, 73, 285, 356, 272, 327, 4744, 17419, 272, 17586, 275, 283, 530, 5107, 21419, 7, 272, 4319, 275, 283, 1214, 21419, 7, 272, 4160, 275, 283, 88, 285, 7, 272, 19774, 275, 283, 24085, 7, 272, 26134, 63, 2472, 275, 283, 4097, 7, 339, 11643, 275, 2850, 3541, 812, 21419, 7, 339, 3651, 4220, 63, 3243, 275, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 1393, 7, 339, 437, 4831, 275, 2475, 83, 4786, 272, 437, 4831, 275, 283, 446, 86, 17, 7, 199, 3, 259, 437, 4831, 847, 283, 446, 45, 28, 3524, 5591, 437, 4831, 847, 283, 446, 83, 4786, 5591, 437, 4831, 847, 283, 446, 36, 6012, 63, 11429, 63, 10765, 7, 5591, 437, 4831, 847, 283, 446, 36, 3998, 63, 11429, 63, 31178, 7, 272, 437, 4831, 847, 283, 446, 87, 4786, 272, 437, 4831, 847, 283, 446, 82, 7, 272, 437, 4831, 847, 283, 446, 41, 4507, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 25205, 4507, 339, 491, 4831, 275, 2475, 88, 706, 7, 272, 491, 4831, 847, 283, 446, 41, 4507, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 5617, 4507, 5591, 491, 4831, 847, 283, 446, 2591, 7, 5591, 491, 4831, 847, 283, 446, 83, 636, 6815, 63, 928, 7, 5591, 491, 4831, 847, 283, 446, 36, 63, 35, 17014, 63, 4305, 29, 5279, 7, 5591, 491, 4831, 847, 283, 3546, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 5617, 15, 5030, 2426, 4411, 17, 14, 82, 2426, 4507, 272, 491, 4831, 847, 283, 446, 36, 63, 23707, 63, 4305, 29, 16, 7, 9948, 199, 3, 259, 491, 4831, 847, 283, 3546, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 773, 15, 1981, 2100, 15, 429, 77, 975, 2177, 78, 556, 13683, 14, 82, 1082, 4507, 221, 199, 3, 257, 491, 4831, 847, 283, 446, 69, 63, 7241, 63, 952, 3699, 15317, 63, 952, 7, 221, 199, 3, 259, 491, 4831, 847, 283, 446, 69, 63, 14345, 63, 739, 3699, 15317, 63, 739, 7, 199, 199, 3, 259, 25149, 275, 11643, 272, 25149, 275, 2850, 6706, 63, 17381, 10164, 24742, 7, 272, 25149, 847, 283, 446, 86, 17, 7, 5591, 25149, 847, 283, 446, 2037, 7, 5591, 25149, 847, 283, 1553, 600, 63, 1238, 3293, 7, 5591, 25149, 847, 283, 1553, 889, 63, 67, 261, 7, 5591, 25149, 847, 283, 1553, 889, 63, 324, 2827, 7, 5591, 25149, 847, 283, 1553, 889, 63, 6460, 7, 5591, 25149, 847, 283, 1553, 889, 63, 600, 63, 15335, 7, 5591, 25149, 847, 283, 1553, 68, 773, 63, 888, 3546, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 5617, 15, 5030, 2426, 4411, 17, 14, 72, 4507, 272, 25149, 847, 283, 446, 41, 4507, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 25205, 4507, 272, 25149, 847, 283, 1553, 889, 63, 5842, 2158, 7, 5591, 25149, 847, 283, 1553, 1757, 7, 5591, 25149, 847, 283, 1553, 831, 63, 23957, 378, 7, 5591, 25149, 847, 283, 1553, 8998, 63, 657, 6459, 63, 5359, 7, 5591, 25149, 847, 283, 446, 69, 7, 5591, 25149, 847, 283, 446, 47, 76, 7, 339 ]
[ 747, 199, 199, 3, 4744, 17419, 1511, 199, 7762, 258, 275, 283, 86, 21419, 7, 199, 11011, 420, 275, 283, 2760, 70, 1082, 7, 199, 199, 28368, 63, 9731, 221, 198, 29, 283, 73, 285, 7, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 2571, 735, 199, 198, 28368, 63, 9731, 275, 747, 14, 12959, 360, 50, 1481, 63, 2571, 358, 199, 199, 692, 221, 445, 23264, 63, 9731, 508, 283, 13112, 356, 272, 870, 283, 1280, 3170, 1280, 5769, 7, 272, 870, 283, 1763, 2291, 19443, 5966, 11213, 272, 870, 283, 12813, 534, 272, 4458, 8, 16, 9, 199, 4164, 445, 23264, 63, 9731, 508, 283, 73, 285, 356, 199, 198, 17805, 221, 198, 29, 283, 73, 285, 7, 199, 198, 41, 689, 63, 3243, 275, 283, 35, 11254, 9184, 16920, 15, 41, 689, 15285, 15, 27395, 9361, 16571, 1227, 14, 16, 16494, 4086, 63, 16, 7, 199, 4164, 445, 23264, 63, 9731, 508, 283, 415, 382, 356, 272, 870, 283, 1280, 3170, 1280, 5769, 7, 272, 870, 283, 1763, 2291, 10074, 382, 5966, 11213, 272, 870, 283, 12813, 534, 272, 4458, 8, 16, 9, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 735, 199, 198, 10276, 63, 3243, 275, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 358, 199, 199, 8248, 275, 283, 1757, 7, 199, 199, 692, 21966, 508, 283, 13112, 356, 272, 327, 4744, 17419, 272, 27884, 275, 283, 77, 708, 67, 13, 25371, 15668, 272, 17586, 275, 27884, 435, 283, 13112, 7, 272, 4319, 275, 27884, 435, 283, 13112, 7, 272, 4160, 275, 27884, 435, 283, 285, 7, 272, 19774, 275, 27884, 435, 283, 13112, 7, 272, 26134, 63, 2472, 275, 283, 548, 7, 272, 32289, 275, 27884, 435, 283, 890, 7, 272, 593, 16262, 26406, 275, 27884, 435, 283, 1113, 2724, 7, 272, 593, 16262, 2890, 57, 275, 27884, 435, 283, 1113, 1574, 7, 339, 11643, 275, 283, 446, 77, 3541, 29, 77, 975, 67, 7, 272, 25149, 275, 11643, 272, 437, 4831, 275, 283, 446, 67, 7, 435, 11643, 435, 283, 446, 88, 22931, 82, 13, 1045, 13, 5910, 7, 272, 491, 4831, 275, 11643, 435, 283, 446, 889, 928, 1725, 7, 435, 283, 446, 16239, 28925, 9493, 13, 7786, 3057, 2956, 29, 2591, 2671, 63, 77, 975, 67, 14, 1130, 3057, 67, 1121, 3057, 85, 16987, 928, 446, 52, 333, 975, 67, 2789, 80, 14, 1447, 7, 339, 445, 3243, 275, 2125, 272, 491, 3243, 275, 2125, 339, 340, 22974, 508, 283, 1757, 356, 267, 25149, 847, 283, 446, 47, 16, 446, 7136, 3281, 70, 13, 18, 7, 267, 437, 4831, 847, 283, 446, 7136, 3281, 70, 13, 18, 7, 272, 587, 26, 267, 25149, 847, 283, 446, 47, 18, 7, 339, 8761, 63, 10052, 275, 593, 16262, 2890, 57, 435, 283, 446, 47, 308, 2761, 2672, 9268, 14059, 2671, 14, 30034, 60, 78, 7, 435, 32289, 435, 283, 2672, 9268, 971, 78, 7, 199, 199, 4164, 21966, 508, 283, 73, 285, 356, 272, 327, 4744, 17419, 272, 17586, 275, 283, 530, 5107, 21419, 7, 272, 4319, 275, 283, 1214, 21419, 7, 272, 4160, 275, 283, 88, 285, 7, 272, 19774, 275, 283, 24085, 7, 272, 26134, 63, 2472, 275, 283, 4097, 7, 339, 11643, 275, 2850, 3541, 812, 21419, 7, 339, 3651, 4220, 63, 3243, 275, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 1393, 7, 339, 437, 4831, 275, 2475, 83, 4786, 272, 437, 4831, 275, 283, 446, 86, 17, 7, 199, 3, 259, 437, 4831, 847, 283, 446, 45, 28, 3524, 5591, 437, 4831, 847, 283, 446, 83, 4786, 5591, 437, 4831, 847, 283, 446, 36, 6012, 63, 11429, 63, 10765, 7, 5591, 437, 4831, 847, 283, 446, 36, 3998, 63, 11429, 63, 31178, 7, 272, 437, 4831, 847, 283, 446, 87, 4786, 272, 437, 4831, 847, 283, 446, 82, 7, 272, 437, 4831, 847, 283, 446, 41, 4507, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 25205, 4507, 339, 491, 4831, 275, 2475, 88, 706, 7, 272, 491, 4831, 847, 283, 446, 41, 4507, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 5617, 4507, 5591, 491, 4831, 847, 283, 446, 2591, 7, 5591, 491, 4831, 847, 283, 446, 83, 636, 6815, 63, 928, 7, 5591, 491, 4831, 847, 283, 446, 36, 63, 35, 17014, 63, 4305, 29, 5279, 7, 5591, 491, 4831, 847, 283, 3546, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 5617, 15, 5030, 2426, 4411, 17, 14, 82, 2426, 4507, 272, 491, 4831, 847, 283, 446, 36, 63, 23707, 63, 4305, 29, 16, 7, 9948, 199, 3, 259, 491, 4831, 847, 283, 3546, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 773, 15, 1981, 2100, 15, 429, 77, 975, 2177, 78, 556, 13683, 14, 82, 1082, 4507, 221, 199, 3, 257, 491, 4831, 847, 283, 446, 69, 63, 7241, 63, 952, 3699, 15317, 63, 952, 7, 221, 199, 3, 259, 491, 4831, 847, 283, 446, 69, 63, 14345, 63, 739, 3699, 15317, 63, 739, 7, 199, 199, 3, 259, 25149, 275, 11643, 272, 25149, 275, 2850, 6706, 63, 17381, 10164, 24742, 7, 272, 25149, 847, 283, 446, 86, 17, 7, 5591, 25149, 847, 283, 446, 2037, 7, 5591, 25149, 847, 283, 1553, 600, 63, 1238, 3293, 7, 5591, 25149, 847, 283, 1553, 889, 63, 67, 261, 7, 5591, 25149, 847, 283, 1553, 889, 63, 324, 2827, 7, 5591, 25149, 847, 283, 1553, 889, 63, 6460, 7, 5591, 25149, 847, 283, 1553, 889, 63, 600, 63, 15335, 7, 5591, 25149, 847, 283, 1553, 68, 773, 63, 888, 3546, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 5617, 15, 5030, 2426, 4411, 17, 14, 72, 4507, 272, 25149, 847, 283, 446, 41, 4507, 435, 473, 689, 63, 3243, 435, 1994, 86, 21419, 15, 25205, 4507, 272, 25149, 847, 283, 1553, 889, 63, 5842, 2158, 7, 5591, 25149, 847, 283, 1553, 1757, 7, 5591, 25149, 847, 283, 1553, 831, 63, 23957, 378, 7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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 ]
gstiebler/odemis
src/odemis/driver/pigcs.py
2
182360
# -*- coding: utf-8 -*- ''' Created on 7 Aug 2012 @author: Éric Piel Copyright © 2012-2015 Éric Piel, Delmic This file is part of Odemis. Odemis is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. Odemis 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 Odemis. If not, see http://www.gnu.org/licenses/. ''' from __future__ import division import Queue from concurrent.futures import CancelledError import glob import logging from odemis import model from odemis.model import isasync, CancellableFuture, CancellableThreadPoolExecutor from odemis.util import driver, TimeoutError import os # import random import re import serial import socket import threading import time # Driver to handle PI's piezo motor controllers that follow the 'GCS' (General # Command Set). In particular it handles the PI E-861, C-867 and E-725 controllers. # Information can be found the manual E-861_User_PZ205E121.pdf (p.107). # For the PI C-170 aka "redstone", see the pi driver. # Note that although they officially support the 'command set', each controller # type (and firmware) has a subset of commands supported, has different parameters # and even slightly different way to expect commands and to send answers. # # It can access the controllers over RS-232, (serial over) USB and TCP/IP. # In a daisy-chain, connected via USB or via RS-232, there must be one # controller with address 1 (=DIP 1111). There is also a broadcast address: 255. # In _some_ TCP/IP configuration, there is a master controller at address 254. # # The controller contains many parameters in flash memory. These parameters must # have been previously written correctly to fit the stage it is driving. This # driver uses and expects the parameters to be correct. # The configuration database is available in a file called pistages2.dat. The # PIMikroMove Windows program allows to load it, but by default doesn't copy it to # the non-volatile memory, so you need to explicitly save them in persistent # memory. (Can also be done with the WPA command and password "100".) # In particular, for closed-loop stages, ensure that the settling windows and time # are correctly set so that a move is considered on target quickly (< 1 s). # With Odemis, the 'piconfig' utility can also be used to read and write the # persistent memory. # # The controller supports closed-loop mode (i.e., absolute positioning) but only # if it is associated to a sensor (not software detectable). When the hardware # has no sensor, the controller should be used only in open-loop mode, to avoid # damaging the actuator. So when there is no sensor: # * Do not switch servo on (SVO command) # * Do not send commands for closed-loop motion, like MOV or MVR # * Do not send the open-loop commands OMA and OMR, since they # use a sensor, too # # The controller accepts several baud rates. We choose 38400 (DIP=01) as it's fast # and it seems accepted by every version. Other settings are 8 data, 1 stop, # no parity. # # In open-loop, the controller has 2 ways to move the actuators: # * Nanostepping: high-speed, and long distance # 1 step ~ 10 μm without load (less with load) # * Analog: very precise, but moves maximum ~5μm # "40 volts corresponds to a motion of approx. 3.3μm" # "20 volts corresponds to a motion of approx. 1μm" # # As an exception, the C-867 only supports officially closed-loop. However, there # is a "testing" command, SMO, that allows to move in open-loop by simulating the input # to the PID controller. PI assured us that as long as the stage used can reach # the limit without getting damaged, it is safe. It's pretty straightforward to # use the command. The voltage defines the speed (and direction) of the move. The # voltage should be set to 0 again when the position desired is reached. 3V is # approximately the minimum to move, and 10V is the maximum. Voltage is more or # less linear between -32766 and 32766 -> -10 and 10V. So the distance moved # depends on the time the SMO is set, which is obviously very imprecise. # The recommended maximum step frequency is 800 Hz. # # In closed-loop, it's almost all automagical. # There are two modes in closed-loop: before and after referencing. Referencing # consists in going to at least one "reference" point so that the actual position # is known. # * Non referenced: that's the only one possible just after boot. It's only # possible to do relative moves. Just a sensor (which indicates a distance) # is needed. # * Referenced: both absolute and relative moves are possible. It's the default # mode. In addition to the sensor, the hardware will also include a reference # switch (which indicates a point, usually in the middle) and/or 2 limit # switches (which indicate the borders). # The problem with referencing is that for some cases, it might be dangerous to # move the actuator, so a user feedback is needed. This means an explicit request # via the API must be done before this is going on, and stopping must be possible. # In addition, in many cases, relative move is sufficient. # # The architecture of the driver relies on four main classes: # * Controller: represent one controller with one or several axes (E-861 has only # one). Each subclass defines a different type of control. The subclass is # picked dynamically according to the physical controller. # * Bus: represent the whole group of controllers daisy-chained from the same # serial port. It's also the Actuator interface for the rest of Odemis. # * SerialBusAccesser: wrapper around the serial port which handles the low-level GCS # protocol. # * ActionManager: handles all the actions (move/stop) sent to the controller so # that the asynchronous ones are ordered. # # In the typical usage, Odemis asks to moveRel() an axis to the Bus. The Bus converts # it into an action, returns a Future and queue the action on the Executor. # When the Controller is free, the Executor picks the next action, call the right # method which converts it into a command for the Controller, which sends it to # the actual PI controller and waits for it to finish. # # Note: in some rare cases, the controller might not answer to commands correctly, # reporting error 555. In that case, it's possible to do a factory reset with the # hidden command (which must be followed by the reconfiguration of the parameters): # zzz 100 parameter class PIGCSError(StandardError): def __init__(self, errno, *args, **kwargs): # Needed for pickling, cf https://bugs.python.org/issue1692335 (fixed in Python 3.3) StandardError.__init__(self, errno, *args, **kwargs) self.errno = errno def __str__(self): desc = self._errordict.get(self.errno, "Unknown error") return "PIGCS error %d: %s" % (self.errno, desc) _errordict = { 0: "No error", 1: "Parameter syntax error", 2: "Unknown command", 3: "Command length out of limits or command buffer overrun", 4: "Error while scanning", 5: "Unallowable move attempted on unreferenced axis, or move attempted with servo off", 6: "Parameter for SGA not valid", 7: "Position out of limits", 8: "Velocity out of limits", 9: "Attempt to set pivot point while U,V and W not all 0", 10: "Controller was stopped by command", 11: "Parameter for SST or for one of the embedded scan algorithms out of range", 12: "Invalid axis combination for fast scan", 13: "Parameter for NAV out of range", 14: "Invalid analog channel", 15: "Invalid axis identifier", 16: "Unknown stage name", 17: "Parameter out of range", 18: "Invalid macro name", 19: "Error while recording macro", 20: "Macro not found", 21: "Axis has no brake", 22: "Axis identifier specified more than once", 23: "Illegal axis", 24: "Incorrect number of parameters", 25: "Invalid floating point number", 26: "Parameter missing", 27: "Soft limit out of range", 28: "No manual pad found", 29: "No more step-response values", 30: "No step-response values recorded", 31: "Axis has no reference sensor", 32: "Axis has no limit switch", 33: "No relay card installed", 34: "Command not allowed for selected stage(s)", 35: "No digital input installed", 36: "No digital output configured", 37: "No more MCM responses", 38: "No MCM values recorded", 39: "Controller number invalid", 40: "No joystick configured", 41: "Invalid axis for electronic gearing, axis cannot be slave", 42: "Position of slave axis is out of range", 43: "Slave axis cannot be commanded directly when electronic gearing is enabled", 44: "Calibration of joystick failed", 45: "Referencing failed", 46: "OPM (Optical Power Meter) missing", 47: "OPM (Optical Power Meter) not initialized or cannot be initialized", 48: "OPM (Optical Power Meter) Communication Error", 49: "Move to limit switch failed", 50: "Attempt to reference axis with referencing disabled", 51: "Selected axis is controlled by joystick", 52: "Controller detected communication error", 53: "MOV! motion still in progress", 54: "Unknown parameter", 55: "No commands were recorded with REP", 56: "Password invalid", 57: "Data Record Table does not exist", 58: "Source does not exist; number too low or too high", 59: "Source Record Table number too low or too high", 60: "Protected Param: current Command Level (CCL) too low", 61: "Command execution not possible while Autozero is running", 62: "Autozero requires at least one linear axis", 63: "Initialization still in progress", 64: "Parameter is read-only", 65: "Parameter not found in non-volatile memory", 66: "Voltage out of limits", 67: "Not enough memory available for requested wave curve", 68: "Not enough memory available for DDL table; DDL cannot be started", 69: "Time delay larger than DDL table; DDL cannot be started", 70: "The requested arrays have different lengths; query them separately", 71: "Attempt to restart the generator while it is running in single step mode", 72: "Motion commands and wave generator activation are not allowed when analog target is active", 73: "Motion commands are not allowed when wave generator is active", 74: "No sensor channel or no piezo channel connected to selected axis (sensor and piezo matrix)", 75: "Generator started (WGO) without having selected a wave table (WSL).", 76: "Interface buffer did overrun and command couldn't be received correctly", 77: "Data Record Table does not hold enough recorded data", 78: "Data Record Table is not configured for recording", 79: "Open-loop commands (SVA, SVR) are not allowed when servo is on", 80: "Hardware error affecting RAM", 81: "Not macro command", 82: "Macro counter out of range", 83: "Joystick is active", 84: "Motor is off", 85: "Macro-only command", 86: "Invalid joystick axis", 87: "Joystick unknown", 88: "Move without referenced stage", 89: "Command not allowed in current motion mode", 90: "No tracing possible while digital IOs are used on this HW revision. Reconnect to switch operation mode.", 91: "Move not possible, would cause collision", 92: "Stage is not capable of following the master. Check the gear ratio.", 100: "PI LabVIEW driver reports error. See source control for details.", 200: "No stage connected to axis", 201: "File with axis parameters not found", 202: "Invalid axis parameter file", 203: "Backup file with axis parameters not found", 204: "PI internal error code 204", 205: "SMO with servo on", 206: "uudecode: incomplete header", 207: "uudecode: nothing to decode", 208: "uudecode: illegal UUE format", 209: "CRC32 error", 210: "Illegal file name (must be 8-0 format)", 211: "File not found on controller", 212: "Error writing file on controller", 213: "VEL command not allowed in DTR Command Mode", 214: "Position calculations failed", 215: "The connection between controller and stage may be broken", 216: "The connected stage has driven into a limit switch, some controllers need CLR to resume operation", 217: "Strut test command failed because of an unexpected strut stop", 218: "While MOV! is running position can only be estimated!", 219: "Position was calculated during MOV motion", 230: "Invalid handle", 231: "No bios found", 232: "Save system configuration failed", 233: "Load system configuration failed", 301: "Send buffer overflow", 302: "Voltage out of limits", 303: "Open-loop motion attempted when servo ON", 304: "Received command is too long", 305: "Error while reading/writing EEPROM", 306: "Error on I2C bus", 307: "Timeout while receiving command", 308: "A lengthy operation has not finished in the expected time", 309: "Insufficient space to store macro", 310: "Configuration data has old version number", 311: "Invalid configuration data", 333: "Internal hardware error", 400: "Wave generator index error", 401: "Wave table not defined", 402: "Wave type not supported", 403: "Wave length exceeds limit", 404: "Wave parameter number error", 405: "Wave parameter out of range", 406: "WGO command bit not supported", 502: "Position consistency check failed", 503: "Hardware collision sensor(s) are activated", 504: "Strut following error occurred, e.g. caused by overload or encoder failure", 555: "BasMac: unknown controller error", 601: "not enough memory", 602: "hardware voltage error", 603: "hardware temperature out of range", 1000: "Too many nested macros", 1001: "Macro already defined", 1002: "Macro recording not activated", 1003: "Invalid parameter for MAC", 1004: "PI internal error code 1004", 1005: "Controller is busy with some lengthy operation (e.g. reference move, fast scan algorithm)", 2000: "Controller already has a serial number", 4000: "Sector erase failed", 4001: "Flash program failed", 4002: "Flash read failed", 4003: "HW match code missing/invalid", 4004: "FW match code missing/invalid", 4005: "HW version missing/invalid", 4006: "FW version missing/invalid", 4007: "FW update failed", 5000: "PicoCompensation scan data is not valid", 5001: "PicoCompensation is running, some actions cannot be executed during scanning/recording", 5002: "Given axis cannot be defined as PPC axis", 5003: "Defined scan area is larger than the travel range", 5004: "Given PicoCompensation type is not defined", 5005: "PicoCompensation parameter error", 5006: "PicoCompensation table is larger than maximum table length", 5100: "Common error in NEXLINE® firmware module", 5101: "Output channel for NEXLINE® cannot be redefined for other usage", 5102: "Memory for NEXLINE® signals is too small", 5103: "RNP cannot be executed if axis is in closed loop", 5104: "Relax procedure (RNP) needed", 5200: "Axis must be configured for this action", - 1024: "Motion error: position error too large, servo is switched off automatically", } # constants for model number MODEL_C867 = 867 MODEL_E725 = 725 MODEL_E861 = 861 MODEL_UNKNOWN = 0 class Controller(object): idn_matches = { MODEL_C867: "Physik Instrumente.*,.*C-867", MODEL_E725: "Physik Instrumente.*,.*E-725", MODEL_E861: "Physik Instrumente.*,.*E-861", } def __new__(cls, busacc, address=None, axes=None, _stem=False, *args, **kwargs): """ Takes care of selecting the right class of controller depending on the hardware. For the arguments, see __init__() """ busacc.flushInput() # Three types of controllers: Closed-loop (detected just from the axes # arguments), normal open-loop, and open-loop via SMO test command. # Difference between the 2 open-loop is hard-coded on the model as it's # faster than checking for the list of commands available. if _stem is True: subcls = Controller # just for tests/scan elif any(axes.values()): if not all(axes.values()): raise ValueError("Controller %d, mix of closed-loop and " "open-loop axes is not supported", address) idn = busacc.sendQueryCommand(address, "*IDN?\n") if re.search(cls.idn_matches[MODEL_E725], idn): subcls = CLAbsController else: subcls = CLRelController else: # Check controller model by asking it, but cannot rely on the # normal commands as nothing is ready, so do all "manually" # Note: IDN works even if error is set idn = busacc.sendQueryCommand(address, "*IDN?\n") if re.search(cls.idn_matches[MODEL_C867], idn): subcls = SMOController else: subcls = OLController return super(Controller, cls).__new__(subcls, busacc, address, axes, *args, **kwargs) def __init__(self, busacc, address=None, axes=None, _stem=False): """ busacc: a BusAccesser address (None or 1<=int<=16): address as configured on the controller axes (dict int -> boolean): determine which axis will be used and whether it will be used closed-loop (True) or open-loop (False). _stem (bool): just allows to do some raw commands, and changing address is allowed """ # TODO: calibration values should be per axis (but for now we only have controllers with 1 axis) self.busacc = busacc self.address = address self._try_recover = False # for now, fully raw access # did the user asked for a raw access only? if _stem: self._channels = set(range(1, 17)) # allow commands to work on any axis return if axes is None: raise ValueError("Need to have at least one axis configured") self.GetErrorNum() # make it happy again (in case it wasn't) # We don't reboot by default because: # * in almost any case we can assume it's in a good state (if not, it's # up to the controller to force it. # * if it's in a really bad state, GetErrorNum will fail and cause a # reboot anyway # * it sometimes actually cause more harm by putting the controller in # a zombie state # * it's slow (especially if you have 5 controllers) version = self.GetSyntaxVersion() if version != "2.0": logging.warning("Controller %d announces untested GCS %s", address, version) self._model = self.getModel() if self._model == MODEL_UNKNOWN: logging.warning("Controller %d is an unsupported version (%s)", address, self.GetIdentification()) self._channels = self.GetAxes() # available channels (=axes) self._avail_cmds = self.GetAvailableCommands() self._avail_params = self.GetAvailableParameters() # FIXME: only if the command is supported # dict axis -> boolean try: self._hasLimitSwitches = {a: self.HasLimitSwitches(a) for a in self._channels} except NotImplementedError: self._hasLimitSwitches = {a: False for a in self._channels} # dict axis -> boolean try: self._hasRefSwitch = {a: self.HasRefSwitch(a) for a in self._channels} except NotImplementedError: self._hasLimitSwitches = {a: False for a in self._channels} # Dict of axis (int) -> bool: whether the axis supports position update self.canUpdate = {a: False for a in self._channels} self._position = {} # m (dict axis-> position) self.pos_rng = {} # m, dict axis -> min,max position self._speed = {} # m/s dict axis -> speed self.speed_rng = {} # m/s, dict axis -> min,max speed self._accel = {} # m/s² dict axis -> acceleration/deceleration # only for interpolated position (on open-loop) self._target = {} # m (dict axis-> expected position at the end of the move) self._end_move = {a: 0 for a in self._channels} # m (dict axis -> time the move will finish) self._start_move = {} # m (dict axis -> time the move started) # If the controller is mis-configured for the actuator, things can go quite # wrong, so make it clear for c in self._channels: logging.info("Controller %s is configured for actuator %s", address, self.GetStageName(c)) logging.info("Axis %s has %slimit switches and has %sreference switch", c, "" if self._hasLimitSwitches[c] else "no ", "a " if self._hasRefSwitch[c] else "no ") self._try_recover = True # full feature only after init def terminate(self): pass def _sendOrderCommand(self, com): """ Send a command which does not expect any report back com (string): command to send (including the \n if necessary) """ self.busacc.sendOrderCommand(self.address, com) def _sendQueryCommand(self, com): """ Send a command and return its report com (string): the command to send (without address prefix but with \n) return (string or list of strings): the report without prefix (e.g.,"0 1") nor newline. If answer is multiline: returns a list of each line """ # Hold the lock until we get an _correct_ answer, so that if recovery # is needed, it's not messed up by other communications with self.busacc.ser_access: try: lines = self.busacc.sendQueryCommand(self.address, com) except IOError: if not self._try_recover: raise success = self.recoverTimeout() if success: logging.warning("Controller %s timeout after '%s', but recovered.", self.address, com.encode('string_escape')) # try one more time (and it has to work this time) lines = self.busacc.sendQueryCommand(self.address, com) else: logging.error("Controller %s timeout after '%s', not recovered.", self.address, com.encode('string_escape')) raise IOError("Controller %s timeout after '%s', not recovered." % (self.address, com.encode('string_escape'))) return lines re_err_ans = r"(-?\d+)$" # ex: ("0 1 ")[-54](\n) def recoverTimeout(self): """ Try to recover from error in the controller state return (boolean): True if it recovered raise PIGCSError: if the timeout was due to a controller error (in which case the controller will be set back to working state if possible) """ logging.warning("Trying to recover controller %s from timeout", self.address) # TODO: update the .state of the component to HwError # Reading error code makes the controller more comfortable... try: for i in range(2): self.busacc.flushInput() resp = self.busacc.sendQueryCommand(self.address, "ERR?\n") if isinstance(resp, list): logging.debug("Got multi-line answer, will try again") continue m = re.match(self.re_err_ans, resp) if m: # looks like an answer to err? err = int(m.group(1)) if err == 0: return True else: # Everything is fine, it's probably just that the # original command was not accepted raise PIGCSError(err) logging.debug("Controller returned weird answer, will try harder to recover") except IOError: pass # We timed out again, try harder: reboot logging.debug("Trying harder to recover by rebooting controller") self.Reboot() try: resp = self.busacc.sendQueryCommand(self.address, "ERR?\n") m = re.match(self.re_err_ans, resp) if m: # looks like an answer to err? # TODO Check if error == 307 or 308? err = int(m.group(1)) if err != 0: logging.warning("Controller %s still has error %d after reboot", self.address, err) return True except IOError: pass # that's getting pretty hopeless return False # The following are function directly mapping to the controller commands. # In general it should not be need to use them directly from outside this class def GetIdentification(self): # *IDN? (Get Device Identification): # ex: 0 2 (c)2010 Physik Instrumente(PI) Karlsruhe,E-861 Version 7.2.0 version = self._sendQueryCommand("*IDN?\n") return version def GetSyntaxVersion(self): # CSV? (Get Current Syntax Version) # GCS version, can be 1.0 (for GCS 1.0) or 2.0 (for GCS 2.0) return self._sendQueryCommand("CSV?\n") def GetStageName(self, axis): """ return (str) the name of the stage for which the controller is configured. Note that the actual stage might be different. """ # CST? does this as well # parameter 0x3c # return self.GetParameter(axis, 0x3C) return self._readAxisValue("CST?", axis) def GetAxes(self): """ returns (set of int): all the available axes """ # SAI? (Get List Of Current Axis Identifiers) # SAI? ALL: list all axes (included disabled ones), one per line answer = self._sendQueryCommand("SAI? ALL\n") axes = set(int(a) for a in answer) return axes def GetAvailableCommands(self): """ return (dict str -> str): command name -> command description """ # HLP? (Get List Of Available Commands), returns lines in such formats: # "HLP? - Get List Of Available Commands \n" or # "HLP? Get List Of Available Commands \n" or # "#24 - Stop All Motion \n" # first line sometimes starts with \x00 lines = self._sendQueryCommand("HLP?\n") lines[0] = lines[0].lstrip("\x00") cmds = {} for l in lines: ll = l.lower() if re.match(r"(the following.*:|^end of.*)", ll): logging.debug("Line doesn't seem to be a command: '%s'", l) else: cd = re.split(r"[\s-]", l, 1) if len(cd) != 2: logging.debug("Line doesn't seem to be a command: '%s'", l) else: cmd = cd[0] if cmd.startswith("#"): # One character command try: cmd = int(cmd[1:]) except ValueError: logging.info("Unexpected command %s", cmd) cmds[cd[0]] = cd[1] return cmds def GetAvailableParameters(self): """ Returns the available parameters return (dict int -> str): parameter number and string used to describe it (typically: 0 1 FLOAT description) """ # HPA? (Get List Of Available Parameters) lines = self._sendQueryCommand("HPA?\n") lines[0] = lines[0].lstrip("\x00") params = {} # first and last lines are typically just user-friendly text # look for something like '0x412=\t0\t1\tINT\tmotorcontroller\tI term 1' # (and old firmwares report like: '0x412 XXX') for l in lines: m = re.match(r"0x(?P<param>[0-9A-Fa-f]+)[= ]\s*(?P<desc>.+)", l) if not m: logging.debug("Line doesn't seem to be a parameter: '%s'", l) continue param, desc = int(m.group("param"), 16), m.group("desc") params[param] = desc return params def GetParameter(self, axis, param): """ axis (1<int<16): axis number param (0<int): parameter id (cf p.35) returns (str): the string representing this parameter """ # SPA? (Get Volatile Memory Parameters) assert 1 <= axis <= 16 assert 0 <= param if hasattr(self, "_avail_params") and param not in self._avail_params: raise ValueError("Parameter %d %d not available" % (axis, param)) answer = self._sendQueryCommand("SPA? %d %d\n" % (axis, param)) try: value = answer.split("=")[1] except IndexError: # no "=" => means the parameter is unknown raise ValueError("Parameter %d %d unknown" % (axis, param)) return value def GetParameters(self): """ Return all the parameters values for all the axes returns (dict (int, int)->str): the axis/parameter number -> value """ # SPA? (Get Volatile Memory Parameters) lines = self._sendQueryCommand("SPA?\n") lines[0] = lines[0].lstrip("\x00") params = {} # look for something like '1 0x412=5.000' for l in lines: m = re.match(r"(?P<axis>\d+)\s0x(?P<param>[0-9A-Fa-f]+)=\s*(?P<value>(\S+))", l) if not m: logging.debug("Line doesn't seem to be a parameter: '%s'", l) continue a, param, value = int(m.group("axis")), int(m.group("param"), 16), m.group("value") params[(a, param)] = value return params def SetParameter(self, axis, param, val, check=True): """ axis (1<int<16): axis number param (0<int): parameter id (cf p.35) val (str): value to set (if not a string, it will be converted) check (bool): if True, will check whether the hardware raised an error Raises ValueError if hardware complains """ # SPA (Set Volatile Memory Parameters) assert(1 <= axis <= 16) assert(0 <= param) self._sendOrderCommand("SPA %d 0x%X %s\n" % (axis, param, val)) if check: err = self.GetErrorNum() if err: raise ValueError("Error %d: setting param 0x%X with val %s failed." % (err, param, val), err) def GetParameterNonVolatile(self, axis, param): """ Read the value of the parameter in the non-volatile memory axis (1<int<16): axis number param (0<int): parameter id (cf p.35) returns (str): the string representing this parameter """ # SEP? (Get Non-Volatile Memory Parameters) assert 1 <= axis <= 16 assert 0 <= param if hasattr(self, "_avail_params") and param not in self._avail_params: raise ValueError("Parameter %d %d not available" % (axis, param)) answer = self._sendQueryCommand("SEP? %d %d\n" % (axis, param)) try: value = answer.split("=")[1] except IndexError: # no "=" => means the parameter is unknown raise ValueError("Parameter %d %d unknown" % (axis, param)) return value def SetCommandLevel(self, level, pwd): """ Change the authorization level level (0<=int): 0 is standard, 1 allows to change parameters pwd (str): 'advanced' for level 1 """ assert(0 <= level) self._sendOrderCommand("CCL %d %s\n" % (level, pwd)) self.checkError() def _readAxisValue(self, com, axis): """ Returns the value for a command with axis. Ex: POS? 1 -> 1=25.3 com (str): the 4 letter command (including the ?) axis (1<int<16): axis number returns (int or float or str): value returned depending on the type detected """ assert(axis in self._channels) assert(2 < len(com) < 8) if com not in self._avail_cmds: raise NotImplementedError("Command %s not supported by the controller" % (com,)) resp = self._sendQueryCommand("%s %d\n" % (com, axis)) try: value_str = resp.split("=")[1] except IndexError: raise ValueError("Failed to parse answer from %s %d: '%s'" % (com, axis, resp)) try: value = int(value_str) except ValueError: try: value = float(value_str) except ValueError: value = value_str return value def HasLimitSwitches(self, axis): """ Report whether the given axis has limit switches (is able to detect the ends of the axis). Note: It's just read from a configuration value in flash memory. Can be configured easily with PIMikroMove axis (1<int<16): axis number returns (bool) """ # LIM? (Indicate Limit Switches) # 1 => True, 0 => False return self._readAxisValue("LIM?", axis) == 1 def HasRefSwitch(self, axis): """ Report whether the given axis has a reference switch (is able to detect the "middle" of the axis). Note: apparently it's just read from a configuration value in flash memory. Can be configured easily with PIMikroMove axis (1<int<16): axis number returns (bool) """ # TRS? (Indicate Reference Switch) # 1 => True, 0 => False return self._readAxisValue("TRS?", axis) == 1 def GetMotionStatus(self, check=True): """ returns (set of int): the set of moving axes Note: it seems the controller doesn't report moves when using OL via PID raise PIGCSError if check is True and an error on a controller happened """ # "\x05" (Request Motion Status) # hexadecimal number bitmap of which axis is moving => 0 if everything is stopped # Ex: 4 => 3rd axis moving if check: errs, answer = self._sendQueryCommand(["ERR?\n", "\x05"]) err = int(errs) if err: raise PIGCSError(err) else: answer = self._sendQueryCommand("\x05") bitmap = int(answer, 16) # convert to a set i = 1 mv_axes = set() while bitmap > 0: if bitmap & 1: mv_axes.add(i) i += 1 bitmap >>= 1 return mv_axes def GetStatus(self): # SRG? = "\x04" (Query Status Register Value) # SRG? 1 1 # Check status # hexadecimal number, a bitmap corresponding to status flags (cf documentation) # Ex: 0x9004 bitmap = self._sendQueryCommand("\x04") assert(bitmap.startswith("0x")) value = int(bitmap[2:], 16) # TODO change to constants return value def IsReady(self): """ return (boolean): True if ready for new command """ # "\x07" (Request Controller Ready Status) # returns 177 if ready, 178 if not ans = self._sendQueryCommand("\x07") if ans == "\xb1": return True elif ans == "\xb0": return False logging.warning("Controller %s replied unknown ready status '%s'", self.address, ans) return None def IsReferenced(self, axis): """ Report whether the given axis has been referenced Note: setting position with RON disabled will also put it in this mode axis (1<int<16): axis number returns (bool) """ # FRF? (Get Referencing Result) # 1 => True, 0 => False return self._readAxisValue("FRF?", axis) == 1 def IsOnTarget(self, axis, check=True): """ Report whether the given axis is considered on target (for closed-loop moves only) axis (1<int<16): axis number returns (bool) raise PIGCSError if check is True and an error on a controller happened """ # ONT? (Get On Target State) # 1 => True, 0 => False # cf parameters 0x3F (settle time), and 0x4D (algo), 0x406 (window size) # 0x407 (window off size) if check: com = ["ERR?\n", "ONT? %d\n" % (axis,)] lresp = self._sendQueryCommand(com) err = int(lresp[0]) if err: raise PIGCSError(err) r = lresp[1] ss = r.split("=") if len(ss) != 2: raise ValueError("Failed to parse answer from %s: '%s'" % (com, lresp)) return (ss[1] == "1") else: return self._readAxisValue("ONT?", axis) == 1 def GetErrorNum(self): """ return (int): the error number (can be negative) of last error See p.192 of manual for the error codes """ # ERR? (Get Error Number): get error code of last error answer = self._sendQueryCommand("ERR?\n") error = int(answer) return error def Reboot(self): self._sendOrderCommand("RBT\n") # empty the serial buffer self.busacc.flushInput() # Sending commands before it's fully rebooted can seriously mess it up. # It might end up in a state where only power cycle can reset it. # Give it some time to reboot before it's accessible again. time.sleep(2) self.busacc.flushInput() def RelaxPiezos(self, axis): """ Call relaxing procedure. Reduce voltage, to increase lifetime and needed to change between modes axis (1<int<16): axis number """ # RNP (Relax PiezoWalk Piezos): reduce voltage when stopped to increase lifetime # Also needed to change between nanostepping and analog assert(axis in self._channels) self._sendOrderCommand("RNP %d 0\n" % axis) def Halt(self, axis=None): """ Stop motion with deceleration Note: see Stop axis (1<int<16): axis number, """ # HLT (Stop All Axes): immediate stop (high deceleration != HLT) # set error code to 10 # => Hold the access to the serial bus until we get rid of the error with self.busacc.ser_access: if axis is None: self._sendOrderCommand("HLT\n") else: assert(axis in self._channels) self._sendOrderCommand("HLT %d\n" % axis) # need to recover from the "error", otherwise nothing works error = self.GetErrorNum() if error != 10: # PI_CNTR_STOP logging.warning("Stopped controller %s, but error code is %d instead of 10", self.address, error) def Stop(self): """ Stop immediately motion on all axes Note: it's not efficient enough with SMO commands """ # STP = "\x18" (Stop All Axes): immediate stop (high deceleration != HLT) # set error code to 10 # => Hold the access to the serial bus until we get rid of the error # TODO: could be a lock just on this controller with self.busacc.ser_access: self._sendOrderCommand("\x18") # need to recover from the "error", otherwise nothing works error = self.GetErrorNum() if error != 10: # PI_CNTR_STOP logging.warning("Stopped controller %s, but error code is %d instead of 10", self.address, error) def SetServo(self, axis, activated): """ Activate or de-activate the servo. Note: only activate it if there is a sensor (cf .HasRefSwitch and ._hasRefSwitch) axis (1<int<16): axis number activated (boolean): True if the servo should be activated (closed-loop) """ # SVO (Set Servo State) assert(axis in self._channels) if activated: # assert(self._hasRefSwitch[axis]) state = 1 else: state = 0 # FIXME: on E861 it seems recommended to first relax piezo. # On C867, it's RNP doesn't exists self._sendOrderCommand("SVO %d %d\n" % (axis, state)) def SetReferenceMode(self, axis, absolute): """ Select the reference mode. Note: only useful for closed-loop moves axis (1<int<16): axis number absolute (bool): If True, absolute moves can be used, but needs to have been referenced. If False only relative moves can be used, but only needs a sensor to be used. """ # RON (Set Reference Mode) assert(axis in self._channels) if absolute: assert(self._hasLimitSwitches[axis] or self._hasRefSwitch[axis]) state = 1 else: state = 0 self._sendOrderCommand("RON %d %d\n" % (axis, state)) # Functions for relative move in open-loop (no sensor) def OLMoveStep(self, axis, steps): """ Moves an axis for a number of steps. Can be done only with servo off. If the axis is already moving, the number of steps to perform is reset to the new number. IOW, it is not added up. axis (1<int<16): axis number steps (float): number of steps to do (can be a float). If negative, goes the opposite direction. 1 step is about 10µm. """ # OSM (Open-Loop Step Moving): move using nanostepping assert(axis in self._channels) if steps == 0: return self._sendOrderCommand("OSM %d %.5g\n" % (axis, steps)) def SetStepAmplitude(self, axis, amplitude): """ Set the amplitude of one step (in nanostep mode). It affects the velocity of OLMoveStep. Note: probably it's best to set it to 55 and use OVL to change speed. axis (1<int<16): axis number amplitude (0<=float<=55): voltage applied (the more the further) """ # SSA (Set Step Amplitude) : for nanostepping assert(axis in self._channels) assert((0 <= amplitude) and (amplitude <= 55)) self._sendOrderCommand("SSA %d %.5g\n" % (axis, amplitude)) def GetStepAmplitude(self, axis): """ Get the amplitude of one step (in nanostep mode). Note: mostly just for self-test axis (1<int<16): axis number returns (0<=float<=55): voltage applied """ # SSA? (Get Step Amplitude), returns something like: # 1=10.0000 assert(axis in self._channels) answer = self._sendQueryCommand("SSA? %d\n" % axis) amp = float(answer.split("=")[1]) return amp def OLAnalogDriving(self, axis, amplitude): """ Use analog mode to move the axis by a given amplitude. axis (1<int<16): axis number amplitude (-55<=float<=55): Amplitude of the move. It's only a small move. 55 is approximately 5 um. """ # OAD (Open-Loop Analog Driving): move using analog assert(axis in self._channels) assert((-55 <= amplitude) and (amplitude <= 55)) self._sendOrderCommand("OAD %d %.5g\n" % (axis, amplitude)) def GetOLVelocity(self, axis): """ Get velocity for open-loop montion. axis (1<int<16): axis number return float: velocity in step-cycles/s """ assert(axis in self._channels) return self._readAxisValue("OVL?", axis) def SetOLVelocity(self, axis, velocity): """ Set velocity for open-loop nanostepping motion. axis (1<int<16): axis number velocity (0<float): velocity in step-cycles/s. Default is 200 (~ 0.002 m/s) """ # OVL (Set Open-Loop Velocity) assert(axis in self._channels) assert(velocity > 0) self._sendOrderCommand("OVL %d %.5g\n" % (axis, velocity)) def GetOLAcceleration(self, axis): """ Get acceleration for open-loop montion. axis (1<int<16): axis number return float: acceleration in step-cycles/s² """ assert(axis in self._channels) return self._readAxisValue("OAC?", axis) def SetOLAcceleration(self, axis, value): """ Set open-loop acceleration of given axis. axis (1<int<16): axis number value (0<float): acceleration in step-cycles/s². Default is 2000 """ # OAC (Set Open-Loop Acceleration) assert(axis in self._channels) assert(value > 0) self._sendOrderCommand("OAC %d %.5g\n" % (axis, value)) def SetOLDeceleration(self, axis, value): """ Set the open-loop deceleration. axis (1<int<16): axis number value (0<float): deceleration in step-cycles/s². Default is 2000 """ # ODC (Set Open-Loop Deceleration) assert(axis in self._channels) assert(value > 0) self._sendOrderCommand("ODC %d %.5g\n" % (axis, value)) # Methods for closed-loop functionality. For all of them, servo must be on def MoveAbs(self, axis, pos): """ Start an absolute move of an axis to specific position. Can only be done with servo on and referenced. axis (1<int<16): axis number pos (float): position in "user" unit """ # MOV (Set Target Position) assert(axis in self._channels) self._sendOrderCommand("MOV %d %.5g\n" % (axis, pos)) def MoveRel(self, axis, shift): """ Start an relative move of an axis to specific position. Can only be done with servo on and referenced. If the axis is moving, the target position is updated, and so the moves will add up. axis (1<int<16): axis number shift (float): change of position in "user" unit """ # MVR (Set Target Relative To Current Position) assert(axis in self._channels) self._sendOrderCommand("MVR %d %.5g\n" % (axis, shift)) def ReferenceToLimit(self, axis, lim=1): """ Start to move the axis to the switch position (typically, the center) Note: Servo and referencing must be on See IsReferenced() axis (1<int<16): axis number lim (-1 or 1): -1 for negative limit and 1 for positive limit """ # FNL (Fast Reference Move To Negative Limit) # FPL (Fast Reference Move To Positive Limit) assert(axis in self._channels) assert(lim in (-1, 1)) if lim == 1: self._sendOrderCommand("FPL %d\n" % axis) else: self._sendOrderCommand("FNL %d\n" % axis) def ReferenceToSwitch(self, axis): """ Start to move the axis to the switch position (typically, the center) Note: Servo and referencing must be on See IsReferenced() axis (1<int<16): axis number """ # FRF (Fast Reference Move To Reference Switch) assert(axis in self._channels) self._sendOrderCommand("FRF %d\n" % axis) def AutoZero(self, axes=None, voltage=None): """ Set Automatic Zero Calibration Point. Runs the calibration procedure. cf E-725 manual p. 29. axes (None or list of int): If None, all axes, otherwise a set of axes voltage (None or list of floats): If None, uses the default low voltage, otherwise uses the voltage given for each axis Note that the axes on which it is not run are automatically reset. So the recommanded usage is to not set any arguments. Check it is over by using GetMotionStatus() """ acmd = "" if axes is not None: for i, a in enumerate(axes): if voltage is None: acmd += " %d NAN" % (a,) else: acmd += " %d %g" % (a, voltage[i]) self._sendOrderCommand("ATZ%s\n" % acmd) def GetAutoZero(self, axis): """ Return the status of the Auto Zero procedure for the given axis axis (1<int<16): axis number return (bool): True if successfull, False otherwise """ ans = self._readAxisValue("ATZ?", axis) return ans == 1 def GetPosition(self, axis): """ Get the position (in "user" units) axis (1<int<16): axis number return (float): pos can be negative Note: after referencing, a constant is added by the controller """ # POS? (GetRealPosition) return self._readAxisValue("POS?", axis) def GetTargetPosition(self, axis): """ Get the target position (in "user" units) Note: only works for closed loop controllers axis (1<int<16): axis number return (float): pos can be negative """ # MOV? (Get Target Position) return self._readAxisValue("MOV?", axis) def SetPosition(self, axis, pos): """ Assign a position value (in "user" units) for the current location. No move is performed. axis (1<int<16): axis number pos (float): pos can be negative """ # POS (SetRealPosition) return self._sendOrderCommand("POS %d %.5g\n" % (axis, pos)) def GetMinPosition(self, axis): """ Get the minimum reachable position (in "user" units) axis (1<int<16): axis number return (float): pos can be negative """ # TMN? (Get Minimum Commandable Position) return self._readAxisValue("TMN?", axis) def GetMaxPosition(self, axis): """ Get the maximum reachable position (in "user" units) axis (1<int<16): axis number return (float): pos can be negative """ # TMX? (Get Maximum Commandable Position) assert(axis in self._channels) return self._readAxisValue("TMX?", axis) def GetCLVelocity(self, axis): """ Get velocity for closed-loop montion. axis (1<int<16): axis number """ # VEL (Get Closed-Loop Velocity) assert(axis in self._channels) return self._readAxisValue("VEL?", axis) def SetCLVelocity(self, axis, velocity): """ Set velocity for closed-loop montion. axis (1<int<16): axis number velocity (0<float): velocity in units/s """ # VEL (Set Closed-Loop Velocity) assert(axis in self._channels) assert(velocity > 0) self._sendOrderCommand("VEL %d %.5g\n" % (axis, velocity)) def GetCLAcceleration(self, axis): """ Get acceleration for closed-loop montion. axis (1<int<16): axis number """ # VEL (Get Closed-Loop Acceleration) assert(axis in self._channels) return self._readAxisValue("ACC?", axis) def SetCLAcceleration(self, axis, value): """ Set closed-loop acceleration of given axis. axis (1<int<16): axis number value (0<float): acceleration in units/s² """ # ACC (Set Closed-Loop Acceleration) assert(axis in self._channels) assert(value > 0) self._sendOrderCommand("ACC %d %.5g\n" % (axis, value)) def SetCLDeceleration(self, axis, value): """ Set the closed-loop deceleration. axis (1<int<16): axis number value (0<float): deceleration in units/s² """ # DEC (Set Closed-Loop Deceleration) assert(axis in self._channels) assert(value > 0) self._sendOrderCommand("DEC %d %.5g\n" % (axis, value)) def SetRecordRate(self, value): """ Set the record table rate Note: on the E-861, a cycle is 20µs value (1<= int): number of cycles when recording. """ assert(value > 0) self._sendOrderCommand("RTR %d\n" % (value,)) def GetRecordRate(self, value): """ Get the record table rate Note: on the E-861, a cycle is 20µs return (1<= int): number of cycles when recording """ ans = self._sendQueryCommand("RTR?\n") return int(ans) def SetRecordConfig(self, table, source, opt): """ Set Data Recorder Configuration table (1<=int): record table ID source (0<=int): Depends on the option. For axis related signal, it's the axis number opt (0<=int): type of signal to be recorded. See documentation for values. """ assert(table > 0) assert(source >= 0) assert(opt >= 0) self._sendOrderCommand("DRC %d %d %d\n" % (table, source, opt)) def SetRecordTrigger(self, table, source, val): """ Set Data Recorder Configuration table (0<=int): record table ID or 0 for all the tables source (0<=int): ID of the trigger source, see documentation for values. 0 = STE, 1 = any command moving, 2 = any command val (0<=int): Depends on the source. See documentation for values. """ assert(table >= 0) assert(source >= 0) assert(val >= 0) self._sendOrderCommand("DRT %d %d %d\n" % (table, source, val)) def GetRecordedData(self, start=None, num=None, table=None): """ Get the recorded data start (None or 1<=int): first item to be read. If None, it will read everything. num (None or 1<=int): number of items to read. If None, start must also be None. table (None or 1<=int): record table ID. If None, it will read all the tables. return (list of tuple of floats): for each cycle, the values for each table """ assert(start is None or start > 0) assert(num is None or num > 0) assert((start is None) == (num is None)) assert(table is None or table > 0) if start is None and table is not None: raise ValueError("Table must be None if start/num are None") # Answer should look like: # # REM E-861 # # # : # # # # NAME0 = Actual Position of Axis AXIS:1 # # NAME1 = Position Error of Axis AXIS:1 # # # # END_HEADER # 5.00000 0.00000 # 4.99998 0.00002 # 5.00000 0.00000 # 5.00000 0.00000 # 5.00000 0.00000 args = "" if start is not None: args += " %d %d" % (start, num) if table is not None: args += " %d" % (table,) ans = self._sendQueryCommand("DRR?%s\n" % (args,)) data = [] for l in ans: if l.startswith("#"): logging.debug("Skipping line %s", l) continue try: vals = tuple(float(s) for s in l.split(" ")) data.append(vals) except ValueError: logging.warning("Failed to decode data line %s", l) return data def MoveRelRecorded(self, axis, shift): """ Moves an axis for a given distance. While it's moving, data will be recorded. Can be done only if not referenced. axis (1<int<16): axis number shift (float): relative distance in user unit """ assert(axis in self._channels) self._sendOrderCommand("STE %d %.5g\n" % (axis, shift)) # Different from OSM because they use the sensor and are defined in physical unit. # Servo must be off! => Probably useless... compared to MOV/MVR # OMR (Relative Open-Loop Motion) # OMA (Absolute Open-Loop Motion) # # Below are methods for manipulating the controller def getModel(self): """ returns a model constant """ idn = self.GetIdentification() for c, m in self.idn_matches.items(): if re.search(m, idn): return c return MODEL_UNKNOWN def checkError(self): """ Check whether the controller has reported an error return nothing raise PIGCSError if an error on a controller happened """ err = self.GetErrorNum() if err: raise PIGCSError(err) def _storeMove(self, axis, shift, duration): """ Save move information for interpolating the position To be called when a new move is started axis (int): the channel shift (float): relative change in position (im m) duration (0<float): time it will take (in s) """ now = time.time() cur_pos = self._interpolatePosition(axis) self._position[axis] = cur_pos self._start_move[axis] = now self._end_move[axis] = now + duration self._target[axis] = cur_pos + shift def _storeStop(self, axis): """ Save the fact that a move was stop immediately (maybe not achieved) """ self._position[axis] = self._interpolatePosition(axis) self._target[axis] = self._position[axis] self._end_move[axis] = 0 def _storeMoveComplete(self, axis): """ Save the fact that the current move is complete (even if the end time is not yet achieved) """ self._position[axis] = self._target.get(axis, self._position[axis]) self._end_move[axis] = 0 def _interpolatePosition(self, axis): """ return (float): interpolated position at the current time """ now = time.time() end_move = self._end_move[axis] if now > end_move: target = self._target.get(axis, self._position[axis]) logging.debug("Interpolating move by reporting target position: %g", target) self._end_move[axis] = 0 return target else: start = self._start_move[axis] completion = (now - start) / (end_move - start) pos = self._position[axis] cur_pos = pos + (self._target[axis] - pos) * completion logging.debug("Interpolating move to %g %% of complete move: %g", completion * 100, cur_pos) return cur_pos def getPosition(self, axis): """ Note: in open-loop mode it's very approximate (and interpolated) return (float): the current position of the given axis """ # This is using interpolation, closed-loop must override this method assert(axis in self._channels) # make sure that if a move finished early, we report the final position if self._end_move[axis] != 0 and not self.isMoving({axis}): self._storeMoveComplete(axis) return self._interpolatePosition(axis) def setSpeed(self, axis, speed): """ Changes the move speed of the motor (for the next move). Note: in open-loop mode, it's very approximate. speed (0<float<10): speed in m/s. axis (1<=int<=16): the axis """ assert (axis in self._channels) assert (self.speed_rng[axis][0] <= speed <= self.speed_rng[axis][1]) self._speed[axis] = speed def getSpeed(self, axis): return self._speed[axis] def getAccel(self, axis): return self._accel[axis] def moveRel(self, axis, distance): """ Move on a given axis for a given distance. It's asynchronous: the method might return before the move is complete. axis (1<=int<=16): the axis distance (float): the distance of move in m (can be negative) returns (float): approximate distance actually moved """ raise NotImplementedError("This method must be overridden by a subclass") def moveAbs(self, axis, position): """ Move on a given axis to a given position. It's asynchronous: the method might return before the move is complete. axis (1<=int<=16): the axis position (float): the target position in m (can be negative) returns (float): approximate distance actually moved """ # This is a default implementation relying on the moveRel # It should be overriden, if it can be done directly old_pos = self.getPosition(axis) shift = position - old_pos return self.moveRel(axis, shift) def isMoving(self, axes=None): """ Indicate whether the motors are moving. axes (None or set of int): axes to check whether for move, or all if None return (boolean): True if at least one of the axes is moving, False otherwise raise PIGCSError if an error on a controller happened """ # TODO: the interface is not useful, we typically want to know whether # each axis is moving or not, so for now all the callers do one axis at # a time => return a set(int) = axes moving? or just take one axis? if axes is None: axes = self._channels else: assert axes.issubset(self._channels) # Note that "isOnTarget" would also work (both for OL and CL), but it # takes more characters and for CL, we need a more clever code anyway return not axes.isdisjoint(self.GetMotionStatus()) def stopMotion(self): """ Stop the motion on all axes immediately """ self.Stop() def waitEndMotion(self, axes=None): """ Wait until the motion of all the given axis is finished. Note: there is a 5 s timeout axes (None or set of int): axes to check whether for move, or all if None """ timeout = 5 # s end = time.time() + timeout while self.isMoving(axes): if time.time() >= end: raise IOError("Timeout while waiting for end of motion") time.sleep(0.005) def isReferenced(self, axis): """ return (bool or None): None if the axis cannot be referenced, or a boolean indicating the status of the referencing. """ return None def selfTest(self): """ check as much as possible that it works without actually moving the motor return (boolean): False if it detects any problem """ try: error = self.GetErrorNum() if error: logging.warning("Controller %s had error status %d", self.address, error) version = self.GetSyntaxVersion() logging.info("GCS version: '%s'", version) ver_num = float(version) if ver_num < 1 or ver_num > 2: logging.error("Controller %s has unexpected GCS version %s", self.address, version) return False axes = self.GetAxes() if len(axes) == 0 or len(axes) > 16: logging.error("Controller %s report axes %s", self.address, str(axes)) return False if self._model in (MODEL_E861,): # support open-loop mode for a in self._channels: self.SetStepAmplitude(a, 10) amp = self.GetStepAmplitude(a) if amp != 10: logging.error("Failed to modify amplitude of controller %s (%f instead of 10)", self.address, amp) return False if self._model in (MODEL_C867,): # support temperature reading # No support for direct open-loop mode # TODO put the temperature as a RO VA? current_temp = float(self.GetParameter(1, 0x57)) max_temp = float(self.GetParameter(1, 0x58)) if current_temp >= max_temp: logging.error("Motor of controller %s too hot (%f C)", self.address, current_temp) return False except Exception: return False return True @staticmethod def scan(busacc, max_add=16): """ Scan the serial network for all the PI GCS compatible devices available. Note this is the low-level part, you probably want to use Controller.scan() for scanning devices on a computer. bus: the bus max_add (1<=int<=16): maximum address to scan return (dict int -> tuple): addresses of available controllers associated to number of axes, and presence of limit switches/sensor """ ctrl = Controller(busacc, _stem=True) present = {} for i in range(1, max_add + 1): # ask for controller #i logging.debug("Querying address %d", i) # is it answering? try: ctrl.address = i ctrl._avail_cmds = ctrl.GetAvailableCommands() axes = {} for a in ctrl.GetAxes(): axes = {a: ctrl.HasRefSwitch(a)} if not axes: logging.info("Found controller %d with no axis", i) else: version = ctrl.GetIdentification() logging.info("Found controller %d with ID '%s'.", i, version) present[i] = axes except IOError: pass ctrl.address = None return present class CLAbsController(Controller): """ Controller managed via closed-loop commands and which is always referenced (ex: E-725 with scan stage). """ def __init__(self, busacc, address=None, axes=None): super(CLAbsController, self).__init__(busacc, address, axes) self._upm = {} # ratio to convert values in user units to meters # For _getPositionCached() self._lastpos = {} # axis (int) -> (pos (float), timestamp (float)) # It's pretty much required to reference the axes, and fast and # normally not dangerous (travel range is very small). # It's also import to reference all the axes simultaneously # TODO: just use a standard parameter to request referencing on init? # TODO: only do if needed referenced = all(self.isReferenced(a) for a in axes) if not referenced: logging.info("Referencing the axes (via AutoZero)") self.AutoZero() tstart = time.time() while self.GetMotionStatus(): time.sleep(0.01) if time.time() > tstart + 10: self.stopMotion() raise IOError("AutoZero refenrencing is taking more that 10s, stopping") logging.debug("Referencing took %f s", time.time() - tstart) for a, cl in axes.items(): if a not in self._channels: raise LookupError("Axis %d is not supported by controller %s" % (a, address)) if not cl: # want open-loop? raise ValueError("Initialising CLAbsController with request for open-loop") # Check the unit is um # TODO: cf PUN? Seems less supported than the parameter (eg, E-861 doesn't) unit = self.GetParameter(a, 0x7000601) if unit.lower() == "um": self._upm[a] = 1e-6 # m else: raise IOError("Controller %s configured with unit %s, but only " "micrometers (UM) is supported." % (address, unit)) # Start the closed loop self.SetServo(a, True) self._lastpos[a] = (None, 0) # Looong time ago not read # Movement range before referencing is max range in both directions self.pos_rng[a] = (self.GetMinPosition(a) * self._upm[a], self.GetMaxPosition(a) * self._upm[a]) # Read speed/accel ranges self._speed[a] = self.GetCLVelocity(a) * self._upm[a] # m/s # TODO: get range from the parameters? self.speed_rng[a] = (10e-6, 1) # m/s (default large values) # Doesn't support accel setting => just assume it's very high (to not wait too long for a move) self._accel[a] = self._speed[a] * 1000 # m/s² # self._accel[a] = self.GetCLAcceleration(a) * self._upm[a] # m/s² # TODO: sometimes (mostly after autozero) the axis position might # be slightly outside of the range, which tends to confuse the clients. # => move to the closest allowed position automatically? def terminate(self): super(CLAbsController, self).terminate() # Disable servo, to allow the user to move the axis manually for a in self._channels: self.SetServo(a, False) def moveRel(self, axis, distance): """ See Controller.moveRel """ assert(axis in self._channels) # self._updateSpeedAccel(axis) # We trust the caller that it knows it's in range # (worst case the hardware will not go further) self.MoveRel(axis, distance / self._upm[axis]) self.checkError() self._lastpos[axis] = (None, 0) return distance def moveAbs(self, axis, position): """ See Controller.moveAbs """ # TODO: support multiple axes to reduce init latency? assert(axis in self._channels) # TODO # self._updateSpeedAccel(axis) # We trust the caller that it knows it's in range # (worst case the hardware will not go further) old_pos = self.getPosition(axis, maxage=1) # It's just a rough estimation anyway self.MoveAbs(axis, position / self._upm[axis]) self.checkError() distance = position - old_pos self._lastpos[axis] = (None, 0) return distance def getPosition(self, axis, maxage=0): """ Find current position as reported by the sensor axis (int) maxage (0 < float): maximum time (in s) since last reading before the position will be re-read from the hardware. return (float): the current position of the given axis """ # Use cached info if it's not too old if maxage > 0: pos, ts = self._lastpos[axis] if time.time() - ts < maxage: return pos pos = self.GetPosition(axis) * self._upm[axis] self._lastpos[axis] = (pos, time.time()) return pos def isMoving(self, axes=None): """ Indicate whether the motors are moving (ie, last requested move is over) axes (None or set of int): axes to check whether for move, or all if None return (boolean): True if at least one of the axes is moving, False otherwise raise PIGCSError: if there is an error with the controller """ if axes is None: axes = set(self._upm.keys()) else: assert axes.issubset(self._channels) # With servo on, it might constantly be _slightly_ moving (around the # target), so it's much better to use IsOnTarget info. The controller # needs to be correctly configured with the right window size. for a in axes: if not self.IsOnTarget(a): return True return False # TODO allow to reference, but need to get multiple axes, and to check the # status, isMoving() cannot be used, but just GetMotionStatus() # def startReferencing(self, axis): def isReferenced(self, axis): """ returns (bool or None): True if the axis is referenced, or None if it's not possible """ return self.GetAutoZero(axis) # Messages to the encoder manager MNG_TERMINATE = "T" MNG_START = "S" # To stop the encoder: send a float representing the earliest time at which it is # possible to stop it. 0 will stop it immediately. class CLRelController(Controller): """ Controller managed via closed-loop commands (ex: C-867 with encoder). Note that it knows if there is a reference or a limit switch only based on what is written in the controller parameters. If none are available, referencing will not be available. """ # TODO: For now, only relative moves are supported. # For supporting absolute moves, we need to add querying and requesting # "homing" procedure. Then the position would reset to 0 (and that's it # from the user's point of view). def __init__(self, busacc, address=None, axes=None, auto_suspend=10): """ auto_suspend (False or 0 < float): delay before turning off the servo and encoder after a normal move. Useful as the encoder might cause some warm up, and also ensures that no vibrations are caused by trying to stay on target. """ super(CLRelController, self).__init__(busacc, address, axes) self._upm = {} # ratio to convert values in user units to meters if not (auto_suspend is False or auto_suspend > 0): raise ValueError("auto_suspend should be False or > 0 but got %s" % (auto_suspend,)) self._auto_suspend = auto_suspend # for managing starting/stopping the encoder: # * one queue to request turning on/off the encoder and terminating the thread # It uses MNG_TERMINATE, MNG_START, and a float to indicate the time # at which it should be stopped earliest. # * one event to know when the encoder is ready self._suspend_req = {} self._axis_ready = {} self._encoder_mng = {} self._pos_lock = {} # acquire to read/write position self._slew_rate = {} # in s, copy of 0x7000002: slew rate, for E-861 for a, cl in axes.items(): if a not in self._channels: raise LookupError("Axis %d is not supported by controller %d" % (a, address)) if not cl: # want open-loop? raise ValueError("Initialising CLRelController with request for open-loop") if not self._hasRefSwitch[a]: logging.warning("Closed-loop control requested but controller " "%d reports no reference sensor for axis %d", address, a) # Check the unit is mm unit = self.GetParameter(a, 0x7000601).lower() if unit == "mm": self._upm[a] = 1e-3 elif unit == "um": self._upm[a] = 1e-6 else: raise IOError("Controller %d configured with unit %s, but only " "millimeters (mm) is supported." % (address, unit)) # To be taken when reading position or affecting encorder reading self._pos_lock[a] = threading.RLock() # We have two modes for auto_suspend: # * Servo and encoder off: used when encoders can be turned off. # That typically happens with the C-867. It allows to reduce heat # due to encoder using infra-red light (and ensures the motor # doesn't move. # * PID values set to 0,0,0: used when encoders cannot be turned off. # That typically happens with the E-861. It allows to still # follow slowly (~10 nm/s) the encoder position, to compensate # for drift. It also avoids going through the piezo "relax" # procedure that takes time (4 x slew rate) and causes up to # 100 nm move. if 0x56 in self._avail_params: # Parameter to control encoder power self._servo_suspend = True if self._auto_suspend: logging.info("Will turn off servo when axis not in use") else: self._servo_suspend = False # Save the "real" PID values, from the EEPROM, so that even if # the driver catastrophically finished with PID set to 0,0,0 , # we will use the correct values. self._pid = tuple(int(self.GetParameterNonVolatile(a, p)) for p in (1, 2, 3)) # Activate the servo from now on self._startServo(a) if self._auto_suspend: logging.info("Will use PID = 0,0,0 when axis not in use") try: # Only exists on E-861 (and only used when _servo_suspend == True) # slew rate is stored in ms self._slew_rate[a] = float(self.GetParameter(a, 0x7000002)) * self._upm[a] except ValueError: # param doesn't exist => no problem pass self.canUpdate[a] = True # TODO: # * if not referenced => disable reference mode to be able to # move relatively (until referencing happens). Use the position as # is, so that if no referencing ever happens, at least the position # is correctly as long as the controller is powered. # * if referenced => beleive it and stay in this mode. # At start, the encoder is either on or (probably) off. In any # case, the current position is the most likely one: either it has # moved with the encoder off, and the position is entirely unknown # anyway, or it hasn't moved and the position is correct. # Movement range before referencing is max range in both directions pos = self.GetPosition(a) * self._upm[a] width = (self.GetMaxPosition(a) - self.GetMinPosition(a)) * self._upm[a] # TODO: check that if the stage starts at a limit, it's still possible # to reach the other side (with relative moves) even if the travel # range limits it. # If not => need to read the range from non-volative memory, and # then double the range (not just in Python but also) in volatile # memory. self.pos_rng[a] = (pos - width, pos + width) # Read speed/accel ranges self._speed[a] = self.GetCLVelocity(a) * self._upm[a] # m/s self._accel[a] = self.GetCLAcceleration(a) * self._upm[a] # m/s² try: max_speed = float(self.GetParameter(a, 0xA)) * self._upm[a] # m/s # max_accel = float(self.GetParameter(a, 0x4A)) * self._upm[a] # m/s² except (IOError, ValueError): max_speed = self._speed[a] # max_accel = self._accel[a] self.speed_rng[a] = (10e-6, max_speed) # m/s (default low value for min) self._suspendAxis(a) # in case it was not off yet self._suspend_req[a] = Queue.Queue() self._axis_ready[a] = threading.Event() t = threading.Thread(target=self._suspend_mng_run, name="Suspend manager ctrl %d axis %d" % (address, a), args=(a,)) t.daemon = True self._encoder_mng[a] = t t.start() self._prev_speed_accel = ({}, {}) def terminate(self): super(CLRelController, self).terminate() # Disable servo, to allow the user to move the axis manually for a in self._channels: self._suspend_req[a].put(MNG_TERMINATE) if not self._servo_suspend: # Make sure the PID values are back to the normal move self._resumeAxis(a) self._stopServo(a) def recoverTimeout(self): ret = Controller.recoverTimeout(self) if ret and not self._servo_suspend: try: # We expect the servo to be always on, so put it back on for a in self._upm.keys(): self._startServo(a) except Exception: logging.exception("Failed to restart the servo") return False return ret def _stopServo(self, axis): """ Turn off the servo the supply power of the encoder. That means during this time it's not possible to move the axes. Referencing is lost. Should only be called when no move is taking place. axis (1<=int<=16): the axis """ with self._pos_lock[axis]: self.SetServo(axis, False) # This can only be done if the servo is turned off if 0x56 in self._avail_params: # Store the position before turning off the encoder because while # turning off the encoder, some signal will be received which will # make the controller beleive it has moved. pos = self.GetPosition(axis) self.SetParameter(axis, 0x56, 0) # 0 = off # SetParameter checks the error num, which gives a bit of time to # the encoder signal to fully settle down self.SetPosition(axis, pos) def _startServo(self, axis): """ Turn on the servo and the suplly power of the encoder. axis (1<=int<=16): the axis """ with self._pos_lock[axis]: # Param 0x56 is only for C-867 and allows to control encoder power # Param 0x7000002 is only for E-861 and indicates time to start servo if 0x56 in self._avail_params: pos = self.GetPosition(axis) # Warning: turning on the encoder can reset the USB connection # (if it's on this very controller) # Turning on the encoder resets the current position self.SetParameter(axis, 0x56, 1, check=False) # 1 = on time.sleep(2) # 2 s seems long enough for the encoder to initialise self.SetServo(axis, True) # To allow (relative) moves, even if it's not actually referenced self.SetReferenceMode(axis, False) if 0x56 in self._avail_params: self.SetPosition(axis, pos) if axis in self._slew_rate: # According to the documentation, changing mode can take up to # 4 times the "slew rate". If you don't wait that time before # moving, the move will sometimes fail with error -1008 (BUSY), # and the controller will go crazy causing lots of vibrations # on the axis. # Note: we could try to also check whether the controller is ready # with self.IsReady(), and stop sooner if it's possible). # But that could lead to # orders/queries to several controllers to be intertwined, which # causes sometimes the "garbage" bug. time.sleep(4 * self._slew_rate[axis]) # The controller is normally ready, as it should be taken cared by # the slewrate, but check to be really sure. for i in range(100): if self.IsReady(): break logging.debug("Controller not yet ready, waiting a bit more") time.sleep(0.01) else: logging.warning("Controller indicates it's still not ready, but will not wait any longer") def _suspendAxis(self, axis): if self._servo_suspend: self._stopServo(axis) else: # TODO: also start servo if it's off? Or not a big deal here? # Force PID to 0, 0, 0 with self.busacc.ser_access: # To avoid garbage when using IP com self.SetParameter(axis, 1, 0, check=False) # P self.SetParameter(axis, 2, 0, check=False) # I self.SetParameter(axis, 3, 0, check=False) # D try: self.checkError() except PIGCSError as ex: logging.error("Changing PID seems to have failed: %s", ex) def _resumeAxis(self, axis): if self._servo_suspend: self._startServo(axis) else: # The servo should be on all the time, but if for some reason there # was an error, the servo might have been disabled => need to put # it back on now. # Note: We use status as it's a bit faster, but it's not sure # whether all controller will report servo the same way # TODO: use GetServo(axis) if controller is unsupported status = self.GetStatus() if not (status & (1 << 12)): # For E861 and C867, bit 12 = servo on logging.info("Servo of controller %s was off, need to restart it", self.address) self._startServo(axis) # Put back PID values with self.busacc.ser_access: # To avoid garbage when using IP com P, I, D = self._pid self.SetParameter(axis, 1, P, check=False) # P self.SetParameter(axis, 2, I, check=False) # I self.SetParameter(axis, 3, D, check=False) # D try: self.checkError() except PIGCSError as ex: logging.error("Changing PID back seems to have failed: %s", ex) def _suspend_mng_run(self, axis): """ Main loop for encoder manager thread: Turn on/off the encoder based on the requests received """ try: q = self._suspend_req[axis] stopt = None # None if must be on, otherwise time to stop while True: # wait for a new message or for the time to stop the encoder now = time.time() if stopt is None or not q.empty(): msg = q.get() elif now < stopt: # soon time to turn off the encoder timeout = stopt - now try: msg = q.get(timeout=timeout) except Queue.Empty: # time to stop the encoder => just do the loop again continue else: # time to stop # the queue should be empty (with some high likelyhood) logging.debug("Turning off the encoder at %f > %f (queue has %d element)", now, stopt, q.qsize()) self._axis_ready[axis].clear() self._suspendAxis(axis) stopt = None continue # parse the new message logging.debug("Decoding encoder message %s", msg) if msg == MNG_TERMINATE: return elif msg == MNG_START: if not self._axis_ready[axis].is_set(): self._resumeAxis(axis) self._axis_ready[axis].set() stopt = None else: # time at which to stop the encoder stopt = msg except Exception: logging.exception("Encoder manager failed:") finally: logging.info("Encoder manager %d/%s thread over", self.address, axis) def prepareAxisForMove(self, axis): """ Request the axis to be ready for a move. Non-blocking. Can be called before really asking to move to save a bit of time. """ self._suspend_req[axis].put(MNG_START) # Just in case eventually no move is requested, it will automatically # stop the encoder. if self._auto_suspend: self._releaseAxis(axis, delay=10 + self._auto_suspend) def _acquireAxis(self, axis): """ Ensure the axis servo and encoder are on. Need to call _releaseAxis once not needed. It will block until the encoder is actually ready """ # TODO: maybe provide a public method as a non-blocking call, to # allow starting the encoders of multiple axes simultaneously self._suspend_req[axis].put(MNG_START) self._axis_ready[axis].wait() def _releaseAxis(self, axis, delay=0): """ Let the axis servo be turned off (within some time) delay (0<float): time (in s) before actually turning off the encoder """ self._suspend_req[axis].put(time.time() + delay) def _updateSpeedAccel(self, axis): """ Update the speed and acceleration values for the given axis. It's only done if necessary, and only for the current closed- or open- loop mode. axis (1<=int<=16): the axis """ prev_speed = self._prev_speed_accel[0].get(axis, None) new_speed = self._speed[axis] if prev_speed != new_speed: # TODO: check it's within range self.SetCLVelocity(axis, new_speed / self._upm[axis]) self._prev_speed_accel[0][axis] = new_speed prev_accel = self._prev_speed_accel[1].get(axis, None) new_accel = self._accel[axis] if prev_accel != new_accel: # TODO: check it's within range self.SetCLAcceleration(axis, new_accel / self._upm[axis]) self.SetCLDeceleration(axis, new_accel / self._upm[axis]) self._prev_speed_accel[1][axis] = new_accel def moveRel(self, axis, distance): """ See Controller.moveRel """ assert(axis in self._channels) self._acquireAxis(axis) # TODO: instead of handling it ad-hoc for each series of message, put # the trick in the bus accesser: if the last command was an order to # another controller, first force a ERR? on that previous controller, # and then send the requested query. # The E861 over the network controller send (sometimes) garbage if # several controllers get an OSM command without any query in between. # This ensures there is one query after each command. with self.busacc.ser_access: self._updateSpeedAccel(axis) # We trust the caller that it knows it's in range # (worst case the hardware will not go further) self.MoveRel(axis, distance / self._upm[axis]) # In case it's an update, the actual distance can be different # Note: merging the queries doesn't seem to save time... actually it # appears to even slow down the answers (maybe because the controller # waits for more answers to send) pos = self.getPosition(axis) tpos = self.getTargetPosition(axis) act_dist = tpos - pos self.checkError() return act_dist def moveAbs(self, axis, position): """ See Controller.moveAbs """ assert(axis in self._channels) self._acquireAxis(axis) # The E861 over the network controller send (sometimes) garbage if # several controllers get an OSM command without any query in between. # This ensures there is one query after each command. with self.busacc.ser_access: self._updateSpeedAccel(axis) # We trust the caller that it knows it's in range # (worst case the hardware will not go further) # Absolute move is only legal if already referenced. if not self.IsReferenced(axis): # TODO: cache # MoveRel adds to the _target_ position (matters in case of move update) tpos = self.getTargetPosition(axis) distance = position - tpos self.MoveRel(axis, distance / self._upm[axis]) else: self.MoveAbs(axis, position / self._upm[axis]) old_pos = self.getPosition(axis) distance = position - old_pos self.checkError() return distance def getPosition(self, axis): """ Find current position as reported by the sensor return (float): the current position of the given axis """ with self._pos_lock[axis]: return self.GetPosition(axis) * self._upm[axis] def getTargetPosition(self, axis): return self.GetTargetPosition(axis) * self._upm[axis] # Warning: if the settling window is too small or settling time too big, # it might take several seconds to reach target (or even never reach it) def isMoving(self, axes=None): """ Indicate whether the motors are moving (ie, last requested move is over) axes (None or set of int): axes to check whether for move, or all if None return (boolean): True if at least one of the axes is moving, False otherwise raise PIGCSError: if there is an error with the controller """ if axes is None: axes = self._channels else: assert axes.issubset(self._channels) # With servo on, it might constantly be _slightly_ moving (around the # target), so it's much better to use IsOnTarget info. The controller # needs to be correctly configured with the right window size. for a in axes: # A merge of the query with error check causes a long delay (~40 ms) # in the answer if not self.IsOnTarget(a, check=False): return True # Nothing is moving => turn off encoder (in a few seconds) for a in axes: # Note: this will also turn off the servo, which leads to relax mode if self._auto_suspend: self._releaseAxis(a, self._auto_suspend) # release in 10 s (5x the cost to start) return False # TODO: handle the fact that if the stage reaches the physical limit without knowing, # the move will fail with: # PIGCSError: PIGCS error -1024: Motion error: position error too large, servo is switched off automatically # => put back the servo if necessary # => keep checking for errors at the same time as ONT? # FIXME: it seems that on the C867 if the axis is stopped while moving, isontarget() # will sometimes keep saying it's not reached forever. However, the documentation # says that the target position is set to the current position after a # stop (to avoid this very problem). On E861 it does update the target position fine. # Need to investigate # MOV 1 1.1 # MOV? 1 # read target pos # time.sleep(0.01) # ONT? 1 # should be false # STP # also try HLT # MOV? 1 # should be new pos # POS? 1 # Should be very close # ONT? 1 # Should be true at worst a little after the settle time window def stopMotion(self): super(CLRelController, self).stopMotion() for c in self._channels: self._releaseAxis(c, delay=1) def startReferencing(self, axis): """ Start a referencing move. Use isMoving() or isReferenced() to know if the move is over. Position will change, as well as absolute positions. axis (1<=int<=16) """ self._acquireAxis(axis) # Note: setting position only works if ron is disabled. It's possible # also to indirectly set it after referencing, but then it will conflict # with TMN/TMX and some correct moves will fail. # So referencing could look like: # ron 1 1 # frf -> go home and now know the position officially # orig_pos = pos? if self._hasRefSwitch[axis]: self.SetReferenceMode(axis, True) self.ReferenceToSwitch(axis) elif self._hasLimitSwitches[axis]: raise NotImplementedError("Don't know how to reference to limit yet") self.ReferenceToLimit(axis) # TODO: need to do that after the move is complete self.waitEndMotion(set(axis)) # Go to 0 (="home") self.MoveAbs(axis, 0) else: # TODO: we _could_ think of hacky way, such as moving a lot to # one direction to be sure to hit the physical limit, and then # marking it as the lower limit, using the range. raise ValueError("Axis has no reference or limit switch so cannot be referenced") def isReferenced(self, axis): """ returns (bool or None): True if the axis is referenced, or None if it's not possible """ if not self._hasRefSwitch[axis] and not self._hasLimitSwitches[axis]: return None else: return self.IsReferenced(axis) class OLController(Controller): """ Controller managed via standard open-loop commands (ex: E-861) """ def __init__(self, busacc, address=None, axes=None, dist_to_steps=None, min_dist=None): """ dist_to_steps (0 < float): allows to calibrate how many steps correspond to a given distance (in step/m). Default is 1e5, a value that could make sense. min_dist (0 <= float < 1): minimum distance required for the axis to even move (in m). Below this distance, a command will be sent, but it is expected that the actuator doesn't move at all. Default is 0.01 step (= 0.01 / dist_to_steps). """ if dist_to_steps and not (0 < dist_to_steps): raise ValueError("dist_to_steps (%s) must be > 0" % dist_to_steps) if min_dist and not (0 <= min_dist < 1): raise ValueError("min_dist (%s) must be between 0 and 1 m" % min_dist) super(OLController, self).__init__(busacc, address, axes) # TODO: params should be per axis # TODO: allow to pass a polynomial self._dist_to_steps = dist_to_steps or 1e5 # step/m if min_dist is None: self.min_stepsize = 0.01 # step, under this, no move at all else: self.min_stepsize = min_dist * self._dist_to_steps for a, cl in axes.items(): if a not in self._channels: raise LookupError("Axis %d is not supported by controller %d" % (a, address)) if cl: # want closed-loop? raise ValueError("Initialising OLController with request for closed-loop") # that should be the default, but for safety we force it self.SetServo(a, False) self.SetStepAmplitude(a, 55) # maximum is best self._position[a] = 0 # TODO: use LIM? values * 2, as for the CLRel version? # Unknown range => give room self.pos_rng[a] = (-1, 1) # m try: # (max m/s) = (max step/s) * (step/m) max_speed = float(self.GetParameter(1, 0x7000204)) / self._dist_to_steps # m/s # Note: the E-861 claims max 0.015 m/s but actually never goes above 0.004 m/s # (max m/s²) = (max step/s²) * (step/m) # max_accel = float(self.GetParameter(1, 0x7000205)) / self._dist_to_steps # m/s² except (IOError, ValueError) as err: # TODO use CL info if not available? # TODO detect better that it's just a problem of sending unsupported command/value # Put default (large values) self.GetErrorNum() # reset error (just in case) max_speed = 0.5 # m/s # max_accel = 0.01 # m/s² logging.debug("Using default speed value after error '%s'", err) # TODO just read the current values self.speed_rng[a] = (10e-6, max_speed) # m/s (default low value) self._speed[a] = (self.speed_rng[a][0] + self.speed_rng[a][1]) / 2 # m/s # acceleration (and deceleration) try: self._accel[a] = self.GetOLAcceleration(a) / self._dist_to_steps # m/s² (both acceleration and deceleration) except (IOError, NotImplementedError): try: # Try with the parameter (for older versions of E-861) self._accel[a] = float(self.GetParameter(1, 0x7000202)) / self._dist_to_steps # m/s² except (IOError, ValueError) as err: self._accel[a] = 0.01 # m/s² # Unknown logging.debug("Using default acceleration value after error '%s'", err) self._prev_speed_accel = ({}, {}) def _convertDistanceToDevice(self, distance): """ converts meters to the unit for this device (steps) in open-loop. distance (float): meters (can be negative) return (float): number of steps, <0 if going opposite direction 0 if too small to move. """ steps = distance * self._dist_to_steps if abs(steps) < self.min_stepsize: return 0 return steps def _convertSpeedToDevice(self, speed): """ converts meters/s to the unit for this device (steps/s) in open-loop. distance (float): meters/s (can be negative) return (float): number of steps/s, <0 if going opposite direction """ steps_ps = speed * self._dist_to_steps return max(1, steps_ps) # don't go at 0 m/s! # in linear approximation, it's the same _convertAccelToDevice = _convertSpeedToDevice def _updateSpeedAccel(self, axis): """ Update the speed and acceleration values for the given axis. It's only done if necessary, and only for the current closed- or open- loop mode. axis (1<=int<=16): the axis """ prev_speed = self._prev_speed_accel[0].get(axis, None) new_speed = self._speed[axis] if prev_speed != new_speed: steps_ps = self._convertSpeedToDevice(new_speed) self.SetOLVelocity(axis, steps_ps) self._prev_speed_accel[0][axis] = new_speed prev_accel = self._prev_speed_accel[1].get(axis, None) new_accel = self._accel[axis] if prev_accel != new_accel: steps_pss = self._convertAccelToDevice(new_accel) self.SetOLAcceleration(axis, steps_pss) self.SetOLDeceleration(axis, steps_pss) self._prev_speed_accel[1][axis] = new_accel def moveRel(self, axis, distance): """ See Controller.moveRel """ assert(axis in self._channels) self._updateSpeedAccel(axis) steps = self._convertDistanceToDevice(distance) if steps == 0: # if distance is too small, report it return 0 # TODO: try to move anyway, just in case it works self.OLMoveStep(axis, steps) # TODO use OLAnalogDriving for very small moves (< 5µm)? # Warning: this is not just what is looks like! # The E861 over the network controller send (sometimes) garbage if # several controllers get an OSM command without any query in between. # This ensures there is one query after each command. self.checkError() duration = abs(distance) / self._speed[axis] self._storeMove(axis, distance, duration) return distance # TODO: call RelaxPiezos after the end of a move def stopMotion(self): super(OLController, self).stopMotion() for c in self._channels: self._storeStop(c) self.RelaxPiezos(c) class SMOController(Controller): """ Controller managed via the test open-loop command "SMO" (ex: C-867) """ def __init__(self, busacc, address=None, axes=None, vmin=2., speed_base=0.03): """ vmin (0.5 < float < 10): lowest voltage at which the actuator moves reliably in V. This is the voltage used when performing small moves (~< 50 µm). speed_base (0<float<10): speed in m/s at the base voltage (3.5V). The base voltage is used for long moves (~> 50 µm). """ # TODO: need 4 settings: # vmin/speed_min: voltage/speed for the smallest moves (will be used < 50 µm) # vmax/speed_max: voltage/speed for the big moves (will be used above) if not (0.5 < vmin < 10): raise ValueError("vmin (%s) must be between 0.5 and 10 V" % vmin) if not (0 < speed_base < 10): raise ValueError("speed_base (%s) must be between 0 and 10 m/s" % speed_base) super(SMOController, self).__init__(busacc, address, axes) for a, cl in axes.items(): if a not in self._channels: raise LookupError("Axis %d is not supported by controller %d" % (a, address)) if cl: # want closed-loop? raise ValueError("Initialising OLController with request for closed-loop") # that should be the default, but for safety we force it self.SetServo(a, False) self._position[a] = 0 # Don't authorize different speeds or accels self._speed_base = speed_base self.speed_rng = (speed_base, speed_base) # m/s self._speed[a] = speed_base # m/s self._accel[a] = 0.01 # m/s² (actually I've got no idea) # Get maximum motor output parameter (0x9) allowed # Because some type of stages cannot bear as much as the full maximum # The maximum output voltage is calculated following this formula: # 200 Vpp*Maximum motor output/32767 self._max_motor_out = int(self.GetParameter(1, 0x9)) # official approx. min is 3V, but from test, it can sometimes go down to 1.5V. self._min_motor_out = int((vmin / 10) * 32767) # encoded as a ratio of 10 V * 32767 if self._max_motor_out < self._min_motor_out: raise ValueError("Controller report max voltage lower than vmin=%g V" % vmin) # FIXME: the manual somehow implies that writing macros writes on the # flash, which is only possible a number of times. So only write macro # if it's different? # Set up a macro that will do the job # To be called like "MAC START OS 16000 500" # First param is voltage between -32766 and 32766 # Second param is delay in ms between 1 and 9999 # Note: it seems it doesn't work to have a third param is the axis # WARNING: old firmware (<1.2) don't support macro arguments, but there # is not a clear way to detect them (but checking firmware version) # Note: macro name is short to be sure to have a short command line mac = "MAC BEG OS\n" \ "%(n)d SMO 1 $1\n" \ "%(n)d DEL $2\n" \ "%(n)d SMO 1 0\n" \ "%(n)d MAC END\n" % {"n": self.address} self._sendOrderCommand(mac) def StopOLViaPID(self, axis): """ Stop the fake PID driving when doing open-loop """ self._sendOrderCommand("SMO %d 0\n" % axis) def OLMovePID(self, axis, voltage, t): """ Moves an axis for a number of steps. Can be done only with servo off. axis (1<int<16): axis number voltage (-32766<=int<=32766): voltage for the PID control. <0 to go towards the negative direction. 32766 is 10V t (0<int <= 9999): time in ms. """ # Uses MAC OS, based on SMO assert(axis == 1) # seems not possible to have 3 parameters?! assert(-32768 <= voltage <= 32767) assert(0 < t <= 9999) # From experiment: a delay of 0 means actually 2**16, and >= 10000 it's 0 self._sendOrderCommand("MAC START OS %d %d\n" % (voltage, t)) def _isAxisMovingOLViaPID(self, axis): """ axis (1<int<16): axis number returns (boolean): True moving axes for the axes controlled via PID raise PIGCSError if an error on a controller happened """ # "SMO?" (Get Control Value) # Reports the speed set. If it's 0, it's not moving, otherwise, it is. errs, answer = self._sendQueryCommand(["ERR?\n", "SMO? %d\n" % axis]) err = int(errs) if err: raise PIGCSError(err) value = answer.split("=")[1] if value == "0": return False else: return True # TODO: automatically pick it based on the firmware name cycles_per_s = 20000 # 20 kHz for new experimental firmware #cycles_per_s = 1000 # 1 kHz for normal firmware _base_motor_out = int((3.5 / 10) * 32767) # High enough to ensures it's never stuck def _convertDistanceSpeedToPIDControl(self, distance, speed): """ converts meters and speed to the units for this device (~V, ms) in open-loop via PID control. distance (float): meters (can be negative) speed (0<float): meters/s UNUSED return (tuple: int, 0<number, float): PID control (in device unit), duration (in device cycles), expected actual distance (in m) """ # TODO: smooth transition of voltage between 50µm and 20µm? if abs(distance) > 50e-6: # big move # Use the fastest speed voltage_u = max(self._min_motor_out, self._base_motor_out) speed = self._speed_base # m/s else: # small move # Consider the speed linear of the voltage with: # * vmin - 0.5 -> 0 m/s # * base voltage -> speed_base # * vmin -> 0.5 * speed_base / (bv - vmin +0.5) # It's totally wrong, but approximately correct voltage_u = self._min_motor_out bv = self._base_motor_out * (10 / 32767) vmin = self._min_motor_out * (10 / 32767) speed = 0.5 * self._speed_base / (bv - vmin + 0.5) mv_time = abs(distance) / speed # s mv_time_cy = int(round(mv_time * self.cycles_per_s)) # cycles if mv_time_cy < 1: # really no hope return 0, 0, 0 elif mv_time_cy < 5: # On fine grain firmware, below 6 cyles gives always the same time mv_time_cy = 5 elif mv_time_cy >= 10000: logging.debug("Too big distance of %f m, shortening it", distance) mv_time_cy = 9999 act_dist = (mv_time_cy / self.cycles_per_s) * speed # m (very approximate) if distance < 0: voltage_u = -voltage_u act_dist = -act_dist return voltage_u, mv_time_cy, act_dist def moveRel(self, axis, distance): """ See Controller.moveRel """ assert(axis in self._channels) speed = self._speed[axis] v, t, ad = self._convertDistanceSpeedToPIDControl(distance, speed) if t == 0: # if distance is too small, report it logging.debug("Move of %g µm too small, not moving", distance * 1e-6) return 0 else: self.OLMovePID(axis, v, t) duration = t / self.cycles_per_s logging.debug("Moving axis at %f V, for %f ms", v * (10 / 32767), duration) self._storeMove(axis, ad, duration) return ad def isMoving(self, axes=None): """ See Controller.isMoving """ if axes is None: axes = self._channels else: assert axes.issubset(self._channels) for c in axes: if self._isAxisMovingOLViaPID(c): return True return False def stopMotion(self): """ Stop the motion on all axes immediately Implementation for open-loop PID control """ self.Stop() # doesn't seem to be effective with SMO macro for c in self._channels: self.StopOLViaPID(c) self._storeStop(c) self.RelaxPiezos(c) class Bus(model.Actuator): """ Represent a chain of PIGCS controllers over a serial port """ def __init__(self, name, role, port, axes, baudrate=38400, dist_to_steps=None, min_dist=None, vmin=None, speed_base=None, auto_suspend=None, _addresses=None, **kwargs): """ port (string): name of the serial port to connect to the controllers (starting with /dev on Linux or COM on windows) or "autoip" for automatically finding an ip address or a "host[:port]". axes (dict string -> 3-tuple(1<=int<=16, 1<=int, boolean): the configuration of the network. For each axis name associates the controller address, channel, and whether it's closed-loop (absolute positioning) or not. Note that even if it's made of several controllers, each controller is _not_ seen as a child from the odemis model point of view. baudrate (int): baudrate of the serial port (default is the recommended 38400). Use .scan() to detect it. auto_suspend (dict str -> (False or 0 < float)): delay before turning off the servo (and encoder if possible) for closed-loop controllers If False, it will never turn the servo off between nornal moves. Default is 10 s. Next 3 parameters are for calibration, see Controller for definition dist_to_steps (dict string -> (0 < float)): axis name -> value min_dist (dict string -> (0 <= float < 1)): axis name -> value vpms (dict string -> (0 < float)): axis name -> value """ dist_to_steps = dist_to_steps or {} min_dist = min_dist or {} vmin = vmin or {} speed_base = speed_base or {} auto_suspend = auto_suspend or {} # Prepare initialisation by grouping axes from the same controller ac_to_axis = {} # address, channel -> axis name controllers = {} # address -> kwargs (axes, dist_to_steps, min_dist, vpms...) for axis, (add, channel, isCL) in axes.items(): if add not in controllers: controllers[add] = {"axes": {}} kwc = controllers[add] if channel in kwc["axes"]: raise ValueError("Multiple axes got assigned to controller %d channel %d" % (add, channel)) ac_to_axis[(add, channel)] = axis kwc["axes"].update({channel: isCL}) # FIXME: for now we rely on the fact 1 axis = 1 controller for the calibration values if axis in dist_to_steps: kwc["dist_to_steps"] = dist_to_steps[axis] if axis in min_dist: kwc["min_dist"] = min_dist[axis] if axis in vmin: kwc["vmin"] = vmin[axis] if axis in speed_base: kwc["speed_base"] = speed_base[axis] if axis in auto_suspend: kwc["auto_suspend"] = auto_suspend[axis] # Special support for no address if len(controllers) == 1 and None in controllers: master = None else: master = 254 # Standard value for IPAccesser with multiple controllers self.accesser = self._openPort(port, baudrate, _addresses, master=master) # Init each controller self._axis_to_cc = {} # axis name => (Controller, channel) axes_def = {} # axis name => axis definition # TODO also a rangesRel : min and max of a step speed = {} referenced = {} for address, kwc in controllers.items(): try: controller = Controller(self.accesser, address, **kwc) except IOError: logging.exception("Failed to find a controller with address %s on %s", address, port) raise except LookupError: logging.exception("Failed to initialise controller %s on %s", address, port) raise channels = kwc["axes"] for c, isCL in channels.items(): axis = ac_to_axis[(address, c)] self._axis_to_cc[axis] = (controller, c) # TODO if closed-loop, the ranges should be updated after homing rng = controller.pos_rng[c] speed_rng = controller.speed_rng[c] # Just to make sure it doesn't go too fast speed[axis] = controller.getSpeed(c) # m/s ad = model.Axis(unit="m", range=rng, speed=speed_rng, canAbs=isCL, canUpdate=controller.canUpdate[c]) axes_def[axis] = ad refed = controller.isReferenced(c) if refed is not None: referenced[axis] = refed # this set ._axes model.Actuator.__init__(self, name, role, axes=axes_def, **kwargs) # It seems it can cause garbage data with E-861/IP if multiple commands # are sent (ex, ERR + ...) and almost at the same time, another axis is # sent command (ex, OSM). Anyway, it doesn't make much sense to refresh # the position while a move is on going (which already takes care of # updating the position for the axes that matter). # To be hold when updating position, or moving axis, so they don't # interfere with each other self._axis_moving_lock = threading.Lock() # TODO: allow to override the unit (per axis) # RO, as to modify it the client must use .moveRel() or .moveAbs() self.position = model.VigilantAttribute({}, unit="m", readonly=True) self._updatePosition() self._cl_axes = set(an for an, ax in self.axes.items() if ax.canAbs) self._pos_needs_update = threading.Event() if self._cl_axes: # To detect position changes not related to a requested move (only CL axes can do that) self._pos_updater = threading.Thread(target=self._refreshPosition, name="PIGCS position refresher") self._pos_updater.daemon = True self._pos_updater.start() self._pos_updater_stop = threading.Event() else: self._pos_updater = None # RO VA dict axis -> bool: True if the axis has been referenced # Only axes which can be referenced are listed self.referenced = model.VigilantAttribute(referenced, readonly=True) # min speed = don't be crazy slow. max speed from hardware spec gspeed_rng = (min(ad.speed[0] for ad in self.axes.values()), max(ad.speed[1] for ad in self.axes.values())) self.speed = model.MultiSpeedVA(speed, range=gspeed_rng, unit="m/s", setter=self._setSpeed) # set HW and SW version self._swVersion = self.accesser.driverInfo hwversions = [] for axis, (ctrl, channel) in self._axis_to_cc.items(): hwversions.append("'%s': %s (GCS %s) for %s" % (axis, ctrl.GetIdentification(), ctrl.GetSyntaxVersion(), ctrl.GetStageName(channel)) ) self._hwVersion = ", ".join(hwversions) # will take care of executing axis move asynchronously self._executor = CancellableThreadPoolExecutor(max_workers=1) # one task at a time def _updatePosition(self, axes=None): """ update the position VA axes (None or set of str): the axes to update (None indicates all of them) """ if axes is None: pos = {} else: pos = self.position._value.copy() npos = {} for a, (controller, channel) in self._axis_to_cc.items(): if axes is None or a in axes: try: npos[a] = controller.getPosition(channel) except PIGCSError: logging.warning("Failed to update position of axis %s", a, exc_info=True) pos.update(self._applyInversion(npos)) logging.debug("Reporting new position at %s", pos) self.position._set_value(pos, force_write=True) def _refreshPosition(self): """ Called regularly to update the position of the closed-loop axes """ try: while True: # wait until a pos update is requested... or once in a while. self._pos_needs_update.wait(10) if self._pos_updater_stop.is_set(): return # Don't immediately read the position, because there are some # chances the pos update is due to a move ending, which could # be followed by another move. The start next move has a higher # priority than reading position. if self._pos_updater_stop.wait(0.3): return with self._axis_moving_lock: logging.debug("Will refresh position of axes %s", self._cl_axes) self._updatePosition(self._cl_axes) self._pos_needs_update.clear() except Exception: logging.exception("Position refresher thread failed") finally: logging.debug("Ending position refresher") def _setSpeed(self, value): """ value (dict string-> float): speed for each axis returns (dict string-> float): the new value """ for axis, v in value.items(): rng = self._axes[axis].speed if not rng[0] <= v <= rng[1]: raise ValueError("Requested speed of %f for axis %s not within %f->%f" % (v, axis, rng[0], rng[1])) controller, channel = self._axis_to_cc[axis] controller.setSpeed(channel, v) return value def _createFuture(self, axes, update): """ Return (CancellableFuture): a future that can be used to manage a move axes (set of str): the axes that are moved update (bool): if it's an update move """ # TODO: do this via the __init__ of subclass of Future? f = CancellableFuture() f._moving_lock = threading.Lock() # taken while moving f._must_stop = threading.Event() # cancel of the current future requested f._was_stopped = False # if cancel was successful f._update_axes = set() # axes handled by the move, if update if update: # Check if all the axes support it if all(self.axes[a].canUpdate for a in axes): f._update_axes = axes else: logging.warning("Trying to do a update move on axes %s not supporting update", axes) f.task_canceller = self._cancelCurrentMove return f @isasync def moveRel(self, shift, update=False): if not shift: return model.InstantaneousFuture() self._checkMoveRel(shift) shift = self._applyInversion(shift) # TODO: drop an axis if the distance is too small to make sense f = self._createFuture(set(shift.keys()), update) f = self._executor.submitf(f, self._doMoveRel, f, shift) return f moveRel.__doc__ = model.Actuator.moveRel.__doc__ @isasync def moveAbs(self, pos, update=False): if not pos: return model.InstantaneousFuture() self._checkMoveAbs(pos) pos = self._applyInversion(pos) f = self._createFuture(set(pos.keys()), update) f = self._executor.submitf(f, self._doMoveAbs, f, pos) return f moveAbs.__doc__ = model.Actuator.moveAbs.__doc__ # TODO reference(self, axes) # @isasync # def reference(self, axes): # if not axes: # return model.InstantaneousFuture() # self._checkReference(axes) # # f = self._executor.submit(self._doReference, axes) # return f # reference.__doc__ = model.Actuator.reference.__doc__ def stop(self, axes=None): """ stops the motion on all axes Warning: this might stop the motion even of axes not managed (it stops all the axes of the related controllers). axes (set of str) """ self._executor.cancel() # For safety, request a stop on all axes # TODO: use the broadcast address to request a stop to all # controllers on the bus at the same time? axes = axes or self._axes ctlrs = set(self._axis_to_cc[an][0] for an in axes) for controller in ctlrs: controller.stopMotion() def _doMoveRel(self, future, shift): """ Blocking and cancellable relative move future (Future): the future it handles shift (dict str -> float): axis name -> relative target position """ with future._moving_lock, self._axis_moving_lock: # Prepare the encoder of all the axes first (non-blocking) for an, v in shift.items(): controller, channel = self._axis_to_cc[an] if hasattr(controller, "prepareAxisForMove"): controller.prepareAxisForMove(channel) end = 0 # expected end old_pos = self.position.value moving_axes = set() try: for an, v in shift.items(): moving_axes.add(an) logging.debug("Expecting axis %s to reach %f", an, old_pos[an] + v) controller, channel = self._axis_to_cc[an] dist = controller.moveRel(channel, v) # compute expected end dur = driver.estimateMoveDuration(abs(dist), controller.getSpeed(channel), controller.getAccel(channel)) logging.debug("Expecting to move %g m = %g s", dist, dur) end = max(time.time() + dur, end) except PIGCSError as ex: # If one axis failed, better be safe than sorry: stop the other # ones too. logging.info("Failure during start of move (%s), will cancel all of it.", ex) ctlrs = set(self._axis_to_cc[an][0] for an in moving_axes) for controller in ctlrs: try: controller.stopMotion() except Exception: logging.exception("Failed to stop axis %s after failure", an) self._updatePosition() raise self._waitEndMove(future, moving_axes, end) logging.debug("Relative move completed") def _doMoveAbs(self, future, pos): """ Blocking and cancellable absolute move future (Future): the future it handles pos (dict str -> float): axis name -> absolute target position """ with future._moving_lock, self._axis_moving_lock: for an, v in pos.items(): controller, channel = self._axis_to_cc[an] if hasattr(controller, "prepareAxisForMove"): controller.prepareAxisForMove(channel) end = 0 # expected end moving_axes = set() try: for an, v in pos.items(): moving_axes.add(an) controller, channel = self._axis_to_cc[an] dist = controller.moveAbs(channel, v) # compute expected end dur = driver.estimateMoveDuration(abs(dist), controller.getSpeed(channel), controller.getAccel(channel)) end = max(time.time() + dur, end) except PIGCSError: # If one axis failed, better be safe than sorry: stop the other # ones too. ctlrs = set(self._axis_to_cc[an][0] for an in moving_axes) for controller in ctlrs: try: controller.stopMotion() except Exception: logging.exception("Failed to stop axis %s after failure", an) self._updatePosition() raise self._waitEndMove(future, moving_axes, end) logging.debug("Absolute move completed") def _waitEndMove(self, future, axes, end): """ Wait until all the given axes are finished moving, or a request to stop has been received. future (Future): the future it handles axes (set of str): the axes names to check end (float): expected end time raise: CancelledError: if cancelled before the end of the move PIGCSError: if a controller reported an error TimeoutError: if took too long to finish the move """ moving_axes = set(axes) need_pos_update = True last_upd = time.time() dur = max(0.01, min(end - last_upd, 60)) max_dur = dur * 2 + 3 timeout = last_upd + max_dur last_axes = moving_axes.copy() # moving axes as of last position update try: while not future._must_stop.is_set(): # If next future is update and all moving_axes are in next future axes # => stop immediately without updating the positions nf = self._executor.get_next_future(future) if nf is not None and moving_axes <= nf._update_axes: need_pos_update = False # TODO: make sure the position gets updated from time to time # there is non-ending series of update moves. # => reuse the .GetPosition() of the controller.moveRel()? logging.debug("Ending move control early as next move is an update containing %s", moving_axes) return for an in moving_axes.copy(): # need copy to remove during iteration controller, channel = self._axis_to_cc[an] # TODO: change isMoving to report separate info on multiple channels if not controller.isMoving({channel}): moving_axes.discard(an) if not moving_axes: # no more axes to wait for break now = time.time() if now > timeout: logging.info("Stopping move due to timeout after %g s.", max_dur) ctlrs = set(self._axis_to_cc[an][0] for an in moving_axes) for controller in ctlrs: controller.stopMotion() raise TimeoutError("Move is not over after %g s, while " "expected it takes only %g s" % (max_dur, dur)) # Update the position from time to time (10 Hz) if now - last_upd > 0.1 or last_axes != moving_axes: self._updatePosition(last_axes) last_upd = now last_axes = moving_axes.copy() # Wait half of the time left (maximum 0.1 s) left = end - time.time() sleept = max(0.001, min(left / 2, 0.1)) future._must_stop.wait(sleept) else: logging.debug("Move of axes %s cancelled before the end", axes) # stop all axes still moving ctlrs = set(self._axis_to_cc[an][0] for an in moving_axes) for controller in ctlrs: controller.stopMotion() future._was_stopped = True raise CancelledError() except Exception: raise finally: if need_pos_update: # Position update takes quite some time, which increases latency for # the caller to know the move is done => only update the last axes # moving (and don't notify the VA) and update the rest of axes in a # separate thread self._updatePosition(last_axes) self._pos_needs_update.set() def _cancelCurrentMove(self, future): """ Cancels the current move (both absolute or relative). Non-blocking. future (Future): the future to stop. Unused, only one future must be running at a time. return (bool): True if it successfully cancelled (stopped) the move. """ # The difficulty is to synchronise correctly when: # * the task is just starting (not finished requesting axes to move) # * the task is finishing (about to say that it finished successfully) logging.debug("Cancelling current move") future._must_stop.set() # tell the thread taking care of the move it's over with future._moving_lock: if not future._was_stopped: logging.debug("Cancelling failed") return future._was_stopped def terminate(self): if self._executor: self.stop() self._executor.shutdown(wait=True) self._executor = None if self._pos_updater: self._pos_updater_stop.set() self._pos_needs_update.set() # To force the thread to check the stop event self._pos_updater = None ctlrs = set(ct for ct, ch in self._axis_to_cc.values()) for controller in ctlrs: controller.terminate() def selfTest(self): """ No move should be going one while doing a self-test """ passed = True ctlrs = set(ct for ct, ch in self._axis_to_cc.values()) for controller in ctlrs: logging.info("Testing controller %d", controller.address) passed &= controller.selfTest() return passed @classmethod def _openPort(cls, port, baudrate=38400, _addresses=None, master=254): if port.startswith("/dev/") or port.startswith("COM"): ser = cls._openSerialPort(port, baudrate, _addresses) return SerialBusAccesser(ser) else: # ip address if port == "autoip": # Search for IP (and hope there is only one result) ipmasters = cls._scanIPMasters() if not ipmasters: raise model.HwError("Failed to find any PI network master controller") host, ipport = ipmasters[0] logging.info("Will connect to %s:%d", host, ipport) else: # split the (IP) port, separated by a : if ":" in port: host, ipport_str = port.split(":") ipport = int(ipport_str) else: host = port ipport = 50000 # default sock = cls._openIPSocket(host, ipport) return IPBusAccesser(sock, master) @classmethod def scan(cls, port=None): """ port (string): name of the serial port. If None, all the serial ports are tried returns (list of 2-tuple): name, kwargs (port, axes(channel -> CL?) Note: it's obviously not advised to call this function if moves on the motors are ongoing """ if port: ports = [port] else: # TODO: use serial.tools.list_ports.comports() (but only availabe in pySerial 2.6) if os.name == "nt": ports = ["COM" + str(n) for n in range(0, 8)] else: ports = glob.glob('/dev/ttyS?*') + glob.glob('/dev/ttyUSB?*') logging.info("Serial network scanning for PI-GCS controllers in progress...") found = [] # (list of 2-tuple): name, args (port, axes(channel -> CL?) axes_names = "xyzabcdefghijklmnopqrstuvw" for p in ports: try: # check all possible baud rates, in the most likely order for br in (38400, 9600, 19200, 115200): logging.debug("Trying port %s at baud rate %d", p, br) ser = cls._openSerialPort(p, br) controllers = Controller.scan(SerialBusAccesser(ser)) if controllers: axis_num = 0 arg = {} for add, axes in controllers.items(): for a, cl in axes.items(): arg[axes_names[axis_num]] = (add, a, cl) axis_num += 1 found.append(("Actuator " + os.path.basename(p), {"port": p, "baudrate": br, "axes": arg})) # it implies the baud rate was correct, and as it's impossible # to have devices on different baud rate, so we are done break except (serial.SerialException, model.HwError): # not possible to use this port? next one! pass # Scan for controllers via each IP master controller ipmasters = cls._scanIPMasters() for ipadd in ipmasters: try: logging.debug("Scanning controllers on master %s:%d", ipadd[0], ipadd[1]) sock = cls._openIPSocket(*ipadd) controllers = Controller.scan(IPBusAccesser(sock, master=None)) if controllers: axis_num = 0 arg = {} for add, axes in controllers.items(): for a, cl in axes.items(): arg[axes_names[axis_num]] = (add, a, cl) axis_num += 1 found.append(("Actuator IP", {"port": "%s:%d" % ipadd, "axes": arg})) except IOError: logging.info("Failed to scan on master %s:%d", ipadd[0], ipadd[1]) return found @classmethod def _scanIPMasters(cls): """ Scans the IP network for master controllers return (list of tuple of str, int): list of ip add and port of the master controllers found. """ logging.info("Ethernet network scanning for PI-GCS controllers in progress...") found = set() # (set of 2-tuple): ip address, ip port # Find all the broadcast addresses possible (one or more per network interfaces) # In the ideal world, we could just use '<broadcast>', but apprently if # there is not gateway to WAN, it will not work. bdc = [] try: import netifaces for itf in netifaces.interfaces(): try: for addrinfo in netifaces.ifaddresses(itf)[socket.AF_INET]: bdc.append(addrinfo["broadcast"]) except KeyError: pass # no INET or no "broadcast" except ImportError: bdc = ['<broadcast>'] for bdcaddr in bdc: for port, msg, ansstart in ((50000, "PI", "PI"), (30718, "\x00\x00\x00\xf8", "\x00\x00\x00\xf9")): # Special protocol by PI (reversed-engineered): # * Broadcast "PI" on a (known) port # * Listen for an answer # * Answer should contain something like "PI C-863K016 SN 0 -- listening on port 50000 --" # It's more or less the same thing for port 30718 (used by E-725) try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) s.bind(('', 0)) logging.debug("Broadcasting on %s:%d", bdcaddr, port) s.sendto(msg, (bdcaddr, port)) s.settimeout(1.0) # It should take less than 1 s to answer while True: data, fulladdr = s.recvfrom(1024) if not data: break if data.startswith(ansstart): # TODO: decode the message to know to which port it's actually listening to # (in practice, it seems to always be 50000) found.add((fulladdr[0], 50000)) else: logging.info("Received %s from %s", data.encode('string_escape'), fulladdr) except socket.timeout: pass except socket.error: logging.info("Couldn't broadcast on %s:%d", bdcaddr, port) except Exception: logging.exception("Failed to broadcast on %s:%d", bdcaddr, port) return list(found) @staticmethod def _openSerialPort(port, baudrate=38400, _addresses=None): """ Opens the given serial port the right way for the PI controllers. port (string): the name of the serial port (e.g., /dev/ttyUSB0) baudrate (int): baudrate to use, default is the recommended 38400 _addresses (unused): only for testing (cf FakeBus) return (serial): the opened serial port """ try: ser = serial.Serial( port=port, baudrate=baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.5 # s ) except serial.SerialException: raise model.HwError("Failed to open '%s', check the device is " "plugged in and turned on." % port) return ser @staticmethod def _openIPSocket(host, port=50000): """ Opens a socket connection to an PI master controller over IP. host (string): the IP address or host name of the master controller port (int): the (IP) port number return (socket): the opened socket connection """ try: sock = socket.create_connection((host, port), timeout=5) except socket.timeout: raise model.HwError("Failed to connect to '%s:%d', check the master " "controller is connected to the network, turned " " on, and correctly configured." % (host, port)) except socket.error: raise model.HwError("Failed to connect to '%s:%d', check the master " "controller is not already in use." % (host, port)) sock.settimeout(1.0) # s # Immediately send the packet, as small as it is (to avoid latency) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) return sock class SerialBusAccesser(object): """ Manages connections to the low-level bus """ def __init__(self, ser): self.serial = ser # to acquire before sending anything on the serial port self.ser_access = threading.RLock() self.driverInfo = "serial driver: %s" % (driver.getSerialDriver(ser.port),) def terminate(self): self.serial.close() def sendOrderCommand(self, addr, com): """ Send a command which does not expect any report back addr (None or 1<=int<=16): address of the controller. If None, no address is used (and it's typically controller 1 answering) com (string): command to send (including the \n if necessary) """ assert(len(com) <= 100) # commands can be quite long (with floats) assert(addr is None or 1 <= addr <= 16 or addr == 254 or addr == 255) if addr is None: full_com = com else: full_com = "%d %s" % (addr, com) with self.ser_access: logging.debug("Sending: '%s'", full_com.encode('string_escape')) self.serial.write(full_com) # We don't flush, as it will be done anyway if an answer is needed def sendQueryCommand(self, addr, com): """ Send a command and return its report (raw) addr (None or 1<=int<=16): address of the controller com (string): the command to send (without address prefix but with \n) return (string or list of strings): the report without prefix (e.g.,"0 1") nor newline. If answer is multiline: returns a list of each line Note: multiline answers seem to always begin with a \x00 character, but it's left as is. raise: HwError: if error communicating with the hardware, probably due to the hardware not being in a good state (or connected) IOError: if error during the communication (such as the protocol is not respected) """ assert(addr is None or 1 <= addr <= 16 or addr == 254) if isinstance(com, basestring): com = [com] multicom = False else: multicom = True for c in com: assert(len(c) <= 100) # commands can be quite long (with floats) if addr is None: full_com = "".join(com) prefix = "" else: full_com = "".join("%d %s" % (addr, c) for c in com) prefix = "0 %d " % addr with self.ser_access: logging.debug("Sending: '%s'", full_com.encode('string_escape')) self.serial.write(full_com) # ensure everything is received, before expecting an answer self.serial.flush() ans = "" # received data not yet processed ret = [] # one answer per command continuing = False while True: char = self.serial.read() # empty if timeout if not char: raise model.HwError("Controller %s timed out, check the device is " "plugged in and turned on." % addr) ans += char anssplited = ans.split("\n") # if the answer finishes with \n, last split is empty anssplited, ans = anssplited[:-1], anssplited[-1] if anssplited: logging.debug("Received: '%s'", "\n".join(anssplited).encode('string_escape')) for l in anssplited: if not continuing: lines = [] # one string per answer line # remove the prefix if l.startswith(prefix): l = l[len(prefix):] else: # Maybe the previous line was actually continuing (but the hardware is strange)? if ret and ret[-1] == "": logging.debug("Reconcidering previous line as beginning of multi-line") ret = ret[:-1] else: logging.debug("Failed to decode answer '%s'", l.encode('string_escape')) raise IOError("Report prefix unexpected after '%s': '%s'." % (full_com, l)) if l[-1:] == " ": # multi-line continuing = True lines.append(l[:-1]) # remove the space indicating multi-line else: # End of the answer for that command continuing = False lines.append(l) if len(lines) == 1: ret.append(lines[0]) else: ret.append(lines) # does it look like we received the end of an answer? if not continuing and not ans and len(ret) >= len(com): break if len(ret) > len(com): logging.warning("Skipping previous answers from hardware %r", ret[:-len(com)]) ret = ret[-len(com):] elif len(ret) < len(com): logging.error("Expected %d answers but only got %d", len(com), len(ret)) if not multicom: return ret[0] else: return ret def flushInput(self): """ Ensure there is no more data queued to be read on the bus (=serial port) """ with self.ser_access: # Flush buffer + give it some time to recover from whatever self.serial.flush() self.serial.flushInput() while True: data = self.serial.read(100) if len(data) < 100: break logging.debug("Flushing data %s", data.encode('string_escape')) class IPBusAccesser(object): """ Manages connections to the low-level bus """ def __init__(self, socket, master=254): """ master (1<=int<=255 or None): address of the master """ self.socket = socket # to acquire before sending anything on the socket self.ser_access = threading.RLock() if master is None: self.driverInfo = "TCP/IP connection" else: # recover the main controller from previous errors (just in case) err = self.sendQueryCommand(master, "ERR?\n") # Get the master controller version version = self.sendQueryCommand(master, "*IDN?\n") self.driverInfo = "%s" % (version.encode('string_escape'),) def terminate(self): self.socket.close() def sendOrderCommand(self, addr, com): """ Send a command which does not expect any report back addr (None or 1<=int<=16): address of the controller. If None, no address is used (and it's typically controller 1 answering) com (string): command to send (including the \n if necessary) """ assert(len(com) <= 100) # commands can be quite long (with floats) assert(addr is None or 1 <= addr <= 16 or addr == 254 or addr == 255) # 255 means "broadcast" if addr is None: full_com = com else: full_com = "%d %s" % (addr, com) with self.ser_access: logging.debug("Sending: '%s'", full_com.encode('string_escape')) self.socket.sendall(full_com) def sendQueryCommand(self, addr, com): """ Send a command and return its report (raw) addr (None or 1<=int<=16): address of the controller com (str or list of str): the command(s) to send (without address prefix but with \n) return (string or list of strings): the report without prefix (e.g.,"0 1") nor newline. If answer is multiline: returns a list of each line If command was a list: one str or list of str per command raise: HwError: if error communicating with the hardware, probably due to the hardware not being in a good state (or connected) IOError: if error during the communication (such as the protocol is not respected) """ assert(addr is None or 1 <= addr <= 16 or addr == 254) if isinstance(com, basestring): com = [com] multicom = False else: multicom = True for c in com: assert(len(c) <= 100) # commands can be quite long (with floats) if addr is None: full_com = "".join(com) prefix = "" else: full_com = "".join("%d %s" % (addr, c) for c in com) prefix = "0 %d " % addr with self.ser_access: logging.debug("Sending: '%s'", full_com.encode('string_escape')) self.socket.sendall(full_com) # Read the answer # The basic is simple. An answer starts with a prefix, and finishes # with \n. If it actually finishes with " \n", then it's just a new # line and not the end of the answer. # However, it gets muddy sometimes with empty answers. For instance, # it can answer "0 1 \n", which is an empty answer. But some # controllers answer "1 HLP\n" with "0 1 \nBla bla \nBla\n" end_time = time.time() + 0.5 ans = "" # received data not yet processed ret = [] # one answer per command continuing = False while True: try: data = self.socket.recv(4096) except socket.timeout: raise model.HwError("Controller %s timed out, check the device is " "plugged in and turned on." % addr) # If the master is already accessed from somewhere else it will just # immediately answer an empty message if not data: if time.time() > end_time: raise model.HwError("Controller not answering. " "It might be already connected with another client.") else: logging.debug("Received empty data packet") time.sleep(0.01) continue logging.debug("Received: '%s'", data.encode('string_escape')) ans += data anssplited = ans.split("\n") # if the answer finishes with \n, last split is empty anssplited, ans = anssplited[:-1], anssplited[-1] for l in anssplited: # logging.debug("Processing %s", l) if not continuing: lines = [] # one string per answer line # remove the prefix if l.startswith(prefix): l = l[len(prefix):] else: # Maybe the previous line was actually continuing (but the hardware is strange)? if ret and ret[-1] == "": logging.debug("Reconcidering previous line as beginning of multi-line") ret = ret[:-1] else: # TODO: maybe we got some garbage data from before, # check if there is already data available that fits the # prefix. (=> keep reading but with a short timeout) logging.debug("Failed to decode answer '%s'", l.encode('string_escape')) raise IOError("Report prefix unexpected after '%s': '%s'." % (full_com, l)) if l[-1:] == " ": # multi-line continuing = True lines.append(l[:-1]) # remove the space indicating multi-line else: # End of the answer for that command continuing = False lines.append(l) if len(lines) == 1: ret.append(lines[0]) else: ret.append(lines) # does it look like we received the end of an answer? if not continuing and not ans and len(ret) >= len(com): break if len(ret) > len(com): logging.warning("Skipping previous answers from hardware %r", ret[:-len(com)]) ret = ret[-len(com):] elif len(ret) < len(com): logging.error("Expected %d answers but only got %d", len(com), len(ret)) if not multicom: return ret[0] else: return ret def flushInput(self): """ Ensure there is no more data queued to be read on the bus """ with self.ser_access: try: end = time.time() + 1 while True: data = self.socket.recv(4096) logging.debug("Flushing data '%s'", data.encode('string_escape')) if time.time() > end: logging.warning("Still trying to flush data after 1 s") return except socket.timeout: pass except Exception: logging.exception("Failed to flush correctly the socket") # All the classes below are for the simulation of the hardware class SimulatedError(Exception): """ Special exception class to simulate error in the controller """ pass class E861Simulator(object): """ Simulates a GCS controller (+ serial port at 38400). Only used for testing. 1 axis, open-loop only, very limited behaviour Same interface as the serial port """ _idn = "(c)2013 Delmic Fake Physik Instrumente(PI) Karlsruhe, E-861 Version 7.2.0" _csv = "2.0" def __init__(self, port, baudrate=9600, timeout=0, address=1, closedloop=False, *args, **kwargs): """ parameters are the same as a serial port address (1<=int<=16): the address of the controller closedloop (bool): whether it simulates a closed-loop actuator or not """ self.port = port self._address = address self._has_encoder = closedloop # we don't care about the actual parameters but timeout self.timeout = timeout self._init_mem() self._end_move = 0 # time the last requested move is over # only used in closed-loop # If move is over: # position == target # else: # position = original position # target = requested position # current position = weigthed average (according to time) self._position = 0.012 # m self._target = self._position # m self._start_move = 0 self._output_buf = "" # what the commands sends back to the "host computer" self._input_buf = "" # what we receive from the "host computer" # special trick to only answer if baudrate is correct if baudrate != 38400: logging.debug("Baudrate incompatible: %d", baudrate) self.write = (lambda s: "") def _init_mem(self): # internal values to simulate the device # Note: the type is used to know how it should be decoded, so it's # important to differentiate between float and int. # Parameter table: address -> value self._parameters = {0x01: 80, # P 0x02: 5, # I 0x03: 130, # D 0x14: 1 if self._has_encoder else 0, # 0 = no ref switch, 1 = ref switch 0x32: 0 if self._has_encoder else 1, # 0 = limit switches, 1 = no limit switches 0x3c: "DEFAULT-FAKE", # stage name 0x15: 25.0, # TMX (in mm) 0x30: 0.0, # TMN (in mm) 0x16: 0.012, # value at ref pos 0x49: 10.0, # VEL 0x0B: 3.2, # ACC 0x0C: 0.9, # DEC 0x0A: 50.0, # max vel 0x4A: 5.0, # max acc 0x4B: 5.0, # max dec 0x0E: 10000000, # unit num (note: normal default is 10000) 0x0F: 1, # unit denum 0x56: 1, # encoder on 0x7000002: 50, # slew rate in ms 0x7000003: 10.0, # SSA 0x7000201: 3.2, # OVL 0x7000202: 0.9, # OAC 0x7000204: 15.3, # max step/s 0x7000205: 1.2, # max step/s² 0x7000206: 0.9, # ODC 0x7000601: "MM", # unit } self._servo = 0 # servo state self._ready = True # is ready? self._referenced = 0 self._ref_mode = 1 self._errno = 0 # last error set _re_command = ".*?[\n\x04\x05\x07\x08\x18\x24]" def write(self, data): self._input_buf += data # process each commands separated by a "\n" or is short command while len(self._input_buf) > 0: m = re.match(self._re_command, self._input_buf) if not m: return # no more full command available c = m.group(0) self._processCommand(c) self._input_buf = self._input_buf[m.end(0):] # all the left over def read(self, size=1): # simulate timeout end_time = time.time() + self.timeout # FIXME: to be correct, we'd need to take a lock ret = self._output_buf[:size] self._output_buf = self._output_buf[len(ret):] while len(ret) < size: time.sleep(0.01) left = size - len(ret) ret += self._output_buf[:left] self._output_buf = self._output_buf[len(ret):] if self.timeout and time.time() > end_time: break return ret def close(self): # using read or write will fail after that del self._output_buf del self._input_buf def _get_cur_pos_cl(self): """ Computes the current position, in closed loop mode """ now = time.time() if now > self._end_move: self._position = self._target return self._position else: completion = (now - self._start_move) / (self._end_move - self._start_move) cur_pos = self._position + (self._target - self._position) * completion return cur_pos # TODO: some commands are read-only # Command name -> parameter number _com_to_param = {# "LIM": 0x32, # LIM actually report the opposite of 0x32 "TRS": 0x14, "CST": 0x3c, "TMN": 0x30, "TMX": 0x15, "VEL": 0x49, "ACC": 0x0B, "DEC": 0x0C, "OVL": 0x7000201, "OAC": 0x7000202, "ODC": 0x7000206, "SSA": 0x7000003, } _re_addr_com = r"((?P<addr>\d+) (0 )?)?(?P<com>.*)" def _processCommand(self, com): """ process the command, and put the result in the output buffer com (str): command """ out = None # None means error while decoding command # command can start with a prefix like "5 0 " or "5 " m = re.match(self._re_addr_com, com) assert m # anything left over should be in com if m.group("addr"): addr = int(m.group("addr")) prefix = "0 %d " % addr else: addr = 1 # default is address == 1 prefix = "" if addr != self._address and addr != 255: # message is for us? # logging.debug("Controller %d skipping message for %d", # self._address, addr) return logging.debug("Fake controller %d processing command '%s'", self._address, com.encode('string_escape')) com = m.group("com") # also removes the \n at the end if it's there # split into arguments separated by spaces (not including empty strings) args = filter(bool, com.split(" ")) logging.debug("Command decoded: %s", args) if self._errno: # if errno is not null, most commands don't work any more if com not in ["*IDN?", "RBT", "ERR?", "CSV?"]: logging.debug("received command %s while errno = %d", com.encode('string_escape'), self._errno) return # TODO: to support more commands, we should have a table, with name of # the command + type of arguments (+ number of optional args) try: if com == "*IDN?": # identification out = self._idn elif com == "CSV?": # command set version out = self._csv elif com == "ERR?": # last error number out = "%d" % self._errno self._errno = 0 # reset error number elif com == "RBT": # reboot self._init_mem() time.sleep(0.1) elif com == "\x04": # Query Status Register Value # return hexadecimal bitmap of moving axes # TODO: to check, much more info returned val = 0 if time.time() < self._end_move: val |= 0x400 # first axis moving if self._servo: val |= 0x1000 # servo on out = "0x%x" % val elif com == "\x05": # Request Motion Status # return hexadecimal bitmap of moving axes if time.time() > self._end_move: val = 0 else: val = 1 # first axis moving out = "%x" % val elif com == "\x07": # Request Controller Ready Status if self._ready: # TODO: when is it not ready?? (for a little while after changing servo mode) out = "\xb1" else: out = "\xb0" elif com == "\x18" or com == "STP": # Stop immediately self._end_move = 0 self._errno = 10 # PI_CNTR_STOP elif args[0].startswith("HLT"): # halt motion with deceleration: axis (optional) self._end_move = 0 elif args[0].startswith("RNP"): # relax pass elif args[0][:3] in self._com_to_param: param = self._com_to_param[args[0][:3]] logging.debug("Converting command %s to param %d", args[0], param) axis = int(args[1]) if axis != 1: raise SimulatedError(15) if args[0][3:4] == "?" and len(args) == 2: # query out = "%s=%s" % (args[1], self._parameters[param]) elif len(args[0]) == 3 and len(args) == 3: # set # convert according to the current type of the parameter typeval = type(self._parameters[param]) self._parameters[param] = typeval(args[2]) else: raise SimulatedError(15) elif args[0] == "SPA?" and len(args) == 3: # GetParameter: axis, address # TODO: when no arguments -> list all parameters axis, addr = int(args[1]), int(args[2]) if axis != 1: raise SimulatedError(15) try: out = "%d=%s" % (addr, self._parameters[addr]) except KeyError: logging.debug("Unknown parameter %d", addr) raise SimulatedError(56) elif args[0] == "SPA" and len(args) == 4: # SetParameter: axis, address, value axis = int(args[1]) if args[2].startswith("0x"): addr = int(args[2][2:], 16) else: addr = int(args[2]) if axis != 1: raise SimulatedError(15) if addr in [0x0E, 0x0F] and self._parameters[addr] != int(args[3]): # TODO: have a list of parameters to update raise NotImplementedError("Simulator cannot change unit") try: typeval = type(self._parameters[addr]) self._parameters[addr] = typeval(args[3]) except KeyError: logging.debug("Unknown parameter %d", addr) raise SimulatedError(56) elif args[0] == "SEP?" and len(args) == 3: # GetParameterNonVolatile: axis, address # TODO: when no arguments -> list all parameters axis, addr = int(args[1]), int(args[2]) if axis != 1: raise SimulatedError(15) try: out = "%d=%s" % (addr, self._parameters[addr]) except KeyError: logging.debug("Unknown parameter %d", addr) raise SimulatedError(56) elif args[0] == "LIM?" and len(args) == 2: # Get Limit Switches axis = int(args[1]) if axis == 1: # opposite of param 0x32 out = "%s=%s" % (args[1], 1 - self._parameters[0x32]) else: self._errno = 15 elif args[0] == "SVO" and len(args) == 3: # Set Servo State axis, state = int(args[1]), int(args[2]) if axis == 1: self._servo = state else: self._errno = 15 elif args[0] == "RON" and len(args) == 3: # Set Reference mode axis, state = int(args[1]), int(args[2]) if axis == 1: self._ref_mode = state else: self._errno = 15 elif args[0] == "OSM" and len(args) == 3: # Open-Loop Step Moving axis, steps = int(args[1]), float(args[2]) if axis != 1: raise SimulatedError(15) speed = self._parameters[self._com_to_param["OVL"]] duration = abs(steps) / speed logging.debug("Simulating a move of %f s", duration) self._end_move = time.time() + duration # current move stopped elif args[0] == "MOV" and len(args) == 3: # Closed-Loop absolute move axis, pos = int(args[1]), float(args[2]) if axis != 1: raise SimulatedError(15) if self._ref_mode and not self._referenced: raise SimulatedError(8) speed = self._parameters[self._com_to_param["VEL"]] cur_pos = self._get_cur_pos_cl() distance = cur_pos - pos duration = abs(distance) / speed + 0.05 logging.debug("Simulating a move of %f s", duration) self._start_move = time.time() self._end_move = self._start_move + duration self._position = cur_pos self._target = pos elif args[0] == "MVR" and len(args) == 3: # Closed-Loop relative move axis, distance = int(args[1]), float(args[2]) if axis != 1: raise SimulatedError(15) if self._ref_mode and not self._referenced: raise SimulatedError(8) speed = self._parameters[self._com_to_param["VEL"]] duration = abs(distance) / speed + 0.05 logging.debug("Simulating a move of %f s", duration) cur_pos = self._get_cur_pos_cl() self._start_move = time.time() self._end_move = self._start_move + duration self._position = cur_pos self._target = cur_pos + distance # # Introduce an error from time to time, just to try the error path # if random.randint(0, 10) == 0: # raise SimulatedError(7) elif args[0] == "POS" and len(args) == 3: # Closed-Loop position set axis, pos = int(args[1]), float(args[2]) if axis != 1: raise SimulatedError(15) self._position = pos elif args[0] == "POS?" and len(args) == 2: # Closed-Loop position query axis = int(args[1]) if axis != 1: raise SimulatedError(15) # if 0 == random.randint(0, 20): # To test with issue about generated garbage # self._output_buf += "\n\x8a\xea\x82r\x82\xa2\x9a\xa2\xca\x8a\n" # else: out = "%s=%s" % (args[1], self._get_cur_pos_cl()) elif args[0] == "MOV?" and len(args) == 2: # Closed-Loop target position query axis = int(args[1]) if axis != 1: raise SimulatedError(15) out = "%s=%s" % (args[1], self._target) elif args[0] == "ONT?" and len(args) == 2: # on target axis = int(args[1]) if axis != 1: raise SimulatedError(15) ont = time.time() > self._end_move out = "%s=%d" % (args[1], 1 if ont else 0) elif args[0] == "FRF?" and len(args) == 2: # is referenced? axis = int(args[1]) if axis != 1: raise SimulatedError(15) out = "%s=%d" % (args[1], self._referenced) elif args[0] == "FRF" and len(args) == 2: # reference to ref switch axis = int(args[1]) if axis != 1: raise SimulatedError(15) self._referenced = 1 self._end_move = 0 self._position = self._parameters[0x16] # value at reference elif args[0] == "SAI?" and len(args) <= 2: # List Of Current Axis Identifiers # Can be followed by "ALL", but for us, it's the same out = "1" elif com == "HLP?": # The important part is " \n" at the end of each line out = ("\x00The following commands are available: \n" "#4 request status register \n" "HLP list the available commands \n" "LIM? booo \n" "TRS? booo \n" "SVO booo \n" "RON booo \n" "HTL booo \n" "STP booo \n" "CST? booo \n" "VEL? booo \n" "ACC? booo \n" "OVL? booo \n" "OAC? booo \n" "TMN? booo \n" "TMX? booo \n" "FRF booo \n" "FRF? booo \n" "SAI? booo \n" "POS booo \n" "POS? booo \n" "ONT? booo \n" "MOV booo \n" "MOV? booo \n" "MVR booo \n" "OSM booo \n" "RNP relax \n" "ERR? get error number \n" "VEL {<AxisId> <Velocity>} set closed-loop velocity \n" "end of help" ) elif com == "HPA?": out = ("\x00The following parameters are valid: \n" + "0x1=\t0\t1\tINT\tmotorcontroller\tP term 1 \n" + "0x2=\t0\t1\tINT\tmotorcontroller\tI term 1 \n" + "0x3=\t0\t1\tINT\tmotorcontroller\tD term 1 \n" + "0x32=\t0\t1\tINT\tmotorcontroller\thas limit\t(0=limitswitchs 1=no limitswitchs) \n" + "0x3C=\t0\t1\tCHAR\tmotorcontroller\tStagename \n" + # "0x56=\t0\t1\tCHAR\tencoder\tactive \n" + # Uncomment to simulate a C-867 "0x7000000=\t0\t1\tFLOAT\tmotorcontroller\ttravel range minimum \n" + "0x7000002=\t0\t1\tFLOAT\tmotorcontroller\tslew rate \n" + "0x7000601=\t0\t1\tCHAR\tunit\tuser unit \n" + "end of help" ) else: logging.debug("Unknown command '%s'", com) self._errno = 1 except SimulatedError as ex: logging.debug("Error detected while processing command '%s'", com) self._errno = ex.args[0] except Exception: logging.debug("Failed to process command '%s'", com) self._errno = 1 # add the response header if out is None: #logging.debug("Fake controller %d doesn't respond", self._address) pass else: out = "%s%s\n" % (prefix, out) logging.debug("Fake controller %d responding '%s'", self._address, out.encode('string_escape')) self._output_buf += out class DaisyChainSimulator(object): """ Simulated serial port that can simulate daisy chain on the controllers Same interface as the serial port + list of (fake) serial ports to connect """ def __init__(self, port, timeout=0, *args, **kwargs): """ subports (list of open ports): the ports to receive the data """ self.port = port self.timeout = timeout self._subports = kwargs["subports"] self._output_buf = "" # TODO: probably cleaner to user lock to access it # TODO: for each port, put a thread listening on the read and push to output self._is_terminated = False for p in self._subports: t = threading.Thread(target=self._thread_read_serial, args=(p,)) t.daemon = True t.start() def flush(self): return def flushInput(self): return def write(self, data): # just duplicate for p in self._subports: p.write(data) def read(self, size=1): # simulate timeout end_time = time.time() + self.timeout ret = self._output_buf[:size] self._output_buf = self._output_buf[len(ret):] while len(ret) < size: time.sleep(0.01) left = size - len(ret) ret += self._output_buf[:left] self._output_buf = self._output_buf[len(ret):] if self.timeout and time.time() > end_time: break return ret def _thread_read_serial(self, ser): """ Push the output of the given serial port into our output """ try: while not self._is_terminated: c = ser.read(1) if len(c) == 0: time.sleep(0.01) else: self._output_buf += c except Exception: logging.exception("Fake daisy chain thread received an exception") def close(self): self._is_terminated = True # using read or write will fail after that del self._output_buf del self._subports class FakeBus(Bus): """ Same as the normal Bus, but connects to simulated controllers """ def __init__(self, name, role, port, axes, baudrate=38400, **kwargs): # compute the addresses from the axes declared addresses = dict([(d[0], d[2]) for d in axes.values()]) Bus.__init__(self, name, role, port, axes, baudrate=baudrate, _addresses=addresses, **kwargs) @classmethod def scan(cls, port=None): # force only one port return super(FakeBus, cls).scan(port="/dev/fake") @staticmethod def _openSerialPort(port, baudrate=38400, _addresses=None): """ Opens a fake serial port port (string): the name of the serial port (e.g., /dev/ttyUSB0) _addresses (dict of int -> bool, or None): list of each address that should have a simulated controller created and wheter it is closed-loop or not. Default to {1: False, 2:False} (used for scan). return (serial): the opened serial port """ _addresses = _addresses or {1: False, 2: False} simulators = [] for addr, cl in _addresses.items(): sim = E861Simulator( port=port, baudrate=baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.5, #s address=addr, closedloop=cl, ) simulators.append(sim) # link all of them in daisy chain ser = DaisyChainSimulator( port=port, baudrate=baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.5, #s subports=simulators, ) return ser
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 199, 10502, 641, 1520, 25298, 6029, 199, 199, 32, 2502, 26, 13333, 232, 1567, 510, 14769, 199, 199, 7384, 22405, 103, 6029, 13, 7806, 13333, 232, 1567, 510, 14769, 12, 18464, 15003, 199, 199, 2765, 570, 365, 1777, 402, 593, 271, 1292, 14, 199, 199, 47, 271, 1292, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 199, 1618, 314, 1664, 1696, 1684, 844, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 30216, 14, 199, 199, 47, 271, 1292, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 199, 7395, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 199, 48, 1230, 3064, 14, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 47, 271, 1292, 14, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 8083, 199, 2344, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 10703, 199, 504, 23002, 14, 25513, 492, 28374, 1146, 547, 199, 646, 5739, 199, 646, 2050, 199, 504, 312, 271, 1292, 492, 1402, 199, 504, 312, 271, 1292, 14, 1238, 492, 365, 4146, 12, 445, 554, 914, 461, 14224, 12, 445, 554, 914, 461, 4436, 5453, 16752, 199, 504, 312, 271, 1292, 14, 1974, 492, 5253, 12, 31886, 199, 646, 747, 199, 3, 492, 2196, 199, 646, 295, 199, 646, 3012, 199, 646, 2838, 199, 646, 5796, 199, 646, 900, 421, 199, 3, 19447, 370, 2429, 16678, 1159, 7708, 18070, 28496, 27325, 626, 2035, 314, 283, 39, 3298, 7, 334, 14109, 199, 3, 5817, 2494, 680, 1010, 6770, 652, 10022, 314, 16678, 662, 13, 16253, 12, 445, 13, 14927, 436, 662, 13, 31304, 27325, 14, 199, 3, 17064, 883, 506, 1911, 314, 8722, 662, 13, 16253, 63, 1899, 63, 48, 58, 10629, 37, 10753, 14, 5607, 334, 80, 14, 7555, 680, 199, 3, 2104, 314, 16678, 445, 13, 11010, 282, 7351, 298, 581, 8361, 401, 1937, 314, 6682, 5253, 14, 199, 3, 3390, 626, 22160, 2985, 402, 4294, 1183, 2291, 314, 283, 1531, 663, 297, 1924, 7614, 199, 3, 730, 334, 460, 27969, 9, 965, 282, 10026, 402, 3718, 3748, 12, 965, 3365, 2633, 199, 3, 436, 2755, 18023, 3365, 4340, 370, 4282, 3718, 436, 370, 3222, 17133, 14, 199, 3, 199, 3, 2779, 883, 2879, 314, 27325, 1806, 820, 51, 13, 8001, 12, 334, 2171, 1806, 9, 28655, 436, 13488, 15, 1772, 14, 199, 3, 1010, 282, 12927, 19765, 13, 4429, 12, 8539, 4799, 28655, 503, 4799, 820, 51, 13, 8001, 12, 2337, 1471, 506, 1373, 199, 3, 7614, 543, 2287, 413, 24649, 36, 1772, 413, 6673, 680, 6006, 365, 2597, 282, 11180, 2287, 26, 5450, 14, 199, 3, 1010, 485, 3972, 63, 13488, 15, 1772, 2897, 12, 2337, 365, 282, 5288, 7614, 737, 2287, 22540, 14, 199, 3, 199, 3, 710, 7614, 3509, 5002, 2633, 315, 14775, 4402, 14, 5723, 2633, 1471, 199, 3, 1172, 2757, 10889, 5313, 6657, 370, 5542, 314, 9546, 652, 365, 20921, 4007, 14, 961, 199, 3, 5253, 4440, 436, 14292, 314, 2633, 370, 506, 3211, 14, 199, 3, 710, 2897, 3050, 365, 2808, 315, 282, 570, 2797, 299, 631, 7441, 18, 14, 4616, 14, 710, 199, 3, 510, 1469, 3258, 293, 10370, 5417, 2240, 6127, 370, 2248, 652, 12, 1325, 701, 849, 3181, 1133, 1331, 652, 370, 199, 3, 314, 2222, 13, 32059, 4402, 12, 880, 1265, 1929, 370, 7662, 3354, 3062, 315, 16149, 199, 3, 4402, 14, 334, 6049, 2597, 506, 4224, 543, 314, 644, 8470, 1414, 436, 2505, 298, 1960, 1674, 9, 199, 3, 1010, 6770, 12, 367, 6876, 13, 3813, 24490, 12, 4868, 626, 314, 663, 32642, 10061, 436, 900, 199, 3, 787, 6657, 663, 880, 626, 282, 4057, 365, 8652, 641, 1347, 23661, 8642, 413, 308, 680, 199, 3, 8777, 593, 271, 1292, 12, 314, 283, 1038, 888, 7, 11420, 883, 2597, 506, 1202, 370, 1586, 436, 2218, 314, 199, 3, 16149, 4402, 14, 199, 3, 199, 3, 710, 7614, 5171, 6876, 13, 3813, 818, 334, 73, 14, 69, 2020, 3679, 3421, 316, 9, 1325, 1454, 199, 3, 340, 652, 365, 4568, 370, 282, 8778, 334, 1397, 2032, 9696, 461, 680, 3979, 314, 14991, 199, 3, 965, 949, 8778, 12, 314, 7614, 1077, 506, 1202, 1454, 315, 1551, 13, 3813, 818, 12, 370, 5126, 199, 3, 12927, 391, 1540, 314, 2454, 16530, 14, 2002, 1380, 2337, 365, 949, 8778, 26, 199, 3, 627, 4226, 440, 6258, 8926, 2392, 641, 334, 4985, 47, 1414, 9, 199, 3, 627, 4226, 440, 3222, 3718, 367, 6876, 13, 3813, 25134, 12, 2839, 10362, 54, 503, 603, 20271, 199, 3, 627, 4226, 440, 3222, 314, 1551, 13, 3813, 3718, 593, 2054, 436, 593, 22153, 12, 3967, 2985, 199, 3, 259, 675, 282, 8778, 12, 4634, 199, 3, 199, 3, 710, 7614, 11479, 9978, 19325, 1181, 24434, 14, 2136, 11496, 29772, 383, 334, 36, 1772, 29, 614, 9, 465, 652, 1159, 7377, 199, 3, 436, 652, 12237, 10226, 701, 4036, 1015, 14, 5439, 2202, 787, 1695, 666, 12, 413, 3631, 12, 199, 3, 949, 623, 1209, 14, 199, 3, 199, 3, 1010, 1551, 13, 3813, 12, 314, 7614, 965, 499, 15217, 370, 4057, 314, 2454, 85, 2750, 26, 199, 3, 221, 627, 653, 290, 736, 266, 3637, 26, 4721, 13, 7625, 12, 436, 1846, 6033, 199, 3, 755, 413, 3650, 6146, 1616, 19123, 121, 77, 1928, 2248, 334, 2003, 543, 2248, 9, 199, 3, 221, 627, 1626, 2548, 26, 7437, 28334, 12, 1325, 14569, 5696, 6146, 21, 24461, 77, 199, 3, 420, 298, 2167, 5236, 1086, 13718, 370, 282, 25134, 402, 14106, 14, 650, 14, 19, 24461, 77, 2, 199, 3, 420, 298, 1165, 5236, 1086, 13718, 370, 282, 25134, 402, 14106, 14, 413, 24461, 77, 2, 199, 3, 199, 3, 3709, 376, 1919, 12, 314, 445, 13, 14927, 1454, 5171, 402, 4294, 1183, 6876, 13, 3813, 14, 9738, 12, 2337, 199, 3, 365, 282, 298, 4776, 2, 1414, 12, 2389, 47, 12, 626, 6127, 370, 4057, 315, 1551, 13, 3813 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 199, 10502, 641, 1520, 25298, 6029, 199, 199, 32, 2502, 26, 13333, 232, 1567, 510, 14769, 199, 199, 7384, 22405, 103, 6029, 13, 7806, 13333, 232, 1567, 510, 14769, 12, 18464, 15003, 199, 199, 2765, 570, 365, 1777, 402, 593, 271, 1292, 14, 199, 199, 47, 271, 1292, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 199, 1618, 314, 1664, 1696, 1684, 844, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 30216, 14, 199, 199, 47, 271, 1292, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 199, 7395, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 199, 48, 1230, 3064, 14, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 47, 271, 1292, 14, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 8083, 199, 2344, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 10703, 199, 504, 23002, 14, 25513, 492, 28374, 1146, 547, 199, 646, 5739, 199, 646, 2050, 199, 504, 312, 271, 1292, 492, 1402, 199, 504, 312, 271, 1292, 14, 1238, 492, 365, 4146, 12, 445, 554, 914, 461, 14224, 12, 445, 554, 914, 461, 4436, 5453, 16752, 199, 504, 312, 271, 1292, 14, 1974, 492, 5253, 12, 31886, 199, 646, 747, 199, 3, 492, 2196, 199, 646, 295, 199, 646, 3012, 199, 646, 2838, 199, 646, 5796, 199, 646, 900, 421, 199, 3, 19447, 370, 2429, 16678, 1159, 7708, 18070, 28496, 27325, 626, 2035, 314, 283, 39, 3298, 7, 334, 14109, 199, 3, 5817, 2494, 680, 1010, 6770, 652, 10022, 314, 16678, 662, 13, 16253, 12, 445, 13, 14927, 436, 662, 13, 31304, 27325, 14, 199, 3, 17064, 883, 506, 1911, 314, 8722, 662, 13, 16253, 63, 1899, 63, 48, 58, 10629, 37, 10753, 14, 5607, 334, 80, 14, 7555, 680, 199, 3, 2104, 314, 16678, 445, 13, 11010, 282, 7351, 298, 581, 8361, 401, 1937, 314, 6682, 5253, 14, 199, 3, 3390, 626, 22160, 2985, 402, 4294, 1183, 2291, 314, 283, 1531, 663, 297, 1924, 7614, 199, 3, 730, 334, 460, 27969, 9, 965, 282, 10026, 402, 3718, 3748, 12, 965, 3365, 2633, 199, 3, 436, 2755, 18023, 3365, 4340, 370, 4282, 3718, 436, 370, 3222, 17133, 14, 199, 3, 199, 3, 2779, 883, 2879, 314, 27325, 1806, 820, 51, 13, 8001, 12, 334, 2171, 1806, 9, 28655, 436, 13488, 15, 1772, 14, 199, 3, 1010, 282, 12927, 19765, 13, 4429, 12, 8539, 4799, 28655, 503, 4799, 820, 51, 13, 8001, 12, 2337, 1471, 506, 1373, 199, 3, 7614, 543, 2287, 413, 24649, 36, 1772, 413, 6673, 680, 6006, 365, 2597, 282, 11180, 2287, 26, 5450, 14, 199, 3, 1010, 485, 3972, 63, 13488, 15, 1772, 2897, 12, 2337, 365, 282, 5288, 7614, 737, 2287, 22540, 14, 199, 3, 199, 3, 710, 7614, 3509, 5002, 2633, 315, 14775, 4402, 14, 5723, 2633, 1471, 199, 3, 1172, 2757, 10889, 5313, 6657, 370, 5542, 314, 9546, 652, 365, 20921, 4007, 14, 961, 199, 3, 5253, 4440, 436, 14292, 314, 2633, 370, 506, 3211, 14, 199, 3, 710, 2897, 3050, 365, 2808, 315, 282, 570, 2797, 299, 631, 7441, 18, 14, 4616, 14, 710, 199, 3, 510, 1469, 3258, 293, 10370, 5417, 2240, 6127, 370, 2248, 652, 12, 1325, 701, 849, 3181, 1133, 1331, 652, 370, 199, 3, 314, 2222, 13, 32059, 4402, 12, 880, 1265, 1929, 370, 7662, 3354, 3062, 315, 16149, 199, 3, 4402, 14, 334, 6049, 2597, 506, 4224, 543, 314, 644, 8470, 1414, 436, 2505, 298, 1960, 1674, 9, 199, 3, 1010, 6770, 12, 367, 6876, 13, 3813, 24490, 12, 4868, 626, 314, 663, 32642, 10061, 436, 900, 199, 3, 787, 6657, 663, 880, 626, 282, 4057, 365, 8652, 641, 1347, 23661, 8642, 413, 308, 680, 199, 3, 8777, 593, 271, 1292, 12, 314, 283, 1038, 888, 7, 11420, 883, 2597, 506, 1202, 370, 1586, 436, 2218, 314, 199, 3, 16149, 4402, 14, 199, 3, 199, 3, 710, 7614, 5171, 6876, 13, 3813, 818, 334, 73, 14, 69, 2020, 3679, 3421, 316, 9, 1325, 1454, 199, 3, 340, 652, 365, 4568, 370, 282, 8778, 334, 1397, 2032, 9696, 461, 680, 3979, 314, 14991, 199, 3, 965, 949, 8778, 12, 314, 7614, 1077, 506, 1202, 1454, 315, 1551, 13, 3813, 818, 12, 370, 5126, 199, 3, 12927, 391, 1540, 314, 2454, 16530, 14, 2002, 1380, 2337, 365, 949, 8778, 26, 199, 3, 627, 4226, 440, 6258, 8926, 2392, 641, 334, 4985, 47, 1414, 9, 199, 3, 627, 4226, 440, 3222, 3718, 367, 6876, 13, 3813, 25134, 12, 2839, 10362, 54, 503, 603, 20271, 199, 3, 627, 4226, 440, 3222, 314, 1551, 13, 3813, 3718, 593, 2054, 436, 593, 22153, 12, 3967, 2985, 199, 3, 259, 675, 282, 8778, 12, 4634, 199, 3, 199, 3, 710, 7614, 11479, 9978, 19325, 1181, 24434, 14, 2136, 11496, 29772, 383, 334, 36, 1772, 29, 614, 9, 465, 652, 1159, 7377, 199, 3, 436, 652, 12237, 10226, 701, 4036, 1015, 14, 5439, 2202, 787, 1695, 666, 12, 413, 3631, 12, 199, 3, 949, 623, 1209, 14, 199, 3, 199, 3, 1010, 1551, 13, 3813, 12, 314, 7614, 965, 499, 15217, 370, 4057, 314, 2454, 85, 2750, 26, 199, 3, 221, 627, 653, 290, 736, 266, 3637, 26, 4721, 13, 7625, 12, 436, 1846, 6033, 199, 3, 755, 413, 3650, 6146, 1616, 19123, 121, 77, 1928, 2248, 334, 2003, 543, 2248, 9, 199, 3, 221, 627, 1626, 2548, 26, 7437, 28334, 12, 1325, 14569, 5696, 6146, 21, 24461, 77, 199, 3, 420, 298, 2167, 5236, 1086, 13718, 370, 282, 25134, 402, 14106, 14, 650, 14, 19, 24461, 77, 2, 199, 3, 420, 298, 1165, 5236, 1086, 13718, 370, 282, 25134, 402, 14106, 14, 413, 24461, 77, 2, 199, 3, 199, 3, 3709, 376, 1919, 12, 314, 445, 13, 14927, 1454, 5171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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 ]
beiko-lab/gengis
bin/Lib/test/test_ascii_formatd.py
13
1977
# PyOS_ascii_formatd is deprecated and not called from anywhere in # Python itself. So this module is the only place it gets tested. # Test that it works, and test that it's deprecated. import unittest from test.test_support import check_warnings, run_unittest, import_module # Skip tests if _ctypes module does not exist import_module('_ctypes') from ctypes import pythonapi, create_string_buffer, sizeof, byref, c_double PyOS_ascii_formatd = pythonapi.PyOS_ascii_formatd class FormatDeprecationTests(unittest.TestCase): def test_format_deprecation(self): buf = create_string_buffer(' ' * 100) with check_warnings(('PyOS_ascii_formatd is deprecated', DeprecationWarning)): PyOS_ascii_formatd(byref(buf), sizeof(buf), '%+.10f', c_double(10.0)) self.assertEqual(buf.value, '+10.0000000000') class FormatTests(unittest.TestCase): # ensure that, for the restricted set of format codes, # %-formatting returns the same values os PyOS_ascii_formatd def test_format(self): buf = create_string_buffer(' ' * 100) tests = [ ('%f', 100.0), ('%g', 100.0), ('%#g', 100.0), ('%#.2g', 100.0), ('%#.2g', 123.4567), ('%#.2g', 1.234567e200), ('%e', 1.234567e200), ('%e', 1.234), ('%+e', 1.234), ('%-e', 1.234), ] with check_warnings(('PyOS_ascii_formatd is deprecated', DeprecationWarning)): for format, val in tests: PyOS_ascii_formatd(byref(buf), sizeof(buf), format, c_double(val)) self.assertEqual(buf.value, format % val) def test_main(): run_unittest(FormatDeprecationTests, FormatTests) if __name__ == '__main__': test_main()
gpl-3.0
[ 3, 1611, 3100, 63, 4371, 63, 908, 68, 365, 5906, 436, 440, 2797, 687, 26523, 315, 202, 199, 3, 221, 2018, 6337, 14, 2002, 642, 859, 365, 314, 1454, 4192, 652, 7545, 12470, 14, 202, 199, 3, 1379, 626, 652, 5419, 12, 436, 511, 626, 652, 1159, 5906, 14, 2999, 199, 646, 2882, 202, 199, 504, 511, 14, 396, 63, 4058, 492, 1104, 63, 5451, 12, 1255, 63, 2796, 12, 492, 63, 578, 2999, 199, 3, 8232, 2295, 340, 485, 9798, 859, 1630, 440, 2187, 202, 199, 646, 63, 578, 6412, 9798, 358, 2999, 199, 504, 5577, 492, 2366, 1246, 12, 1218, 63, 875, 63, 2738, 12, 13855, 12, 15968, 12, 286, 63, 3157, 202, 199, 2713, 3100, 63, 4371, 63, 908, 68, 275, 2366, 1246, 14, 2713, 3100, 63, 4371, 63, 908, 68, 8065, 199, 533, 9701, 872, 6444, 2925, 8, 2796, 14, 1746, 304, 2958, 347, 511, 63, 908, 63, 15383, 8, 277, 304, 1039, 4123, 275, 1218, 63, 875, 63, 2738, 360, 283, 627, 2948, 9, 4341, 543, 1104, 63, 5451, 4725, 2713, 3100, 63, 4371, 63, 908, 68, 365, 5906, 297, 202, 2490, 13413, 2298, 1675, 1611, 3100, 63, 4371, 63, 908, 68, 8, 20447, 8, 1436, 395, 13855, 8, 1436, 395, 1543, 26240, 709, 70, 297, 202, 3044, 286, 63, 3157, 8, 709, 14, 16, 430, 1675, 291, 14, 629, 8, 1436, 14, 585, 12, 6681, 709, 14, 20625, 358, 8065, 199, 533, 9701, 2925, 8, 2796, 14, 1746, 304, 1128, 327, 4868, 626, 12, 367, 314, 15297, 663, 402, 1475, 9479, 12, 1128, 327, 19752, 20034, 2529, 314, 2011, 1338, 747, 1611, 3100, 63, 4371, 63, 908, 68, 1128, 347, 511, 63, 908, 8, 277, 304, 1039, 4123, 275, 1218, 63, 875, 63, 2738, 360, 283, 627, 2948, 9, 4341, 2295, 275, 359, 1675, 16651, 70, 297, 2948, 14, 16, 395, 1675, 16651, 71, 297, 2948, 14, 16, 395, 1675, 16651, 3, 71, 297, 2948, 14, 16, 395, 1675, 16651, 31827, 18, 71, 297, 2948, 14, 16, 395, 1675, 16651, 31827, 18, 71, 297, 11869, 14, 20, 5308, 395, 1675, 16651, 31827, 18, 71, 297, 413, 14, 5533, 5308, 69, 1840, 395, 1675, 16651, 69, 297, 413, 14, 5533, 5308, 69, 1840, 395, 1675, 16651, 69, 297, 413, 14, 5533, 395, 1675, 16651, 11, 69, 297, 413, 14, 5533, 395, 1675, 16651, 13, 69, 297, 413, 14, 5533, 395, 1675, 1622, 4341, 543, 1104, 63, 5451, 4725, 2713, 3100, 63, 4371, 63, 908, 68, 365, 5906, 297, 202, 2490, 13413, 2298, 1675, 367, 1475, 12, 1139, 315, 2295, 26, 2628, 1611, 3100, 63, 4371, 63, 908, 68, 8, 20447, 8, 1436, 395, 13855, 8, 1436, 395, 1475, 12, 202, 3521, 286, 63, 3157, 8, 637, 430, 2628, 291, 14, 629, 8, 1436, 14, 585, 12, 1475, 450, 1139, 9, 8065, 199, 318, 511, 63, 973, 837, 1128, 1255, 63, 2796, 8, 3484, 872, 6444, 2925, 12, 9701, 2925, 9, 2999, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 511, 63, 973, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1611, 3100, 63, 4371, 63, 908, 68, 365, 5906, 436, 440, 2797, 687, 26523, 315, 202, 199, 3, 221, 2018, 6337, 14, 2002, 642, 859, 365, 314, 1454, 4192, 652, 7545, 12470, 14, 202, 199, 3, 1379, 626, 652, 5419, 12, 436, 511, 626, 652, 1159, 5906, 14, 2999, 199, 646, 2882, 202, 199, 504, 511, 14, 396, 63, 4058, 492, 1104, 63, 5451, 12, 1255, 63, 2796, 12, 492, 63, 578, 2999, 199, 3, 8232, 2295, 340, 485, 9798, 859, 1630, 440, 2187, 202, 199, 646, 63, 578, 6412, 9798, 358, 2999, 199, 504, 5577, 492, 2366, 1246, 12, 1218, 63, 875, 63, 2738, 12, 13855, 12, 15968, 12, 286, 63, 3157, 202, 199, 2713, 3100, 63, 4371, 63, 908, 68, 275, 2366, 1246, 14, 2713, 3100, 63, 4371, 63, 908, 68, 8065, 199, 533, 9701, 872, 6444, 2925, 8, 2796, 14, 1746, 304, 2958, 347, 511, 63, 908, 63, 15383, 8, 277, 304, 1039, 4123, 275, 1218, 63, 875, 63, 2738, 360, 283, 627, 2948, 9, 4341, 543, 1104, 63, 5451, 4725, 2713, 3100, 63, 4371, 63, 908, 68, 365, 5906, 297, 202, 2490, 13413, 2298, 1675, 1611, 3100, 63, 4371, 63, 908, 68, 8, 20447, 8, 1436, 395, 13855, 8, 1436, 395, 1543, 26240, 709, 70, 297, 202, 3044, 286, 63, 3157, 8, 709, 14, 16, 430, 1675, 291, 14, 629, 8, 1436, 14, 585, 12, 6681, 709, 14, 20625, 358, 8065, 199, 533, 9701, 2925, 8, 2796, 14, 1746, 304, 1128, 327, 4868, 626, 12, 367, 314, 15297, 663, 402, 1475, 9479, 12, 1128, 327, 19752, 20034, 2529, 314, 2011, 1338, 747, 1611, 3100, 63, 4371, 63, 908, 68, 1128, 347, 511, 63, 908, 8, 277, 304, 1039, 4123, 275, 1218, 63, 875, 63, 2738, 360, 283, 627, 2948, 9, 4341, 2295, 275, 359, 1675, 16651, 70, 297, 2948, 14, 16, 395, 1675, 16651, 71, 297, 2948, 14, 16, 395, 1675, 16651, 3, 71, 297, 2948, 14, 16, 395, 1675, 16651, 31827, 18, 71, 297, 2948, 14, 16, 395, 1675, 16651, 31827, 18, 71, 297, 11869, 14, 20, 5308, 395, 1675, 16651, 31827, 18, 71, 297, 413, 14, 5533, 5308, 69, 1840, 395, 1675, 16651, 69, 297, 413, 14, 5533, 5308, 69, 1840, 395, 1675, 16651, 69, 297, 413, 14, 5533, 395, 1675, 16651, 11, 69, 297, 413, 14, 5533, 395, 1675, 16651, 13, 69, 297, 413, 14, 5533, 395, 1675, 1622, 4341, 543, 1104, 63, 5451, 4725, 2713, 3100, 63, 4371, 63, 908, 68, 365, 5906, 297, 202, 2490, 13413, 2298, 1675, 367, 1475, 12, 1139, 315, 2295, 26, 2628, 1611, 3100, 63, 4371, 63, 908, 68, 8, 20447, 8, 1436, 395, 13855, 8, 1436, 395, 1475, 12, 202, 3521, 286, 63, 3157, 8, 637, 430, 2628, 291, 14, 629, 8, 1436, 14, 585, 12, 1475, 450, 1139, 9, 8065, 199, 318, 511, 63, 973, 837, 1128, 1255, 63, 2796, 8, 3484, 872, 6444, 2925, 12, 9701, 2925, 9, 2999, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 511, 63, 973, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
Fusion-Rom/android_external_chromium_org
chrome/common/extensions/docs/server2/appengine_wrappers.py
25
8570
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. def IsDeadlineExceededError(error): '''A general way of determining whether |error| is a DeadlineExceededError, since there are 3 different types thrown by AppEngine and we might as well handle them all the same way. For more info see: https://developers.google.com/appengine/articles/deadlineexceedederrors ''' return type(error).__name__ == 'DeadlineExceededError' def IsDownloadError(error): return type(error).__name__ == 'DownloadError' # This will attempt to import the actual App Engine modules, and if it fails, # they will be replaced with fake modules. This is useful during testing. try: import google.appengine.api.app_identity as app_identity import google.appengine.api.files as files import google.appengine.api.logservice as logservice import google.appengine.api.memcache as memcache import google.appengine.api.taskqueue as taskqueue import google.appengine.api.urlfetch as urlfetch import google.appengine.ext.blobstore as blobstore from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty import google.appengine.ext.db as db import webapp2 except ImportError: import re from StringIO import StringIO FAKE_URL_FETCHER_CONFIGURATION = None def ConfigureFakeUrlFetch(configuration): """|configuration| is a dictionary mapping strings to fake urlfetch classes. A fake urlfetch class just needs to have a fetch method. The keys of the dictionary are treated as regex, and they are matched with the URL to determine which fake urlfetch is used. """ global FAKE_URL_FETCHER_CONFIGURATION FAKE_URL_FETCHER_CONFIGURATION = dict( (re.compile(k), v) for k, v in configuration.iteritems()) def _GetConfiguration(key): if not FAKE_URL_FETCHER_CONFIGURATION: raise ValueError('No fake fetch paths have been configured. ' 'See ConfigureFakeUrlFetch in appengine_wrappers.py.') for k, v in FAKE_URL_FETCHER_CONFIGURATION.iteritems(): if k.match(key): return v raise ValueError('No configuration found for %s' % key) class _RPC(object): def __init__(self, result=None): self.result = result def get_result(self): return self.result def wait(self): pass class FakeAppIdentity(object): """A fake app_identity module that returns no access tokens.""" def get_access_token(self, scope): return (None, None) app_identity = FakeAppIdentity() class FakeUrlFetch(object): """A fake urlfetch module that uses the current |FAKE_URL_FETCHER_CONFIGURATION| to map urls to fake fetchers. """ class DownloadError(Exception): pass class _Response(object): def __init__(self, content): self.content = content self.headers = {'Content-Type': 'none'} self.status_code = 200 def fetch(self, url, **kwargs): url = url.split('?', 1)[0] response = self._Response(_GetConfiguration(url).fetch(url)) if response.content is None: response.status_code = 404 return response def create_rpc(self, **kwargs): return _RPC() def make_fetch_call(self, rpc, url, **kwargs): rpc.result = self.fetch(url) urlfetch = FakeUrlFetch() _BLOBS = {} class FakeBlobstore(object): class BlobNotFoundError(Exception): pass class BlobReader(object): def __init__(self, blob_key): self._data = _BLOBS[blob_key].getvalue() def read(self): return self._data blobstore = FakeBlobstore() class FakeFileInterface(object): """This class allows a StringIO object to be used in a with block like a file. """ def __init__(self, io): self._io = io def __exit__(self, *args): pass def write(self, data): self._io.write(data) def __enter__(self, *args): return self._io class FakeFiles(object): _next_blobstore_key = 0 class blobstore(object): @staticmethod def create(): FakeFiles._next_blobstore_key += 1 return FakeFiles._next_blobstore_key @staticmethod def get_blob_key(filename): return filename def open(self, filename, mode): _BLOBS[filename] = StringIO() return FakeFileInterface(_BLOBS[filename]) def GetBlobKeys(self): return _BLOBS.keys() def finalize(self, filename): pass files = FakeFiles() class Logservice(object): AUTOFLUSH_ENABLED = True def flush(self): pass logservice = Logservice() class InMemoryMemcache(object): """An in-memory memcache implementation. """ def __init__(self): self._namespaces = {} class Client(object): def set_multi_async(self, mapping, namespace='', time=0): for k, v in mapping.iteritems(): memcache.set(k, v, namespace=namespace, time=time) def get_multi_async(self, keys, namespace='', time=0): return _RPC(result=dict( (k, memcache.get(k, namespace=namespace, time=time)) for k in keys)) def set(self, key, value, namespace='', time=0): self._GetNamespace(namespace)[key] = value def get(self, key, namespace='', time=0): return self._GetNamespace(namespace).get(key) def delete(self, key, namespace=''): self._GetNamespace(namespace).pop(key, None) def delete_multi(self, keys, namespace=''): for k in keys: self.delete(k, namespace=namespace) def _GetNamespace(self, namespace): if namespace not in self._namespaces: self._namespaces[namespace] = {} return self._namespaces[namespace] memcache = InMemoryMemcache() class webapp2(object): class RequestHandler(object): """A fake webapp2.RequestHandler class for Handler to extend. """ def __init__(self, request, response): self.request = request self.response = response self.response.status = 200 def redirect(self, path, permanent=False): self.response.status = 301 if permanent else 302 self.response.headers['Location'] = path class _Db_Result(object): def __init__(self, data): self._data = data class _Result(object): def __init__(self, value): self.value = value def get(self): return self._Result(self._data) class db(object): _store = {} class StringProperty(object): pass class BlobProperty(object): pass class Key(object): def __init__(self, key): self._key = key @staticmethod def from_path(model_name, path): return db.Key('%s/%s' % (model_name, path)) def __eq__(self, obj): return self.__class__ == obj.__class__ and self._key == obj._key def __hash__(self): return hash(self._key) def __str__(self): return str(self._key) class Model(object): key = None def __init__(self, **optargs): cls = self.__class__ for k, v in optargs.iteritems(): assert hasattr(cls, k), '%s does not define property %s' % ( cls.__name__, k) setattr(self, k, v) @staticmethod def gql(query, key): return _Db_Result(db._store.get(key)) def put(self): db._store[self.key_] = self.value @staticmethod def get_async(key): return _RPC(result=db._store.get(key)) @staticmethod def delete_async(key): db._store.pop(key, None) return _RPC() @staticmethod def put_async(value): db._store[value.key] = value return _RPC() class BlobReferenceProperty(object): pass # Executes any queued tasks synchronously as they are queued. _task_runner = None def SetTaskRunnerForTest(task_runner): global _task_runner _task_runner = task_runner class SynchronousTaskQueue(object): class Task(object): def __init__(self, url=None, params={}): self.url_ = url self.params_ = params def GetUrl(self): return self.url_ def GetCommit(self): return self.params_.get('commit') class Queue(object): def __init__(self, name='default'): pass def add(self, task): global _task_runner if _task_runner: _task_runner(task.GetUrl(), task.GetCommit()) return _RPC() def purge(self): return _RPC() taskqueue = SynchronousTaskQueue()
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 318, 6596, 22147, 604, 24748, 547, 8, 705, 304, 523, 1449, 33, 8605, 4340, 402, 26638, 3775, 1204, 705, 92, 365, 282, 1487, 350, 604, 24748, 547, 12, 523, 3967, 2337, 787, 650, 3365, 2943, 14031, 701, 4693, 8524, 436, 781, 5594, 465, 5521, 523, 2429, 3062, 1006, 314, 2011, 4340, 14, 2104, 1655, 2256, 1937, 26, 523, 4178, 921, 23826, 14, 3098, 14, 957, 15, 15358, 15, 19813, 15, 22357, 476, 29377, 271, 424, 451, 83, 523, 1449, 523, 372, 730, 8, 705, 2843, 354, 363, 508, 283, 22147, 604, 24748, 547, 7, 421, 199, 318, 6596, 11950, 547, 8, 705, 304, 523, 372, 730, 8, 705, 2843, 354, 363, 508, 283, 11950, 547, 7, 421, 199, 3, 961, 911, 7427, 370, 492, 314, 3503, 4693, 12580, 4621, 12, 436, 340, 652, 6918, 12, 199, 3, 2985, 911, 506, 8717, 543, 4026, 4621, 14, 961, 365, 2997, 5309, 5343, 14, 199, 893, 26, 523, 492, 6233, 14, 15358, 14, 1246, 14, 571, 63, 5582, 465, 1145, 63, 5582, 523, 492, 6233, 14, 15358, 14, 1246, 14, 1725, 465, 1584, 523, 492, 6233, 14, 15358, 14, 1246, 14, 793, 1364, 465, 943, 1364, 523, 492, 6233, 14, 15358, 14, 1246, 14, 25835, 465, 21598, 523, 492, 6233, 14, 15358, 14, 1246, 14, 1765, 1825, 465, 2120, 1825, 523, 492, 6233, 14, 15358, 14, 1246, 14, 300, 29429, 465, 7629, 29429, 523, 492, 6233, 14, 15358, 14, 832, 14, 6582, 1617, 465, 9182, 1617, 523, 687, 6233, 14, 15358, 14, 832, 14, 6582, 1617, 14, 6582, 1617, 492, 31745, 5083, 3697, 523, 492, 6233, 14, 15358, 14, 832, 14, 697, 465, 1592, 523, 492, 24812, 18, 199, 2590, 3545, 26, 523, 492, 295, 523, 687, 5228, 492, 5228, 819, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 275, 488, 819, 347, 15453, 8249, 6417, 11135, 8, 4758, 304, 272, 408, 92, 4758, 92, 365, 282, 2600, 4412, 3326, 370, 4026, 7629, 29429, 3992, 14, 272, 437, 4026, 7629, 29429, 1021, 2951, 4839, 370, 1172, 282, 5267, 1083, 14, 710, 2883, 402, 314, 272, 2600, 787, 10184, 465, 5163, 12, 436, 2985, 787, 7838, 543, 314, 2851, 370, 272, 6705, 1314, 4026, 7629, 29429, 365, 1202, 14, 272, 408, 272, 2288, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 272, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 275, 1211, 8, 267, 334, 264, 14, 2014, 8, 75, 395, 373, 9, 367, 1022, 12, 373, 315, 2897, 14, 4611, 1012, 819, 347, 485, 1002, 5688, 8, 498, 304, 272, 340, 440, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 26, 489, 746, 1722, 360, 1944, 4026, 5267, 3792, 1172, 2757, 7526, 14, 283, 2432, 283, 9295, 15453, 8249, 6417, 11135, 315, 1145, 3908, 63, 21148, 14, 647, 2659, 272, 367, 1022, 12, 373, 315, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 14, 4611, 837, 489, 340, 1022, 14, 1431, 8, 498, 304, 267, 372, 373, 272, 746, 1722, 360, 1944, 2897, 1911, 367, 450, 83, 7, 450, 790, 9, 819, 1021, 485, 8171, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 754, 29, 403, 304, 489, 291, 14, 1099, 275, 754, 339, 347, 664, 63, 1099, 8, 277, 304, 489, 372, 291, 14, 1099, 339, 347, 3618, 8, 277, 304, 489, 986, 819, 1021, 7777, 2640, 10193, 8, 785, 304, 272, 408, 33, 4026, 1145, 63, 5582, 859, 626, 2529, 949, 2879, 4645, 1041, 272, 347, 664, 63, 2732, 63, 1418, 8, 277, 12, 4194, 304, 489, 372, 334, 403, 12, 488, 9, 523, 1145, 63, 5582, 275, 7777, 2640, 10193, 342, 819, 1021, 7777, 6417, 11135, 8, 785, 304, 272, 408, 33, 4026, 7629, 29429, 859, 626, 4440, 314, 1453, 272, 1204, 14623, 63, 2632, 63, 32097, 540, 63, 22212, 92, 370, 2341, 8187, 370, 4026, 5267, 1192, 14, 272, 408, 272, 1021, 17955, 547, 8, 1726, 304, 489, 986, 339, 1021, 485, 2364, 8, 785, 304, 489, 347, 636, 826, 721, 277, 12, 1564, 304, 267, 291, 14, 1317, 275, 1564, 267, 291, 14, 2139, 275, 791, 2714, 13, 804, 356, 283, 3592, 936, 267, 291, 14, 1205, 63, 600, 275, 1926, 339, 347, 5267, 8, 277, 12, 1166, 12, 1011, 958, 304, 489, 1166, 275, 1166, 14, 1294, 360, 7044, 413, 2788, 16, 61, 489, 1177, 275, 291, 423, 2364, 1547, 1002, 5688, 8, 633, 680, 3535, 8, 633, 430, 489, 340, 1177, 14, 1317, 365, 488, 26, 267, 1177, 14, 1205, 63, 600, 275, 7901, 489, 372, 1177, 339, 347, 1218, 63, 4354, 8, 277, 12, 1011, 958, 304, 489, 372, 485, 8171, 342, 339, 347, 1852, 63, 3535, 63, 1250, 8, 277, 12, 8985, 12, 1166, 12, 1011, 958, 304, 489, 8985, 14, 1099, 275, 291, 14, 3535, 8, 633, 9, 523, 7629, 29429, 275, 7777, 6417, 11135, 342, 819, 485, 26275, 51, 275, 1052, 523, 1021, 7777, 16799, 1617, 8, 785, 304, 272, 1021, 31745, 10870, 8, 1726, 304, 489, 986, 339, 1021, 31745, 5929, 8, 785, 304, 489, 347, 636, 826, 721, 277, 12, 9182, 63, 498, 304, 267, 291, 423, 576, 275, 485, 26275, 51, 59, 6582, 63, 498, 1055, 7150, 342, 2541, 347, 1586, 8, 277, 304, 267, 372, 291, 423, 576, 819, 9182, 1617, 275, 7777, 16799, 1617, 342, 819, 1021, 7777, 1173, 4267, 8, 785, 304, 272, 408, 2765, 1021, 6127, 282, 5228, 909, 370, 506, 1202, 315, 282, 543, 1853, 2839, 282, 272, 570, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5890, 304, 489, 291, 423, 2308, 275, 5890, 339, 347, 636, 2224, 721, 277, 12, 627, 589, 304, 489, 986, 339, 347, 2218, 8, 277, 12, 666, 304, 489, 291, 423, 2308, 14, 952, 8, 576, 9, 339, 347, 636, 4200, 721, 277, 12, 627, 589, 304, 489, 372, 291, 423, 2308, 819, 1021, 7777, 5535, 8, 785, 304, 272, 485, 2184, 63, 6582, 1617, 63, 498, 275, 378, 272, 1021, 9182, 1617, 8, 785 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 318, 6596, 22147, 604, 24748, 547, 8, 705, 304, 523, 1449, 33, 8605, 4340, 402, 26638, 3775, 1204, 705, 92, 365, 282, 1487, 350, 604, 24748, 547, 12, 523, 3967, 2337, 787, 650, 3365, 2943, 14031, 701, 4693, 8524, 436, 781, 5594, 465, 5521, 523, 2429, 3062, 1006, 314, 2011, 4340, 14, 2104, 1655, 2256, 1937, 26, 523, 4178, 921, 23826, 14, 3098, 14, 957, 15, 15358, 15, 19813, 15, 22357, 476, 29377, 271, 424, 451, 83, 523, 1449, 523, 372, 730, 8, 705, 2843, 354, 363, 508, 283, 22147, 604, 24748, 547, 7, 421, 199, 318, 6596, 11950, 547, 8, 705, 304, 523, 372, 730, 8, 705, 2843, 354, 363, 508, 283, 11950, 547, 7, 421, 199, 3, 961, 911, 7427, 370, 492, 314, 3503, 4693, 12580, 4621, 12, 436, 340, 652, 6918, 12, 199, 3, 2985, 911, 506, 8717, 543, 4026, 4621, 14, 961, 365, 2997, 5309, 5343, 14, 199, 893, 26, 523, 492, 6233, 14, 15358, 14, 1246, 14, 571, 63, 5582, 465, 1145, 63, 5582, 523, 492, 6233, 14, 15358, 14, 1246, 14, 1725, 465, 1584, 523, 492, 6233, 14, 15358, 14, 1246, 14, 793, 1364, 465, 943, 1364, 523, 492, 6233, 14, 15358, 14, 1246, 14, 25835, 465, 21598, 523, 492, 6233, 14, 15358, 14, 1246, 14, 1765, 1825, 465, 2120, 1825, 523, 492, 6233, 14, 15358, 14, 1246, 14, 300, 29429, 465, 7629, 29429, 523, 492, 6233, 14, 15358, 14, 832, 14, 6582, 1617, 465, 9182, 1617, 523, 687, 6233, 14, 15358, 14, 832, 14, 6582, 1617, 14, 6582, 1617, 492, 31745, 5083, 3697, 523, 492, 6233, 14, 15358, 14, 832, 14, 697, 465, 1592, 523, 492, 24812, 18, 199, 2590, 3545, 26, 523, 492, 295, 523, 687, 5228, 492, 5228, 819, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 275, 488, 819, 347, 15453, 8249, 6417, 11135, 8, 4758, 304, 272, 408, 92, 4758, 92, 365, 282, 2600, 4412, 3326, 370, 4026, 7629, 29429, 3992, 14, 272, 437, 4026, 7629, 29429, 1021, 2951, 4839, 370, 1172, 282, 5267, 1083, 14, 710, 2883, 402, 314, 272, 2600, 787, 10184, 465, 5163, 12, 436, 2985, 787, 7838, 543, 314, 2851, 370, 272, 6705, 1314, 4026, 7629, 29429, 365, 1202, 14, 272, 408, 272, 2288, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 272, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 275, 1211, 8, 267, 334, 264, 14, 2014, 8, 75, 395, 373, 9, 367, 1022, 12, 373, 315, 2897, 14, 4611, 1012, 819, 347, 485, 1002, 5688, 8, 498, 304, 272, 340, 440, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 26, 489, 746, 1722, 360, 1944, 4026, 5267, 3792, 1172, 2757, 7526, 14, 283, 2432, 283, 9295, 15453, 8249, 6417, 11135, 315, 1145, 3908, 63, 21148, 14, 647, 2659, 272, 367, 1022, 12, 373, 315, 25699, 63, 2632, 63, 32097, 540, 63, 22212, 14, 4611, 837, 489, 340, 1022, 14, 1431, 8, 498, 304, 267, 372, 373, 272, 746, 1722, 360, 1944, 2897, 1911, 367, 450, 83, 7, 450, 790, 9, 819, 1021, 485, 8171, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 754, 29, 403, 304, 489, 291, 14, 1099, 275, 754, 339, 347, 664, 63, 1099, 8, 277, 304, 489, 372, 291, 14, 1099, 339, 347, 3618, 8, 277, 304, 489, 986, 819, 1021, 7777, 2640, 10193, 8, 785, 304, 272, 408, 33, 4026, 1145, 63, 5582, 859, 626, 2529, 949, 2879, 4645, 1041, 272, 347, 664, 63, 2732, 63, 1418, 8, 277, 12, 4194, 304, 489, 372, 334, 403, 12, 488, 9, 523, 1145, 63, 5582, 275, 7777, 2640, 10193, 342, 819, 1021, 7777, 6417, 11135, 8, 785, 304, 272, 408, 33, 4026, 7629, 29429, 859, 626, 4440, 314, 1453, 272, 1204, 14623, 63, 2632, 63, 32097, 540, 63, 22212, 92, 370, 2341, 8187, 370, 4026, 5267, 1192, 14, 272, 408, 272, 1021, 17955, 547, 8, 1726, 304, 489, 986, 339, 1021, 485, 2364, 8, 785, 304, 489, 347, 636, 826, 721, 277, 12, 1564, 304, 267, 291, 14, 1317, 275, 1564, 267, 291, 14, 2139, 275, 791, 2714, 13, 804, 356, 283, 3592, 936, 267, 291, 14, 1205, 63, 600, 275, 1926, 339, 347, 5267, 8, 277, 12, 1166, 12, 1011, 958, 304, 489, 1166, 275, 1166, 14, 1294, 360, 7044, 413, 2788, 16, 61, 489, 1177, 275, 291, 423, 2364, 1547, 1002, 5688, 8, 633, 680, 3535, 8, 633, 430, 489, 340, 1177, 14, 1317, 365, 488, 26, 267, 1177, 14, 1205, 63, 600, 275, 7901, 489, 372, 1177, 339, 347, 1218, 63, 4354, 8, 277, 12, 1011, 958, 304, 489, 372, 485, 8171, 342, 339, 347, 1852, 63, 3535, 63, 1250, 8, 277, 12, 8985, 12, 1166, 12, 1011, 958, 304, 489, 8985, 14, 1099, 275, 291, 14, 3535, 8, 633, 9, 523, 7629, 29429, 275, 7777, 6417, 11135, 342, 819, 485, 26275, 51, 275, 1052, 523, 1021, 7777, 16799, 1617, 8, 785, 304, 272, 1021, 31745, 10870, 8, 1726, 304, 489, 986, 339, 1021, 31745, 5929, 8, 785, 304, 489, 347, 636, 826, 721, 277, 12, 9182, 63, 498, 304, 267, 291, 423, 576, 275, 485, 26275, 51, 59, 6582, 63, 498, 1055, 7150, 342, 2541, 347, 1586, 8, 277, 304, 267, 372, 291, 423, 576, 819, 9182, 1617, 275, 7777, 16799, 1617, 342, 819, 1021, 7777, 1173, 4267, 8, 785, 304, 272, 408, 2765, 1021, 6127, 282, 5228, 909, 370, 506, 1202, 315, 282, 543, 1853, 2839, 282, 272, 570, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5890, 304, 489, 291, 423, 2308, 275, 5890, 339, 347, 636, 2224, 721, 277, 12, 627, 589, 304, 489, 986, 339, 347, 2218, 8, 277, 12, 666, 304, 489, 291, 423, 2308, 14, 952, 8, 576, 9, 339, 347, 636, 4200, 721, 277, 12, 627, 589, 304, 489, 372, 291, 423, 2308, 819, 1021, 7777, 5535, 8, 785, 304, 272, 485, 2184, 63, 6582, 1617, 63, 498, 275, 378, 272, 1021, 9182, 1617, 8, 785, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
trondhindenes/ansible
lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
27
3766
#!/usr/bin/python # coding: utf-8 -*- # (c) 2017, Wayne Witzel III <wayne@riotousliving.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: tower_user author: "Wayne Witzel III (@wwitzel3)" version_added: "2.3" short_description: create, update, or destroy Ansible Tower user. description: - Create, update, or destroy Ansible Tower users. See U(https://www.ansible.com/tower) for an overview. options: username: description: - The username of the user. required: True first_name: description: - First name of the user. last_name: description: - Last name of the user. email: description: - Email address of the user. required: True password: description: - Password of the user. superuser: description: - User is a system wide administator. type: bool default: 'no' auditor: description: - User is a system wide auditor. type: bool default: 'no' state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] extends_documentation_fragment: tower ''' EXAMPLES = ''' - name: Add tower user tower_user: username: jdoe password: foobarbaz email: jdoe@example.org first_name: John last_name: Doe state: present tower_config_file: "~/tower_cli.cfg" ''' from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode try: import tower_cli import tower_cli.utils.exceptions as exc from tower_cli.conf import settings except ImportError: pass def main(): argument_spec = dict( username=dict(required=True), first_name=dict(), last_name=dict(), password=dict(no_log=True), email=dict(required=True), superuser=dict(type='bool', default=False), auditor=dict(type='bool', default=False), state=dict(choices=['present', 'absent'], default='present'), ) module = TowerModule(argument_spec=argument_spec, supports_check_mode=True) username = module.params.get('username') first_name = module.params.get('first_name') last_name = module.params.get('last_name') password = module.params.get('password') email = module.params.get('email') superuser = module.params.get('superuser') auditor = module.params.get('auditor') state = module.params.get('state') json_output = {'username': username, 'state': state} tower_auth = tower_auth_config(module) with settings.runtime_values(**tower_auth): tower_check_mode(module) user = tower_cli.get_resource('user') try: if state == 'present': result = user.modify(username=username, first_name=first_name, last_name=last_name, email=email, password=password, is_superuser=superuser, is_auditor=auditor, create_on_missing=True) json_output['id'] = result['id'] elif state == 'absent': result = user.delete(username=username) except (exc.ConnectionError, exc.BadRequest) as excinfo: module.fail_json(msg='Failed to update the user: {0}'.format(excinfo), changed=False) json_output['changed'] = result['changed'] module.exit_json(**json_output) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 12, 644, 1187, 685, 644, 23751, 352, 473, 8921, 665, 3316, 685, 32, 322, 357, 1785, 317, 4007, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18915, 63, 751, 199, 2502, 26, 298, 25544, 685, 644, 23751, 352, 473, 8921, 8593, 978, 23751, 352, 19, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 1218, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 922, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 4390, 14, 1666, 489, 738, 8, 2859, 921, 1544, 14, 4853, 14, 957, 15, 21651, 9, 367, 376, 23503, 14, 199, 1419, 26, 272, 3434, 26, 489, 1369, 26, 267, 446, 710, 3434, 402, 314, 922, 14, 489, 1415, 26, 715, 272, 1642, 63, 354, 26, 489, 1369, 26, 267, 446, 7758, 536, 402, 314, 922, 14, 272, 2061, 63, 354, 26, 489, 1369, 26, 267, 446, 15237, 536, 402, 314, 922, 14, 272, 3031, 26, 489, 1369, 26, 267, 446, 11426, 2287, 402, 314, 922, 14, 489, 1415, 26, 715, 272, 2505, 26, 489, 1369, 26, 267, 446, 13635, 402, 314, 922, 14, 272, 32590, 26, 489, 1369, 26, 267, 446, 2876, 365, 282, 2656, 20239, 4628, 631, 707, 14, 489, 730, 26, 2155, 489, 849, 26, 283, 889, 7, 272, 13968, 269, 26, 489, 1369, 26, 267, 446, 2876, 365, 282, 2656, 20239, 13968, 269, 14, 489, 730, 26, 2155, 489, 849, 26, 283, 889, 7, 272, 1174, 26, 489, 1369, 26, 267, 446, 1487, 5381, 1174, 402, 314, 2073, 14, 489, 849, 26, 298, 1881, 2, 489, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 199, 11036, 63, 9970, 63, 7677, 26, 18915, 199, 2344, 421, 199, 8918, 275, 1449, 199, 13, 536, 26, 2654, 18915, 922, 523, 18915, 63, 751, 26, 272, 3434, 26, 1335, 1117, 69, 272, 2505, 26, 29245, 6185, 272, 3031, 26, 1335, 1117, 69, 32, 2694, 14, 1308, 272, 1642, 63, 354, 26, 17815, 272, 2061, 63, 354, 26, 30795, 272, 1174, 26, 3451, 272, 18915, 63, 888, 63, 493, 26, 26810, 15, 21651, 63, 2764, 14, 4128, 2, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4853, 63, 21651, 492, 377, 3891, 2377, 12, 18915, 63, 1178, 63, 888, 12, 18915, 63, 1074, 63, 632, 199, 199, 893, 26, 272, 492, 18915, 63, 2764, 272, 492, 18915, 63, 2764, 14, 1208, 14, 3924, 465, 3178, 339, 687, 18915, 63, 2764, 14, 2190, 492, 2202, 199, 2590, 3545, 26, 272, 986, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 1211, 8, 267, 3434, 29, 807, 8, 2427, 29, 549, 395, 267, 1642, 63, 354, 29, 807, 1062, 267, 2061, 63, 354, 29, 807, 1062, 267, 2505, 29, 807, 8, 889, 63, 793, 29, 549, 395, 267, 3031, 29, 807, 8, 2427, 29, 549, 395, 267, 32590, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 797, 395, 267, 13968, 269, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 797, 395, 267, 1174, 29, 807, 8, 4577, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 272, 776, 339, 859, 275, 377, 3891, 2377, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 549, 9, 339, 3434, 275, 859, 14, 1162, 14, 362, 360, 2473, 358, 272, 1642, 63, 354, 275, 859, 14, 1162, 14, 362, 360, 2246, 63, 354, 358, 272, 2061, 63, 354, 275, 859, 14, 1162, 14, 362, 360, 2019, 63, 354, 358, 272, 2505, 275, 859, 14, 1162, 14, 362, 360, 2060, 358, 272, 3031, 275, 859, 14, 1162, 14, 362, 360, 2123, 358, 272, 32590, 275, 859, 14, 1162, 14, 362, 360, 11434, 358, 272, 13968, 269, 275, 859, 14, 1162, 14, 362, 360, 14274, 269, 358, 272, 1174, 275, 859, 14, 1162, 14, 362, 360, 929, 358, 339, 2022, 63, 1199, 275, 791, 2473, 356, 3434, 12, 283, 929, 356, 1174, 93, 339, 18915, 63, 1178, 275, 18915, 63, 1178, 63, 888, 8, 578, 9, 272, 543, 2202, 14, 7726, 63, 1459, 3682, 21651, 63, 1178, 304, 267, 18915, 63, 1074, 63, 632, 8, 578, 9, 267, 922, 275, 18915, 63, 2764, 14, 362, 63, 1927, 360, 751, 358, 267, 862, 26, 288, 340, 1174, 508, 283, 1881, 356, 355, 754, 275, 922, 14, 8951, 8, 2473, 29, 2473, 12, 1642, 63, 354, 29, 2246, 63, 354, 12, 2061, 63, 354, 29, 2019, 63, 354, 12, 3660, 3031, 29, 2123, 12, 2505, 29, 2060, 12, 365, 63, 11434, 29, 11434, 12, 3660, 365, 63, 14274, 269, 29, 14274, 269, 12, 1218, 63, 265, 63, 4752, 29, 549, 9, 355, 2022, 63, 1199, 459, 344, 418, 275, 754, 459, 344, 418, 288, 916, 1174, 508, 283, 5575, 356, 355, 754, 275, 922, 14, 1807, 8, 2473, 29, 2473, 9, 267, 871, 334, 2804, 14, 20349, 12, 3178, 14, 12380, 9, 465, 21596, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 534, 4276, 370, 1678, 314, 922, 26, 469, 16, 5285, 908, 8, 27447, 395, 2896, 29, 797, 9, 339, 2022, 63, 1199, 459, 2489, 418, 275, 754, 459, 2489, 418, 272, 859, 14, 2224, 63, 1001, 3682, 1001, 63, 1199, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 12, 644, 1187, 685, 644, 23751, 352, 473, 8921, 665, 3316, 685, 32, 322, 357, 1785, 317, 4007, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18915, 63, 751, 199, 2502, 26, 298, 25544, 685, 644, 23751, 352, 473, 8921, 8593, 978, 23751, 352, 19, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 1218, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 922, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 4390, 14, 1666, 489, 738, 8, 2859, 921, 1544, 14, 4853, 14, 957, 15, 21651, 9, 367, 376, 23503, 14, 199, 1419, 26, 272, 3434, 26, 489, 1369, 26, 267, 446, 710, 3434, 402, 314, 922, 14, 489, 1415, 26, 715, 272, 1642, 63, 354, 26, 489, 1369, 26, 267, 446, 7758, 536, 402, 314, 922, 14, 272, 2061, 63, 354, 26, 489, 1369, 26, 267, 446, 15237, 536, 402, 314, 922, 14, 272, 3031, 26, 489, 1369, 26, 267, 446, 11426, 2287, 402, 314, 922, 14, 489, 1415, 26, 715, 272, 2505, 26, 489, 1369, 26, 267, 446, 13635, 402, 314, 922, 14, 272, 32590, 26, 489, 1369, 26, 267, 446, 2876, 365, 282, 2656, 20239, 4628, 631, 707, 14, 489, 730, 26, 2155, 489, 849, 26, 283, 889, 7, 272, 13968, 269, 26, 489, 1369, 26, 267, 446, 2876, 365, 282, 2656, 20239, 13968, 269, 14, 489, 730, 26, 2155, 489, 849, 26, 283, 889, 7, 272, 1174, 26, 489, 1369, 26, 267, 446, 1487, 5381, 1174, 402, 314, 2073, 14, 489, 849, 26, 298, 1881, 2, 489, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 199, 11036, 63, 9970, 63, 7677, 26, 18915, 199, 2344, 421, 199, 8918, 275, 1449, 199, 13, 536, 26, 2654, 18915, 922, 523, 18915, 63, 751, 26, 272, 3434, 26, 1335, 1117, 69, 272, 2505, 26, 29245, 6185, 272, 3031, 26, 1335, 1117, 69, 32, 2694, 14, 1308, 272, 1642, 63, 354, 26, 17815, 272, 2061, 63, 354, 26, 30795, 272, 1174, 26, 3451, 272, 18915, 63, 888, 63, 493, 26, 26810, 15, 21651, 63, 2764, 14, 4128, 2, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4853, 63, 21651, 492, 377, 3891, 2377, 12, 18915, 63, 1178, 63, 888, 12, 18915, 63, 1074, 63, 632, 199, 199, 893, 26, 272, 492, 18915, 63, 2764, 272, 492, 18915, 63, 2764, 14, 1208, 14, 3924, 465, 3178, 339, 687, 18915, 63, 2764, 14, 2190, 492, 2202, 199, 2590, 3545, 26, 272, 986, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 1211, 8, 267, 3434, 29, 807, 8, 2427, 29, 549, 395, 267, 1642, 63, 354, 29, 807, 1062, 267, 2061, 63, 354, 29, 807, 1062, 267, 2505, 29, 807, 8, 889, 63, 793, 29, 549, 395, 267, 3031, 29, 807, 8, 2427, 29, 549, 395, 267, 32590, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 797, 395, 267, 13968, 269, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 797, 395, 267, 1174, 29, 807, 8, 4577, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 272, 776, 339, 859, 275, 377, 3891, 2377, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 549, 9, 339, 3434, 275, 859, 14, 1162, 14, 362, 360, 2473, 358, 272, 1642, 63, 354, 275, 859, 14, 1162, 14, 362, 360, 2246, 63, 354, 358, 272, 2061, 63, 354, 275, 859, 14, 1162, 14, 362, 360, 2019, 63, 354, 358, 272, 2505, 275, 859, 14, 1162, 14, 362, 360, 2060, 358, 272, 3031, 275, 859, 14, 1162, 14, 362, 360, 2123, 358, 272, 32590, 275, 859, 14, 1162, 14, 362, 360, 11434, 358, 272, 13968, 269, 275, 859, 14, 1162, 14, 362, 360, 14274, 269, 358, 272, 1174, 275, 859, 14, 1162, 14, 362, 360, 929, 358, 339, 2022, 63, 1199, 275, 791, 2473, 356, 3434, 12, 283, 929, 356, 1174, 93, 339, 18915, 63, 1178, 275, 18915, 63, 1178, 63, 888, 8, 578, 9, 272, 543, 2202, 14, 7726, 63, 1459, 3682, 21651, 63, 1178, 304, 267, 18915, 63, 1074, 63, 632, 8, 578, 9, 267, 922, 275, 18915, 63, 2764, 14, 362, 63, 1927, 360, 751, 358, 267, 862, 26, 288, 340, 1174, 508, 283, 1881, 356, 355, 754, 275, 922, 14, 8951, 8, 2473, 29, 2473, 12, 1642, 63, 354, 29, 2246, 63, 354, 12, 2061, 63, 354, 29, 2019, 63, 354, 12, 3660, 3031, 29, 2123, 12, 2505, 29, 2060, 12, 365, 63, 11434, 29, 11434, 12, 3660, 365, 63, 14274, 269, 29, 14274, 269, 12, 1218, 63, 265, 63, 4752, 29, 549, 9, 355, 2022, 63, 1199, 459, 344, 418, 275, 754, 459, 344, 418, 288, 916, 1174, 508, 283, 5575, 356, 355, 754, 275, 922, 14, 1807, 8, 2473, 29, 2473, 9, 267, 871, 334, 2804, 14, 20349, 12, 3178, 14, 12380, 9, 465, 21596, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 534, 4276, 370, 1678, 314, 922, 26, 469, 16, 5285, 908, 8, 27447, 395, 2896, 29, 797, 9, 339, 2022, 63, 1199, 459, 2489, 418, 275, 754, 459, 2489, 418, 272, 859, 14, 2224, 63, 1001, 3682, 1001, 63, 1199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
peacekeeper/indy-sdk
docs/how-tos/rotate-key/python/step4.py
4
1548
print_log('\n13. Reading new verkey from wallet\n') verkey_in_wallet = await did.key_for_local_did(wallet_handle, trust_anchor_did) print_log('Trust Anchor Verkey in wallet: ', verkey_in_wallet) print_log('\n14. Building GET_NYM request to get Trust Anchor verkey\n') get_nym_request = await ledger.build_get_nym_request(trust_anchor_did, trust_anchor_did) print_log('Get NYM request:') pprint.pprint(json.loads(get_nym_request)) print_log('\n15. Sending GET_NYM request to ledger\n') get_nym_response_json = await ledger.submit_request(pool_handle, get_nym_request) get_nym_response = json.loads(get_nym_response_json) print_log('GET NYM response:') pprint.pprint(get_nym_response) print_log('\n16. Comparing Trust Anchor verkeys: written by Steward (original), ' 'current in wallet and current from ledger\n') print_log('Written by Steward: ', trust_anchor_verkey) print_log('Current in wallet: ', verkey_in_wallet) verkey_from_ledger = json.loads(get_nym_response['result']['data'])['verkey'] print_log('Current from ledger: ', verkey_from_ledger) print_log('Matching: ', verkey_from_ledger == verkey_in_wallet != trust_anchor_verkey) # Do some cleanup. print_log('\n17. Closing wallet and pool\n') await wallet.close_wallet(wallet_handle) await pool.close_pool_ledger(pool_handle) print_log('\n18. Deleting created wallet\n') await wallet.delete_wallet(wallet_config, wallet_credentials) print_log('\n19. Deleting pool ledger config') await pool.delete_pool_ledger_config(pool_name)
apache-2.0
[ 198, 198, 1361, 63, 793, 2258, 78, 969, 14, 799, 5384, 892, 809, 498, 687, 20534, 60, 78, 358, 507, 198, 422, 498, 63, 262, 63, 13892, 275, 5517, 8103, 14, 498, 63, 509, 63, 1832, 63, 14887, 8, 13892, 63, 2479, 12, 16822, 63, 11498, 63, 14887, 9, 507, 198, 1361, 63, 793, 360, 14064, 833, 1626, 7050, 5444, 498, 315, 20534, 26, 1656, 809, 498, 63, 262, 63, 13892, 9, 2742, 198, 1361, 63, 793, 2258, 78, 1079, 14, 6516, 316, 9576, 63, 27437, 45, 1056, 370, 664, 377, 19622, 1626, 7050, 809, 498, 60, 78, 358, 507, 198, 362, 63, 9745, 77, 63, 1069, 275, 5517, 29239, 836, 14, 1506, 63, 362, 63, 9745, 77, 63, 1069, 8, 15756, 63, 11498, 63, 14887, 12, 16822, 63, 11498, 63, 14887, 9, 507, 198, 1361, 63, 793, 360, 1002, 653, 57, 45, 1056, 10993, 507, 198, 15380, 14, 15380, 8, 1001, 14, 3640, 8, 362, 63, 9745, 77, 63, 1069, 430, 2742, 198, 1361, 63, 793, 2258, 78, 1046, 14, 428, 3219, 9576, 63, 27437, 45, 1056, 370, 29239, 836, 60, 78, 358, 507, 198, 362, 63, 9745, 77, 63, 1310, 63, 1001, 275, 5517, 29239, 836, 14, 7275, 63, 1069, 8, 2293, 63, 2479, 12, 664, 63, 9745, 77, 63, 1069, 9, 507, 198, 362, 63, 9745, 77, 63, 1310, 275, 2022, 14, 3640, 8, 362, 63, 9745, 77, 63, 1310, 63, 1001, 9, 507, 198, 1361, 63, 793, 360, 2970, 653, 57, 45, 1177, 10993, 507, 198, 15380, 14, 15380, 8, 362, 63, 9745, 77, 63, 1310, 9, 2742, 198, 1361, 63, 793, 2258, 78, 975, 14, 3599, 9332, 377, 19622, 1626, 7050, 809, 1612, 26, 5313, 701, 17854, 3079, 334, 5043, 395, 283, 686, 283, 1818, 315, 20534, 436, 1453, 687, 29239, 836, 60, 78, 358, 507, 198, 1361, 63, 793, 360, 32329, 701, 17854, 3079, 26, 1656, 16822, 63, 11498, 63, 422, 498, 9, 507, 198, 1361, 63, 793, 360, 5639, 315, 20534, 26, 1656, 809, 498, 63, 262, 63, 13892, 9, 507, 198, 422, 498, 63, 504, 63, 28771, 275, 2022, 14, 3640, 8, 362, 63, 9745, 77, 63, 1310, 459, 1099, 2545, 576, 1105, 459, 422, 498, 418, 507, 198, 1361, 63, 793, 360, 5639, 687, 29239, 836, 26, 1656, 809, 498, 63, 504, 63, 28771, 9, 507, 198, 1361, 63, 793, 360, 14215, 26, 1656, 809, 498, 63, 504, 63, 28771, 508, 809, 498, 63, 262, 63, 13892, 1137, 16822, 63, 11498, 63, 422, 498, 9, 2742, 198, 3, 4226, 2005, 9058, 14, 507, 198, 1361, 63, 793, 2258, 78, 1196, 14, 5980, 1044, 20534, 436, 4203, 60, 78, 358, 507, 198, 32365, 20534, 14, 1600, 63, 13892, 8, 13892, 63, 2479, 9, 507, 198, 32365, 4203, 14, 1600, 63, 2293, 63, 28771, 8, 2293, 63, 2479, 9, 2742, 198, 1361, 63, 793, 2258, 78, 1085, 14, 15920, 2737, 20534, 60, 78, 358, 507, 198, 32365, 20534, 14, 1807, 63, 13892, 8, 13892, 63, 888, 12, 20534, 63, 6942, 9, 2742, 198, 1361, 63, 793, 2258, 78, 1167, 14, 15920, 4203, 29239, 836, 1101, 358, 507, 198, 32365, 4203, 14, 1807, 63, 2293, 63, 28771, 63, 888, 8, 2293, 63, 354, 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 ]
[ 198, 1361, 63, 793, 2258, 78, 969, 14, 799, 5384, 892, 809, 498, 687, 20534, 60, 78, 358, 507, 198, 422, 498, 63, 262, 63, 13892, 275, 5517, 8103, 14, 498, 63, 509, 63, 1832, 63, 14887, 8, 13892, 63, 2479, 12, 16822, 63, 11498, 63, 14887, 9, 507, 198, 1361, 63, 793, 360, 14064, 833, 1626, 7050, 5444, 498, 315, 20534, 26, 1656, 809, 498, 63, 262, 63, 13892, 9, 2742, 198, 1361, 63, 793, 2258, 78, 1079, 14, 6516, 316, 9576, 63, 27437, 45, 1056, 370, 664, 377, 19622, 1626, 7050, 809, 498, 60, 78, 358, 507, 198, 362, 63, 9745, 77, 63, 1069, 275, 5517, 29239, 836, 14, 1506, 63, 362, 63, 9745, 77, 63, 1069, 8, 15756, 63, 11498, 63, 14887, 12, 16822, 63, 11498, 63, 14887, 9, 507, 198, 1361, 63, 793, 360, 1002, 653, 57, 45, 1056, 10993, 507, 198, 15380, 14, 15380, 8, 1001, 14, 3640, 8, 362, 63, 9745, 77, 63, 1069, 430, 2742, 198, 1361, 63, 793, 2258, 78, 1046, 14, 428, 3219, 9576, 63, 27437, 45, 1056, 370, 29239, 836, 60, 78, 358, 507, 198, 362, 63, 9745, 77, 63, 1310, 63, 1001, 275, 5517, 29239, 836, 14, 7275, 63, 1069, 8, 2293, 63, 2479, 12, 664, 63, 9745, 77, 63, 1069, 9, 507, 198, 362, 63, 9745, 77, 63, 1310, 275, 2022, 14, 3640, 8, 362, 63, 9745, 77, 63, 1310, 63, 1001, 9, 507, 198, 1361, 63, 793, 360, 2970, 653, 57, 45, 1177, 10993, 507, 198, 15380, 14, 15380, 8, 362, 63, 9745, 77, 63, 1310, 9, 2742, 198, 1361, 63, 793, 2258, 78, 975, 14, 3599, 9332, 377, 19622, 1626, 7050, 809, 1612, 26, 5313, 701, 17854, 3079, 334, 5043, 395, 283, 686, 283, 1818, 315, 20534, 436, 1453, 687, 29239, 836, 60, 78, 358, 507, 198, 1361, 63, 793, 360, 32329, 701, 17854, 3079, 26, 1656, 16822, 63, 11498, 63, 422, 498, 9, 507, 198, 1361, 63, 793, 360, 5639, 315, 20534, 26, 1656, 809, 498, 63, 262, 63, 13892, 9, 507, 198, 422, 498, 63, 504, 63, 28771, 275, 2022, 14, 3640, 8, 362, 63, 9745, 77, 63, 1310, 459, 1099, 2545, 576, 1105, 459, 422, 498, 418, 507, 198, 1361, 63, 793, 360, 5639, 687, 29239, 836, 26, 1656, 809, 498, 63, 504, 63, 28771, 9, 507, 198, 1361, 63, 793, 360, 14215, 26, 1656, 809, 498, 63, 504, 63, 28771, 508, 809, 498, 63, 262, 63, 13892, 1137, 16822, 63, 11498, 63, 422, 498, 9, 2742, 198, 3, 4226, 2005, 9058, 14, 507, 198, 1361, 63, 793, 2258, 78, 1196, 14, 5980, 1044, 20534, 436, 4203, 60, 78, 358, 507, 198, 32365, 20534, 14, 1600, 63, 13892, 8, 13892, 63, 2479, 9, 507, 198, 32365, 4203, 14, 1600, 63, 2293, 63, 28771, 8, 2293, 63, 2479, 9, 2742, 198, 1361, 63, 793, 2258, 78, 1085, 14, 15920, 2737, 20534, 60, 78, 358, 507, 198, 32365, 20534, 14, 1807, 63, 13892, 8, 13892, 63, 888, 12, 20534, 63, 6942, 9, 2742, 198, 1361, 63, 793, 2258, 78, 1167, 14, 15920, 4203, 29239, 836, 1101, 358, 507, 198, 32365, 4203, 14, 1807, 63, 2293, 63, 28771, 63, 888, 8, 2293, 63, 354, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
NGnius/ModScraper
ModScraper.py
1
4720
'''This actually runs everything''' import sys, os, time sys.path.append(os.getcwd()+'/Resources') import ForumsToCheck, scraper, config, log_it import necroDetector, profanityDetector, capsDetector, annoyanceAlerts from multiprocessing import Process def init(queue): global q q = queue def main(): '''() -> None main function, goes through the all the stuff''' startTime = time.time() #for science! log_it.logg("Starting scraping round", q, genus=["debug"]) scrapeForums() elapsedTime = time.time()-startTime #for science! log_it.logg("Scraping round completed successfully", q, genus=["debug"]) log_it.logg ("Time elapsed in latest scrape: " + str(elapsedTime), q, genus=["benchmarking"]) if elapsedTime < config.retrieveConfig("Period"): #if the period specified in config hasn't elapsed completely log_it.logg("Sleeping",q, genus=["debug"]) #debug time.sleep(config.retrieveConfig("Period")-elapsedTime) #sleep until the period time has elapsed def scrapePost(p, q, check): ''' (url : str, Queue object, str) scrape post if check is right''' startTime = time.time() post = scraper.pageClass() log_it.logg("Scraping " + p, q, genus=["debug", "verbose"]) post.ret(p) if config.retrieveConfig("NecroDetection")==check: if necroDetector.isNecro(post, config.retrieveConfig("NecroTimeDelta")): log_it.logg(p + " has been bumped from the dead.", q, genus=["output"]) if config.retrieveConfig("ProfanityDetection")==check: if profanityDetector.isProfanity(post, config.retrieveConfig("SwearThreshold")): log_it.logg(p + " has been sworn in a lot.", q, genus=["output"]) if config.retrieveConfig("CapsTitleDetection")==check: if capsDetector.isCapsTitle(post, config.retrieveConfig("CapsTitleThreshold")): log_it.logg(p + " has a lot of caps in the title.", q, genus=["output"]) if config.retrieveConfig("CrusherAlerts")==check: if annoyanceAlerts.isCrusher(post): log_it.logg("Crusher Alert at " + p) if config.retrieveConfig("RotatingPlatformAlerts")==check: if annoyanceAlerts.isRotatingPlatforms(post): log_it.logg("Rotating Platforms Alert at " + p) elapsedTime = time.time()-startTime #for science! log_it.logg("Finished scraping " + p + " in " + str(elapsedTime), q, genus=["verbose", "benchmarking"]) def scrapeSection(section, q): '''(url : str, Queue object) scrape a forum section by creating a thread for every page that needs to be scraped''' startTime = time.time() page = scraper.pageClass() threads = [] page.ret(section) check = "all" log_it.logg("Creating post scraping threads for " + section, q, genus=["debug"]) if config.retrieveConfig("NecroDetection") == check or config.retrieveConfig("ProfanityDetection") == check or config.retrieveConfig("CapsTitleDetection") == check: #don't run if nothing wants it to sectionPosts = page.findAllPosts() log_it.logg("Found " + str(len(sectionPosts)) + " threads in section " + section, q, genus=["debug", "verbose"]) for postNum in range(len(sectionPosts)): threads.append(Process(target=scrapePost, args=(sectionPosts[postNum], q, check,))) threads[postNum].start() check = "first" if config.retrieveConfig("NecroDetection") == check or config.retrieveConfig("ProfanityDetection") == check or config.retrieveConfig("CapsTitleDetection") == check: #don't run if nothing wants it to sectionFirstPost = page.findFirstPost() threads.append(Process(target=scrapePost, args=(sectionFirstPost, q, check,))) threads[len(threads)].start() log_it.logg("Finished creating post scraping threads for " + section, q, genus=["debug"]) for thread in threads: #wait for all created threads to finish thread.join() elapsedTime = time.time()-startTime #for science! log_it.logg("Time elapsed in scraping section " + section + " : " + str(elapsedTime), q, genus=["verbose", "benchmarking"]) def scrapeForums(): '''() -> None starts the forum section threads''' threads=[] log_it.logg("Creating section scraping threads", q, genus=["debug"]) log_it.logg("There are " + str(len(ForumsToCheck.forums)) + " forum sections to scrape", q, genus=["debug", "verbose"]) for n in range(len(ForumsToCheck.forums)): threads.append(Process(target=scrapeSection, args=(ForumsToCheck.forums[n],q,))) threads[n].start() log_it.logg("Finished creating section scraping threads", q, genus=["debug"]) for thread in threads: #wait for all created threads to finish thread.join()
gpl-3.0
[ 2344, 2765, 5965, 7858, 8137, 2344, 199, 199, 646, 984, 12, 747, 12, 900, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 9458, 342, 23164, 13745, 358, 199, 646, 2104, 23816, 1378, 1799, 12, 21435, 12, 1101, 12, 943, 63, 390, 199, 646, 302, 825, 293, 24402, 12, 22398, 8945, 24402, 12, 22053, 24402, 12, 22984, 89, 554, 33, 16676, 199, 504, 12866, 492, 7132, 199, 199, 318, 4205, 8, 1825, 304, 272, 2288, 1894, 272, 1894, 275, 4126, 199, 199, 318, 2446, 837, 272, 1449, 342, 1035, 488, 272, 2446, 805, 12, 13538, 4012, 314, 1006, 314, 8292, 2344, 272, 28517, 275, 900, 14, 521, 342, 327, 509, 6276, 4894, 1, 272, 943, 63, 390, 14, 793, 71, 480, 14139, 4061, 1330, 316, 6168, 401, 1894, 12, 3805, 527, 6270, 1757, 3135, 272, 10328, 321, 1858, 23816, 342, 272, 14439, 1366, 275, 900, 14, 521, 22251, 28276, 327, 509, 6276, 4894, 1, 272, 943, 63, 390, 14, 793, 71, 480, 7181, 1330, 316, 6168, 9709, 8792, 401, 1894, 12, 3805, 527, 6270, 1757, 3135, 272, 943, 63, 390, 14, 793, 71, 1689, 1366, 14439, 315, 8839, 10328, 321, 26, 298, 435, 620, 8, 16691, 1366, 395, 1894, 12, 3805, 527, 6270, 11861, 316, 3135, 272, 340, 14439, 1366, 665, 1101, 14, 14270, 2028, 480, 15518, 2349, 327, 692, 314, 6247, 2013, 315, 1101, 18699, 1133, 14439, 14793, 267, 943, 63, 390, 14, 793, 71, 480, 25925, 401, 81, 12, 3805, 527, 6270, 1757, 3135, 327, 1757, 267, 900, 14, 4532, 8, 888, 14, 14270, 2028, 480, 15518, 531, 13, 16691, 1366, 9, 327, 4532, 5133, 314, 6247, 900, 965, 14439, 199, 199, 318, 10328, 321, 6564, 8, 80, 12, 1894, 12, 1104, 304, 272, 1449, 334, 633, 520, 620, 12, 10703, 909, 12, 620, 9, 272, 10328, 321, 2963, 340, 1104, 365, 2451, 2344, 272, 28517, 275, 900, 14, 521, 342, 272, 2963, 275, 21435, 14, 1606, 2543, 342, 272, 943, 63, 390, 14, 793, 71, 480, 7181, 1330, 316, 298, 435, 299, 12, 1894, 12, 3805, 527, 6270, 1757, 401, 298, 3832, 3135, 272, 2963, 14, 3292, 8, 80, 9, 272, 340, 1101, 14, 14270, 2028, 480, 46, 825, 293, 31198, 531, 389, 1074, 26, 267, 340, 302, 825, 293, 24402, 14, 374, 46, 825, 293, 8, 1932, 12, 1101, 14, 14270, 2028, 480, 46, 825, 293, 1366, 13411, 14150, 288, 943, 63, 390, 14, 793, 71, 8, 80, 435, 298, 965, 2757, 28108, 379, 687, 314, 12314, 4765, 1894, 12, 3805, 527, 6270, 1199, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 919, 70, 8945, 31198, 531, 389, 1074, 26, 267, 340, 22398, 8945, 24402, 14, 374, 919, 70, 8945, 8, 1932, 12, 1101, 14, 14270, 2028, 480, 51, 1129, 285, 12109, 14150, 288, 943, 63, 390, 14, 793, 71, 8, 80, 435, 298, 965, 2757, 308, 584, 78, 315, 282, 13918, 4765, 1894, 12, 3805, 527, 6270, 1199, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 31198, 531, 389, 1074, 26, 267, 340, 22053, 24402, 14, 374, 35, 7461, 6888, 8, 1932, 12, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 12109, 14150, 288, 943, 63, 390, 14, 793, 71, 8, 80, 435, 298, 965, 282, 13918, 402, 22053, 315, 314, 2538, 4765, 1894, 12, 3805, 527, 6270, 1199, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 17345, 2084, 281, 33, 16676, 531, 389, 1074, 26, 267, 340, 22984, 89, 554, 33, 16676, 14, 374, 17345, 2084, 281, 8, 1932, 304, 288, 943, 63, 390, 14, 793, 71, 480, 17345, 2084, 281, 25762, 737, 298, 435, 299, 9, 272, 340, 1101, 14, 14270, 2028, 480, 14728, 1958, 10397, 33, 16676, 531, 389, 1074, 26, 267, 340, 22984, 89, 554, 33, 16676, 14, 374, 14728, 1958, 3714, 8560, 8, 1932, 304, 288, 943, 63, 390, 14, 793, 71, 480, 14728, 1958, 510, 4452, 3351, 25762, 737, 298, 435, 299, 9, 2286, 14439, 1366, 275, 900, 14, 521, 22251, 28276, 327, 509, 6276, 4894, 1, 272, 943, 63, 390, 14, 793, 71, 480, 13430, 4061, 1330, 316, 298, 435, 299, 435, 298, 315, 298, 435, 620, 8, 16691, 1366, 395, 1894, 12, 3805, 527, 6270, 3832, 401, 298, 11861, 316, 3135, 199, 199, 318, 10328, 321, 8660, 8, 2792, 12, 1894, 304, 272, 1449, 8, 633, 520, 620, 12, 10703, 909, 9, 272, 10328, 321, 282, 21575, 3420, 701, 6425, 282, 2462, 367, 4036, 2034, 626, 4839, 370, 506, 24514, 2344, 272, 28517, 275, 900, 14, 521, 342, 272, 2034, 275, 21435, 14, 1606, 2543, 342, 272, 7183, 275, 942, 272, 2034, 14, 3292, 8, 2792, 9, 272, 1104, 275, 298, 452, 2, 272, 943, 63, 390, 14, 793, 71, 480, 14380, 2963, 4061, 1330, 316, 7183, 367, 298, 435, 3420, 12, 1894, 12, 3805, 527, 6270, 1757, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 46, 825, 293, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 919, 70, 8945, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 31198, 531, 508, 1104, 26, 327, 13196, 1133, 1255, 340, 6548, 15061, 652, 370, 267, 3420, 6564, 83, 275, 2034, 14, 32651, 6564, 83, 342, 267, 943, 63, 390, 14, 793, 71, 480, 3601, 298, 435, 620, 8, 552, 8, 2792, 6564, 83, 430, 435, 298, 7183, 315, 3420, 298, 435, 3420, 12, 1894, 12, 3805, 527, 6270, 1757, 401, 298, 3832, 3135, 267, 367, 2963, 5667, 315, 1425, 8, 552, 8, 2792, 6564, 83, 2298, 288, 7183, 14, 740, 8, 3498, 8, 1375, 29, 12865, 321, 6564, 12, 1249, 2687, 2792, 6564, 83, 59, 1932, 5667, 467, 1894, 12, 1104, 20097, 288, 7183, 59, 1932, 5667, 1055, 928, 342, 272, 1104, 275, 298, 2246, 2, 272, 340, 1101, 14, 14270, 2028, 480, 46, 825, 293, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 919, 70, 8945, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 31198, 531, 508, 1104, 26, 327, 13196, 1133, 1255, 340, 6548, 15061, 652, 370, 267, 3420, 7147, 6564, 275, 2034, 14, 1623, 7147, 6564, 342, 267, 7183, 14, 740, 8, 3498, 8, 1375, 29, 12865, 321, 6564, 12, 1249, 2687, 2792 ]
[ 2765, 5965, 7858, 8137, 2344, 199, 199, 646, 984, 12, 747, 12, 900, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 9458, 342, 23164, 13745, 358, 199, 646, 2104, 23816, 1378, 1799, 12, 21435, 12, 1101, 12, 943, 63, 390, 199, 646, 302, 825, 293, 24402, 12, 22398, 8945, 24402, 12, 22053, 24402, 12, 22984, 89, 554, 33, 16676, 199, 504, 12866, 492, 7132, 199, 199, 318, 4205, 8, 1825, 304, 272, 2288, 1894, 272, 1894, 275, 4126, 199, 199, 318, 2446, 837, 272, 1449, 342, 1035, 488, 272, 2446, 805, 12, 13538, 4012, 314, 1006, 314, 8292, 2344, 272, 28517, 275, 900, 14, 521, 342, 327, 509, 6276, 4894, 1, 272, 943, 63, 390, 14, 793, 71, 480, 14139, 4061, 1330, 316, 6168, 401, 1894, 12, 3805, 527, 6270, 1757, 3135, 272, 10328, 321, 1858, 23816, 342, 272, 14439, 1366, 275, 900, 14, 521, 22251, 28276, 327, 509, 6276, 4894, 1, 272, 943, 63, 390, 14, 793, 71, 480, 7181, 1330, 316, 6168, 9709, 8792, 401, 1894, 12, 3805, 527, 6270, 1757, 3135, 272, 943, 63, 390, 14, 793, 71, 1689, 1366, 14439, 315, 8839, 10328, 321, 26, 298, 435, 620, 8, 16691, 1366, 395, 1894, 12, 3805, 527, 6270, 11861, 316, 3135, 272, 340, 14439, 1366, 665, 1101, 14, 14270, 2028, 480, 15518, 2349, 327, 692, 314, 6247, 2013, 315, 1101, 18699, 1133, 14439, 14793, 267, 943, 63, 390, 14, 793, 71, 480, 25925, 401, 81, 12, 3805, 527, 6270, 1757, 3135, 327, 1757, 267, 900, 14, 4532, 8, 888, 14, 14270, 2028, 480, 15518, 531, 13, 16691, 1366, 9, 327, 4532, 5133, 314, 6247, 900, 965, 14439, 199, 199, 318, 10328, 321, 6564, 8, 80, 12, 1894, 12, 1104, 304, 272, 1449, 334, 633, 520, 620, 12, 10703, 909, 12, 620, 9, 272, 10328, 321, 2963, 340, 1104, 365, 2451, 2344, 272, 28517, 275, 900, 14, 521, 342, 272, 2963, 275, 21435, 14, 1606, 2543, 342, 272, 943, 63, 390, 14, 793, 71, 480, 7181, 1330, 316, 298, 435, 299, 12, 1894, 12, 3805, 527, 6270, 1757, 401, 298, 3832, 3135, 272, 2963, 14, 3292, 8, 80, 9, 272, 340, 1101, 14, 14270, 2028, 480, 46, 825, 293, 31198, 531, 389, 1074, 26, 267, 340, 302, 825, 293, 24402, 14, 374, 46, 825, 293, 8, 1932, 12, 1101, 14, 14270, 2028, 480, 46, 825, 293, 1366, 13411, 14150, 288, 943, 63, 390, 14, 793, 71, 8, 80, 435, 298, 965, 2757, 28108, 379, 687, 314, 12314, 4765, 1894, 12, 3805, 527, 6270, 1199, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 919, 70, 8945, 31198, 531, 389, 1074, 26, 267, 340, 22398, 8945, 24402, 14, 374, 919, 70, 8945, 8, 1932, 12, 1101, 14, 14270, 2028, 480, 51, 1129, 285, 12109, 14150, 288, 943, 63, 390, 14, 793, 71, 8, 80, 435, 298, 965, 2757, 308, 584, 78, 315, 282, 13918, 4765, 1894, 12, 3805, 527, 6270, 1199, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 31198, 531, 389, 1074, 26, 267, 340, 22053, 24402, 14, 374, 35, 7461, 6888, 8, 1932, 12, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 12109, 14150, 288, 943, 63, 390, 14, 793, 71, 8, 80, 435, 298, 965, 282, 13918, 402, 22053, 315, 314, 2538, 4765, 1894, 12, 3805, 527, 6270, 1199, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 17345, 2084, 281, 33, 16676, 531, 389, 1074, 26, 267, 340, 22984, 89, 554, 33, 16676, 14, 374, 17345, 2084, 281, 8, 1932, 304, 288, 943, 63, 390, 14, 793, 71, 480, 17345, 2084, 281, 25762, 737, 298, 435, 299, 9, 272, 340, 1101, 14, 14270, 2028, 480, 14728, 1958, 10397, 33, 16676, 531, 389, 1074, 26, 267, 340, 22984, 89, 554, 33, 16676, 14, 374, 14728, 1958, 3714, 8560, 8, 1932, 304, 288, 943, 63, 390, 14, 793, 71, 480, 14728, 1958, 510, 4452, 3351, 25762, 737, 298, 435, 299, 9, 2286, 14439, 1366, 275, 900, 14, 521, 22251, 28276, 327, 509, 6276, 4894, 1, 272, 943, 63, 390, 14, 793, 71, 480, 13430, 4061, 1330, 316, 298, 435, 299, 435, 298, 315, 298, 435, 620, 8, 16691, 1366, 395, 1894, 12, 3805, 527, 6270, 3832, 401, 298, 11861, 316, 3135, 199, 199, 318, 10328, 321, 8660, 8, 2792, 12, 1894, 304, 272, 1449, 8, 633, 520, 620, 12, 10703, 909, 9, 272, 10328, 321, 282, 21575, 3420, 701, 6425, 282, 2462, 367, 4036, 2034, 626, 4839, 370, 506, 24514, 2344, 272, 28517, 275, 900, 14, 521, 342, 272, 2034, 275, 21435, 14, 1606, 2543, 342, 272, 7183, 275, 942, 272, 2034, 14, 3292, 8, 2792, 9, 272, 1104, 275, 298, 452, 2, 272, 943, 63, 390, 14, 793, 71, 480, 14380, 2963, 4061, 1330, 316, 7183, 367, 298, 435, 3420, 12, 1894, 12, 3805, 527, 6270, 1757, 3135, 272, 340, 1101, 14, 14270, 2028, 480, 46, 825, 293, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 919, 70, 8945, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 31198, 531, 508, 1104, 26, 327, 13196, 1133, 1255, 340, 6548, 15061, 652, 370, 267, 3420, 6564, 83, 275, 2034, 14, 32651, 6564, 83, 342, 267, 943, 63, 390, 14, 793, 71, 480, 3601, 298, 435, 620, 8, 552, 8, 2792, 6564, 83, 430, 435, 298, 7183, 315, 3420, 298, 435, 3420, 12, 1894, 12, 3805, 527, 6270, 1757, 401, 298, 3832, 3135, 267, 367, 2963, 5667, 315, 1425, 8, 552, 8, 2792, 6564, 83, 2298, 288, 7183, 14, 740, 8, 3498, 8, 1375, 29, 12865, 321, 6564, 12, 1249, 2687, 2792, 6564, 83, 59, 1932, 5667, 467, 1894, 12, 1104, 20097, 288, 7183, 59, 1932, 5667, 1055, 928, 342, 272, 1104, 275, 298, 2246, 2, 272, 340, 1101, 14, 14270, 2028, 480, 46, 825, 293, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 919, 70, 8945, 31198, 531, 508, 1104, 503, 1101, 14, 14270, 2028, 480, 35, 7461, 6888, 31198, 531, 508, 1104, 26, 327, 13196, 1133, 1255, 340, 6548, 15061, 652, 370, 267, 3420, 7147, 6564, 275, 2034, 14, 1623, 7147, 6564, 342, 267, 7183, 14, 740, 8, 3498, 8, 1375, 29, 12865, 321, 6564, 12, 1249, 2687, 2792, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
konstruktoid/ansible-upstream
lib/ansible/modules/cloud/azure/azure_rm_functionapp.py
7
10280
#!/usr/bin/python # # Copyright (c) 2016 Thomas Stringer, <tomstr@microsoft.com> # # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: azure_rm_functionapp version_added: "2.4" short_description: Manage Azure Function Apps description: - Create, update or delete an Azure Function App options: resource_group: description: - Name of resource group required: true aliases: - resource_group_name name: description: - Name of the Azure Function App required: true location: description: - Valid Azure location. Defaults to location of the resource group. storage_account: description: - Name of the storage account to use. required: true aliases: - storage - storage_account_name app_settings: description: - Dictionary containing application settings state: description: - Assert the state of the Function App. Use 'present' to create or update a Function App and 'absent' to delete. required: false default: present choices: - absent - present extends_documentation_fragment: - azure - azure_tags author: - "Thomas Stringer (@tstringer)" ''' EXAMPLES = ''' - name: create function app azure_rm_functionapp: resource_group: ansible-rg name: myfunctionapp - name: create a function app with app settings azure_rm_functionapp: resource_group: ansible-rg name: myfunctionapp app_settings: setting1: value1 setting2: value2 - name: delete a function app azure_rm_functionapp: name: myfunctionapp state: absent ''' RETURN = ''' state: description: Current state of the Azure Function App returned: success type: dict example: id: /subscriptions/.../resourceGroups/ansible-rg/providers/Microsoft.Web/sites/myfunctionapp name: myfunctionapp kind: functionapp location: East US type: Microsoft.Web/sites state: Running host_names: - myfunctionapp.azurewebsites.net repository_site_name: myfunctionapp usage_state: Normal enabled: true enabled_host_names: - myfunctionapp.azurewebsites.net - myfunctionapp.scm.azurewebsites.net availability_state: Normal host_name_ssl_states: - name: myfunctionapp.azurewebsites.net ssl_state: Disabled host_type: Standard - name: myfunctionapp.scm.azurewebsites.net ssl_state: Disabled host_type: Repository server_farm_id: /subscriptions/.../resourceGroups/ansible-rg/providers/Microsoft.Web/serverfarms/EastUSPlan reserved: false last_modified_time_utc: 2017-08-22T18:54:01.190Z scm_site_also_stopped: false client_affinity_enabled: true client_cert_enabled: false host_names_disabled: false outbound_ip_addresses: ............ container_size: 1536 daily_memory_time_quota: 0 resource_group: ansible-rg default_host_name: myfunctionapp.azurewebsites.net ''' # NOQA from ansible.module_utils.azure_rm_common import AzureRMModuleBase try: from msrestazure.azure_exceptions import CloudError from azure.mgmt.web.models import Site, SiteConfig, NameValuePair, SiteSourceControl from azure.mgmt.resource.resources import ResourceManagementClient except ImportError: # This is handled in azure_rm_common pass class AzureRMFunctionApp(AzureRMModuleBase): def __init__(self): self.module_arg_spec = dict( resource_group=dict(type='str', required=True, aliases=['resource_group_name']), name=dict(type='str', required=True), state=dict(type='str', default='present', choices=['present', 'absent']), location=dict(type='str', required=False), storage_account=dict( type='str', required=False, aliases=['storage', 'storage_account_name'] ), app_settings=dict(type='dict') ) self.results = dict( changed=False, state=dict() ) self.resource_group = None self.name = None self.state = None self.location = None self.storage_account = None self.app_settings = None required_if = [('state', 'present', ['storage_account'])] super(AzureRMFunctionApp, self).__init__( self.module_arg_spec, supports_check_mode=True, required_if=required_if ) def exec_module(self, **kwargs): for key in self.module_arg_spec: setattr(self, key, kwargs[key]) if self.app_settings is None: self.app_settings = dict() try: resource_group = self.rm_client.resource_groups.get(self.resource_group) except CloudError: self.fail('Unable to retrieve resource group') self.location = self.location or resource_group.location try: function_app = self.web_client.web_apps.get( resource_group_name=self.resource_group, name=self.name ) exists = True except CloudError as exc: exists = False if self.state == 'absent': if exists: if self.check_mode: self.results['changed'] = True return self.results try: self.web_client.web_apps.delete( resource_group_name=self.resource_group, name=self.name ) self.results['changed'] = True except CloudError as exc: self.fail('Failure while deleting web app: {}'.format(exc)) else: self.results['changed'] = False else: if not exists: function_app = Site( location=self.location, kind='functionapp', site_config=SiteConfig( app_settings=self.aggregated_app_settings(), scm_type='LocalGit' ) ) self.results['changed'] = True else: self.results['changed'], function_app = self.update(function_app) if self.check_mode: self.results['state'] = function_app.as_dict() elif self.results['changed']: try: new_function_app = self.web_client.web_apps.create_or_update( resource_group_name=self.resource_group, name=self.name, site_envelope=function_app ).result() self.results['state'] = new_function_app.as_dict() except CloudError as exc: self.fail('Error creating or updating web app: {}'.format(exc)) return self.results def update(self, source_function_app): """Update the Site object if there are any changes""" source_app_settings = self.web_client.web_apps.list_application_settings( resource_group_name=self.resource_group, name=self.name ) changed, target_app_settings = self.update_app_settings(source_app_settings.properties) source_function_app.site_config = SiteConfig( app_settings=target_app_settings, scm_type='LocalGit' ) return changed, source_function_app def update_app_settings(self, source_app_settings): """Update app settings""" target_app_settings = self.aggregated_app_settings() target_app_settings_dict = dict([(i.name, i.value) for i in target_app_settings]) return target_app_settings_dict != source_app_settings, target_app_settings def necessary_functionapp_settings(self): """Construct the necessary app settings required for an Azure Function App""" function_app_settings = [] for key in ['AzureWebJobsStorage', 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING', 'AzureWebJobsDashboard']: function_app_settings.append(NameValuePair(name=key, value=self.storage_connection_string)) function_app_settings.append(NameValuePair(name='FUNCTIONS_EXTENSION_VERSION', value='~1')) function_app_settings.append(NameValuePair(name='WEBSITE_NODE_DEFAULT_VERSION', value='6.5.0')) function_app_settings.append(NameValuePair(name='WEBSITE_CONTENTSHARE', value=self.storage_account)) return function_app_settings def aggregated_app_settings(self): """Combine both system and user app settings""" function_app_settings = self.necessary_functionapp_settings() for app_setting_key in self.app_settings: function_app_settings.append(NameValuePair( name=app_setting_key, value=self.app_settings[app_setting_key] )) return function_app_settings @property def storage_connection_string(self): """Construct the storage account connection string""" return 'DefaultEndpointsProtocol=https;AccountName={};AccountKey={}'.format( self.storage_account, self.storage_key ) @property def storage_key(self): """Retrieve the storage account key""" return self.storage_client.storage_accounts.list_keys( resource_group_name=self.resource_group, account_name=self.storage_account ).keys[0].value def main(): """Main function execution""" AzureRMFunctionApp() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 27864, 2624, 281, 12, 665, 3151, 495, 32, 17040, 14, 957, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 13601, 63, 5682, 63, 1593, 571, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 14944, 15474, 6801, 4693, 83, 199, 1802, 26, 272, 446, 2790, 12, 1678, 503, 3145, 376, 15474, 6801, 4693, 199, 1419, 26, 272, 2073, 63, 923, 26, 267, 1369, 26, 288, 446, 2812, 402, 2073, 1572, 267, 1415, 26, 2549, 267, 5481, 26, 288, 446, 2073, 63, 923, 63, 354, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 15474, 6801, 4693, 267, 1415, 26, 2549, 272, 2909, 26, 267, 1369, 26, 288, 446, 4821, 15474, 2909, 14, 7827, 370, 2909, 402, 314, 2073, 1572, 14, 272, 4887, 63, 2048, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 4887, 2933, 370, 675, 14, 267, 1415, 26, 2549, 267, 5481, 26, 288, 446, 4887, 288, 446, 4887, 63, 2048, 63, 354, 272, 1145, 63, 1751, 26, 267, 1369, 26, 288, 446, 11932, 3035, 4223, 2202, 272, 1174, 26, 267, 1369, 26, 288, 446, 10716, 314, 1174, 402, 314, 6801, 4693, 14, 3645, 283, 1881, 7, 370, 1218, 503, 1678, 282, 6801, 4693, 436, 1598, 283, 5575, 7, 370, 3145, 14, 267, 1415, 26, 3055, 267, 849, 26, 3451, 267, 3415, 26, 288, 446, 9552, 288, 446, 3451, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 13601, 272, 446, 13601, 63, 2969, 199, 199, 2502, 26, 272, 446, 298, 52, 526, 5892, 2624, 281, 8593, 84, 875, 281, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 1218, 805, 1145, 523, 13601, 63, 5682, 63, 1593, 571, 26, 489, 2073, 63, 923, 26, 3242, 13, 12430, 489, 536, 26, 3002, 1593, 571, 199, 199, 13, 536, 26, 1218, 282, 805, 1145, 543, 1145, 2202, 523, 13601, 63, 5682, 63, 1593, 571, 26, 489, 2073, 63, 923, 26, 3242, 13, 12430, 489, 536, 26, 3002, 1593, 571, 489, 1145, 63, 1751, 26, 881, 4260, 17, 26, 574, 17, 881, 4260, 18, 26, 574, 18, 199, 199, 13, 536, 26, 3145, 282, 805, 1145, 523, 13601, 63, 5682, 63, 1593, 571, 26, 489, 536, 26, 3002, 1593, 571, 489, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 1449, 199, 929, 26, 272, 1369, 26, 9338, 1174, 402, 314, 15474, 6801, 4693, 272, 2138, 26, 3182, 272, 730, 26, 1211, 272, 2893, 26, 267, 1305, 26, 1182, 13233, 15, 1396, 15, 26952, 15, 4853, 13, 12430, 15, 9710, 15, 12940, 14, 5926, 15, 8619, 15, 1662, 1593, 571, 267, 536, 26, 3002, 1593, 571, 267, 4928, 26, 805, 571, 267, 2909, 26, 662, 1810, 19635, 267, 730, 26, 15332, 14, 5926, 15, 8619, 267, 1174, 26, 26848, 267, 1591, 63, 1247, 26, 881, 446, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 267, 7611, 63, 2124, 63, 354, 26, 3002, 1593, 571, 267, 4503, 63, 929, 26, 11514, 267, 5223, 26, 2549, 267, 5223, 63, 1102, 63, 1247, 26, 881, 446, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 881, 446, 3002, 1593, 571, 14, 17143, 14, 9078, 2520, 8619, 14, 846, 267, 14962, 63, 929, 26, 11514, 267, 1591, 63, 354, 63, 4266, 63, 4981, 26, 881, 446, 536, 26, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 288, 6149, 63, 929, 26, 5289, 1909, 288, 1591, 63, 466, 26, 9739, 881, 446, 536, 26, 3002, 1593, 571, 14, 17143, 14, 9078, 2520, 8619, 14, 846, 288, 6149, 63, 929, 26, 5289, 1909, 288, 1591, 63, 466, 26, 24426, 267, 1654, 63, 70, 5362, 63, 344, 26, 1182, 13233, 15, 1396, 15, 26952, 15, 4853, 13, 12430, 15, 9710, 15, 12940, 14, 5926, 15, 1000, 15315, 706, 15, 37, 1810, 1668, 13375, 267, 4644, 26, 3055, 267, 2061, 63, 5540, 63, 521, 63, 5834, 26, 9708, 13, 2036, 13, 1081, 52, 1085, 26, 1477, 26, 614, 14, 12205, 58, 267, 25811, 63, 2124, 63, 12344, 63, 14661, 26, 3055, 267, 1890, 63, 15964, 63, 3827, 26, 2549, 267, 1890, 63, 4736, 63, 3827, 26, 3055, 267, 1591, 63, 1247, 63, 7011, 26, 3055, 267, 734, 3556, 63, 711, 63, 7423, 26, 2508, 7955, 703, 267, 3970, 63, 890, 26, 4114, 1344, 267, 26122, 63, 4844, 63, 521, 63, 8848, 26, 378, 267, 2073, 63, 923, 26, 3242, 13, 12430, 267, 849, 63, 1102, 63, 354, 26, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 199, 2344, 221, 327, 20432, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 9078, 63, 5682, 63, 2330, 492, 15474, 11026, 2377, 1563, 199, 199, 893, 26, 272, 687, 6605, 264, 1207, 7895, 14, 9078, 63, 3924, 492, 30059, 272, 687, 13601, 14, 9752, 14, 2520, 14, 992, 492, 11666, 12, 11666, 2028, 12, 2812, 1110, 12882, 12, 11666, 2980, 3717, 272, 687, 13601, 14, 9752, 14, 1927, 14, 4435, 492, 7337, 14552, 3041, 199, 2590, 3545, 26, 272, 327, 961, 365, 8860, 315, 13601, 63, 5682, 63, 2330, 272, 986, 421, 199, 533, 15474, 11026, 3481, 2640, 8, 22386, 11026, 2377, 1563, 304, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 578, 63, 1273, 63, 1650, 275, 1211, 8, 288, 2073, 63, 923, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 549, 12, 5481, 2968, 1927, 63, 923, 63, 354, 3815, 288, 536, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 549, 395, 288, 1174, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1881, 297, 3415, 2968 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 27864, 2624, 281, 12, 665, 3151, 495, 32, 17040, 14, 957, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 13601, 63, 5682, 63, 1593, 571, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 14944, 15474, 6801, 4693, 83, 199, 1802, 26, 272, 446, 2790, 12, 1678, 503, 3145, 376, 15474, 6801, 4693, 199, 1419, 26, 272, 2073, 63, 923, 26, 267, 1369, 26, 288, 446, 2812, 402, 2073, 1572, 267, 1415, 26, 2549, 267, 5481, 26, 288, 446, 2073, 63, 923, 63, 354, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 15474, 6801, 4693, 267, 1415, 26, 2549, 272, 2909, 26, 267, 1369, 26, 288, 446, 4821, 15474, 2909, 14, 7827, 370, 2909, 402, 314, 2073, 1572, 14, 272, 4887, 63, 2048, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 4887, 2933, 370, 675, 14, 267, 1415, 26, 2549, 267, 5481, 26, 288, 446, 4887, 288, 446, 4887, 63, 2048, 63, 354, 272, 1145, 63, 1751, 26, 267, 1369, 26, 288, 446, 11932, 3035, 4223, 2202, 272, 1174, 26, 267, 1369, 26, 288, 446, 10716, 314, 1174, 402, 314, 6801, 4693, 14, 3645, 283, 1881, 7, 370, 1218, 503, 1678, 282, 6801, 4693, 436, 1598, 283, 5575, 7, 370, 3145, 14, 267, 1415, 26, 3055, 267, 849, 26, 3451, 267, 3415, 26, 288, 446, 9552, 288, 446, 3451, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 13601, 272, 446, 13601, 63, 2969, 199, 199, 2502, 26, 272, 446, 298, 52, 526, 5892, 2624, 281, 8593, 84, 875, 281, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 1218, 805, 1145, 523, 13601, 63, 5682, 63, 1593, 571, 26, 489, 2073, 63, 923, 26, 3242, 13, 12430, 489, 536, 26, 3002, 1593, 571, 199, 199, 13, 536, 26, 1218, 282, 805, 1145, 543, 1145, 2202, 523, 13601, 63, 5682, 63, 1593, 571, 26, 489, 2073, 63, 923, 26, 3242, 13, 12430, 489, 536, 26, 3002, 1593, 571, 489, 1145, 63, 1751, 26, 881, 4260, 17, 26, 574, 17, 881, 4260, 18, 26, 574, 18, 199, 199, 13, 536, 26, 3145, 282, 805, 1145, 523, 13601, 63, 5682, 63, 1593, 571, 26, 489, 536, 26, 3002, 1593, 571, 489, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 1449, 199, 929, 26, 272, 1369, 26, 9338, 1174, 402, 314, 15474, 6801, 4693, 272, 2138, 26, 3182, 272, 730, 26, 1211, 272, 2893, 26, 267, 1305, 26, 1182, 13233, 15, 1396, 15, 26952, 15, 4853, 13, 12430, 15, 9710, 15, 12940, 14, 5926, 15, 8619, 15, 1662, 1593, 571, 267, 536, 26, 3002, 1593, 571, 267, 4928, 26, 805, 571, 267, 2909, 26, 662, 1810, 19635, 267, 730, 26, 15332, 14, 5926, 15, 8619, 267, 1174, 26, 26848, 267, 1591, 63, 1247, 26, 881, 446, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 267, 7611, 63, 2124, 63, 354, 26, 3002, 1593, 571, 267, 4503, 63, 929, 26, 11514, 267, 5223, 26, 2549, 267, 5223, 63, 1102, 63, 1247, 26, 881, 446, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 881, 446, 3002, 1593, 571, 14, 17143, 14, 9078, 2520, 8619, 14, 846, 267, 14962, 63, 929, 26, 11514, 267, 1591, 63, 354, 63, 4266, 63, 4981, 26, 881, 446, 536, 26, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 288, 6149, 63, 929, 26, 5289, 1909, 288, 1591, 63, 466, 26, 9739, 881, 446, 536, 26, 3002, 1593, 571, 14, 17143, 14, 9078, 2520, 8619, 14, 846, 288, 6149, 63, 929, 26, 5289, 1909, 288, 1591, 63, 466, 26, 24426, 267, 1654, 63, 70, 5362, 63, 344, 26, 1182, 13233, 15, 1396, 15, 26952, 15, 4853, 13, 12430, 15, 9710, 15, 12940, 14, 5926, 15, 1000, 15315, 706, 15, 37, 1810, 1668, 13375, 267, 4644, 26, 3055, 267, 2061, 63, 5540, 63, 521, 63, 5834, 26, 9708, 13, 2036, 13, 1081, 52, 1085, 26, 1477, 26, 614, 14, 12205, 58, 267, 25811, 63, 2124, 63, 12344, 63, 14661, 26, 3055, 267, 1890, 63, 15964, 63, 3827, 26, 2549, 267, 1890, 63, 4736, 63, 3827, 26, 3055, 267, 1591, 63, 1247, 63, 7011, 26, 3055, 267, 734, 3556, 63, 711, 63, 7423, 26, 2508, 7955, 703, 267, 3970, 63, 890, 26, 4114, 1344, 267, 26122, 63, 4844, 63, 521, 63, 8848, 26, 378, 267, 2073, 63, 923, 26, 3242, 13, 12430, 267, 849, 63, 1102, 63, 354, 26, 3002, 1593, 571, 14, 9078, 2520, 8619, 14, 846, 199, 2344, 221, 327, 20432, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 9078, 63, 5682, 63, 2330, 492, 15474, 11026, 2377, 1563, 199, 199, 893, 26, 272, 687, 6605, 264, 1207, 7895, 14, 9078, 63, 3924, 492, 30059, 272, 687, 13601, 14, 9752, 14, 2520, 14, 992, 492, 11666, 12, 11666, 2028, 12, 2812, 1110, 12882, 12, 11666, 2980, 3717, 272, 687, 13601, 14, 9752, 14, 1927, 14, 4435, 492, 7337, 14552, 3041, 199, 2590, 3545, 26, 272, 327, 961, 365, 8860, 315, 13601, 63, 5682, 63, 2330, 272, 986, 421, 199, 533, 15474, 11026, 3481, 2640, 8, 22386, 11026, 2377, 1563, 304, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 578, 63, 1273, 63, 1650, 275, 1211, 8, 288, 2073, 63, 923, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 549, 12, 5481, 2968, 1927, 63, 923, 63, 354, 3815, 288, 536, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 549, 395, 288, 1174, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1881, 297, 3415, 2968, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1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py
6
5139
# # 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. from typing import Any, Callable, Dict, Optional from airflow.exceptions import AirflowException from airflow.models import BaseOperator from airflow.providers.http.hooks.http import HttpHook from airflow.utils.decorators import apply_defaults class SimpleHttpOperator(BaseOperator): """ Calls an endpoint on an HTTP system to execute an action .. seealso:: For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:SimpleHttpOperator` :param http_conn_id: The connection to run the operator against :type http_conn_id: str :param endpoint: The relative part of the full url. (templated) :type endpoint: str :param method: The HTTP method to use, default = "POST" :type method: str :param data: The data to pass. POST-data in POST/PUT and params in the URL for a GET request. (templated) :type data: For POST/PUT, depends on the content-type parameter, for GET a dictionary of key/value string pairs :param headers: The HTTP headers to be added to the GET request :type headers: a dictionary of string key/value pairs :param response_check: A check against the 'requests' response object. The callable takes the response object as the first positional argument and optionally any number of keyword arguments available in the context dictionary. It should return True for 'pass' and False otherwise. :type response_check: A lambda or defined function. :param response_filter: A function allowing you to manipulate the response text. e.g response_filter=lambda response: json.loads(response.text). The callable takes the response object as the first positional argument and optionally any number of keyword arguments available in the context dictionary. :type response_filter: A lambda or defined function. :param extra_options: Extra options for the 'requests' library, see the 'requests' documentation (options to modify timeout, ssl, etc.) :type extra_options: A dictionary of options, where key is string and value depends on the option that's being modified. :param log_response: Log the response (default: False) :type log_response: bool """ template_fields = [ 'endpoint', 'data', 'headers', ] template_fields_renderers = {'headers': 'json', 'data': 'py'} template_ext = () ui_color = '#f4a460' @apply_defaults def __init__( self, *, endpoint: Optional[str] = None, method: str = 'POST', data: Any = None, headers: Optional[Dict[str, str]] = None, response_check: Optional[Callable[..., bool]] = None, response_filter: Optional[Callable[..., Any]] = None, extra_options: Optional[Dict[str, Any]] = None, http_conn_id: str = 'http_default', log_response: bool = False, **kwargs: Any, ) -> None: super().__init__(**kwargs) self.http_conn_id = http_conn_id self.method = method self.endpoint = endpoint self.headers = headers or {} self.data = data or {} self.response_check = response_check self.response_filter = response_filter self.extra_options = extra_options or {} self.log_response = log_response if kwargs.get('xcom_push') is not None: raise AirflowException("'xcom_push' was deprecated, use 'BaseOperator.do_xcom_push' instead") def execute(self, context: Dict[str, Any]) -> Any: from airflow.utils.operator_helpers import make_kwargs_callable http = HttpHook(self.method, http_conn_id=self.http_conn_id) self.log.info("Calling HTTP method") response = http.run(self.endpoint, self.data, self.headers, self.extra_options) if self.log_response: self.log.info(response.text) if self.response_check: kwargs_callable = make_kwargs_callable(self.response_check) if not kwargs_callable(response, **context): raise AirflowException("Response check returned False.") if self.response_filter: kwargs_callable = make_kwargs_callable(self.response_filter) return kwargs_callable(response, **context) return response.text
apache-2.0
[ 3, 199, 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, 504, 14090, 492, 6184, 12, 16975, 12, 7448, 12, 4879, 199, 199, 504, 16321, 14, 3924, 492, 31040, 1726, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 9710, 14, 1014, 14, 7922, 14, 1014, 492, 4760, 8481, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 421, 199, 533, 5870, 5779, 7961, 8, 1563, 7961, 304, 272, 408, 272, 28055, 376, 6037, 641, 376, 3101, 2656, 370, 5341, 376, 1595, 339, 2508, 19352, 447, 267, 2104, 1655, 2556, 641, 4212, 370, 675, 642, 4182, 12, 5452, 282, 3648, 737, 314, 22885, 26, 267, 520, 1121, 1705, 21232, 15, 3856, 26, 3184, 5779, 7961, 64, 339, 520, 635, 1455, 63, 1631, 63, 344, 26, 710, 1950, 370, 1255, 314, 4182, 6169, 272, 520, 466, 1455, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 6037, 26, 710, 3847, 1777, 402, 314, 2615, 1166, 14, 334, 1160, 68, 9, 272, 520, 466, 6037, 26, 620, 272, 520, 635, 1083, 26, 710, 3101, 1083, 370, 675, 12, 849, 275, 298, 4030, 2, 272, 520, 466, 1083, 26, 620, 272, 520, 635, 666, 26, 710, 666, 370, 986, 14, 8761, 13, 576, 315, 8761, 15, 4013, 436, 1862, 267, 315, 314, 2851, 367, 282, 9576, 1056, 14, 334, 1160, 68, 9, 272, 520, 466, 666, 26, 2104, 8761, 15, 4013, 12, 8350, 641, 314, 1564, 13, 466, 2725, 12, 267, 367, 9576, 282, 2600, 402, 790, 15, 585, 1059, 6342, 272, 520, 635, 2323, 26, 710, 3101, 2323, 370, 506, 3483, 370, 314, 9576, 1056, 272, 520, 466, 2323, 26, 282, 2600, 402, 1059, 790, 15, 585, 6342, 272, 520, 635, 1177, 63, 1074, 26, 437, 1104, 6169, 314, 283, 6615, 7, 1177, 909, 14, 267, 710, 4550, 6181, 314, 1177, 909, 465, 314, 1642, 11333, 1423, 267, 436, 14190, 1263, 1329, 402, 4252, 2368, 2808, 315, 314, 1067, 2600, 14, 267, 2779, 1077, 372, 715, 367, 283, 1529, 7, 436, 756, 4257, 14, 272, 520, 466, 1177, 63, 1074, 26, 437, 2400, 503, 3247, 805, 14, 272, 520, 635, 1177, 63, 1541, 26, 437, 805, 17266, 1265, 370, 27232, 314, 1177, 267, 1318, 14, 325, 14, 71, 1177, 63, 1541, 29, 2734, 1177, 26, 2022, 14, 3640, 8, 1310, 14, 505, 680, 267, 710, 4550, 6181, 314, 1177, 909, 465, 314, 1642, 11333, 1423, 267, 436, 14190, 1263, 1329, 402, 4252, 2368, 2808, 315, 314, 1067, 2600, 14, 272, 520, 466, 1177, 63, 1541, 26, 437, 2400, 503, 3247, 805, 14, 272, 520, 635, 2402, 63, 1419, 26, 11177, 1511, 367, 314, 283, 6615, 7, 3555, 12, 1937, 314, 267, 283, 6615, 7, 3794, 334, 1419, 370, 2811, 2653, 12, 6149, 12, 5423, 4959, 272, 520, 466, 2402, 63, 1419, 26, 437, 2600, 402, 1511, 12, 2382, 790, 365, 1059, 436, 574, 267, 8350, 641, 314, 945, 626, 1159, 3769, 6042, 14, 272, 520, 635, 943, 63, 1310, 26, 5297, 314, 1177, 334, 885, 26, 756, 9, 272, 520, 466, 943, 63, 1310, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 359, 267, 283, 6520, 297, 267, 283, 576, 297, 267, 283, 2139, 297, 272, 1622, 272, 1978, 63, 955, 63, 828, 26529, 275, 791, 2139, 356, 283, 1001, 297, 283, 576, 356, 283, 647, 936, 272, 1978, 63, 832, 275, 6248, 272, 8574, 63, 2326, 275, 3943, 70, 20, 65, 30231, 7, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 267, 291, 12, 267, 9889, 267, 6037, 26, 4879, 59, 495, 61, 275, 488, 12, 267, 1083, 26, 620, 275, 283, 4030, 297, 267, 666, 26, 6184, 275, 488, 12, 267, 2323, 26, 4879, 59, 2141, 59, 495, 12, 620, 2677, 275, 488, 12, 267, 1177, 63, 1074, 26, 4879, 59, 16410, 18999, 2155, 2677, 275, 488, 12, 267, 1177, 63, 1541, 26, 4879, 59, 16410, 18999, 6184, 2677, 275, 488, 12, 267, 2402, 63, 1419, 26, 4879, 59, 2141, 59, 495, 12, 6184, 2677, 275, 488, 12, 267, 1455, 63, 1631, 63, 344, 26, 620, 275, 283, 1014, 63, 885, 297, 267, 943, 63, 1310, 26, 2155, 275, 756, 12, 267, 1011, 958, 26, 6184, 12, 272, 776, 1035, 488, 26, 267, 1613, 11027, 826, 14155, 958, 9, 267, 291, 14, 1014, 63, 1631, 63, 344, 275, 1455, 63, 1631, 63, 344, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 6520, 275, 6037, 267, 291, 14, 2139, 275, 2323, 503, 1052, 267, 291, 14, 576, 275, 666, 503, 1052, 267, 291, 14, 1310, 63, 1074, 275, 1177, 63, 1074, 267, 291, 14, 1310, 63, 1541, 275, 1177, 63, 1541, 267, 291, 14, 2911, 63, 1419, 275, 2402, 63, 1419, 503, 1052, 267, 291, 14, 793, 63, 1310, 275, 943, 63, 1310, 267, 340, 2074, 14, 362, 360, 88, 957, 63, 5335, 358, 365, 440, 488, 26, 288, 746, 31040, 1726, 15587, 88, 957, 63, 5335, 7, 1990, 5906, 12, 675, 283, 1563, 7961, 14, 1117, 63, 88, 957, 63, 5335, 7, 3140, 531, 339, 347, 5341, 8, 277, 12, 1067, 26, 7448, 59, 495, 12, 6184, 566, 1035, 6184, 26, 267, 687 ]
[ 199, 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, 504, 14090, 492, 6184, 12, 16975, 12, 7448, 12, 4879, 199, 199, 504, 16321, 14, 3924, 492, 31040, 1726, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 9710, 14, 1014, 14, 7922, 14, 1014, 492, 4760, 8481, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 421, 199, 533, 5870, 5779, 7961, 8, 1563, 7961, 304, 272, 408, 272, 28055, 376, 6037, 641, 376, 3101, 2656, 370, 5341, 376, 1595, 339, 2508, 19352, 447, 267, 2104, 1655, 2556, 641, 4212, 370, 675, 642, 4182, 12, 5452, 282, 3648, 737, 314, 22885, 26, 267, 520, 1121, 1705, 21232, 15, 3856, 26, 3184, 5779, 7961, 64, 339, 520, 635, 1455, 63, 1631, 63, 344, 26, 710, 1950, 370, 1255, 314, 4182, 6169, 272, 520, 466, 1455, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 6037, 26, 710, 3847, 1777, 402, 314, 2615, 1166, 14, 334, 1160, 68, 9, 272, 520, 466, 6037, 26, 620, 272, 520, 635, 1083, 26, 710, 3101, 1083, 370, 675, 12, 849, 275, 298, 4030, 2, 272, 520, 466, 1083, 26, 620, 272, 520, 635, 666, 26, 710, 666, 370, 986, 14, 8761, 13, 576, 315, 8761, 15, 4013, 436, 1862, 267, 315, 314, 2851, 367, 282, 9576, 1056, 14, 334, 1160, 68, 9, 272, 520, 466, 666, 26, 2104, 8761, 15, 4013, 12, 8350, 641, 314, 1564, 13, 466, 2725, 12, 267, 367, 9576, 282, 2600, 402, 790, 15, 585, 1059, 6342, 272, 520, 635, 2323, 26, 710, 3101, 2323, 370, 506, 3483, 370, 314, 9576, 1056, 272, 520, 466, 2323, 26, 282, 2600, 402, 1059, 790, 15, 585, 6342, 272, 520, 635, 1177, 63, 1074, 26, 437, 1104, 6169, 314, 283, 6615, 7, 1177, 909, 14, 267, 710, 4550, 6181, 314, 1177, 909, 465, 314, 1642, 11333, 1423, 267, 436, 14190, 1263, 1329, 402, 4252, 2368, 2808, 315, 314, 1067, 2600, 14, 267, 2779, 1077, 372, 715, 367, 283, 1529, 7, 436, 756, 4257, 14, 272, 520, 466, 1177, 63, 1074, 26, 437, 2400, 503, 3247, 805, 14, 272, 520, 635, 1177, 63, 1541, 26, 437, 805, 17266, 1265, 370, 27232, 314, 1177, 267, 1318, 14, 325, 14, 71, 1177, 63, 1541, 29, 2734, 1177, 26, 2022, 14, 3640, 8, 1310, 14, 505, 680, 267, 710, 4550, 6181, 314, 1177, 909, 465, 314, 1642, 11333, 1423, 267, 436, 14190, 1263, 1329, 402, 4252, 2368, 2808, 315, 314, 1067, 2600, 14, 272, 520, 466, 1177, 63, 1541, 26, 437, 2400, 503, 3247, 805, 14, 272, 520, 635, 2402, 63, 1419, 26, 11177, 1511, 367, 314, 283, 6615, 7, 3555, 12, 1937, 314, 267, 283, 6615, 7, 3794, 334, 1419, 370, 2811, 2653, 12, 6149, 12, 5423, 4959, 272, 520, 466, 2402, 63, 1419, 26, 437, 2600, 402, 1511, 12, 2382, 790, 365, 1059, 436, 574, 267, 8350, 641, 314, 945, 626, 1159, 3769, 6042, 14, 272, 520, 635, 943, 63, 1310, 26, 5297, 314, 1177, 334, 885, 26, 756, 9, 272, 520, 466, 943, 63, 1310, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 359, 267, 283, 6520, 297, 267, 283, 576, 297, 267, 283, 2139, 297, 272, 1622, 272, 1978, 63, 955, 63, 828, 26529, 275, 791, 2139, 356, 283, 1001, 297, 283, 576, 356, 283, 647, 936, 272, 1978, 63, 832, 275, 6248, 272, 8574, 63, 2326, 275, 3943, 70, 20, 65, 30231, 7, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 267, 291, 12, 267, 9889, 267, 6037, 26, 4879, 59, 495, 61, 275, 488, 12, 267, 1083, 26, 620, 275, 283, 4030, 297, 267, 666, 26, 6184, 275, 488, 12, 267, 2323, 26, 4879, 59, 2141, 59, 495, 12, 620, 2677, 275, 488, 12, 267, 1177, 63, 1074, 26, 4879, 59, 16410, 18999, 2155, 2677, 275, 488, 12, 267, 1177, 63, 1541, 26, 4879, 59, 16410, 18999, 6184, 2677, 275, 488, 12, 267, 2402, 63, 1419, 26, 4879, 59, 2141, 59, 495, 12, 6184, 2677, 275, 488, 12, 267, 1455, 63, 1631, 63, 344, 26, 620, 275, 283, 1014, 63, 885, 297, 267, 943, 63, 1310, 26, 2155, 275, 756, 12, 267, 1011, 958, 26, 6184, 12, 272, 776, 1035, 488, 26, 267, 1613, 11027, 826, 14155, 958, 9, 267, 291, 14, 1014, 63, 1631, 63, 344, 275, 1455, 63, 1631, 63, 344, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 6520, 275, 6037, 267, 291, 14, 2139, 275, 2323, 503, 1052, 267, 291, 14, 576, 275, 666, 503, 1052, 267, 291, 14, 1310, 63, 1074, 275, 1177, 63, 1074, 267, 291, 14, 1310, 63, 1541, 275, 1177, 63, 1541, 267, 291, 14, 2911, 63, 1419, 275, 2402, 63, 1419, 503, 1052, 267, 291, 14, 793, 63, 1310, 275, 943, 63, 1310, 267, 340, 2074, 14, 362, 360, 88, 957, 63, 5335, 358, 365, 440, 488, 26, 288, 746, 31040, 1726, 15587, 88, 957, 63, 5335, 7, 1990, 5906, 12, 675, 283, 1563, 7961, 14, 1117, 63, 88, 957, 63, 5335, 7, 3140, 531, 339, 347, 5341, 8, 277, 12, 1067, 26, 7448, 59, 495, 12, 6184, 566, 1035, 6184, 26, 267, 687, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ramanajee/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/common/system/urlfetcher_mock.py
165
2053
# Copyright (C) 2011 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. def make_fetcher_cls(urls): """UrlFetcher factory routine that simulates network access using a dict of URLs -> contents.""" class MockFetcher(object): def __init__(self, filesystem): self._filesystem = filesystem def fetch(self, url): return urls[url] def fetch_into_file(self, url): f, fn = self._filesystem.open_binary_tempfile('mockfetcher') f.write(self.fetch(url)) f.close() return fn return MockFetcher
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7760, 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, 259, 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, 259, 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, 259, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 318, 1852, 63, 26983, 63, 1886, 8, 3603, 304, 272, 408, 6417, 11135, 281, 6434, 12981, 626, 4389, 15409, 2784, 2879, 272, 1808, 282, 1211, 402, 10867, 1035, 4072, 1041, 272, 1021, 4420, 11135, 281, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 10036, 304, 288, 291, 423, 11381, 275, 10036, 398, 347, 5267, 8, 277, 12, 1166, 304, 288, 372, 8187, 59, 633, 61, 398, 347, 5267, 63, 9924, 63, 493, 8, 277, 12, 1166, 304, 288, 289, 12, 4325, 275, 291, 423, 11381, 14, 1490, 63, 3008, 63, 17336, 360, 1805, 26983, 358, 288, 289, 14, 952, 8, 277, 14, 3535, 8, 633, 430, 288, 289, 14, 1600, 342, 288, 372, 4325, 339, 372, 4420, 11135, 281, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7760, 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, 259, 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, 259, 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, 259, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 318, 1852, 63, 26983, 63, 1886, 8, 3603, 304, 272, 408, 6417, 11135, 281, 6434, 12981, 626, 4389, 15409, 2784, 2879, 272, 1808, 282, 1211, 402, 10867, 1035, 4072, 1041, 272, 1021, 4420, 11135, 281, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 10036, 304, 288, 291, 423, 11381, 275, 10036, 398, 347, 5267, 8, 277, 12, 1166, 304, 288, 372, 8187, 59, 633, 61, 398, 347, 5267, 63, 9924, 63, 493, 8, 277, 12, 1166, 304, 288, 289, 12, 4325, 275, 291, 423, 11381, 14, 1490, 63, 3008, 63, 17336, 360, 1805, 26983, 358, 288, 289, 14, 952, 8, 277, 14, 3535, 8, 633, 430, 288, 289, 14, 1600, 342, 288, 372, 4325, 339, 372, 4420, 11135, 281, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
thegooglecodearchive/mpmath
mpmath/tests/test_ode.py
15
1822
#from mpmath.calculus import ODE_step_euler, ODE_step_rk4, odeint, arange from mpmath import odefun, cos, sin, mpf, sinc, mp ''' solvers = [ODE_step_euler, ODE_step_rk4] def test_ode1(): """ Let's solve: x'' + w**2 * x = 0 i.e. x1 = x, x2 = x1': x1' = x2 x2' = -x1 """ def derivs((x1, x2), t): return x2, -x1 for solver in solvers: t = arange(0, 3.1415926, 0.005) sol = odeint(derivs, (0., 1.), t, solver) x1 = [a[0] for a in sol] x2 = [a[1] for a in sol] # the result is x1 = sin(t), x2 = cos(t) # let's just check the end points for t = pi assert abs(x1[-1]) < 1e-2 assert abs(x2[-1] - (-1)) < 1e-2 def test_ode2(): """ Let's solve: x' - x = 0 i.e. x = exp(x) """ def derivs((x), t): return x for solver in solvers: t = arange(0, 1, 1e-3) sol = odeint(derivs, (1.,), t, solver) x = [a[0] for a in sol] # the result is x = exp(t) # let's just check the end point for t = 1, i.e. x = e assert abs(x[-1] - 2.718281828) < 1e-2 ''' def test_odefun_rational(): mp.dps = 15 # A rational function f = lambda t: 1/(1+mpf(t)**2) g = odefun(lambda x, y: [-2*x*y[0]**2], 0, [f(0)]) assert f(2).ae(g(2)[0]) def test_odefun_sinc_large(): mp.dps = 15 # Sinc function; test for large x f = sinc g = odefun(lambda x, y: [(cos(x)-y[0])/x], 1, [f(1)], tol=0.01, degree=5) assert abs(f(100) - g(100)[0])/f(100) < 0.01 def test_odefun_harmonic(): mp.dps = 15 # Harmonic oscillator f = odefun(lambda x, y: [-y[1], y[0]], 0, [1, 0]) for x in [0, 1, 2.5, 8, 3.7]: # we go back to 3.7 to check caching c, s = f(x) assert c.ae(cos(x)) assert s.ae(sin(x))
bsd-3-clause
[ 3, 504, 6118, 3442, 14, 13494, 527, 492, 593, 1093, 63, 2926, 63, 69, 19345, 12, 593, 1093, 63, 2926, 63, 23992, 20, 12, 312, 271, 442, 12, 20461, 199, 504, 6118, 3442, 492, 312, 318, 324, 12, 9794, 12, 9829, 12, 21129, 12, 308, 6559, 12, 6118, 199, 199, 2344, 199, 11263, 83, 275, 359, 9125, 63, 2926, 63, 69, 19345, 12, 593, 1093, 63, 2926, 63, 23992, 20, 61, 199, 199, 318, 511, 63, 380, 17, 837, 272, 408, 272, 12230, 1159, 14241, 26, 339, 671, 891, 435, 336, 538, 18, 627, 671, 275, 378, 339, 284, 14, 69, 14, 671, 17, 275, 671, 12, 671, 18, 275, 671, 17, 356, 339, 671, 17, 7, 275, 221, 671, 18, 272, 671, 18, 7, 275, 446, 88, 17, 272, 408, 272, 347, 5405, 3122, 1332, 88, 17, 12, 671, 18, 395, 307, 304, 267, 372, 671, 18, 12, 446, 88, 17, 339, 367, 10196, 315, 10196, 83, 26, 267, 307, 275, 20461, 8, 16, 12, 650, 14, 1079, 9327, 1479, 12, 378, 14, 7972, 9, 267, 8597, 275, 312, 271, 442, 8, 9910, 3122, 12, 334, 16, 2020, 413, 15631, 307, 12, 10196, 9, 267, 671, 17, 275, 359, 65, 59, 16, 61, 367, 282, 315, 8597, 61, 267, 671, 18, 275, 359, 65, 59, 17, 61, 367, 282, 315, 8597, 61, 267, 327, 314, 754, 365, 671, 17, 275, 9829, 8, 84, 395, 671, 18, 275, 9794, 8, 84, 9, 267, 327, 4691, 1159, 2951, 1104, 314, 1284, 4501, 367, 307, 275, 6682, 267, 702, 2853, 8, 88, 17, 1988, 17, 566, 665, 413, 69, 13, 18, 267, 702, 2853, 8, 88, 18, 1988, 17, 61, 446, 5868, 17, 430, 665, 413, 69, 13, 18, 199, 199, 318, 511, 63, 380, 18, 837, 272, 408, 272, 12230, 1159, 14241, 26, 339, 671, 7, 446, 671, 275, 378, 339, 284, 14, 69, 14, 671, 275, 1437, 8, 88, 9, 339, 408, 272, 347, 5405, 3122, 1332, 88, 395, 307, 304, 267, 372, 671, 339, 367, 10196, 315, 10196, 83, 26, 267, 307, 275, 20461, 8, 16, 12, 413, 12, 413, 69, 13, 19, 9, 267, 8597, 275, 312, 271, 442, 8, 9910, 3122, 12, 334, 17, 2020, 395, 307, 12, 10196, 9, 267, 671, 275, 359, 65, 59, 16, 61, 367, 282, 315, 8597, 61, 267, 327, 314, 754, 365, 671, 275, 1437, 8, 84, 9, 267, 327, 4691, 1159, 2951, 1104, 314, 1284, 2376, 367, 307, 275, 413, 12, 284, 14, 69, 14, 671, 275, 325, 267, 702, 2853, 8, 88, 1988, 17, 61, 446, 499, 14, 26948, 1651, 1085, 1651, 9, 665, 413, 69, 13, 18, 199, 2344, 199, 199, 318, 511, 63, 79, 318, 324, 63, 21005, 837, 272, 6118, 14, 30168, 275, 4114, 272, 327, 437, 30239, 805, 272, 289, 275, 2400, 307, 26, 413, 7985, 17, 11, 26716, 8, 84, 6422, 18, 9, 272, 486, 275, 312, 318, 324, 8, 2734, 671, 12, 612, 26, 5243, 18, 10, 88, 10, 89, 59, 16, 24186, 18, 467, 378, 12, 359, 70, 8, 16, 3948, 272, 702, 289, 8, 18, 680, 3624, 8, 71, 8, 18, 2788, 16, 566, 199, 199, 318, 511, 63, 79, 318, 324, 63, 5911, 67, 63, 9629, 837, 272, 6118, 14, 30168, 275, 4114, 272, 327, 428, 6559, 805, 27, 511, 367, 7031, 671, 272, 289, 275, 308, 6559, 272, 486, 275, 312, 318, 324, 8, 2734, 671, 12, 612, 26, 3842, 5197, 8, 88, 7216, 89, 59, 16, 23067, 88, 467, 413, 12, 359, 70, 8, 17, 4360, 9561, 29, 16, 14, 614, 12, 13666, 29, 21, 9, 272, 702, 2853, 8, 70, 8, 1960, 9, 446, 486, 8, 1960, 2788, 16, 23067, 70, 8, 1960, 9, 665, 378, 14, 614, 199, 199, 318, 511, 63, 79, 318, 324, 63, 8210, 16082, 837, 272, 6118, 14, 30168, 275, 4114, 272, 327, 25378, 16082, 31920, 778, 707, 272, 289, 275, 312, 318, 324, 8, 2734, 671, 12, 612, 26, 5243, 89, 59, 17, 467, 612, 59, 16, 2365, 378, 12, 359, 17, 12, 378, 566, 272, 367, 671, 315, 359, 16, 12, 413, 12, 499, 14, 21, 12, 1695, 12, 650, 14, 23, 2189, 259, 327, 221, 781, 2621, 1771, 370, 650, 14, 23, 370, 1104, 13627, 267, 286, 12, 308, 275, 289, 8, 88, 9, 267, 702, 286, 14, 3624, 8, 5197, 8, 88, 430, 267, 702, 308, 14, 3624, 8, 5911, 8, 88, 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 ]
[ 504, 6118, 3442, 14, 13494, 527, 492, 593, 1093, 63, 2926, 63, 69, 19345, 12, 593, 1093, 63, 2926, 63, 23992, 20, 12, 312, 271, 442, 12, 20461, 199, 504, 6118, 3442, 492, 312, 318, 324, 12, 9794, 12, 9829, 12, 21129, 12, 308, 6559, 12, 6118, 199, 199, 2344, 199, 11263, 83, 275, 359, 9125, 63, 2926, 63, 69, 19345, 12, 593, 1093, 63, 2926, 63, 23992, 20, 61, 199, 199, 318, 511, 63, 380, 17, 837, 272, 408, 272, 12230, 1159, 14241, 26, 339, 671, 891, 435, 336, 538, 18, 627, 671, 275, 378, 339, 284, 14, 69, 14, 671, 17, 275, 671, 12, 671, 18, 275, 671, 17, 356, 339, 671, 17, 7, 275, 221, 671, 18, 272, 671, 18, 7, 275, 446, 88, 17, 272, 408, 272, 347, 5405, 3122, 1332, 88, 17, 12, 671, 18, 395, 307, 304, 267, 372, 671, 18, 12, 446, 88, 17, 339, 367, 10196, 315, 10196, 83, 26, 267, 307, 275, 20461, 8, 16, 12, 650, 14, 1079, 9327, 1479, 12, 378, 14, 7972, 9, 267, 8597, 275, 312, 271, 442, 8, 9910, 3122, 12, 334, 16, 2020, 413, 15631, 307, 12, 10196, 9, 267, 671, 17, 275, 359, 65, 59, 16, 61, 367, 282, 315, 8597, 61, 267, 671, 18, 275, 359, 65, 59, 17, 61, 367, 282, 315, 8597, 61, 267, 327, 314, 754, 365, 671, 17, 275, 9829, 8, 84, 395, 671, 18, 275, 9794, 8, 84, 9, 267, 327, 4691, 1159, 2951, 1104, 314, 1284, 4501, 367, 307, 275, 6682, 267, 702, 2853, 8, 88, 17, 1988, 17, 566, 665, 413, 69, 13, 18, 267, 702, 2853, 8, 88, 18, 1988, 17, 61, 446, 5868, 17, 430, 665, 413, 69, 13, 18, 199, 199, 318, 511, 63, 380, 18, 837, 272, 408, 272, 12230, 1159, 14241, 26, 339, 671, 7, 446, 671, 275, 378, 339, 284, 14, 69, 14, 671, 275, 1437, 8, 88, 9, 339, 408, 272, 347, 5405, 3122, 1332, 88, 395, 307, 304, 267, 372, 671, 339, 367, 10196, 315, 10196, 83, 26, 267, 307, 275, 20461, 8, 16, 12, 413, 12, 413, 69, 13, 19, 9, 267, 8597, 275, 312, 271, 442, 8, 9910, 3122, 12, 334, 17, 2020, 395, 307, 12, 10196, 9, 267, 671, 275, 359, 65, 59, 16, 61, 367, 282, 315, 8597, 61, 267, 327, 314, 754, 365, 671, 275, 1437, 8, 84, 9, 267, 327, 4691, 1159, 2951, 1104, 314, 1284, 2376, 367, 307, 275, 413, 12, 284, 14, 69, 14, 671, 275, 325, 267, 702, 2853, 8, 88, 1988, 17, 61, 446, 499, 14, 26948, 1651, 1085, 1651, 9, 665, 413, 69, 13, 18, 199, 2344, 199, 199, 318, 511, 63, 79, 318, 324, 63, 21005, 837, 272, 6118, 14, 30168, 275, 4114, 272, 327, 437, 30239, 805, 272, 289, 275, 2400, 307, 26, 413, 7985, 17, 11, 26716, 8, 84, 6422, 18, 9, 272, 486, 275, 312, 318, 324, 8, 2734, 671, 12, 612, 26, 5243, 18, 10, 88, 10, 89, 59, 16, 24186, 18, 467, 378, 12, 359, 70, 8, 16, 3948, 272, 702, 289, 8, 18, 680, 3624, 8, 71, 8, 18, 2788, 16, 566, 199, 199, 318, 511, 63, 79, 318, 324, 63, 5911, 67, 63, 9629, 837, 272, 6118, 14, 30168, 275, 4114, 272, 327, 428, 6559, 805, 27, 511, 367, 7031, 671, 272, 289, 275, 308, 6559, 272, 486, 275, 312, 318, 324, 8, 2734, 671, 12, 612, 26, 3842, 5197, 8, 88, 7216, 89, 59, 16, 23067, 88, 467, 413, 12, 359, 70, 8, 17, 4360, 9561, 29, 16, 14, 614, 12, 13666, 29, 21, 9, 272, 702, 2853, 8, 70, 8, 1960, 9, 446, 486, 8, 1960, 2788, 16, 23067, 70, 8, 1960, 9, 665, 378, 14, 614, 199, 199, 318, 511, 63, 79, 318, 324, 63, 8210, 16082, 837, 272, 6118, 14, 30168, 275, 4114, 272, 327, 25378, 16082, 31920, 778, 707, 272, 289, 275, 312, 318, 324, 8, 2734, 671, 12, 612, 26, 5243, 89, 59, 17, 467, 612, 59, 16, 2365, 378, 12, 359, 17, 12, 378, 566, 272, 367, 671, 315, 359, 16, 12, 413, 12, 499, 14, 21, 12, 1695, 12, 650, 14, 23, 2189, 259, 327, 221, 781, 2621, 1771, 370, 650, 14, 23, 370, 1104, 13627, 267, 286, 12, 308, 275, 289, 8, 88, 9, 267, 702, 286, 14, 3624, 8, 5197, 8, 88, 430, 267, 702, 308, 14, 3624, 8, 5911, 8, 88, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pixbuffer/django-cms
cms/tests/i18n.py
10
11055
from cms.test_utils.testcases import SettingsOverrideTestCase from cms.utils import i18n class TestLanguages(SettingsOverrideTestCase): settings_overrides = { 'LANGUAGE_CODE': 'en-us', 'LANGUAGES': (('fr', 'French'), ('en', 'English'), ('de', 'German'), ('es', 'Spanish')), 'CMS_LANGUAGES': { 1: [ {'code' : 'en', 'name': 'English', 'public': True}, {'code': 'fr', 'name': 'French', 'public': False}, ], 'default': { 'public': True, 'hide_untranslated': False, } }, 'SITE_ID': 1, } def test_language_code(self): self.assertEqual(i18n.get_language_code(self.settings_overrides['LANGUAGE_CODE']), 'en') self.assertEqual(i18n.get_current_language(), 'en') def test_get_languages_default_site(self): result = i18n.get_languages() self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en') self.assertEqual(i18n.get_language_code(lang['code']), 'en') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr') self.assertEqual(i18n.get_language_code(lang['code']), 'fr') self.assertEqual(lang['public'], False) def test_get_languages_defined_site(self): result = i18n.get_languages(1) self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en') self.assertEqual(i18n.get_language_code(lang['code']), 'en') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr') self.assertEqual(i18n.get_language_code(lang['code']), 'fr') self.assertEqual(lang['public'], False) def test_get_languages_undefined_site(self): result = i18n.get_languages(66) self.assertEqual(4, len(result)) self.assertEqual(result[0]['code'], 'fr') self.assertEqual(i18n.get_language_code(result[0]['code']), 'fr') self.assertEqual(result[1]['code'], 'en') self.assertEqual(i18n.get_language_code(result[1]['code']), 'en') self.assertEqual(result[2]['code'], 'de') self.assertEqual(i18n.get_language_code(result[2]['code']), 'de') self.assertEqual(result[3]['code'], 'es') self.assertEqual(i18n.get_language_code(result[3]['code']), 'es') for lang in result: self.assertEqual(lang['public'], True) self.assertEqual(lang['hide_untranslated'], False) class TestLanguagesNoDefault(SettingsOverrideTestCase): settings_overrides = { 'LANGUAGE_CODE': 'en-us', 'LANGUAGES': (('fr', 'French'), ('en', 'English'), ('de', 'German'), ('es', 'Spanish')), 'CMS_LANGUAGES': { 1: [ {'code' : 'en', 'name': 'English', 'public': True}, {'code': 'fr', 'name': 'French', 'public': False}, ], }, 'SITE_ID': 1, } def test_get_languages_default_site(self): result = i18n.get_languages() self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en') self.assertEqual(i18n.get_language_code(lang['code']), 'en') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr') self.assertEqual(i18n.get_language_code(lang['code']), 'fr') self.assertEqual(lang['public'], False) def test_get_languages_defined_site(self): result = i18n.get_languages(1) self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en') self.assertEqual(i18n.get_language_code(lang['code']), 'en') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr') self.assertEqual(i18n.get_language_code(lang['code']), 'fr') self.assertEqual(lang['public'], False) def test_get_languages_undefined_site(self): result = i18n.get_languages(66) self.assertEqual(4, len(result)) self.assertEqual(result[0]['code'], 'fr') self.assertEqual(i18n.get_language_code(result[0]['code']), 'fr') self.assertEqual(result[1]['code'], 'en') self.assertEqual(i18n.get_language_code(result[1]['code']), 'en') self.assertEqual(result[2]['code'], 'de') self.assertEqual(i18n.get_language_code(result[2]['code']), 'de') self.assertEqual(result[3]['code'], 'es') self.assertEqual(i18n.get_language_code(result[3]['code']), 'es') for lang in result: self.assertEqual(lang['public'], True) self.assertEqual(lang['hide_untranslated'], True) class TestLanguageCodesEnUS(SettingsOverrideTestCase): settings_overrides = { 'LANGUAGE_CODE': 'en-us', 'LANGUAGES': (('fr-ca', 'French (Canada)'), ('en-us', 'English (US)'), ('en-gb', 'English (UK)'), ('de', 'German'), ('es', 'Spanish')), 'CMS_LANGUAGES': { 1: [ {'code' : 'en-us', 'name': 'English (US)', 'public': True}, {'code': 'fr-ca', 'name': 'French (Canada)', 'public': False}, ], 'default': { 'public': True, 'hide_untranslated': False, } }, 'SITE_ID': 1, } def test_language_code(self): self.assertEqual(i18n.get_language_code(self.settings_overrides['LANGUAGE_CODE']), 'en-us') self.assertEqual(i18n.get_current_language(), 'en-us') #error def test_get_languages_default_site(self): result = i18n.get_languages() self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en-us') self.assertEqual(i18n.get_language_code(lang['code']), 'en-us') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr-ca') self.assertEqual(i18n.get_language_code(lang['code']), 'fr-ca') self.assertEqual(lang['public'], False) def test_get_languages_defined_site(self): result = i18n.get_languages(1) self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en-us') self.assertEqual(i18n.get_language_code(lang['code']), 'en-us') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr-ca') self.assertEqual(i18n.get_language_code(lang['code']), 'fr-ca') self.assertEqual(lang['public'], False) def test_get_languages_undefined_site(self): result = i18n.get_languages(66) self.assertEqual(5, len(result)) self.assertEqual(result[0]['code'], 'fr-ca') self.assertEqual(i18n.get_language_code(result[0]['code']), 'fr-ca') self.assertEqual(result[1]['code'], 'en-us') self.assertEqual(i18n.get_language_code(result[1]['code']), 'en-us') self.assertEqual(result[2]['code'], 'en-gb') self.assertEqual(i18n.get_language_code(result[2]['code']), 'en-gb') self.assertEqual(result[3]['code'], 'de') self.assertEqual(i18n.get_language_code(result[3]['code']), 'de') self.assertEqual(result[4]['code'], 'es') self.assertEqual(i18n.get_language_code(result[4]['code']), 'es') for lang in result: self.assertEqual(lang['public'], True) self.assertEqual(lang['hide_untranslated'], False) class TestLanguageCodesEnGB(SettingsOverrideTestCase): settings_overrides = { 'LANGUAGE_CODE': 'en-gb', 'LANGUAGES': (('fr-ca', 'French (Canada)'), ('en-us', 'English (US)'), ('en-gb', 'English (UK)'), ('de', 'German'), ('es', 'Spanish')), 'CMS_LANGUAGES': { 1: [ {'code' : 'en-gb', 'name': 'English (UK)', 'public': True}, {'code': 'fr-ca', 'name': 'French (Canada)', 'public': False}, ], 'default': { 'public': True, 'hide_untranslated': False, } }, 'SITE_ID': 1, } def test_language_code(self): self.assertEqual(i18n.get_language_code(self.settings_overrides['LANGUAGE_CODE']), 'en-gb') self.assertEqual(i18n.get_current_language(), 'en-gb') #error def test_get_languages_default_site(self): result = i18n.get_languages() self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en-gb') self.assertEqual(i18n.get_language_code(lang['code']), 'en-gb') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr-ca') self.assertEqual(i18n.get_language_code(lang['code']), 'fr-ca') self.assertEqual(lang['public'], False) def test_get_languages_defined_site(self): result = i18n.get_languages(1) self.assertEqual(2, len(result)) lang = result[0] self.assertEqual(lang['code'], 'en-gb') self.assertEqual(i18n.get_language_code(lang['code']), 'en-gb') self.assertEqual(lang['public'], True) lang = result[1] self.assertEqual(lang['code'], 'fr-ca') self.assertEqual(i18n.get_language_code(lang['code']), 'fr-ca') self.assertEqual(lang['public'], False) def test_get_languages_undefined_site(self): result = i18n.get_languages(66) self.assertEqual(5, len(result)) self.assertEqual(result[0]['code'], 'fr-ca') self.assertEqual(i18n.get_language_code(result[0]['code']), 'fr-ca') self.assertEqual(result[1]['code'], 'en-us') self.assertEqual(i18n.get_language_code(result[1]['code']), 'en-us') self.assertEqual(result[2]['code'], 'en-gb') self.assertEqual(i18n.get_language_code(result[2]['code']), 'en-gb') self.assertEqual(result[3]['code'], 'de') self.assertEqual(i18n.get_language_code(result[3]['code']), 'de') self.assertEqual(result[4]['code'], 'es') self.assertEqual(i18n.get_language_code(result[4]['code']), 'es') for lang in result: self.assertEqual(lang['public'], True) self.assertEqual(lang['hide_untranslated'], False)
bsd-3-clause
[ 504, 19240, 14, 396, 63, 1208, 14, 396, 9403, 492, 13303, 11954, 1746, 199, 504, 19240, 14, 1208, 492, 284, 1085, 78, 199, 199, 533, 1379, 8493, 83, 8, 5268, 11954, 1746, 304, 339, 2202, 63, 12867, 275, 469, 267, 283, 13947, 63, 6012, 356, 283, 287, 13, 527, 297, 267, 283, 26886, 356, 13636, 4391, 297, 283, 38, 15148, 659, 1993, 661, 287, 297, 283, 19410, 659, 1993, 661, 271, 297, 283, 27866, 1237, 659, 1993, 661, 397, 297, 283, 23717, 2453, 3855, 267, 283, 17834, 63, 26886, 356, 469, 288, 413, 26, 359, 791, 600, 7, 520, 283, 287, 297, 2116, 283, 354, 356, 283, 19410, 297, 2116, 283, 3455, 356, 715, 1386, 326, 791, 600, 356, 283, 4391, 297, 2116, 283, 354, 356, 283, 38, 15148, 297, 2116, 283, 3455, 356, 756, 1386, 288, 2156, 288, 283, 885, 356, 469, 355, 283, 3455, 356, 715, 12, 355, 283, 8191, 63, 324, 18065, 356, 756, 12, 288, 789, 267, 1660, 267, 283, 7917, 63, 998, 356, 413, 12, 272, 789, 2286, 347, 511, 63, 3671, 63, 600, 8, 277, 304, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 277, 14, 1751, 63, 12867, 459, 13947, 63, 6012, 3815, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 1818, 63, 3671, 1062, 283, 287, 358, 339, 347, 511, 63, 362, 63, 13209, 63, 885, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 342, 267, 291, 14, 629, 8, 18, 12, 822, 8, 1099, 430, 267, 6339, 275, 754, 59, 16, 61, 18418, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 287, 358, 18418, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 287, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 267, 6339, 275, 754, 59, 17, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 4391, 358, 267, 291, 14, 629, 8, 4159, 459, 3455, 995, 756, 9, 260, 339, 347, 511, 63, 362, 63, 13209, 63, 4037, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 8, 17, 9, 267, 291, 14, 629, 8, 18, 12, 822, 8, 1099, 430, 267, 6339, 275, 754, 59, 16, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 287, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 267, 6339, 275, 754, 59, 17, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 4391, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 756, 9, 339, 347, 511, 63, 362, 63, 13209, 63, 10705, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 8, 1272, 9, 267, 291, 14, 629, 8, 20, 12, 822, 8, 1099, 430, 267, 291, 14, 629, 8, 1099, 59, 16, 2733, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 16, 2733, 600, 3815, 283, 4391, 358, 267, 291, 14, 629, 8, 1099, 59, 17, 2733, 600, 995, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 17, 2733, 600, 3815, 283, 287, 358, 267, 291, 14, 629, 8, 1099, 59, 18, 2733, 600, 995, 283, 271, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 18, 2733, 600, 3815, 283, 271, 358, 267, 291, 14, 629, 8, 1099, 59, 19, 2733, 600, 995, 283, 397, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 19, 2733, 600, 3815, 283, 397, 358, 267, 367, 6339, 315, 754, 26, 288, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 288, 291, 14, 629, 8, 4159, 459, 8191, 63, 324, 18065, 995, 756, 9, 421, 199, 533, 1379, 8493, 83, 1944, 2698, 8, 5268, 11954, 1746, 304, 339, 2202, 63, 12867, 275, 469, 267, 283, 13947, 63, 6012, 356, 283, 287, 13, 527, 297, 267, 283, 26886, 356, 13636, 4391, 297, 283, 38, 15148, 659, 1993, 661, 287, 297, 283, 19410, 659, 1993, 661, 271, 297, 283, 27866, 1237, 659, 1993, 661, 397, 297, 283, 23717, 2453, 3855, 267, 283, 17834, 63, 26886, 356, 469, 288, 413, 26, 359, 791, 600, 7, 520, 283, 287, 297, 2116, 283, 354, 356, 283, 19410, 297, 2116, 283, 3455, 356, 715, 1386, 326, 791, 600, 356, 283, 4391, 297, 2116, 283, 354, 356, 283, 38, 15148, 297, 2116, 283, 3455, 356, 756, 1386, 326, 2156, 267, 1660, 267, 283, 7917, 63, 998, 356, 413, 12, 267, 789, 339, 347, 511, 63, 362, 63, 13209, 63, 885, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 342, 267, 291, 14, 629, 8, 18, 12, 822, 8, 1099, 430, 267, 6339, 275, 754, 59, 16, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 287, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 267, 6339, 275, 754, 59, 17, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 4391, 358, 4960, 291, 14, 629, 8, 4159, 459, 3455, 995, 756, 9, 339, 347, 511, 63, 362, 63, 13209, 63, 4037, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362 ]
[ 19240, 14, 396, 63, 1208, 14, 396, 9403, 492, 13303, 11954, 1746, 199, 504, 19240, 14, 1208, 492, 284, 1085, 78, 199, 199, 533, 1379, 8493, 83, 8, 5268, 11954, 1746, 304, 339, 2202, 63, 12867, 275, 469, 267, 283, 13947, 63, 6012, 356, 283, 287, 13, 527, 297, 267, 283, 26886, 356, 13636, 4391, 297, 283, 38, 15148, 659, 1993, 661, 287, 297, 283, 19410, 659, 1993, 661, 271, 297, 283, 27866, 1237, 659, 1993, 661, 397, 297, 283, 23717, 2453, 3855, 267, 283, 17834, 63, 26886, 356, 469, 288, 413, 26, 359, 791, 600, 7, 520, 283, 287, 297, 2116, 283, 354, 356, 283, 19410, 297, 2116, 283, 3455, 356, 715, 1386, 326, 791, 600, 356, 283, 4391, 297, 2116, 283, 354, 356, 283, 38, 15148, 297, 2116, 283, 3455, 356, 756, 1386, 288, 2156, 288, 283, 885, 356, 469, 355, 283, 3455, 356, 715, 12, 355, 283, 8191, 63, 324, 18065, 356, 756, 12, 288, 789, 267, 1660, 267, 283, 7917, 63, 998, 356, 413, 12, 272, 789, 2286, 347, 511, 63, 3671, 63, 600, 8, 277, 304, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 277, 14, 1751, 63, 12867, 459, 13947, 63, 6012, 3815, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 1818, 63, 3671, 1062, 283, 287, 358, 339, 347, 511, 63, 362, 63, 13209, 63, 885, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 342, 267, 291, 14, 629, 8, 18, 12, 822, 8, 1099, 430, 267, 6339, 275, 754, 59, 16, 61, 18418, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 287, 358, 18418, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 287, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 267, 6339, 275, 754, 59, 17, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 4391, 358, 267, 291, 14, 629, 8, 4159, 459, 3455, 995, 756, 9, 260, 339, 347, 511, 63, 362, 63, 13209, 63, 4037, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 8, 17, 9, 267, 291, 14, 629, 8, 18, 12, 822, 8, 1099, 430, 267, 6339, 275, 754, 59, 16, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 287, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 267, 6339, 275, 754, 59, 17, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 4391, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 756, 9, 339, 347, 511, 63, 362, 63, 13209, 63, 10705, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 8, 1272, 9, 267, 291, 14, 629, 8, 20, 12, 822, 8, 1099, 430, 267, 291, 14, 629, 8, 1099, 59, 16, 2733, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 16, 2733, 600, 3815, 283, 4391, 358, 267, 291, 14, 629, 8, 1099, 59, 17, 2733, 600, 995, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 17, 2733, 600, 3815, 283, 287, 358, 267, 291, 14, 629, 8, 1099, 59, 18, 2733, 600, 995, 283, 271, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 18, 2733, 600, 3815, 283, 271, 358, 267, 291, 14, 629, 8, 1099, 59, 19, 2733, 600, 995, 283, 397, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 1099, 59, 19, 2733, 600, 3815, 283, 397, 358, 267, 367, 6339, 315, 754, 26, 288, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 288, 291, 14, 629, 8, 4159, 459, 8191, 63, 324, 18065, 995, 756, 9, 421, 199, 533, 1379, 8493, 83, 1944, 2698, 8, 5268, 11954, 1746, 304, 339, 2202, 63, 12867, 275, 469, 267, 283, 13947, 63, 6012, 356, 283, 287, 13, 527, 297, 267, 283, 26886, 356, 13636, 4391, 297, 283, 38, 15148, 659, 1993, 661, 287, 297, 283, 19410, 659, 1993, 661, 271, 297, 283, 27866, 1237, 659, 1993, 661, 397, 297, 283, 23717, 2453, 3855, 267, 283, 17834, 63, 26886, 356, 469, 288, 413, 26, 359, 791, 600, 7, 520, 283, 287, 297, 2116, 283, 354, 356, 283, 19410, 297, 2116, 283, 3455, 356, 715, 1386, 326, 791, 600, 356, 283, 4391, 297, 2116, 283, 354, 356, 283, 38, 15148, 297, 2116, 283, 3455, 356, 756, 1386, 326, 2156, 267, 1660, 267, 283, 7917, 63, 998, 356, 413, 12, 267, 789, 339, 347, 511, 63, 362, 63, 13209, 63, 885, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 63, 13209, 342, 267, 291, 14, 629, 8, 18, 12, 822, 8, 1099, 430, 267, 6339, 275, 754, 59, 16, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 287, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 287, 358, 18418, 291, 14, 629, 8, 4159, 459, 3455, 995, 715, 9, 267, 6339, 275, 754, 59, 17, 61, 267, 291, 14, 629, 8, 4159, 459, 600, 995, 283, 4391, 358, 267, 291, 14, 629, 8, 73, 1085, 78, 14, 362, 63, 3671, 63, 600, 8, 4159, 459, 600, 3815, 283, 4391, 358, 4960, 291, 14, 629, 8, 4159, 459, 3455, 995, 756, 9, 339, 347, 511, 63, 362, 63, 13209, 63, 4037, 63, 2124, 8, 277, 304, 267, 754, 275, 284, 1085, 78, 14, 362, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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2001-2009 Twisted Matrix Laboratories. # See LICENSE for details. """ SSL transport. Requires PyOpenSSL (http://pyopenssl.sf.net). SSL connections require a ContextFactory so they can create SSL contexts. End users should only use the ContextFactory classes directly - for SSL connections use the reactor.connectSSL/listenSSL and so on, as documented in IReactorSSL. All server context factories should inherit from ContextFactory, and all client context factories should inherit from ClientContextFactory. At the moment this is not enforced, but in the future it might be. Future Plans: - split module so reactor-specific classes are in a separate module - support for switching TCP into SSL - more options Maintainer: Itamar Shtull-Trauring """ # If something goes wrong, most notably an OpenSSL import failure, # sys.modules['twisted.internet.ssl'] will be bound to a partially # initialized module object. This is wacko, but we will take advantage # of it to publish whether or not SSL is available. # See the end of this module for the other half of this solution. # The correct idiom to import this module is thus: # try: # from twisted.internet import ssl # except ImportError: # # happens the first time the interpreter tries to import it # ssl = None # if ssl and not ssl.supported: # # happens second and later times # ssl = None supported = False # System imports from OpenSSL import SSL from zope.interface import implements, implementsOnly, implementedBy # Twisted imports from twisted.internet import tcp, interfaces, base, address class ContextFactory: """A factory for SSL context objects, for server SSL connections.""" isClient = 0 def getContext(self): """Return a SSL.Context object. override in subclasses.""" raise NotImplementedError class DefaultOpenSSLContextFactory(ContextFactory): """ L{DefaultOpenSSLContextFactory} is a factory for server-side SSL context objects. These objects define certain parameters related to SSL handshakes and the subsequent connection. @ivar _contextFactory: A callable which will be used to create new context objects. This is typically L{SSL.Context}. """ _context = None def __init__(self, privateKeyFileName, certificateFileName, sslmethod=SSL.SSLv23_METHOD, _contextFactory=SSL.Context): """ @param privateKeyFileName: Name of a file containing a private key @param certificateFileName: Name of a file containing a certificate @param sslmethod: The SSL method to use """ self.privateKeyFileName = privateKeyFileName self.certificateFileName = certificateFileName self.sslmethod = sslmethod self._contextFactory = _contextFactory # Create a context object right now. This is to force validation of # the given parameters so that errors are detected earlier rather # than later. self.cacheContext() def cacheContext(self): if self._context is None: ctx = self._contextFactory(self.sslmethod) # Disallow SSLv2! It's insecure! SSLv3 has been around since # 1996. It's time to move on. ctx.set_options(SSL.OP_NO_SSLv2) ctx.use_certificate_file(self.certificateFileName) ctx.use_privatekey_file(self.privateKeyFileName) self._context = ctx def __getstate__(self): d = self.__dict__.copy() del d['_context'] return d def __setstate__(self, state): self.__dict__ = state def getContext(self): """ Return an SSL context. """ return self._context class ClientContextFactory: """A context factory for SSL clients.""" isClient = 1 # SSLv23_METHOD allows SSLv2, SSLv3, and TLSv1. We disable SSLv2 below, # though. method = SSL.SSLv23_METHOD _contextFactory = SSL.Context def getContext(self): ctx = self._contextFactory(self.method) # See comment in DefaultOpenSSLContextFactory about SSLv2. ctx.set_options(SSL.OP_NO_SSLv2) return ctx class Client(tcp.Client): """I am an SSL client.""" implementsOnly(interfaces.ISSLTransport, *[i for i in implementedBy(tcp.Client) if i != interfaces.ITLSTransport]) def __init__(self, host, port, bindAddress, ctxFactory, connector, reactor=None): # tcp.Client.__init__ depends on self.ctxFactory being set self.ctxFactory = ctxFactory tcp.Client.__init__(self, host, port, bindAddress, connector, reactor) def getHost(self): """Returns the address from which I am connecting.""" h, p = self.socket.getsockname() return address.IPv4Address('TCP', h, p, 'SSL') def getPeer(self): """Returns the address that I am connected.""" return address.IPv4Address('TCP', self.addr[0], self.addr[1], 'SSL') def _connectDone(self): self.startTLS(self.ctxFactory) self.startWriting() tcp.Client._connectDone(self) class Server(tcp.Server): """I am an SSL server. """ implements(interfaces.ISSLTransport) def getHost(self): """Return server's address.""" h, p = self.socket.getsockname() return address.IPv4Address('TCP', h, p, 'SSL') def getPeer(self): """Return address of peer.""" h, p = self.client return address.IPv4Address('TCP', h, p, 'SSL') class Port(tcp.Port): """I am an SSL port.""" _socketShutdownMethod = 'sock_shutdown' transport = Server def __init__(self, port, factory, ctxFactory, backlog=50, interface='', reactor=None): tcp.Port.__init__(self, port, factory, backlog, interface, reactor) self.ctxFactory = ctxFactory def createInternetSocket(self): """(internal) create an SSL socket """ sock = tcp.Port.createInternetSocket(self) return SSL.Connection(self.ctxFactory.getContext(), sock) def _preMakeConnection(self, transport): # *Don't* call startTLS here # The transport already has the SSL.Connection object from above transport._startTLS() return tcp.Port._preMakeConnection(self, transport) class Connector(base.BaseConnector): def __init__(self, host, port, factory, contextFactory, timeout, bindAddress, reactor=None): self.host = host self.port = port self.bindAddress = bindAddress self.contextFactory = contextFactory base.BaseConnector.__init__(self, factory, timeout, reactor) def _makeTransport(self): return Client(self.host, self.port, self.bindAddress, self.contextFactory, self, self.reactor) def getDestination(self): return address.IPv4Address('TCP', self.host, self.port, 'SSL') from twisted.internet._sslverify import DistinguishedName, DN, Certificate from twisted.internet._sslverify import CertificateRequest, PrivateCertificate from twisted.internet._sslverify import KeyPair from twisted.internet._sslverify import OpenSSLCertificateOptions as CertificateOptions __all__ = [ "ContextFactory", "DefaultOpenSSLContextFactory", "ClientContextFactory", 'DistinguishedName', 'DN', 'Certificate', 'CertificateRequest', 'PrivateCertificate', 'KeyPair', 'CertificateOptions', ] supported = True
apache-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 4266, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 5413, 7773, 14, 15127, 1611, 22791, 334, 1014, 921, 647, 14837, 14, 7646, 14, 846, 680, 199, 199, 5413, 6947, 4409, 282, 9470, 2927, 880, 2985, 883, 1218, 7799, 18191, 14, 199, 3005, 4390, 1077, 1454, 675, 314, 9470, 2927, 3992, 5370, 446, 367, 7799, 199, 7995, 675, 314, 9655, 14, 2242, 5413, 15, 5859, 5413, 436, 880, 641, 12, 465, 22751, 199, 262, 473, 15860, 5413, 14, 199, 199, 2422, 1654, 1067, 22115, 1077, 8287, 687, 9470, 2927, 12, 436, 1006, 199, 1258, 1067, 22115, 1077, 8287, 687, 6810, 2998, 2927, 14, 2854, 314, 199, 17282, 642, 365, 440, 30163, 12, 1325, 315, 314, 6466, 652, 5594, 506, 14, 199, 199, 14224, 7497, 796, 26, 272, 446, 3715, 859, 880, 9655, 13, 6100, 3992, 787, 315, 282, 7396, 859, 272, 446, 2291, 367, 31620, 13488, 1901, 7799, 272, 446, 1655, 1511, 199, 199, 11903, 8368, 281, 26, 2779, 455, 285, 428, 517, 979, 13, 2437, 4039, 199, 624, 199, 199, 3, 982, 6020, 13538, 6835, 12, 4750, 440, 6665, 376, 14296, 492, 5988, 12, 199, 3, 984, 14, 3112, 459, 12145, 14, 4901, 14, 4266, 418, 911, 506, 3914, 370, 282, 25172, 199, 3, 10038, 859, 909, 14, 221, 961, 365, 336, 564, 79, 12, 1325, 781, 911, 5452, 30268, 199, 3, 402, 652, 370, 2780, 3775, 503, 440, 7799, 365, 2808, 14, 199, 3, 1666, 314, 1284, 402, 642, 859, 367, 314, 1163, 12995, 402, 642, 8744, 14, 199, 199, 3, 710, 3211, 284, 328, 676, 370, 492, 642, 859, 365, 12850, 26, 199, 199, 3, 862, 26, 199, 3, 259, 687, 7390, 14, 4901, 492, 6149, 199, 3, 871, 3545, 26, 199, 3, 259, 327, 10986, 314, 1642, 900, 314, 12693, 11275, 370, 492, 652, 199, 3, 259, 6149, 275, 488, 199, 3, 340, 6149, 436, 440, 6149, 14, 4946, 26, 199, 3, 259, 327, 10986, 3499, 436, 2945, 5431, 199, 3, 259, 6149, 275, 488, 199, 199, 4946, 275, 756, 199, 199, 3, 6187, 8925, 199, 504, 14296, 492, 7799, 199, 504, 20110, 14, 3266, 492, 9031, 12, 9031, 5903, 12, 6366, 2175, 199, 199, 3, 17078, 8925, 199, 504, 7390, 14, 4901, 492, 14719, 12, 8386, 12, 1300, 12, 2287, 421, 199, 533, 9470, 2927, 26, 272, 408, 33, 6434, 367, 7799, 1067, 2251, 12, 367, 1654, 7799, 6947, 1041, 339, 365, 3041, 275, 378, 339, 347, 664, 2998, 8, 277, 304, 267, 408, 1767, 282, 7799, 14, 2998, 909, 14, 4278, 315, 9180, 1041, 267, 746, 4279, 421, 199, 533, 3758, 22791, 2998, 2927, 8, 2998, 2927, 304, 272, 408, 272, 491, 91, 2698, 22791, 2998, 2927, 93, 365, 282, 6434, 367, 1654, 13, 2441, 7799, 1067, 272, 2251, 14, 221, 5723, 2251, 5627, 9842, 2633, 4048, 370, 7799, 272, 4926, 609, 4364, 436, 314, 13372, 1950, 14, 339, 768, 7725, 485, 1100, 2927, 26, 437, 4550, 1314, 911, 506, 1202, 370, 1218, 892, 267, 1067, 2251, 14, 221, 961, 365, 13609, 491, 91, 5413, 14, 2998, 5565, 272, 408, 272, 485, 1100, 275, 488, 339, 347, 636, 826, 721, 277, 12, 30471, 7733, 12, 5897, 7733, 12, 326, 6149, 765, 29, 5413, 14, 21082, 1789, 63, 9977, 12, 485, 1100, 2927, 29, 5413, 14, 2998, 304, 267, 408, 267, 768, 635, 30471, 7733, 26, 2812, 402, 282, 570, 3035, 282, 5726, 790, 267, 768, 635, 5897, 7733, 26, 2812, 402, 282, 570, 3035, 282, 5897, 267, 768, 635, 6149, 765, 26, 710, 7799, 1083, 370, 675, 267, 408, 267, 291, 14, 4239, 1197, 7733, 275, 30471, 7733, 267, 291, 14, 6999, 7733, 275, 5897, 7733, 267, 291, 14, 4266, 765, 275, 6149, 765, 267, 291, 423, 1100, 2927, 275, 485, 1100, 2927, 398, 327, 2790, 282, 1067, 909, 2451, 3063, 14, 221, 961, 365, 370, 3542, 6411, 402, 267, 327, 314, 1627, 2633, 880, 626, 2552, 787, 10501, 14119, 7830, 267, 327, 2419, 2945, 14, 267, 291, 14, 1637, 2998, 342, 2378, 347, 2581, 2998, 8, 277, 304, 267, 340, 291, 423, 1100, 365, 488, 26, 288, 4027, 275, 291, 423, 1100, 2927, 8, 277, 14, 4266, 765, 9, 288, 327, 5289, 3306, 7799, 86, 18, 1, 221, 2779, 1159, 26097, 1, 221, 7799, 86, 19, 965, 2757, 6818, 3967, 288, 327, 31347, 14, 221, 2779, 1159, 900, 370, 4057, 641, 14, 288, 4027, 14, 409, 63, 1419, 8, 5413, 14, 1938, 63, 2826, 63, 21082, 18, 9, 288, 4027, 14, 1180, 63, 6999, 63, 493, 8, 277, 14, 6999, 7733, 9, 288, 4027, 14, 1180, 63, 4239, 498, 63, 493, 8, 277, 14, 4239, 1197, 7733, 9, 288, 291, 423, 1100, 275, 4027, 2378, 347, 636, 16011, 721, 277, 304, 267, 366, 275, 291, 855, 807, 4343, 1574, 342, 267, 2150, 366, 8680, 1100, 418, 267, 372, 366, 2378, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 291, 855, 807, 363, 275, 1174, 2378, 347, 664, 2998, 8, 277, 304, 267, 408, 267, 1432, 376, 7799, 1067, 14, 267, 408, 267, 372, 291, 423, 1100, 421, 199, 533, 6810, 2998, 2927, 26, 272, 408, 33, 1067, 6434, 367, 7799, 13431, 1041, 339, 365, 3041, 275, 413, 339, 327, 7799, 86, 1789, 63, 9977, 6127, 7799, 86, 18, 12, 7799, 86, 19, 12, 436, 12213, 86, 17, 14, 221, 2136, 3507, 7799, 86, 18, 5084, 12, 272, 327, 10617, 14, 272, 1083, 275, 7799, 14, 21082, 1789, 63, 9977, 339, 485, 1100, 2927, 275, 7799, 14, 2998, 339, 347, 664, 2998, 8, 277, 304, 267, 4027, 275, 291, 423, 1100, 2927, 8, 277, 14, 765, 9, 267, 327, 1666, 3721, 315, 3758, 22791, 2998, 2927, 3595, 7799, 86, 18, 14, 267, 4027, 14, 409, 63, 1419, 8, 5413, 14, 1938, 63, 2826, 63, 21082, 18, 9, 267, 372, 4027, 4388, 199, 533, 6810, 8, 8815, 14, 3041, 304, 272, 408, 41, 8140, 376, 7799, 1890, 1041, 339, 9031, 5903, 8, 7436, 14, 1311, 4929, 7836, 12, 673, 627, 59, 73, 367, 284, 315, 6366, 2175, 8 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 4266, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 5413, 7773, 14, 15127, 1611, 22791, 334, 1014, 921, 647, 14837, 14, 7646, 14, 846, 680, 199, 199, 5413, 6947, 4409, 282, 9470, 2927, 880, 2985, 883, 1218, 7799, 18191, 14, 199, 3005, 4390, 1077, 1454, 675, 314, 9470, 2927, 3992, 5370, 446, 367, 7799, 199, 7995, 675, 314, 9655, 14, 2242, 5413, 15, 5859, 5413, 436, 880, 641, 12, 465, 22751, 199, 262, 473, 15860, 5413, 14, 199, 199, 2422, 1654, 1067, 22115, 1077, 8287, 687, 9470, 2927, 12, 436, 1006, 199, 1258, 1067, 22115, 1077, 8287, 687, 6810, 2998, 2927, 14, 2854, 314, 199, 17282, 642, 365, 440, 30163, 12, 1325, 315, 314, 6466, 652, 5594, 506, 14, 199, 199, 14224, 7497, 796, 26, 272, 446, 3715, 859, 880, 9655, 13, 6100, 3992, 787, 315, 282, 7396, 859, 272, 446, 2291, 367, 31620, 13488, 1901, 7799, 272, 446, 1655, 1511, 199, 199, 11903, 8368, 281, 26, 2779, 455, 285, 428, 517, 979, 13, 2437, 4039, 199, 624, 199, 199, 3, 982, 6020, 13538, 6835, 12, 4750, 440, 6665, 376, 14296, 492, 5988, 12, 199, 3, 984, 14, 3112, 459, 12145, 14, 4901, 14, 4266, 418, 911, 506, 3914, 370, 282, 25172, 199, 3, 10038, 859, 909, 14, 221, 961, 365, 336, 564, 79, 12, 1325, 781, 911, 5452, 30268, 199, 3, 402, 652, 370, 2780, 3775, 503, 440, 7799, 365, 2808, 14, 199, 3, 1666, 314, 1284, 402, 642, 859, 367, 314, 1163, 12995, 402, 642, 8744, 14, 199, 199, 3, 710, 3211, 284, 328, 676, 370, 492, 642, 859, 365, 12850, 26, 199, 199, 3, 862, 26, 199, 3, 259, 687, 7390, 14, 4901, 492, 6149, 199, 3, 871, 3545, 26, 199, 3, 259, 327, 10986, 314, 1642, 900, 314, 12693, 11275, 370, 492, 652, 199, 3, 259, 6149, 275, 488, 199, 3, 340, 6149, 436, 440, 6149, 14, 4946, 26, 199, 3, 259, 327, 10986, 3499, 436, 2945, 5431, 199, 3, 259, 6149, 275, 488, 199, 199, 4946, 275, 756, 199, 199, 3, 6187, 8925, 199, 504, 14296, 492, 7799, 199, 504, 20110, 14, 3266, 492, 9031, 12, 9031, 5903, 12, 6366, 2175, 199, 199, 3, 17078, 8925, 199, 504, 7390, 14, 4901, 492, 14719, 12, 8386, 12, 1300, 12, 2287, 421, 199, 533, 9470, 2927, 26, 272, 408, 33, 6434, 367, 7799, 1067, 2251, 12, 367, 1654, 7799, 6947, 1041, 339, 365, 3041, 275, 378, 339, 347, 664, 2998, 8, 277, 304, 267, 408, 1767, 282, 7799, 14, 2998, 909, 14, 4278, 315, 9180, 1041, 267, 746, 4279, 421, 199, 533, 3758, 22791, 2998, 2927, 8, 2998, 2927, 304, 272, 408, 272, 491, 91, 2698, 22791, 2998, 2927, 93, 365, 282, 6434, 367, 1654, 13, 2441, 7799, 1067, 272, 2251, 14, 221, 5723, 2251, 5627, 9842, 2633, 4048, 370, 7799, 272, 4926, 609, 4364, 436, 314, 13372, 1950, 14, 339, 768, 7725, 485, 1100, 2927, 26, 437, 4550, 1314, 911, 506, 1202, 370, 1218, 892, 267, 1067, 2251, 14, 221, 961, 365, 13609, 491, 91, 5413, 14, 2998, 5565, 272, 408, 272, 485, 1100, 275, 488, 339, 347, 636, 826, 721, 277, 12, 30471, 7733, 12, 5897, 7733, 12, 326, 6149, 765, 29, 5413, 14, 21082, 1789, 63, 9977, 12, 485, 1100, 2927, 29, 5413, 14, 2998, 304, 267, 408, 267, 768, 635, 30471, 7733, 26, 2812, 402, 282, 570, 3035, 282, 5726, 790, 267, 768, 635, 5897, 7733, 26, 2812, 402, 282, 570, 3035, 282, 5897, 267, 768, 635, 6149, 765, 26, 710, 7799, 1083, 370, 675, 267, 408, 267, 291, 14, 4239, 1197, 7733, 275, 30471, 7733, 267, 291, 14, 6999, 7733, 275, 5897, 7733, 267, 291, 14, 4266, 765, 275, 6149, 765, 267, 291, 423, 1100, 2927, 275, 485, 1100, 2927, 398, 327, 2790, 282, 1067, 909, 2451, 3063, 14, 221, 961, 365, 370, 3542, 6411, 402, 267, 327, 314, 1627, 2633, 880, 626, 2552, 787, 10501, 14119, 7830, 267, 327, 2419, 2945, 14, 267, 291, 14, 1637, 2998, 342, 2378, 347, 2581, 2998, 8, 277, 304, 267, 340, 291, 423, 1100, 365, 488, 26, 288, 4027, 275, 291, 423, 1100, 2927, 8, 277, 14, 4266, 765, 9, 288, 327, 5289, 3306, 7799, 86, 18, 1, 221, 2779, 1159, 26097, 1, 221, 7799, 86, 19, 965, 2757, 6818, 3967, 288, 327, 31347, 14, 221, 2779, 1159, 900, 370, 4057, 641, 14, 288, 4027, 14, 409, 63, 1419, 8, 5413, 14, 1938, 63, 2826, 63, 21082, 18, 9, 288, 4027, 14, 1180, 63, 6999, 63, 493, 8, 277, 14, 6999, 7733, 9, 288, 4027, 14, 1180, 63, 4239, 498, 63, 493, 8, 277, 14, 4239, 1197, 7733, 9, 288, 291, 423, 1100, 275, 4027, 2378, 347, 636, 16011, 721, 277, 304, 267, 366, 275, 291, 855, 807, 4343, 1574, 342, 267, 2150, 366, 8680, 1100, 418, 267, 372, 366, 2378, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 291, 855, 807, 363, 275, 1174, 2378, 347, 664, 2998, 8, 277, 304, 267, 408, 267, 1432, 376, 7799, 1067, 14, 267, 408, 267, 372, 291, 423, 1100, 421, 199, 533, 6810, 2998, 2927, 26, 272, 408, 33, 1067, 6434, 367, 7799, 13431, 1041, 339, 365, 3041, 275, 413, 339, 327, 7799, 86, 1789, 63, 9977, 6127, 7799, 86, 18, 12, 7799, 86, 19, 12, 436, 12213, 86, 17, 14, 221, 2136, 3507, 7799, 86, 18, 5084, 12, 272, 327, 10617, 14, 272, 1083, 275, 7799, 14, 21082, 1789, 63, 9977, 339, 485, 1100, 2927, 275, 7799, 14, 2998, 339, 347, 664, 2998, 8, 277, 304, 267, 4027, 275, 291, 423, 1100, 2927, 8, 277, 14, 765, 9, 267, 327, 1666, 3721, 315, 3758, 22791, 2998, 2927, 3595, 7799, 86, 18, 14, 267, 4027, 14, 409, 63, 1419, 8, 5413, 14, 1938, 63, 2826, 63, 21082, 18, 9, 267, 372, 4027, 4388, 199, 533, 6810, 8, 8815, 14, 3041, 304, 272, 408, 41, 8140, 376, 7799, 1890, 1041, 339, 9031, 5903, 8, 7436, 14, 1311, 4929, 7836, 12, 673, 627, 59, 73, 367, 284, 315, 6366, 2175, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
aaltinisik/OCBAltinkaya
openerp/cli/deploy.py
369
3947
#!/usr/bin/env python # -*- coding: utf-8 -*- import argparse import os import requests import sys import tempfile import zipfile from . import Command class Deploy(Command): """Deploy a module on an Odoo instance""" def __init__(self): super(Deploy, self).__init__() self.session = requests.session() def deploy_module(self, module_path, url, login, password, db='', force=False): url = url.rstrip('/') self.authenticate(url, login, password, db) module_file = self.zip_module(module_path) try: return self.upload_module(url, module_file, force=force) finally: os.remove(module_file) def upload_module(self, server, module_file, force=False): print("Uploading module file...") url = server + '/base_import_module/upload' files = dict(mod_file=open(module_file, 'rb')) force = '1' if force else '' res = self.session.post(url, files=files, data=dict(force=force)) if res.status_code != 200: raise Exception("Could not authenticate on server '%s'" % server) return res.text def authenticate(self, server, login, password, db=''): print("Authenticating on server '%s' ..." % server) # Fixate session with a given db if any self.session.get(server + '/web/login', params=dict(db=db)) args = dict(login=login, password=password, db=db) res = self.session.post(server + '/base_import_module/login', args) if res.status_code == 404: raise Exception("The server '%s' does not have the 'base_import_module' installed." % server) elif res.status_code != 200: raise Exception(res.text) def zip_module(self, path): path = os.path.abspath(path) if not os.path.isdir(path): raise Exception("Could not find module directory '%s'" % path) container, module_name = os.path.split(path) temp = tempfile.mktemp(suffix='.zip') try: print("Zipping module directory...") with zipfile.ZipFile(temp, 'w') as zfile: for root, dirs, files in os.walk(path): for file in files: file_path = os.path.join(root, file) zfile.write(file_path, file_path.split(container).pop()) return temp except Exception: os.remove(temp) raise def run(self, cmdargs): parser = argparse.ArgumentParser( prog="%s deploy" % sys.argv[0].split(os.path.sep)[-1], description=self.__doc__ ) parser.add_argument('path', help="Path of the module to deploy") parser.add_argument('url', nargs='?', help='Url of the server (default=http://localhost:8069)', default="http://localhost:8069") parser.add_argument('--db', dest='db', help='Database to use if server does not use db-filter.') parser.add_argument('--login', dest='login', default="admin", help='Login (default=admin)') parser.add_argument('--password', dest='password', default="admin", help='Password (default=admin)') parser.add_argument('--verify-ssl', action='store_true', help='Verify SSL certificate') parser.add_argument('--force', action='store_true', help='Force init even if module is already installed. (will update `noupdate="1"` records)') if not cmdargs: sys.exit(parser.print_help()) args = parser.parse_args(args=cmdargs) if not args.verify_ssl: self.session.verify = False try: if not args.url.startswith(('http://', 'https://')): args.url = 'https://%s' % args.url result = self.deploy_module(args.path, args.url, args.login, args.password, args.db, force=args.force) print(result) except Exception, e: sys.exit("ERROR: %s" % e)
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 7534, 199, 646, 747, 199, 646, 4145, 199, 646, 984, 199, 646, 5549, 199, 646, 10392, 199, 199, 504, 1275, 492, 5817, 199, 199, 533, 21588, 3374, 8, 3110, 304, 272, 408, 27597, 282, 859, 641, 376, 28935, 1256, 624, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 27597, 12, 291, 2843, 826, 4533, 267, 291, 14, 1730, 275, 4145, 14, 1730, 342, 339, 347, 12287, 63, 578, 8, 277, 12, 859, 63, 515, 12, 1166, 12, 4676, 12, 2505, 12, 1592, 4581, 3542, 29, 797, 304, 267, 1166, 275, 1166, 14, 6735, 7825, 267, 291, 14, 13975, 8, 633, 12, 4676, 12, 2505, 12, 1592, 9, 267, 859, 63, 493, 275, 291, 14, 3065, 63, 578, 8, 578, 63, 515, 9, 267, 862, 26, 288, 372, 291, 14, 5064, 63, 578, 8, 633, 12, 859, 63, 493, 12, 3542, 29, 3990, 9, 267, 3753, 26, 288, 747, 14, 2168, 8, 578, 63, 493, 9, 339, 347, 5802, 63, 578, 8, 277, 12, 1654, 12, 859, 63, 493, 12, 3542, 29, 797, 304, 267, 870, 480, 1721, 8786, 859, 570, 12594, 267, 1166, 275, 1654, 435, 1994, 1095, 63, 646, 63, 578, 15, 5064, 7, 267, 1584, 275, 1211, 8, 1494, 63, 493, 29, 1490, 8, 578, 63, 493, 12, 283, 4848, 1333, 267, 3542, 275, 283, 17, 7, 340, 3542, 587, 2125, 267, 522, 275, 291, 14, 1730, 14, 1932, 8, 633, 12, 1584, 29, 1725, 12, 666, 29, 807, 8, 3990, 29, 3990, 430, 267, 340, 522, 14, 1205, 63, 600, 1137, 1926, 26, 288, 746, 2186, 480, 6531, 440, 12895, 641, 1654, 1543, 83, 4065, 450, 1654, 9, 267, 372, 522, 14, 505, 339, 347, 12895, 8, 277, 12, 1654, 12, 4676, 12, 2505, 12, 1592, 9280, 267, 870, 480, 2817, 2815, 1958, 641, 1654, 1543, 83, 7, 21742, 450, 1654, 9, 398, 327, 14811, 323, 2351, 543, 282, 1627, 1592, 340, 1263, 267, 291, 14, 1730, 14, 362, 8, 1000, 435, 1994, 2520, 15, 2886, 297, 1862, 29, 807, 8, 697, 29, 697, 430, 398, 1249, 275, 1211, 8, 2886, 29, 2886, 12, 2505, 29, 2060, 12, 1592, 29, 697, 9, 267, 522, 275, 291, 14, 1730, 14, 1932, 8, 1000, 435, 1994, 1095, 63, 646, 63, 578, 15, 2886, 297, 1249, 9, 267, 340, 522, 14, 1205, 63, 600, 508, 7901, 26, 288, 746, 2186, 480, 1918, 1654, 1543, 83, 7, 1630, 440, 1172, 314, 283, 1095, 63, 646, 63, 578, 7, 4903, 2122, 450, 1654, 9, 267, 916, 522, 14, 1205, 63, 600, 1137, 1926, 26, 288, 746, 2186, 8, 470, 14, 505, 9, 339, 347, 3482, 63, 578, 8, 277, 12, 931, 304, 267, 931, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 267, 340, 440, 747, 14, 515, 14, 6027, 8, 515, 304, 288, 746, 2186, 480, 6531, 440, 2342, 859, 2082, 1543, 83, 4065, 450, 931, 9, 267, 3970, 12, 859, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 515, 9, 267, 2388, 275, 5549, 14, 22136, 8, 4511, 15637, 3065, 358, 267, 862, 26, 288, 870, 480, 8674, 4073, 859, 2082, 12594, 288, 543, 10392, 14, 15016, 8, 808, 12, 283, 87, 358, 465, 1315, 493, 26, 355, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 515, 304, 490, 367, 570, 315, 1584, 26, 717, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 570, 9, 717, 1315, 493, 14, 952, 8, 493, 63, 515, 12, 570, 63, 515, 14, 1294, 8, 3600, 680, 1935, 1012, 355, 372, 2388, 267, 871, 2186, 26, 288, 747, 14, 2168, 8, 808, 9, 288, 746, 339, 347, 1255, 8, 277, 12, 2088, 589, 304, 267, 1798, 275, 7534, 14, 10730, 8, 288, 13205, 5961, 83, 12287, 2, 450, 984, 14, 3020, 59, 16, 1055, 1294, 8, 736, 14, 515, 14, 4127, 15786, 17, 467, 288, 1369, 29, 277, 855, 1301, 363, 267, 776, 267, 1798, 14, 525, 63, 2094, 360, 515, 297, 1720, 628, 2042, 402, 314, 859, 370, 12287, 531, 267, 1798, 14, 525, 63, 2094, 360, 633, 297, 9237, 31468, 1720, 534, 6417, 402, 314, 1654, 334, 885, 29, 1014, 921, 5967, 26, 1257, 1876, 3196, 849, 628, 1014, 921, 5967, 26, 1257, 1876, 531, 267, 1798, 14, 525, 63, 2094, 4517, 697, 297, 2053, 534, 697, 297, 1720, 534, 7243, 370, 675, 340, 1654, 1630, 440, 675, 1592, 13, 1541, 2659, 267, 1798, 14, 525, 63, 2094, 4517, 2886, 297, 2053, 534, 2886, 297, 849, 628, 2113, 401, 1720, 534, 8880, 334, 885, 29, 2113, 5942, 267, 1798, 14, 525, 63, 2094, 4517, 2060, 297, 2053, 534, 2060, 297, 849, 628, 2113, 401, 1720, 534, 6139, 334, 885, 29, 2113, 5942, 267, 1798, 14, 525, 63, 2094, 4517, 4712, 13, 4266, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 7496, 7799, 5897, 358, 267, 1798, 14, 525, 63, 2094, 4517, 3990, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 13606, 4205, 2755, 340, 859, 365, 2575, 4903, 14, 334, 14117, 1678, 658, 889, 873, 628, 17, 2, 64, 5767, 5942, 267, 340, 440, 2088, 589, 26, 288, 984, 14, 2224, 8, 2087, 14, 1361, 63, 3437, 1012, 398, 1249, 275, 1798, 14, 1122, 63, 589, 8, 589, 29, 1760, 589, 9, 398, 340, 440, 1249, 14, 4712, 63, 4266, 26, 288, 291, 14, 1730, 14, 4712, 275, 756, 398, 862, 26, 288, 340, 440, 1249, 14, 633, 14, 2460, 4725, 1014, 921, 297, 283, 2859, 921, 8109, 355, 1249, 14, 633, 275, 283, 2859, 13827, 83, 7, 450, 1249, 14, 633, 288, 754, 275, 291, 14, 11060, 63, 578, 8, 589, 14, 515, 12, 1249, 14, 633, 12, 1249, 14, 2886, 12, 1249, 14, 2060, 12, 1249, 14, 697, 12, 3542, 29, 589, 14, 3990, 9, 288, 870, 8, 1099, 9, 267, 871, 2186, 12, 325, 26, 288, 984, 14, 2224, 480, 3170, 26, 450, 83, 2, 450, 325, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 7534, 199, 646, 747, 199, 646, 4145, 199, 646, 984, 199, 646, 5549, 199, 646, 10392, 199, 199, 504, 1275, 492, 5817, 199, 199, 533, 21588, 3374, 8, 3110, 304, 272, 408, 27597, 282, 859, 641, 376, 28935, 1256, 624, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 27597, 12, 291, 2843, 826, 4533, 267, 291, 14, 1730, 275, 4145, 14, 1730, 342, 339, 347, 12287, 63, 578, 8, 277, 12, 859, 63, 515, 12, 1166, 12, 4676, 12, 2505, 12, 1592, 4581, 3542, 29, 797, 304, 267, 1166, 275, 1166, 14, 6735, 7825, 267, 291, 14, 13975, 8, 633, 12, 4676, 12, 2505, 12, 1592, 9, 267, 859, 63, 493, 275, 291, 14, 3065, 63, 578, 8, 578, 63, 515, 9, 267, 862, 26, 288, 372, 291, 14, 5064, 63, 578, 8, 633, 12, 859, 63, 493, 12, 3542, 29, 3990, 9, 267, 3753, 26, 288, 747, 14, 2168, 8, 578, 63, 493, 9, 339, 347, 5802, 63, 578, 8, 277, 12, 1654, 12, 859, 63, 493, 12, 3542, 29, 797, 304, 267, 870, 480, 1721, 8786, 859, 570, 12594, 267, 1166, 275, 1654, 435, 1994, 1095, 63, 646, 63, 578, 15, 5064, 7, 267, 1584, 275, 1211, 8, 1494, 63, 493, 29, 1490, 8, 578, 63, 493, 12, 283, 4848, 1333, 267, 3542, 275, 283, 17, 7, 340, 3542, 587, 2125, 267, 522, 275, 291, 14, 1730, 14, 1932, 8, 633, 12, 1584, 29, 1725, 12, 666, 29, 807, 8, 3990, 29, 3990, 430, 267, 340, 522, 14, 1205, 63, 600, 1137, 1926, 26, 288, 746, 2186, 480, 6531, 440, 12895, 641, 1654, 1543, 83, 4065, 450, 1654, 9, 267, 372, 522, 14, 505, 339, 347, 12895, 8, 277, 12, 1654, 12, 4676, 12, 2505, 12, 1592, 9280, 267, 870, 480, 2817, 2815, 1958, 641, 1654, 1543, 83, 7, 21742, 450, 1654, 9, 398, 327, 14811, 323, 2351, 543, 282, 1627, 1592, 340, 1263, 267, 291, 14, 1730, 14, 362, 8, 1000, 435, 1994, 2520, 15, 2886, 297, 1862, 29, 807, 8, 697, 29, 697, 430, 398, 1249, 275, 1211, 8, 2886, 29, 2886, 12, 2505, 29, 2060, 12, 1592, 29, 697, 9, 267, 522, 275, 291, 14, 1730, 14, 1932, 8, 1000, 435, 1994, 1095, 63, 646, 63, 578, 15, 2886, 297, 1249, 9, 267, 340, 522, 14, 1205, 63, 600, 508, 7901, 26, 288, 746, 2186, 480, 1918, 1654, 1543, 83, 7, 1630, 440, 1172, 314, 283, 1095, 63, 646, 63, 578, 7, 4903, 2122, 450, 1654, 9, 267, 916, 522, 14, 1205, 63, 600, 1137, 1926, 26, 288, 746, 2186, 8, 470, 14, 505, 9, 339, 347, 3482, 63, 578, 8, 277, 12, 931, 304, 267, 931, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 267, 340, 440, 747, 14, 515, 14, 6027, 8, 515, 304, 288, 746, 2186, 480, 6531, 440, 2342, 859, 2082, 1543, 83, 4065, 450, 931, 9, 267, 3970, 12, 859, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 515, 9, 267, 2388, 275, 5549, 14, 22136, 8, 4511, 15637, 3065, 358, 267, 862, 26, 288, 870, 480, 8674, 4073, 859, 2082, 12594, 288, 543, 10392, 14, 15016, 8, 808, 12, 283, 87, 358, 465, 1315, 493, 26, 355, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 515, 304, 490, 367, 570, 315, 1584, 26, 717, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 570, 9, 717, 1315, 493, 14, 952, 8, 493, 63, 515, 12, 570, 63, 515, 14, 1294, 8, 3600, 680, 1935, 1012, 355, 372, 2388, 267, 871, 2186, 26, 288, 747, 14, 2168, 8, 808, 9, 288, 746, 339, 347, 1255, 8, 277, 12, 2088, 589, 304, 267, 1798, 275, 7534, 14, 10730, 8, 288, 13205, 5961, 83, 12287, 2, 450, 984, 14, 3020, 59, 16, 1055, 1294, 8, 736, 14, 515, 14, 4127, 15786, 17, 467, 288, 1369, 29, 277, 855, 1301, 363, 267, 776, 267, 1798, 14, 525, 63, 2094, 360, 515, 297, 1720, 628, 2042, 402, 314, 859, 370, 12287, 531, 267, 1798, 14, 525, 63, 2094, 360, 633, 297, 9237, 31468, 1720, 534, 6417, 402, 314, 1654, 334, 885, 29, 1014, 921, 5967, 26, 1257, 1876, 3196, 849, 628, 1014, 921, 5967, 26, 1257, 1876, 531, 267, 1798, 14, 525, 63, 2094, 4517, 697, 297, 2053, 534, 697, 297, 1720, 534, 7243, 370, 675, 340, 1654, 1630, 440, 675, 1592, 13, 1541, 2659, 267, 1798, 14, 525, 63, 2094, 4517, 2886, 297, 2053, 534, 2886, 297, 849, 628, 2113, 401, 1720, 534, 8880, 334, 885, 29, 2113, 5942, 267, 1798, 14, 525, 63, 2094, 4517, 2060, 297, 2053, 534, 2060, 297, 849, 628, 2113, 401, 1720, 534, 6139, 334, 885, 29, 2113, 5942, 267, 1798, 14, 525, 63, 2094, 4517, 4712, 13, 4266, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 7496, 7799, 5897, 358, 267, 1798, 14, 525, 63, 2094, 4517, 3990, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 13606, 4205, 2755, 340, 859, 365, 2575, 4903, 14, 334, 14117, 1678, 658, 889, 873, 628, 17, 2, 64, 5767, 5942, 267, 340, 440, 2088, 589, 26, 288, 984, 14, 2224, 8, 2087, 14, 1361, 63, 3437, 1012, 398, 1249, 275, 1798, 14, 1122, 63, 589, 8, 589, 29, 1760, 589, 9, 398, 340, 440, 1249, 14, 4712, 63, 4266, 26, 288, 291, 14, 1730, 14, 4712, 275, 756, 398, 862, 26, 288, 340, 440, 1249, 14, 633, 14, 2460, 4725, 1014, 921, 297, 283, 2859, 921, 8109, 355, 1249, 14, 633, 275, 283, 2859, 13827, 83, 7, 450, 1249, 14, 633, 288, 754, 275, 291, 14, 11060, 63, 578, 8, 589, 14, 515, 12, 1249, 14, 633, 12, 1249, 14, 2886, 12, 1249, 14, 2060, 12, 1249, 14, 697, 12, 3542, 29, 589, 14, 3990, 9, 288, 870, 8, 1099, 9, 267, 871, 2186, 12, 325, 26, 288, 984, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Bismarrck/tensorflow
tensorflow/python/data/experimental/kernel_tests/serialization/sample_from_datasets_serialization_test.py
21
1758
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for the SampleFromDatasets serialization.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.data.experimental.kernel_tests.serialization import dataset_serialization_test_base from tensorflow.python.data.experimental.ops import interleave_ops from tensorflow.python.data.ops import dataset_ops from tensorflow.python.platform import test class SampleFromDatasetsSerializationTest( dataset_serialization_test_base.DatasetSerializationTestBase): def _build_dataset(self, probs, num_samples): dataset = interleave_ops.sample_from_datasets( [ dataset_ops.Dataset.from_tensors(i).repeat(None) for i in range(len(probs)) ], probs, seed=1813) return dataset.take(num_samples) def testSerializationCore(self): self.run_core_tests( lambda: self._build_dataset([0.5, 0.5], 100), lambda: self._build_dataset([0.25, 0.25, 0.25, 0.25], 1000), 100) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 15227, 2532, 1451, 2193, 16953, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 576, 14, 18924, 14, 4989, 63, 2219, 14, 12161, 492, 4789, 63, 12161, 63, 396, 63, 1095, 199, 504, 3228, 14, 1548, 14, 576, 14, 18924, 14, 1483, 492, 1640, 12422, 63, 1483, 199, 504, 3228, 14, 1548, 14, 576, 14, 1483, 492, 4789, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 15227, 2532, 1451, 2193, 3571, 2072, 774, 8, 272, 4789, 63, 12161, 63, 396, 63, 1095, 14, 9271, 3571, 2072, 14440, 304, 819, 347, 485, 1506, 63, 5214, 8, 277, 12, 24329, 12, 1967, 63, 3356, 304, 272, 4789, 275, 1640, 12422, 63, 1483, 14, 3271, 63, 504, 63, 12281, 8, 267, 359, 288, 4789, 63, 1483, 14, 9271, 14, 504, 63, 10206, 8, 73, 680, 8755, 8, 403, 9, 288, 367, 284, 315, 1425, 8, 552, 8, 15349, 430, 267, 2156, 267, 24329, 12, 267, 6347, 29, 1085, 969, 9, 272, 372, 4789, 14, 11066, 8, 1507, 63, 3356, 9, 819, 347, 511, 3571, 2072, 5402, 8, 277, 304, 272, 291, 14, 1065, 63, 1018, 63, 2219, 8, 267, 2400, 26, 291, 423, 1506, 63, 5214, 779, 16, 14, 21, 12, 378, 14, 21, 467, 2948, 395, 267, 2400, 26, 291, 423, 1506, 63, 5214, 779, 16, 14, 821, 12, 378, 14, 821, 12, 378, 14, 821, 12, 378, 14, 821, 467, 5198, 395, 2948, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 15227, 2532, 1451, 2193, 16953, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 576, 14, 18924, 14, 4989, 63, 2219, 14, 12161, 492, 4789, 63, 12161, 63, 396, 63, 1095, 199, 504, 3228, 14, 1548, 14, 576, 14, 18924, 14, 1483, 492, 1640, 12422, 63, 1483, 199, 504, 3228, 14, 1548, 14, 576, 14, 1483, 492, 4789, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 15227, 2532, 1451, 2193, 3571, 2072, 774, 8, 272, 4789, 63, 12161, 63, 396, 63, 1095, 14, 9271, 3571, 2072, 14440, 304, 819, 347, 485, 1506, 63, 5214, 8, 277, 12, 24329, 12, 1967, 63, 3356, 304, 272, 4789, 275, 1640, 12422, 63, 1483, 14, 3271, 63, 504, 63, 12281, 8, 267, 359, 288, 4789, 63, 1483, 14, 9271, 14, 504, 63, 10206, 8, 73, 680, 8755, 8, 403, 9, 288, 367, 284, 315, 1425, 8, 552, 8, 15349, 430, 267, 2156, 267, 24329, 12, 267, 6347, 29, 1085, 969, 9, 272, 372, 4789, 14, 11066, 8, 1507, 63, 3356, 9, 819, 347, 511, 3571, 2072, 5402, 8, 277, 304, 272, 291, 14, 1065, 63, 1018, 63, 2219, 8, 267, 2400, 26, 291, 423, 1506, 63, 5214, 779, 16, 14, 21, 12, 378, 14, 21, 467, 2948, 395, 267, 2400, 26, 291, 423, 1506, 63, 5214, 779, 16, 14, 821, 12, 378, 14, 821, 12, 378, 14, 821, 12, 378, 14, 821, 467, 5198, 395, 2948, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jtorrents/networkx
networkx/generators/degree_seq.py
11
21837
# -*- coding: utf-8 -*- """Generate graphs with a given degree sequence or expected degree sequence. """ # Copyright (C) 2004-2011 by # Aric Hagberg <hagberg@lanl.gov> # Dan Schult <dschult@colgate.edu> # Pieter Swart <swart@lanl.gov> # All rights reserved. # BSD license. import heapq from itertools import combinations, permutations import math from operator import itemgetter import random import networkx as nx from networkx.utils import random_weighted_sample __author__ = "\n".join(['Aric Hagberg <aric.hagberg@gmail.com>', 'Pieter Swart <swart@lanl.gov>', 'Dan Schult <dschult@colgate.edu>' 'Joel Miller <joel.c.miller.research@gmail.com>', 'Nathan Lemons <nlemons@gmail.com>']) __all__ = ['configuration_model', 'directed_configuration_model', 'expected_degree_graph', 'havel_hakimi_graph', 'degree_sequence_tree', 'random_degree_sequence_graph'] def configuration_model(deg_sequence,create_using=None,seed=None): """Return a random graph with the given degree sequence. The configuration model generates a random pseudograph (graph with parallel edges and self loops) by randomly assigning edges to match the given degree sequence. Parameters ---------- deg_sequence : list of integers Each list entry corresponds to the degree of a node. create_using : graph, optional (default MultiGraph) Return graph of this type. The instance will be cleared. seed : hashable object, optional Seed for random number generator. Returns ------- G : MultiGraph A graph with the specified degree sequence. Nodes are labeled starting at 0 with an index corresponding to the position in deg_sequence. Raises ------ NetworkXError If the degree sequence does not have an even sum. See Also -------- is_valid_degree_sequence Notes ----- As described by Newman [1]_. A non-graphical degree sequence (not realizable by some simple graph) is allowed since this function returns graphs with self loops and parallel edges. An exception is raised if the degree sequence does not have an even sum. This configuration model construction process can lead to duplicate edges and loops. You can remove the self-loops and parallel edges (see below) which will likely result in a graph that doesn't have the exact degree sequence specified. This "finite-size effect" decreases as the size of the graph increases. References ---------- .. [1] M.E.J. Newman, "The structure and function of complex networks", SIAM REVIEW 45-2, pp 167-256, 2003. Examples -------- >>> from networkx.utils import powerlaw_sequence >>> z=nx.utils.create_degree_sequence(100,powerlaw_sequence) >>> G=nx.configuration_model(z) To remove parallel edges: >>> G=nx.Graph(G) To remove self loops: >>> G.remove_edges_from(G.selfloop_edges()) """ if not sum(deg_sequence)%2 ==0: raise nx.NetworkXError('Invalid degree sequence') if create_using is None: create_using = nx.MultiGraph() elif create_using.is_directed(): raise nx.NetworkXError("Directed Graph not supported") if not seed is None: random.seed(seed) # start with empty N-node graph N=len(deg_sequence) # allow multiedges and selfloops G=nx.empty_graph(N,create_using) if N==0 or max(deg_sequence)==0: # done if no edges return G # build stublist, a list of available degree-repeated stubs # e.g. for deg_sequence=[3,2,1,1,1] # initially, stublist=[1,1,1,2,2,3,4,5] # i.e., node 1 has degree=3 and is repeated 3 times, etc. stublist=[] for n in G: for i in range(deg_sequence[n]): stublist.append(n) # shuffle stublist and assign pairs by removing 2 elements at a time random.shuffle(stublist) while stublist: n1 = stublist.pop() n2 = stublist.pop() G.add_edge(n1,n2) G.name="configuration_model %d nodes %d edges"%(G.order(),G.size()) return G def directed_configuration_model(in_degree_sequence, out_degree_sequence, create_using=None,seed=None): """Return a directed_random graph with the given degree sequences. The configuration model generates a random directed pseudograph (graph with parallel edges and self loops) by randomly assigning edges to match the given degree sequences. Parameters ---------- in_degree_sequence : list of integers Each list entry corresponds to the in-degree of a node. out_degree_sequence : list of integers Each list entry corresponds to the out-degree of a node. create_using : graph, optional (default MultiDiGraph) Return graph of this type. The instance will be cleared. seed : hashable object, optional Seed for random number generator. Returns ------- G : MultiDiGraph A graph with the specified degree sequences. Nodes are labeled starting at 0 with an index corresponding to the position in deg_sequence. Raises ------ NetworkXError If the degree sequences do not have the same sum. See Also -------- configuration_model Notes ----- Algorithm as described by Newman [1]_. A non-graphical degree sequence (not realizable by some simple graph) is allowed since this function returns graphs with self loops and parallel edges. An exception is raised if the degree sequences does not have the same sum. This configuration model construction process can lead to duplicate edges and loops. You can remove the self-loops and parallel edges (see below) which will likely result in a graph that doesn't have the exact degree sequence specified. This "finite-size effect" decreases as the size of the graph increases. References ---------- .. [1] Newman, M. E. J. and Strogatz, S. H. and Watts, D. J. Random graphs with arbitrary degree distributions and their applications Phys. Rev. E, 64, 026118 (2001) Examples -------- >>> D=nx.DiGraph([(0,1),(1,2),(2,3)]) # directed path graph >>> din=list(D.in_degree().values()) >>> dout=list(D.out_degree().values()) >>> din.append(1) >>> dout[0]=2 >>> D=nx.directed_configuration_model(din,dout) To remove parallel edges: >>> D=nx.DiGraph(D) To remove self loops: >>> D.remove_edges_from(D.selfloop_edges()) """ if not sum(in_degree_sequence) == sum(out_degree_sequence): raise nx.NetworkXError('Invalid degree sequences. ' 'Sequences must have equal sums.') if create_using is None: create_using = nx.MultiDiGraph() if not seed is None: random.seed(seed) nin=len(in_degree_sequence) nout=len(out_degree_sequence) # pad in- or out-degree sequence with zeros to match lengths if nin>nout: out_degree_sequence.extend((nin-nout)*[0]) else: in_degree_sequence.extend((nout-nin)*[0]) # start with empty N-node graph N=len(in_degree_sequence) # allow multiedges and selfloops G=nx.empty_graph(N,create_using) if N==0 or max(in_degree_sequence)==0: # done if no edges return G # build stublists of available degree-repeated stubs # e.g. for degree_sequence=[3,2,1,1,1] # initially, stublist=[1,1,1,2,2,3,4,5] # i.e., node 1 has degree=3 and is repeated 3 times, etc. in_stublist=[] for n in G: for i in range(in_degree_sequence[n]): in_stublist.append(n) out_stublist=[] for n in G: for i in range(out_degree_sequence[n]): out_stublist.append(n) # shuffle stublists and assign pairs by removing 2 elements at a time random.shuffle(in_stublist) random.shuffle(out_stublist) while in_stublist and out_stublist: source = out_stublist.pop() target = in_stublist.pop() G.add_edge(source,target) G.name="directed configuration_model %d nodes %d edges"%(G.order(),G.size()) return G def expected_degree_graph(w, seed=None, selfloops=True): r"""Return a random graph with given expected degrees. Given a sequence of expected degrees `W=(w_0,w_1,\ldots,w_{n-1}`) of length `n` this algorithm assigns an edge between node `u` and node `v` with probability .. math:: p_{uv} = \frac{w_u w_v}{\sum_k w_k} . Parameters ---------- w : list The list of expected degrees. selfloops: bool (default=True) Set to False to remove the possibility of self-loop edges. seed : hashable object, optional The seed for the random number generator. Returns ------- Graph Examples -------- >>> z=[10 for i in range(100)] >>> G=nx.expected_degree_graph(z) Notes ----- The nodes have integer labels corresponding to index of expected degrees input sequence. The complexity of this algorithm is `\mathcal{O}(n+m)` where `n` is the number of nodes and `m` is the expected number of edges. The model in [1]_ includes the possibility of self-loop edges. Set selfloops=False to produce a graph without self loops. For finite graphs this model doesn't produce exactly the given expected degree sequence. Instead the expected degrees are as follows. For the case without self loops (selfloops=False), .. math:: E[deg(u)] = \sum_{v \ne u} p_{uv} = w_u \left( 1 - \frac{w_u}{\sum_k w_k} \right) . NetworkX uses the standard convention that a self-loop edge counts 2 in the degree of a node, so with self loops (selfloops=True), .. math:: E[deg(u)] = \sum_{v \ne u} p_{uv} + 2 p_{uu} = w_u \left( 1 + \frac{w_u}{\sum_k w_k} \right) . References ---------- .. [1] Fan Chung and L. Lu, Connected components in random graphs with given expected degree sequences, Ann. Combinatorics, 6, pp. 125-145, 2002. .. [2] Joel Miller and Aric Hagberg, Efficient generation of networks with given expected degrees, in Algorithms and Models for the Web-Graph (WAW 2011), Alan Frieze, Paul Horn, and Paweł Prałat (Eds), LNCS 6732, pp. 115-126, 2011. """ n = len(w) G=nx.empty_graph(n) if n==0 or max(w)==0: # done if no edges return G if seed is not None: random.seed(seed) rho = 1/float(sum(w)) # sort weights, largest first # preserve order of weights for integer node label mapping order = sorted(enumerate(w),key=itemgetter(1),reverse=True) mapping = dict((c,uv[0]) for c,uv in enumerate(order)) seq = [v for u,v in order] last=n if not selfloops: last-=1 for u in range(last): v = u if not selfloops: v += 1 factor = seq[u] * rho p = seq[v]*factor if p>1: p = 1 while v<n and p>0: if p != 1: r = random.random() v += int(math.floor(math.log(r)/math.log(1-p))) if v < n: q = seq[v]*factor if q>1: q = 1 if random.random() < q/p: G.add_edge(mapping[u],mapping[v]) v += 1 p = q return G def havel_hakimi_graph(deg_sequence,create_using=None): """Return a simple graph with given degree sequence constructed using the Havel-Hakimi algorithm. Parameters ---------- deg_sequence: list of integers Each integer corresponds to the degree of a node (need not be sorted). create_using : graph, optional (default Graph) Return graph of this type. The instance will be cleared. Multigraphs and directed graphs are not allowed. Raises ------ NetworkXException For a non-graphical degree sequence (i.e. one not realizable by some simple graph). Notes ----- The Havel-Hakimi algorithm constructs a simple graph by successively connecting the node of highest degree to other nodes of highest degree, resorting remaining nodes by degree, and repeating the process. The resulting graph has a high degree-associativity. Nodes are labeled 1,.., len(deg_sequence), corresponding to their position in deg_sequence. See Theorem 1.4 in [1]_. This algorithm is also used in the function is_valid_degree_sequence. References ---------- .. [1] G. Chartrand and L. Lesniak, "Graphs and Digraphs", Chapman and Hall/CRC, 1996. """ if not nx.is_valid_degree_sequence(deg_sequence): raise nx.NetworkXError('Invalid degree sequence') if create_using is not None: if create_using.is_directed(): raise nx.NetworkXError("Directed Graph not supported") if create_using.is_multigraph(): raise nx.NetworkXError("Havel-Hakimi requires simple graph") N=len(deg_sequence) G=nx.empty_graph(N,create_using) if N==0 or max(deg_sequence)==0: # done if no edges return G # form list of [stubs,name] for each node. stublist=[ [deg_sequence[n],n] for n in G] # Now connect the stubs while stublist: stublist.sort() if stublist[0][0]<0: # took too many off some vertex return False # should not happen if deg_seq is valid (freestubs,source) = stublist.pop() # the node with the most stubs if freestubs==0: break # the rest must also be 0 --Done! if freestubs > len(stublist): # Trouble--can't make that many edges return False # should not happen if deg_seq is valid # attach edges to biggest nodes for stubtarget in stublist[-freestubs:]: G.add_edge(source, stubtarget[1]) stubtarget[0] -= 1 # updating stublist on the fly G.name="havel_hakimi_graph %d nodes %d edges"%(G.order(),G.size()) return G def degree_sequence_tree(deg_sequence,create_using=None): """Make a tree for the given degree sequence. A tree has #nodes-#edges=1 so the degree sequence must have len(deg_sequence)-sum(deg_sequence)/2=1 """ if not len(deg_sequence)-sum(deg_sequence)/2.0 == 1.0: raise nx.NetworkXError("Degree sequence invalid") if create_using is not None and create_using.is_directed(): raise nx.NetworkXError("Directed Graph not supported") # single node tree if len(deg_sequence)==1: G=nx.empty_graph(0,create_using) return G # all degrees greater than 1 deg=[s for s in deg_sequence if s>1] deg.sort(reverse=True) # make path graph as backbone n=len(deg)+2 G=nx.path_graph(n,create_using) last=n # add the leaves for source in range(1,n-1): nedges=deg.pop()-2 for target in range(last,last+nedges): G.add_edge(source, target) last+=nedges # in case we added one too many if len(G.degree())>len(deg_sequence): G.remove_node(0) return G def random_degree_sequence_graph(sequence, seed=None, tries=10): r"""Return a simple random graph with the given degree sequence. If the maximum degree `d_m` in the sequence is `O(m^{1/4})` then the algorithm produces almost uniform random graphs in `O(m d_m)` time where `m` is the number of edges. Parameters ---------- sequence : list of integers Sequence of degrees seed : hashable object, optional Seed for random number generator tries : int, optional Maximum number of tries to create a graph Returns ------- G : Graph A graph with the specified degree sequence. Nodes are labeled starting at 0 with an index corresponding to the position in the sequence. Raises ------ NetworkXUnfeasible If the degree sequence is not graphical. NetworkXError If a graph is not produced in specified number of tries See Also -------- is_valid_degree_sequence, configuration_model Notes ----- The generator algorithm [1]_ is not guaranteed to produce a graph. References ---------- .. [1] Moshen Bayati, Jeong Han Kim, and Amin Saberi, A sequential algorithm for generating random graphs. Algorithmica, Volume 58, Number 4, 860-910, DOI: 10.1007/s00453-009-9340-1 Examples -------- >>> sequence = [1, 2, 2, 3] >>> G = nx.random_degree_sequence_graph(sequence) >>> sorted(G.degree().values()) [1, 2, 2, 3] """ DSRG = DegreeSequenceRandomGraph(sequence, seed=seed) for try_n in range(tries): try: return DSRG.generate() except nx.NetworkXUnfeasible: pass raise nx.NetworkXError('failed to generate graph in %d tries'%tries) class DegreeSequenceRandomGraph(object): # class to generate random graphs with a given degree sequence # use random_degree_sequence_graph() def __init__(self, degree, seed=None): if not nx.is_valid_degree_sequence(degree): raise nx.NetworkXUnfeasible('degree sequence is not graphical') if seed is not None: random.seed(seed) self.degree = list(degree) # node labels are integers 0,...,n-1 self.m = sum(self.degree)/2.0 # number of edges try: self.dmax = max(self.degree) # maximum degree except ValueError: self.dmax = 0 def generate(self): # remaining_degree is mapping from int->remaining degree self.remaining_degree = dict(enumerate(self.degree)) # add all nodes to make sure we get isolated nodes self.graph = nx.Graph() self.graph.add_nodes_from(self.remaining_degree) # remove zero degree nodes for n,d in list(self.remaining_degree.items()): if d == 0: del self.remaining_degree[n] if len(self.remaining_degree) > 0: # build graph in three phases according to how many unmatched edges self.phase1() self.phase2() self.phase3() return self.graph def update_remaining(self, u, v, aux_graph=None): # decrement remaining nodes, modify auxilliary graph if in phase3 if aux_graph is not None: # remove edges from auxilliary graph aux_graph.remove_edge(u,v) if self.remaining_degree[u] == 1: del self.remaining_degree[u] if aux_graph is not None: aux_graph.remove_node(u) else: self.remaining_degree[u] -= 1 if self.remaining_degree[v] == 1: del self.remaining_degree[v] if aux_graph is not None: aux_graph.remove_node(v) else: self.remaining_degree[v] -= 1 def p(self,u,v): # degree probability return 1 - self.degree[u]*self.degree[v]/(4.0*self.m) def q(self,u,v): # remaining degree probability norm = float(max(self.remaining_degree.values()))**2 return self.remaining_degree[u]*self.remaining_degree[v]/norm def suitable_edge(self): # Check if there is a suitable edge that is not in the graph # True if an (arbitrary) remaining node has at least one possible # connection to another remaining node nodes = iter(self.remaining_degree) u = next(nodes) # one arbitrary node for v in nodes: # loop over all other remaining nodes if not self.graph.has_edge(u, v): return True return False def phase1(self): # choose node pairs from (degree) weighted distribution while sum(self.remaining_degree.values()) >= 2 * self.dmax**2: u,v = sorted(random_weighted_sample(self.remaining_degree, 2)) if self.graph.has_edge(u,v): continue if random.random() < self.p(u,v): # accept edge self.graph.add_edge(u,v) self.update_remaining(u,v) def phase2(self): # choose remaining nodes uniformly at random and use rejection sampling while len(self.remaining_degree) >= 2 * self.dmax: norm = float(max(self.remaining_degree.values()))**2 while True: u,v = sorted(random.sample(self.remaining_degree.keys(), 2)) if self.graph.has_edge(u,v): continue if random.random() < self.q(u,v): break if random.random() < self.p(u,v): # accept edge self.graph.add_edge(u,v) self.update_remaining(u,v) def phase3(self): # build potential remaining edges and choose with rejection sampling potential_edges = combinations(self.remaining_degree, 2) # build auxilliary graph of potential edges not already in graph H = nx.Graph([(u,v) for (u,v) in potential_edges if not self.graph.has_edge(u,v)]) while self.remaining_degree: if not self.suitable_edge(): raise nx.NetworkXUnfeasible('no suitable edges left') while True: u,v = sorted(random.choice(H.edges())) if random.random() < self.q(u,v): break if random.random() < self.p(u,v): # accept edge self.graph.add_edge(u,v) self.update_remaining(u,v, aux_graph=H)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 6864, 18312, 543, 282, 1627, 13666, 3414, 503, 1420, 13666, 3414, 14, 199, 624, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8128, 701, 221, 199, 3, 259, 437, 1567, 869, 643, 14630, 665, 72, 643, 14630, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 24747, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 30, 199, 3, 259, 510, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 6289, 4190, 14, 199, 646, 13295, 81, 199, 504, 7975, 492, 15821, 12, 26899, 199, 646, 3473, 199, 504, 4182, 492, 1242, 7416, 199, 646, 2196, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 492, 2196, 63, 13522, 63, 3271, 199, 199, 363, 2502, 363, 275, 1867, 78, 1674, 904, 2941, 33, 1567, 869, 643, 14630, 665, 285, 530, 14, 72, 643, 14630, 32, 6799, 14, 957, 4206, 717, 283, 48, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 4206, 717, 283, 29336, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 3524, 717, 283, 5691, 352, 603, 19576, 665, 743, 352, 14, 67, 14, 77, 19576, 14, 31788, 32, 6799, 14, 957, 4206, 717, 283, 46, 1619, 290, 7005, 2106, 83, 665, 78, 274, 2106, 83, 32, 6799, 14, 957, 24782, 199, 199, 363, 452, 363, 275, 788, 4758, 63, 1238, 297, 1779, 283, 12080, 63, 4758, 63, 1238, 297, 1779, 283, 2062, 63, 10956, 63, 2180, 297, 1779, 283, 2411, 1090, 63, 72, 1151, 1017, 73, 63, 2180, 297, 1779, 283, 10956, 63, 4041, 63, 2350, 297, 1779, 283, 2355, 63, 10956, 63, 4041, 63, 2180, 418, 421, 199, 318, 2897, 63, 1238, 8, 6458, 63, 4041, 12, 981, 63, 4941, 29, 403, 12, 5176, 29, 403, 304, 272, 408, 1767, 282, 2196, 3343, 543, 314, 1627, 13666, 3414, 14, 339, 710, 2897, 1402, 12821, 282, 2196, 15984, 2180, 334, 2180, 543, 272, 9861, 8207, 436, 291, 17222, 9, 701, 19311, 26694, 8207, 370, 272, 1336, 314, 1627, 13666, 3414, 14, 339, 3897, 272, 4143, 272, 7926, 63, 4041, 520, 221, 769, 402, 9446, 267, 7048, 769, 2397, 13718, 370, 314, 13666, 402, 282, 1031, 14, 272, 1218, 63, 4941, 520, 3343, 12, 2716, 334, 885, 6879, 4578, 9, 2126, 1432, 3343, 402, 642, 730, 14, 710, 1256, 911, 506, 20518, 14, 272, 6347, 520, 21197, 909, 12, 2716, 267, 3240, 379, 367, 2196, 1329, 4306, 14, 339, 1803, 272, 5514, 272, 598, 520, 6879, 4578, 267, 437, 3343, 543, 314, 2013, 13666, 3414, 14, 267, 23836, 787, 23677, 6617, 737, 378, 543, 376, 1478, 267, 5226, 370, 314, 3421, 315, 7926, 63, 4041, 14, 339, 6218, 272, 21397, 272, 7220, 29356, 267, 982, 314, 13666, 3414, 1630, 440, 1172, 376, 2755, 3089, 14, 339, 1666, 6121, 272, 3001, 272, 365, 63, 1078, 63, 10956, 63, 4041, 339, 8144, 272, 9063, 272, 3709, 11736, 701, 7053, 1237, 359, 17, 61, 3754, 339, 437, 2222, 13, 2180, 2652, 13666, 3414, 334, 1397, 3363, 14065, 701, 2005, 3486, 272, 3343, 9, 365, 4370, 3967, 642, 805, 2529, 18312, 543, 291, 272, 17222, 436, 9861, 8207, 14, 221, 1626, 1919, 365, 4915, 340, 314, 13666, 272, 3414, 1630, 440, 1172, 376, 2755, 3089, 14, 339, 961, 2897, 1402, 14538, 2112, 883, 12690, 370, 272, 9250, 8207, 436, 17222, 14, 221, 2047, 883, 2813, 314, 291, 13, 22412, 436, 272, 9861, 8207, 334, 3239, 5084, 9, 1314, 911, 12060, 754, 315, 282, 3343, 272, 626, 3181, 1133, 1172, 314, 5835, 13666, 3414, 2013, 14, 221, 961, 272, 298, 8005, 13, 890, 7763, 2, 477, 1353, 3274, 465, 314, 1568, 402, 314, 3343, 10035, 3274, 14, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 603, 14, 37, 14, 42, 14, 7053, 1237, 12, 298, 1918, 5523, 436, 805, 402, 6114, 11759, 401, 2126, 428, 41, 1156, 5363, 12058, 10416, 13, 18, 12, 11618, 31650, 13, 3912, 12, 13004, 14, 339, 6058, 272, 3001, 272, 1306, 687, 24313, 14, 1208, 492, 7074, 22277, 63, 4041, 272, 1306, 1315, 29, 7343, 14, 1208, 14, 981, 63, 10956, 63, 4041, 8, 1960, 12, 5652, 22277, 63, 4041, 9, 272, 1306, 598, 29, 7343, 14, 4758, 63, 1238, 8, 90, 9, 339, 4005, 2813, 9861, 8207, 26, 339, 1306, 598, 29, 7343, 14, 4578, 8, 39, 9, 339, 4005, 2813, 291, 17222, 26, 339, 1306, 598, 14, 2168, 63, 6929, 63, 504, 8, 39, 14, 277, 3813, 63, 6929, 1012, 272, 408, 272, 340, 440, 3089, 8, 6458, 63, 4041, 19656, 18, 508, 16, 26, 267, 746, 8484, 14, 4491, 29356, 360, 3364, 13666, 3414, 358, 339, 340, 1218, 63, 4941, 365, 488, 26, 267, 1218, 63, 4941, 275, 8484, 14, 3947, 4578, 342, 272, 916, 1218, 63, 4941, 14, 374, 63, 12080, 837, 267, 746, 8484, 14, 4491, 29356, 480, 1341, 7983, 11513, 440, 3748, 531, 339, 340, 440, 6347, 365, 488, 26, 267, 2196, 14, 5176, 8, 5176, 9, 339, 327, 1343, 543, 2701, 653, 13, 932, 3343, 272, 653, 29, 552, 8, 6458, 63, 4041, 9, 339, 327, 2040, 3510, 6929, 436, 291, 22412, 272, 598, 29, 7343, 14, 1667, 63, 2180, 8, 46, 12, 981, 63, 4941, 9, 339, 340, 653, 389, 16, 503, 1390, 8, 6458, 63, 4041, 12694, 16, 26, 327, 4224, 340, 949, 8207, 267, 372, 598, 18407, 327, 1900, 10098, 513, 12, 282, 769, 402, 2808, 13666, 13, 7593, 22312, 272, 327, 325, 14, 71, 14, 367, 7926, 63, 4041, 1524, 19, 12, 18, 12, 17, 12, 17, 12, 17, 61, 272, 327, 22801, 12, 10098, 513, 1524, 17, 12, 17, 12, 17, 12, 18, 12, 18, 12, 19, 12, 20, 12, 21, 61, 272, 327, 284, 14, 69, 2020, 1031, 413, 965, 13666, 29, 19, 436, 365, 10877, 650, 5431, 12, 5423, 14, 272, 10098, 513, 9811, 272, 367, 302, 315, 598, 26, 267, 367, 284, 315, 1425, 8, 6458, 63, 4041, 59, 78, 4682, 288, 10098, 513, 14, 740, 8, 78, 9, 339, 327, 13031, 10098, 513, 436, 5090, 6342, 701, 12881, 499, 4008, 737 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 6864, 18312, 543, 282, 1627, 13666, 3414, 503, 1420, 13666, 3414, 14, 199, 624, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8128, 701, 221, 199, 3, 259, 437, 1567, 869, 643, 14630, 665, 72, 643, 14630, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 24747, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 30, 199, 3, 259, 510, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 6289, 4190, 14, 199, 646, 13295, 81, 199, 504, 7975, 492, 15821, 12, 26899, 199, 646, 3473, 199, 504, 4182, 492, 1242, 7416, 199, 646, 2196, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 492, 2196, 63, 13522, 63, 3271, 199, 199, 363, 2502, 363, 275, 1867, 78, 1674, 904, 2941, 33, 1567, 869, 643, 14630, 665, 285, 530, 14, 72, 643, 14630, 32, 6799, 14, 957, 4206, 717, 283, 48, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 4206, 717, 283, 29336, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 3524, 717, 283, 5691, 352, 603, 19576, 665, 743, 352, 14, 67, 14, 77, 19576, 14, 31788, 32, 6799, 14, 957, 4206, 717, 283, 46, 1619, 290, 7005, 2106, 83, 665, 78, 274, 2106, 83, 32, 6799, 14, 957, 24782, 199, 199, 363, 452, 363, 275, 788, 4758, 63, 1238, 297, 1779, 283, 12080, 63, 4758, 63, 1238, 297, 1779, 283, 2062, 63, 10956, 63, 2180, 297, 1779, 283, 2411, 1090, 63, 72, 1151, 1017, 73, 63, 2180, 297, 1779, 283, 10956, 63, 4041, 63, 2350, 297, 1779, 283, 2355, 63, 10956, 63, 4041, 63, 2180, 418, 421, 199, 318, 2897, 63, 1238, 8, 6458, 63, 4041, 12, 981, 63, 4941, 29, 403, 12, 5176, 29, 403, 304, 272, 408, 1767, 282, 2196, 3343, 543, 314, 1627, 13666, 3414, 14, 339, 710, 2897, 1402, 12821, 282, 2196, 15984, 2180, 334, 2180, 543, 272, 9861, 8207, 436, 291, 17222, 9, 701, 19311, 26694, 8207, 370, 272, 1336, 314, 1627, 13666, 3414, 14, 339, 3897, 272, 4143, 272, 7926, 63, 4041, 520, 221, 769, 402, 9446, 267, 7048, 769, 2397, 13718, 370, 314, 13666, 402, 282, 1031, 14, 272, 1218, 63, 4941, 520, 3343, 12, 2716, 334, 885, 6879, 4578, 9, 2126, 1432, 3343, 402, 642, 730, 14, 710, 1256, 911, 506, 20518, 14, 272, 6347, 520, 21197, 909, 12, 2716, 267, 3240, 379, 367, 2196, 1329, 4306, 14, 339, 1803, 272, 5514, 272, 598, 520, 6879, 4578, 267, 437, 3343, 543, 314, 2013, 13666, 3414, 14, 267, 23836, 787, 23677, 6617, 737, 378, 543, 376, 1478, 267, 5226, 370, 314, 3421, 315, 7926, 63, 4041, 14, 339, 6218, 272, 21397, 272, 7220, 29356, 267, 982, 314, 13666, 3414, 1630, 440, 1172, 376, 2755, 3089, 14, 339, 1666, 6121, 272, 3001, 272, 365, 63, 1078, 63, 10956, 63, 4041, 339, 8144, 272, 9063, 272, 3709, 11736, 701, 7053, 1237, 359, 17, 61, 3754, 339, 437, 2222, 13, 2180, 2652, 13666, 3414, 334, 1397, 3363, 14065, 701, 2005, 3486, 272, 3343, 9, 365, 4370, 3967, 642, 805, 2529, 18312, 543, 291, 272, 17222, 436, 9861, 8207, 14, 221, 1626, 1919, 365, 4915, 340, 314, 13666, 272, 3414, 1630, 440, 1172, 376, 2755, 3089, 14, 339, 961, 2897, 1402, 14538, 2112, 883, 12690, 370, 272, 9250, 8207, 436, 17222, 14, 221, 2047, 883, 2813, 314, 291, 13, 22412, 436, 272, 9861, 8207, 334, 3239, 5084, 9, 1314, 911, 12060, 754, 315, 282, 3343, 272, 626, 3181, 1133, 1172, 314, 5835, 13666, 3414, 2013, 14, 221, 961, 272, 298, 8005, 13, 890, 7763, 2, 477, 1353, 3274, 465, 314, 1568, 402, 314, 3343, 10035, 3274, 14, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 603, 14, 37, 14, 42, 14, 7053, 1237, 12, 298, 1918, 5523, 436, 805, 402, 6114, 11759, 401, 2126, 428, 41, 1156, 5363, 12058, 10416, 13, 18, 12, 11618, 31650, 13, 3912, 12, 13004, 14, 339, 6058, 272, 3001, 272, 1306, 687, 24313, 14, 1208, 492, 7074, 22277, 63, 4041, 272, 1306, 1315, 29, 7343, 14, 1208, 14, 981, 63, 10956, 63, 4041, 8, 1960, 12, 5652, 22277, 63, 4041, 9, 272, 1306, 598, 29, 7343, 14, 4758, 63, 1238, 8, 90, 9, 339, 4005, 2813, 9861, 8207, 26, 339, 1306, 598, 29, 7343, 14, 4578, 8, 39, 9, 339, 4005, 2813, 291, 17222, 26, 339, 1306, 598, 14, 2168, 63, 6929, 63, 504, 8, 39, 14, 277, 3813, 63, 6929, 1012, 272, 408, 272, 340, 440, 3089, 8, 6458, 63, 4041, 19656, 18, 508, 16, 26, 267, 746, 8484, 14, 4491, 29356, 360, 3364, 13666, 3414, 358, 339, 340, 1218, 63, 4941, 365, 488, 26, 267, 1218, 63, 4941, 275, 8484, 14, 3947, 4578, 342, 272, 916, 1218, 63, 4941, 14, 374, 63, 12080, 837, 267, 746, 8484, 14, 4491, 29356, 480, 1341, 7983, 11513, 440, 3748, 531, 339, 340, 440, 6347, 365, 488, 26, 267, 2196, 14, 5176, 8, 5176, 9, 339, 327, 1343, 543, 2701, 653, 13, 932, 3343, 272, 653, 29, 552, 8, 6458, 63, 4041, 9, 339, 327, 2040, 3510, 6929, 436, 291, 22412, 272, 598, 29, 7343, 14, 1667, 63, 2180, 8, 46, 12, 981, 63, 4941, 9, 339, 340, 653, 389, 16, 503, 1390, 8, 6458, 63, 4041, 12694, 16, 26, 327, 4224, 340, 949, 8207, 267, 372, 598, 18407, 327, 1900, 10098, 513, 12, 282, 769, 402, 2808, 13666, 13, 7593, 22312, 272, 327, 325, 14, 71, 14, 367, 7926, 63, 4041, 1524, 19, 12, 18, 12, 17, 12, 17, 12, 17, 61, 272, 327, 22801, 12, 10098, 513, 1524, 17, 12, 17, 12, 17, 12, 18, 12, 18, 12, 19, 12, 20, 12, 21, 61, 272, 327, 284, 14, 69, 2020, 1031, 413, 965, 13666, 29, 19, 436, 365, 10877, 650, 5431, 12, 5423, 14, 272, 10098, 513, 9811, 272, 367, 302, 315, 598, 26, 267, 367, 284, 315, 1425, 8, 6458, 63, 4041, 59, 78, 4682, 288, 10098, 513, 14, 740, 8, 78, 9, 339, 327, 13031, 10098, 513, 436, 5090, 6342, 701, 12881, 499, 4008, 737, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eptmp3/Sick-Beard
sickbeard/providers/newzbin.py
46
13632
# Author: Nic Wolfe <nic@wolfeden.ca> # URL: http://code.google.com/p/sickbeard/ # # This file is part of Sick Beard. # # Sick Beard 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. # # Sick Beard 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 Sick Beard. If not, see <http://www.gnu.org/licenses/>. import os import re import sys import time import urllib from xml.dom.minidom import parseString from datetime import datetime, timedelta import sickbeard import generic import sickbeard.encodingKludge as ek from sickbeard import classes, logger, helpers, exceptions, show_name_helpers from sickbeard import tvcache from sickbeard.common import Quality from sickbeard.exceptions import ex from lib.dateutil.parser import parse as parseDate class NewzbinDownloader(urllib.FancyURLopener): def __init__(self): urllib.FancyURLopener.__init__(self) def http_error_default(self, url, fp, errcode, errmsg, headers): # if newzbin is throttling us, wait seconds and try again if errcode == 400: newzbinErrCode = int(headers.getheader('X-DNZB-RCode')) if newzbinErrCode == 450: rtext = str(headers.getheader('X-DNZB-RText')) result = re.search("wait (\d+) seconds", rtext) elif newzbinErrCode == 401: raise exceptions.AuthException("Newzbin username or password incorrect") elif newzbinErrCode == 402: raise exceptions.AuthException("Newzbin account not premium status, can't download NZBs") logger.log("Newzbin throttled our NZB downloading, pausing for " + result.group(1) + "seconds") time.sleep(int(result.group(1))) raise exceptions.NewzbinAPIThrottled() class NewzbinProvider(generic.NZBProvider): def __init__(self): generic.NZBProvider.__init__(self, "Newzbin") self.supportsBacklog = True self.cache = NewzbinCache(self) self.url = 'https://www.newzbin2.es/' self.NEWZBIN_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S %Z' def isEnabled(self): return sickbeard.NEWZBIN def getQuality(self, item): attributes = item.getElementsByTagName('report:attributes')[0] attr_dict = {} for attribute in attributes.getElementsByTagName('report:attribute'): cur_attr = attribute.getAttribute('type') cur_attr_value = helpers.get_xml_text(attribute) if cur_attr not in attr_dict: attr_dict[cur_attr] = [cur_attr_value] else: attr_dict[cur_attr].append(cur_attr_value) logger.log("Finding quality of item based on attributes "+str(attr_dict), logger.DEBUG) if self._is_SDTV(attr_dict): quality = Quality.SDTV elif self._is_SDDVD(attr_dict): quality = Quality.SDDVD elif self._is_HDTV(attr_dict): quality = Quality.HDTV elif self._is_WEBDL(attr_dict): quality = Quality.HDWEBDL elif self._is_720pBluRay(attr_dict): quality = Quality.HDBLURAY elif self._is_1080pBluRay(attr_dict): quality = Quality.FULLHDBLURAY else: quality = Quality.UNKNOWN logger.log("Resulting quality: "+str(quality), logger.DEBUG) return quality def _is_SDTV(self, attrs): # Video Fmt: (XviD, DivX, H.264/x264), NOT 720p, NOT 1080p, NOT 1080i video_fmt = 'Video Fmt' in attrs and ('XviD' in attrs['Video Fmt'] or 'DivX' in attrs['Video Fmt'] or 'H.264/x264' in attrs['Video Fmt']) \ and ('720p' not in attrs['Video Fmt']) \ and ('1080p' not in attrs['Video Fmt']) \ and ('1080i' not in attrs['Video Fmt']) # Source: TV Cap or HDTV or (None) source = 'Source' not in attrs or 'TV Cap' in attrs['Source'] or 'HDTV' in attrs['Source'] # Subtitles: (None) subs = 'Subtitles' not in attrs return video_fmt and source and subs def _is_SDDVD(self, attrs): # Video Fmt: (XviD, DivX, H.264/x264), NOT 720p, NOT 1080p, NOT 1080i video_fmt = 'Video Fmt' in attrs and ('XviD' in attrs['Video Fmt'] or 'DivX' in attrs['Video Fmt'] or 'H.264/x264' in attrs['Video Fmt']) \ and ('720p' not in attrs['Video Fmt']) \ and ('1080p' not in attrs['Video Fmt']) \ and ('1080i' not in attrs['Video Fmt']) # Source: DVD source = 'Source' in attrs and 'DVD' in attrs['Source'] # Subtitles: (None) subs = 'Subtitles' not in attrs return video_fmt and source and subs def _is_HDTV(self, attrs): # Video Fmt: H.264/x264, 720p video_fmt = 'Video Fmt' in attrs and ('H.264/x264' in attrs['Video Fmt']) \ and ('720p' in attrs['Video Fmt']) # Source: TV Cap or HDTV or (None) source = 'Source' not in attrs or 'TV Cap' in attrs['Source'] or 'HDTV' in attrs['Source'] # Subtitles: (None) subs = 'Subtitles' not in attrs return video_fmt and source and subs def _is_WEBDL(self, attrs): # Video Fmt: H.264/x264, 720p video_fmt = 'Video Fmt' in attrs and ('H.264/x264' in attrs['Video Fmt']) \ and ('720p' in attrs['Video Fmt']) # Source: WEB-DL source = 'Source' in attrs and 'WEB-DL' in attrs['Source'] # Subtitles: (None) subs = 'Subtitles' not in attrs return video_fmt and source and subs def _is_720pBluRay(self, attrs): # Video Fmt: H.264/x264, 720p video_fmt = 'Video Fmt' in attrs and ('H.264/x264' in attrs['Video Fmt']) \ and ('720p' in attrs['Video Fmt']) # Source: Blu-ray or HD-DVD source = 'Source' in attrs and ('Blu-ray' in attrs['Source'] or 'HD-DVD' in attrs['Source']) return video_fmt and source def _is_1080pBluRay(self, attrs): # Video Fmt: H.264/x264, 1080p video_fmt = 'Video Fmt' in attrs and ('H.264/x264' in attrs['Video Fmt']) \ and ('1080p' in attrs['Video Fmt']) # Source: Blu-ray or HD-DVD source = 'Source' in attrs and ('Blu-ray' in attrs['Source'] or 'HD-DVD' in attrs['Source']) return video_fmt and source def getIDFromURL(self, url): id_regex = re.escape(self.url) + 'browse/post/(\d+)/' id_match = re.match(id_regex, url) if not id_match: return None else: return id_match.group(1) def downloadResult(self, nzb): id = self.getIDFromURL(nzb.url) if not id: logger.log("Unable to get an ID from "+str(nzb.url)+", can't download from Newzbin's API", logger.ERROR) return False logger.log("Downloading an NZB from newzbin with id "+id) fileName = ek.ek(os.path.join, sickbeard.NZB_DIR, helpers.sanitizeFileName(nzb.name)+'.nzb') logger.log("Saving to " + fileName) urllib._urlopener = NewzbinDownloader() params = urllib.urlencode({"username": sickbeard.NEWZBIN_USERNAME, "password": sickbeard.NEWZBIN_PASSWORD, "reportid": id}) try: urllib.urlretrieve(self.url+"api/dnzb/", fileName, data=params) except exceptions.NewzbinAPIThrottled: logger.log("Done waiting for Newzbin API throttle limit, starting downloads again") self.downloadResult(nzb) except (urllib.ContentTooShortError, IOError), e: logger.log("Error downloading NZB: " + str(sys.exc_info()) + " - " + ex(e), logger.ERROR) return False return True def getURL(self, url): myOpener = classes.AuthURLOpener(sickbeard.NEWZBIN_USERNAME, sickbeard.NEWZBIN_PASSWORD) try: f = myOpener.openit(url) except (urllib.ContentTooShortError, IOError), e: logger.log("Error loading search results: " + str(sys.exc_info()) + " - " + ex(e), logger.ERROR) return None data = f.read() f.close() return data def _get_season_search_strings(self, show, season): nameList = set(show_name_helpers.allPossibleShowNames(show)) if show.air_by_date: suffix = '' else: suffix = 'x' searchTerms = ['^"'+x+' - '+str(season)+suffix+'"' for x in nameList] #searchTerms += ['^"'+x+' - Season '+str(season)+'"' for x in nameList] searchStr = " OR ".join(searchTerms) searchStr += " -subpack -extras" logger.log("Searching newzbin for string "+searchStr, logger.DEBUG) return [searchStr] def _get_episode_search_strings(self, ep_obj): nameList = set(show_name_helpers.allPossibleShowNames(ep_obj.show)) if not ep_obj.show.air_by_date: searchStr = " OR ".join(['^"'+x+' - %dx%02d"'%(ep_obj.season, ep_obj.episode) for x in nameList]) else: searchStr = " OR ".join(['^"'+x+' - '+str(ep_obj.airdate)+'"' for x in nameList]) return [searchStr] def _doSearch(self, searchStr, show=None): data = self._getRSSData(searchStr.encode('utf-8')) item_list = [] try: parsedXML = parseString(data) items = parsedXML.getElementsByTagName('item') except Exception, e: logger.log("Error trying to load Newzbin RSS feed: "+ex(e), logger.ERROR) return [] for cur_item in items: title = helpers.get_xml_text(cur_item.getElementsByTagName('title')[0]) if title == 'Feeds Error': raise exceptions.AuthException("The feed wouldn't load, probably because of invalid auth info") if sickbeard.USENET_RETENTION is not None: try: dateString = helpers.get_xml_text(cur_item.getElementsByTagName('report:postdate')[0]) # use the parse (imported as parseDate) function from the dateutil lib # and we have to remove the timezone info from it because the retention_date will not have one # and a comparison of them is not possible post_date = parseDate(dateString).replace(tzinfo=None) retention_date = datetime.now() - timedelta(days=sickbeard.USENET_RETENTION) if post_date < retention_date: logger.log(u"Date "+str(post_date)+" is out of retention range, skipping", logger.DEBUG) continue except Exception, e: logger.log("Error parsing date from Newzbin RSS feed: " + str(e), logger.ERROR) continue item_list.append(cur_item) return item_list def _getRSSData(self, search=None): params = { 'searchaction': 'Search', 'fpn': 'p', 'category': 8, 'u_nfo_posts_only': 0, 'u_url_posts_only': 0, 'u_comment_posts_only': 0, 'u_show_passworded': 0, 'u_v3_retention': 0, 'ps_rb_video_format': 3082257, 'ps_rb_language': 4096, 'sort': 'date', 'order': 'desc', 'u_post_results_amt': 50, 'feed': 'rss', 'hauth': 1, } if search: params['q'] = search + " AND " else: params['q'] = '' params['q'] += 'Attr:Lang~Eng AND NOT Attr:VideoF=DVD' url = self.url + "search/?%s" % urllib.urlencode(params) logger.log("Newzbin search URL: " + url, logger.DEBUG) data = self.getURL(url) return data def _checkAuth(self): if sickbeard.NEWZBIN_USERNAME in (None, "") or sickbeard.NEWZBIN_PASSWORD in (None, ""): raise exceptions.AuthException("Newzbin authentication details are empty, check your config") class NewzbinCache(tvcache.TVCache): def __init__(self, provider): tvcache.TVCache.__init__(self, provider) # only poll Newzbin every 10 mins max self.minTime = 1 def _getRSSData(self): data = self.provider._getRSSData() return data def _parseItem(self, item): (title, url) = self.provider._get_title_and_url(item) if title == 'Feeds Error': logger.log("There's an error in the feed, probably bad auth info", logger.DEBUG) raise exceptions.AuthException("Invalid Newzbin username/password") if not title or not url: logger.log("The XML returned from the "+self.provider.name+" feed is incomplete, this result is unusable", logger.ERROR) return quality = self.provider.getQuality(item) logger.log("Found quality "+str(quality), logger.DEBUG) logger.log("Adding item from RSS to cache: "+title, logger.DEBUG) self._addCacheEntry(title, url, quality=quality) provider = NewzbinProvider()
gpl-3.0
[ 3, 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 6423, 1005, 14, 199, 3, 199, 3, 28964, 6423, 1005, 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, 28964, 6423, 1005, 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, 28964, 6423, 1005, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 900, 199, 646, 4011, 199, 199, 504, 2748, 14, 4556, 14, 21827, 492, 2198, 1558, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 646, 17898, 199, 646, 7809, 199, 199, 646, 17898, 14, 2991, 43, 76, 16603, 465, 325, 75, 199, 504, 17898, 492, 3992, 12, 2512, 12, 10897, 12, 4967, 12, 2498, 63, 354, 63, 7546, 199, 504, 17898, 492, 13466, 1637, 199, 504, 17898, 14, 2330, 492, 24108, 199, 504, 17898, 14, 3924, 492, 444, 199, 504, 1973, 14, 602, 1974, 14, 2087, 492, 2198, 465, 2198, 2506, 199, 199, 533, 7053, 90, 1393, 3514, 3422, 8, 4078, 14, 38, 9844, 2632, 11637, 304, 339, 347, 636, 826, 721, 277, 304, 267, 4011, 14, 38, 9844, 2632, 11637, 855, 826, 721, 277, 9, 339, 347, 1455, 63, 705, 63, 885, 8, 277, 12, 1166, 12, 4090, 12, 30771, 12, 22070, 12, 2323, 304, 398, 327, 340, 892, 90, 1393, 365, 294, 4571, 32642, 2739, 12, 3618, 4696, 436, 862, 4020, 267, 340, 30771, 508, 8290, 26, 953, 892, 90, 1393, 5432, 3034, 275, 1109, 8, 2139, 14, 19958, 360, 56, 13, 10872, 58, 34, 13, 50, 3034, 1333, 953, 340, 892, 90, 1393, 5432, 3034, 508, 841, 1400, 26, 355, 519, 505, 275, 620, 8, 2139, 14, 19958, 360, 56, 13, 10872, 58, 34, 13, 50, 1872, 1333, 355, 754, 275, 295, 14, 1733, 480, 2573, 14749, 68, 8771, 4696, 401, 519, 505, 9, 953, 916, 892, 90, 1393, 5432, 3034, 508, 13952, 26, 355, 746, 4967, 14, 2817, 1726, 480, 4665, 90, 1393, 3434, 503, 2505, 8927, 531, 953, 916, 892, 90, 1393, 5432, 3034, 508, 841, 996, 26, 355, 746, 4967, 14, 2817, 1726, 480, 4665, 90, 1393, 2933, 440, 876, 23481, 2004, 12, 883, 1133, 5235, 653, 58, 26394, 531, 953, 2512, 14, 793, 480, 4665, 90, 1393, 27048, 68, 4154, 653, 58, 34, 25937, 12, 691, 4941, 367, 298, 435, 754, 14, 923, 8, 17, 9, 435, 298, 4515, 531, 953, 900, 14, 4532, 8, 442, 8, 1099, 14, 923, 8, 17, 1724, 953, 746, 4967, 14, 4665, 90, 1393, 2642, 72, 12301, 68, 342, 199, 199, 533, 7053, 90, 1393, 6663, 8, 6767, 14, 19011, 34, 6663, 304, 339, 347, 636, 826, 721, 277, 304, 398, 7809, 14, 19011, 34, 6663, 855, 826, 721, 277, 12, 298, 4665, 90, 1393, 531, 398, 291, 14, 9823, 4540, 793, 275, 715, 398, 291, 14, 1637, 275, 7053, 90, 1393, 4437, 8, 277, 9, 398, 291, 14, 633, 275, 283, 2859, 921, 1544, 14, 1222, 90, 1393, 18, 14, 397, 4805, 398, 291, 14, 11365, 58, 9431, 63, 5390, 63, 4807, 275, 1543, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 450, 58, 7, 339, 347, 365, 6589, 8, 277, 304, 267, 372, 17898, 14, 11365, 58, 9431, 339, 347, 664, 19436, 8, 277, 12, 1242, 304, 267, 3004, 275, 1242, 14, 15045, 360, 3070, 26, 2987, 5832, 16, 61, 267, 1921, 63, 807, 275, 1052, 398, 367, 2225, 315, 3004, 14, 15045, 360, 3070, 26, 3215, 735, 288, 1094, 63, 962, 275, 2225, 14, 12956, 360, 466, 358, 288, 1094, 63, 962, 63, 585, 275, 10897, 14, 362, 63, 1652, 63, 505, 8, 3215, 9, 288, 340, 1094, 63, 962, 440, 315, 1921, 63, 807, 26, 355, 1921, 63, 807, 59, 895, 63, 962, 61, 275, 359, 895, 63, 962, 63, 585, 61, 288, 587, 26, 355, 1921, 63, 807, 59, 895, 63, 962, 1055, 740, 8, 895, 63, 962, 63, 585, 9, 398, 2512, 14, 793, 480, 6591, 316, 11030, 402, 1242, 4079, 641, 3004, 7210, 495, 8, 962, 63, 807, 395, 2512, 14, 5287, 9, 398, 340, 291, 423, 374, 63, 3693, 12764, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 3693, 12764, 267, 916, 291, 423, 374, 63, 3693, 6741, 36, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 3693, 6741, 36, 267, 916, 291, 423, 374, 63, 40, 7438, 54, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 40, 7438, 54, 267, 916, 291, 423, 374, 63, 13166, 8045, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 14903, 13166, 8045, 267, 916, 291, 423, 374, 63, 18386, 80, 34, 10836, 25474, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 40, 2846, 44, 1230, 3448, 267, 916, 291, 423, 374, 63, 23514, 80, 34, 10836, 25474, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 14742, 40, 2846, 44, 1230, 3448, 267, 587, 26, 288, 11030, 275, 24108, 14, 11588, 398, 2512, 14, 793, 480, 2889, 316, 11030, 26, 7210, 495, 8, 9161, 395, 2512, 14, 5287, 9, 398, 372, 11030, 339, 347, 485, 374, 63, 3693, 12764, 8, 277, 12, 3290, 304, 398, 327, 15709, 481, 2037, 26, 334, 56, 433, 36, 12, 32077, 56, 12, 869, 14, 9408, 15, 88, 9408, 395 ]
[ 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 6423, 1005, 14, 199, 3, 199, 3, 28964, 6423, 1005, 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, 28964, 6423, 1005, 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, 28964, 6423, 1005, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 900, 199, 646, 4011, 199, 199, 504, 2748, 14, 4556, 14, 21827, 492, 2198, 1558, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 646, 17898, 199, 646, 7809, 199, 199, 646, 17898, 14, 2991, 43, 76, 16603, 465, 325, 75, 199, 504, 17898, 492, 3992, 12, 2512, 12, 10897, 12, 4967, 12, 2498, 63, 354, 63, 7546, 199, 504, 17898, 492, 13466, 1637, 199, 504, 17898, 14, 2330, 492, 24108, 199, 504, 17898, 14, 3924, 492, 444, 199, 504, 1973, 14, 602, 1974, 14, 2087, 492, 2198, 465, 2198, 2506, 199, 199, 533, 7053, 90, 1393, 3514, 3422, 8, 4078, 14, 38, 9844, 2632, 11637, 304, 339, 347, 636, 826, 721, 277, 304, 267, 4011, 14, 38, 9844, 2632, 11637, 855, 826, 721, 277, 9, 339, 347, 1455, 63, 705, 63, 885, 8, 277, 12, 1166, 12, 4090, 12, 30771, 12, 22070, 12, 2323, 304, 398, 327, 340, 892, 90, 1393, 365, 294, 4571, 32642, 2739, 12, 3618, 4696, 436, 862, 4020, 267, 340, 30771, 508, 8290, 26, 953, 892, 90, 1393, 5432, 3034, 275, 1109, 8, 2139, 14, 19958, 360, 56, 13, 10872, 58, 34, 13, 50, 3034, 1333, 953, 340, 892, 90, 1393, 5432, 3034, 508, 841, 1400, 26, 355, 519, 505, 275, 620, 8, 2139, 14, 19958, 360, 56, 13, 10872, 58, 34, 13, 50, 1872, 1333, 355, 754, 275, 295, 14, 1733, 480, 2573, 14749, 68, 8771, 4696, 401, 519, 505, 9, 953, 916, 892, 90, 1393, 5432, 3034, 508, 13952, 26, 355, 746, 4967, 14, 2817, 1726, 480, 4665, 90, 1393, 3434, 503, 2505, 8927, 531, 953, 916, 892, 90, 1393, 5432, 3034, 508, 841, 996, 26, 355, 746, 4967, 14, 2817, 1726, 480, 4665, 90, 1393, 2933, 440, 876, 23481, 2004, 12, 883, 1133, 5235, 653, 58, 26394, 531, 953, 2512, 14, 793, 480, 4665, 90, 1393, 27048, 68, 4154, 653, 58, 34, 25937, 12, 691, 4941, 367, 298, 435, 754, 14, 923, 8, 17, 9, 435, 298, 4515, 531, 953, 900, 14, 4532, 8, 442, 8, 1099, 14, 923, 8, 17, 1724, 953, 746, 4967, 14, 4665, 90, 1393, 2642, 72, 12301, 68, 342, 199, 199, 533, 7053, 90, 1393, 6663, 8, 6767, 14, 19011, 34, 6663, 304, 339, 347, 636, 826, 721, 277, 304, 398, 7809, 14, 19011, 34, 6663, 855, 826, 721, 277, 12, 298, 4665, 90, 1393, 531, 398, 291, 14, 9823, 4540, 793, 275, 715, 398, 291, 14, 1637, 275, 7053, 90, 1393, 4437, 8, 277, 9, 398, 291, 14, 633, 275, 283, 2859, 921, 1544, 14, 1222, 90, 1393, 18, 14, 397, 4805, 398, 291, 14, 11365, 58, 9431, 63, 5390, 63, 4807, 275, 1543, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 450, 58, 7, 339, 347, 365, 6589, 8, 277, 304, 267, 372, 17898, 14, 11365, 58, 9431, 339, 347, 664, 19436, 8, 277, 12, 1242, 304, 267, 3004, 275, 1242, 14, 15045, 360, 3070, 26, 2987, 5832, 16, 61, 267, 1921, 63, 807, 275, 1052, 398, 367, 2225, 315, 3004, 14, 15045, 360, 3070, 26, 3215, 735, 288, 1094, 63, 962, 275, 2225, 14, 12956, 360, 466, 358, 288, 1094, 63, 962, 63, 585, 275, 10897, 14, 362, 63, 1652, 63, 505, 8, 3215, 9, 288, 340, 1094, 63, 962, 440, 315, 1921, 63, 807, 26, 355, 1921, 63, 807, 59, 895, 63, 962, 61, 275, 359, 895, 63, 962, 63, 585, 61, 288, 587, 26, 355, 1921, 63, 807, 59, 895, 63, 962, 1055, 740, 8, 895, 63, 962, 63, 585, 9, 398, 2512, 14, 793, 480, 6591, 316, 11030, 402, 1242, 4079, 641, 3004, 7210, 495, 8, 962, 63, 807, 395, 2512, 14, 5287, 9, 398, 340, 291, 423, 374, 63, 3693, 12764, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 3693, 12764, 267, 916, 291, 423, 374, 63, 3693, 6741, 36, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 3693, 6741, 36, 267, 916, 291, 423, 374, 63, 40, 7438, 54, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 40, 7438, 54, 267, 916, 291, 423, 374, 63, 13166, 8045, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 14903, 13166, 8045, 267, 916, 291, 423, 374, 63, 18386, 80, 34, 10836, 25474, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 40, 2846, 44, 1230, 3448, 267, 916, 291, 423, 374, 63, 23514, 80, 34, 10836, 25474, 8, 962, 63, 807, 304, 288, 11030, 275, 24108, 14, 14742, 40, 2846, 44, 1230, 3448, 267, 587, 26, 288, 11030, 275, 24108, 14, 11588, 398, 2512, 14, 793, 480, 2889, 316, 11030, 26, 7210, 495, 8, 9161, 395, 2512, 14, 5287, 9, 398, 372, 11030, 339, 347, 485, 374, 63, 3693, 12764, 8, 277, 12, 3290, 304, 398, 327, 15709, 481, 2037, 26, 334, 56, 433, 36, 12, 32077, 56, 12, 869, 14, 9408, 15, 88, 9408, 395, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
broferek/ansible
lib/ansible/modules/network/nxos/nxos_vrf_af.py
16
4381
#!/usr/bin/python # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'network'} DOCUMENTATION = ''' --- module: nxos_vrf_af extends_documentation_fragment: nxos version_added: "2.2" short_description: Manages VRF AF. description: - Manages VRF AF author: Gabriele Gerbino (@GGabriele) notes: - Tested against NXOSv 7.3.(0)D1(1) on VIRL - Default, where supported, restores params default value. options: vrf: description: - Name of the VRF. required: true afi: description: - Address-Family Identifier (AFI). required: true choices: ['ipv4', 'ipv6'] route_target_both_auto_evpn: description: - Enable/Disable the EVPN route-target 'auto' setting for both import and export target communities. type: bool state: description: - Determines whether the config should be present or not on the device. default: present choices: ['present','absent'] ''' EXAMPLES = ''' - nxos_vrf_af: vrf: ntc afi: ipv4 route_target_both_auto_evpn: True state: present ''' RETURN = ''' commands: description: commands sent to the device returned: always type: list sample: ["vrf context ntc", "address-family ipv4 unicast"] ''' from ansible.module_utils.network.nxos.nxos import get_config, load_config from ansible.module_utils.network.nxos.nxos import nxos_argument_spec from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.common.config import NetworkConfig def main(): argument_spec = dict( vrf=dict(required=True), afi=dict(required=True, choices=['ipv4', 'ipv6']), route_target_both_auto_evpn=dict(required=False, type='bool'), state=dict(choices=['present', 'absent'], default='present'), ) argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {'changed': False, 'warnings': warnings} config_text = get_config(module) config = NetworkConfig(indent=2, contents=config_text) path = ['vrf context %s' % module.params['vrf'], 'address-family %s unicast' % module.params['afi']] try: current = config.get_block_config(path) except ValueError: current = None commands = list() if current and module.params['state'] == 'absent': commands.append('no address-family %s unicast' % module.params['afi']) elif module.params['state'] == 'present': if current: have = 'route-target both auto evpn' in current if module.params['route_target_both_auto_evpn'] is not None: want = bool(module.params['route_target_both_auto_evpn']) if want and not have: commands.append('address-family %s unicast' % module.params['afi']) commands.append('route-target both auto evpn') elif have and not want: commands.append('address-family %s unicast' % module.params['afi']) commands.append('no route-target both auto evpn') else: commands.append('address-family %s unicast' % module.params['afi']) if module.params['route_target_both_auto_evpn']: commands.append('route-target both auto evpn') if commands: commands.insert(0, 'vrf context %s' % module.params['vrf']) if not module.check_mode: load_config(module, commands) result['changed'] = True result['commands'] = commands module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 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, 1200, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22072, 63, 11863, 63, 2756, 199, 11036, 63, 9970, 63, 7677, 26, 22072, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 3612, 63, 1802, 26, 21612, 812, 11778, 20089, 14, 199, 1802, 26, 523, 446, 21612, 812, 11778, 20089, 199, 2502, 26, 598, 371, 322, 8081, 22261, 1393, 79, 8593, 2916, 371, 322, 8081, 9, 199, 5983, 26, 523, 446, 30568, 6169, 653, 56, 3100, 86, 1520, 14, 19, 14, 8, 16, 9, 36, 17, 8, 17, 9, 641, 812, 41, 2431, 523, 446, 3758, 12, 2382, 3748, 12, 4618, 7944, 1862, 849, 574, 14, 199, 1419, 26, 523, 15209, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 812, 11778, 14, 272, 1415, 26, 2549, 523, 282, 329, 26, 272, 1369, 26, 489, 446, 9906, 13, 16345, 23285, 334, 33, 1976, 680, 272, 1415, 26, 2549, 272, 3415, 26, 788, 4774, 20, 297, 283, 4774, 22, 418, 523, 7475, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 26, 272, 1369, 26, 489, 446, 12030, 15, 13707, 314, 30069, 9060, 7475, 13, 1375, 283, 2495, 7, 4260, 367, 3865, 267, 492, 436, 4843, 1347, 1923, 22047, 14, 272, 730, 26, 2155, 523, 1174, 26, 272, 1369, 26, 489, 446, 22391, 3775, 314, 1101, 1077, 506, 3451, 503, 267, 440, 641, 314, 2243, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 1673, 5575, 418, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 22072, 63, 11863, 63, 2756, 26, 272, 15209, 26, 302, 3641, 272, 282, 329, 26, 3278, 20, 272, 7475, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 26, 715, 272, 1174, 26, 3451, 199, 2344, 199, 199, 9677, 275, 1449, 199, 4405, 26, 272, 1369, 26, 3718, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 11863, 1067, 302, 3641, 401, 298, 1562, 13, 6606, 3278, 20, 625, 530, 1810, 937, 199, 2344, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 17982, 14, 17982, 492, 664, 63, 888, 12, 2248, 63, 888, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 17982, 14, 17982, 492, 22072, 63, 2094, 63, 1650, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 888, 492, 7220, 2028, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 1211, 8, 267, 15209, 29, 807, 8, 2427, 29, 549, 395, 267, 282, 329, 29, 807, 8, 2427, 29, 549, 12, 3415, 2968, 4774, 20, 297, 283, 4774, 22, 3815, 267, 7475, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 2245, 659, 267, 1174, 29, 807, 8, 4577, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 272, 776, 339, 1423, 63, 1650, 14, 873, 8, 17982, 63, 2094, 63, 1650, 9, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 549, 9, 339, 3598, 275, 769, 342, 339, 754, 275, 791, 2489, 356, 756, 12, 283, 5451, 356, 3598, 93, 339, 1101, 63, 505, 275, 664, 63, 888, 8, 578, 9, 272, 1101, 275, 7220, 2028, 8, 3724, 29, 18, 12, 4072, 29, 888, 63, 505, 9, 339, 931, 275, 788, 11863, 1067, 450, 83, 7, 450, 859, 14, 1162, 459, 11863, 995, 288, 283, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 6538, 339, 862, 26, 267, 1453, 275, 1101, 14, 362, 63, 1457, 63, 888, 8, 515, 9, 272, 871, 1722, 26, 267, 1453, 275, 488, 339, 3718, 275, 769, 342, 272, 340, 1453, 436, 859, 14, 1162, 459, 929, 418, 508, 283, 5575, 356, 267, 3718, 14, 740, 360, 889, 2287, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 1105, 339, 916, 859, 14, 1162, 459, 929, 418, 508, 283, 1881, 356, 398, 340, 1453, 26, 288, 1172, 275, 283, 4449, 13, 1375, 3865, 2599, 8145, 4812, 7, 315, 1453, 288, 340, 859, 14, 1162, 459, 4449, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 418, 365, 440, 488, 26, 355, 2934, 275, 2155, 8, 578, 14, 1162, 459, 4449, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 1105, 355, 340, 2934, 436, 440, 1172, 26, 490, 3718, 14, 740, 360, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 1105, 490, 3718, 14, 740, 360, 4449, 13, 1375, 3865, 2599, 8145, 4812, 358, 355, 916, 1172, 436, 440, 2934, 26, 490, 3718, 14, 740, 360, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 1105, 490, 3718, 14, 740, 360, 889, 7475, 13, 1375, 3865, 2599, 8145, 4812, 358, 398, 587, 26, 288, 3718, 14, 740, 360, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 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, 1200, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22072, 63, 11863, 63, 2756, 199, 11036, 63, 9970, 63, 7677, 26, 22072, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 3612, 63, 1802, 26, 21612, 812, 11778, 20089, 14, 199, 1802, 26, 523, 446, 21612, 812, 11778, 20089, 199, 2502, 26, 598, 371, 322, 8081, 22261, 1393, 79, 8593, 2916, 371, 322, 8081, 9, 199, 5983, 26, 523, 446, 30568, 6169, 653, 56, 3100, 86, 1520, 14, 19, 14, 8, 16, 9, 36, 17, 8, 17, 9, 641, 812, 41, 2431, 523, 446, 3758, 12, 2382, 3748, 12, 4618, 7944, 1862, 849, 574, 14, 199, 1419, 26, 523, 15209, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 812, 11778, 14, 272, 1415, 26, 2549, 523, 282, 329, 26, 272, 1369, 26, 489, 446, 9906, 13, 16345, 23285, 334, 33, 1976, 680, 272, 1415, 26, 2549, 272, 3415, 26, 788, 4774, 20, 297, 283, 4774, 22, 418, 523, 7475, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 26, 272, 1369, 26, 489, 446, 12030, 15, 13707, 314, 30069, 9060, 7475, 13, 1375, 283, 2495, 7, 4260, 367, 3865, 267, 492, 436, 4843, 1347, 1923, 22047, 14, 272, 730, 26, 2155, 523, 1174, 26, 272, 1369, 26, 489, 446, 22391, 3775, 314, 1101, 1077, 506, 3451, 503, 267, 440, 641, 314, 2243, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 1673, 5575, 418, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 22072, 63, 11863, 63, 2756, 26, 272, 15209, 26, 302, 3641, 272, 282, 329, 26, 3278, 20, 272, 7475, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 26, 715, 272, 1174, 26, 3451, 199, 2344, 199, 199, 9677, 275, 1449, 199, 4405, 26, 272, 1369, 26, 3718, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 11863, 1067, 302, 3641, 401, 298, 1562, 13, 6606, 3278, 20, 625, 530, 1810, 937, 199, 2344, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 17982, 14, 17982, 492, 664, 63, 888, 12, 2248, 63, 888, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 17982, 14, 17982, 492, 22072, 63, 2094, 63, 1650, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 888, 492, 7220, 2028, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 1211, 8, 267, 15209, 29, 807, 8, 2427, 29, 549, 395, 267, 282, 329, 29, 807, 8, 2427, 29, 549, 12, 3415, 2968, 4774, 20, 297, 283, 4774, 22, 3815, 267, 7475, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 2245, 659, 267, 1174, 29, 807, 8, 4577, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 272, 776, 339, 1423, 63, 1650, 14, 873, 8, 17982, 63, 2094, 63, 1650, 9, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 12, 5171, 63, 1074, 63, 632, 29, 549, 9, 339, 3598, 275, 769, 342, 339, 754, 275, 791, 2489, 356, 756, 12, 283, 5451, 356, 3598, 93, 339, 1101, 63, 505, 275, 664, 63, 888, 8, 578, 9, 272, 1101, 275, 7220, 2028, 8, 3724, 29, 18, 12, 4072, 29, 888, 63, 505, 9, 339, 931, 275, 788, 11863, 1067, 450, 83, 7, 450, 859, 14, 1162, 459, 11863, 995, 288, 283, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 6538, 339, 862, 26, 267, 1453, 275, 1101, 14, 362, 63, 1457, 63, 888, 8, 515, 9, 272, 871, 1722, 26, 267, 1453, 275, 488, 339, 3718, 275, 769, 342, 272, 340, 1453, 436, 859, 14, 1162, 459, 929, 418, 508, 283, 5575, 356, 267, 3718, 14, 740, 360, 889, 2287, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 1105, 339, 916, 859, 14, 1162, 459, 929, 418, 508, 283, 1881, 356, 398, 340, 1453, 26, 288, 1172, 275, 283, 4449, 13, 1375, 3865, 2599, 8145, 4812, 7, 315, 1453, 288, 340, 859, 14, 1162, 459, 4449, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 418, 365, 440, 488, 26, 355, 2934, 275, 2155, 8, 578, 14, 1162, 459, 4449, 63, 1375, 63, 10727, 63, 2495, 63, 6857, 4812, 1105, 355, 340, 2934, 436, 440, 1172, 26, 490, 3718, 14, 740, 360, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 1105, 490, 3718, 14, 740, 360, 4449, 13, 1375, 3865, 2599, 8145, 4812, 358, 355, 916, 1172, 436, 440, 2934, 26, 490, 3718, 14, 740, 360, 1562, 13, 6606, 450, 83, 625, 530, 1810, 7, 450, 859, 14, 1162, 459, 13030, 1105, 490, 3718, 14, 740, 360, 889, 7475, 13, 1375, 3865, 2599, 8145, 4812, 358, 398, 587, 26, 288, 3718, 14, 740, 360, 1562, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
spisneha25/django
tests/template_tests/test_response.py
199
14388
from __future__ import unicode_literals import pickle import time from datetime import datetime from django.conf import settings from django.template import Context, engines from django.template.response import ( ContentNotRenderedError, SimpleTemplateResponse, TemplateResponse, ) from django.test import ( RequestFactory, SimpleTestCase, ignore_warnings, override_settings, ) from django.test.utils import require_jinja2 from django.utils.deprecation import RemovedInDjango110Warning from .utils import TEMPLATE_DIR def test_processor(request): return {'processors': 'yes'} test_processor_name = 'template_tests.test_response.test_processor' # A test middleware that installs a temporary URLConf class CustomURLConfMiddleware(object): def process_request(self, request): request.urlconf = 'template_tests.alternate_urls' class SimpleTemplateResponseTest(SimpleTestCase): def _response(self, template='foo', *args, **kwargs): template = engines['django'].from_string(template) return SimpleTemplateResponse(template, *args, **kwargs) def test_template_resolving(self): response = SimpleTemplateResponse('first/test.html') response.render() self.assertEqual(response.content, b'First template\n') templates = ['foo.html', 'second/test.html', 'first/test.html'] response = SimpleTemplateResponse(templates) response.render() self.assertEqual(response.content, b'Second template\n') response = self._response() response.render() self.assertEqual(response.content, b'foo') def test_explicit_baking(self): # explicit baking response = self._response() self.assertFalse(response.is_rendered) response.render() self.assertTrue(response.is_rendered) def test_render(self): # response is not re-rendered without the render call response = self._response().render() self.assertEqual(response.content, b'foo') # rebaking doesn't change the rendered content template = engines['django'].from_string('bar{{ baz }}') response.template_name = template response.render() self.assertEqual(response.content, b'foo') # but rendered content can be overridden by manually # setting content response.content = 'bar' self.assertEqual(response.content, b'bar') def test_iteration_unrendered(self): # unrendered response raises an exception on iteration response = self._response() self.assertFalse(response.is_rendered) def iteration(): for x in response: pass self.assertRaises(ContentNotRenderedError, iteration) self.assertFalse(response.is_rendered) def test_iteration_rendered(self): # iteration works for rendered responses response = self._response().render() res = [x for x in response] self.assertEqual(res, [b'foo']) def test_content_access_unrendered(self): # unrendered response raises an exception when content is accessed response = self._response() self.assertFalse(response.is_rendered) self.assertRaises(ContentNotRenderedError, lambda: response.content) self.assertFalse(response.is_rendered) def test_content_access_rendered(self): # rendered response content can be accessed response = self._response().render() self.assertEqual(response.content, b'foo') def test_set_content(self): # content can be overridden response = self._response() self.assertFalse(response.is_rendered) response.content = 'spam' self.assertTrue(response.is_rendered) self.assertEqual(response.content, b'spam') response.content = 'baz' self.assertEqual(response.content, b'baz') def test_dict_context(self): response = self._response('{{ foo }}{{ processors }}', {'foo': 'bar'}) self.assertEqual(response.context_data, {'foo': 'bar'}) response.render() self.assertEqual(response.content, b'bar') @ignore_warnings(category=RemovedInDjango110Warning) def test_context_instance(self): response = self._response('{{ foo }}{{ processors }}', Context({'foo': 'bar'})) self.assertEqual(response.context_data.__class__, Context) response.render() self.assertEqual(response.content, b'bar') def test_kwargs(self): response = self._response(content_type='application/json', status=504) self.assertEqual(response['content-type'], 'application/json') self.assertEqual(response.status_code, 504) def test_args(self): response = SimpleTemplateResponse('', {}, 'application/json', 504) self.assertEqual(response['content-type'], 'application/json') self.assertEqual(response.status_code, 504) @require_jinja2 def test_using(self): response = SimpleTemplateResponse('template_tests/using.html').render() self.assertEqual(response.content, b'DTL\n') response = SimpleTemplateResponse('template_tests/using.html', using='django').render() self.assertEqual(response.content, b'DTL\n') response = SimpleTemplateResponse('template_tests/using.html', using='jinja2').render() self.assertEqual(response.content, b'Jinja2\n') def test_post_callbacks(self): "Rendering a template response triggers the post-render callbacks" post = [] def post1(obj): post.append('post1') def post2(obj): post.append('post2') response = SimpleTemplateResponse('first/test.html', {}) response.add_post_render_callback(post1) response.add_post_render_callback(post2) # When the content is rendered, all the callbacks are invoked, too. response.render() self.assertEqual(response.content, b'First template\n') self.assertEqual(post, ['post1', 'post2']) def test_pickling(self): # Create a template response. The context is # known to be unpickleable (e.g., a function). response = SimpleTemplateResponse('first/test.html', { 'value': 123, 'fn': datetime.now, }) self.assertRaises(ContentNotRenderedError, pickle.dumps, response) # But if we render the response, we can pickle it. response.render() pickled_response = pickle.dumps(response) unpickled_response = pickle.loads(pickled_response) self.assertEqual(unpickled_response.content, response.content) self.assertEqual(unpickled_response['content-type'], response['content-type']) self.assertEqual(unpickled_response.status_code, response.status_code) # ...and the unpickled response doesn't have the # template-related attributes, so it can't be re-rendered template_attrs = ('template_name', 'context_data', '_post_render_callbacks') for attr in template_attrs: self.assertFalse(hasattr(unpickled_response, attr)) # ...and requesting any of those attributes raises an exception for attr in template_attrs: with self.assertRaises(AttributeError): getattr(unpickled_response, attr) def test_repickling(self): response = SimpleTemplateResponse('first/test.html', { 'value': 123, 'fn': datetime.now, }) self.assertRaises(ContentNotRenderedError, pickle.dumps, response) response.render() pickled_response = pickle.dumps(response) unpickled_response = pickle.loads(pickled_response) pickle.dumps(unpickled_response) def test_pickling_cookie(self): response = SimpleTemplateResponse('first/test.html', { 'value': 123, 'fn': datetime.now, }) response.cookies['key'] = 'value' response.render() pickled_response = pickle.dumps(response, pickle.HIGHEST_PROTOCOL) unpickled_response = pickle.loads(pickled_response) self.assertEqual(unpickled_response.cookies['key'].value, 'value') @override_settings(TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATE_DIR], 'OPTIONS': { 'context_processors': [test_processor_name], }, }]) class TemplateResponseTest(SimpleTestCase): def setUp(self): self.factory = RequestFactory() def _response(self, template='foo', *args, **kwargs): self._request = self.factory.get('/') template = engines['django'].from_string(template) return TemplateResponse(self._request, template, *args, **kwargs) def test_render(self): response = self._response('{{ foo }}{{ processors }}').render() self.assertEqual(response.content, b'yes') def test_render_with_requestcontext(self): response = self._response('{{ foo }}{{ processors }}', {'foo': 'bar'}).render() self.assertEqual(response.content, b'baryes') @ignore_warnings(category=RemovedInDjango110Warning) def test_render_with_context(self): response = self._response('{{ foo }}{{ processors }}', Context({'foo': 'bar'})).render() self.assertEqual(response.content, b'bar') def test_context_processor_priority(self): # context processors should be overridden by passed-in context response = self._response('{{ foo }}{{ processors }}', {'processors': 'no'}).render() self.assertEqual(response.content, b'no') def test_kwargs(self): response = self._response(content_type='application/json', status=504) self.assertEqual(response['content-type'], 'application/json') self.assertEqual(response.status_code, 504) def test_args(self): response = TemplateResponse(self.factory.get('/'), '', {}, 'application/json', 504) self.assertEqual(response['content-type'], 'application/json') self.assertEqual(response.status_code, 504) @require_jinja2 def test_using(self): request = self.factory.get('/') response = TemplateResponse(request, 'template_tests/using.html').render() self.assertEqual(response.content, b'DTL\n') response = TemplateResponse(request, 'template_tests/using.html', using='django').render() self.assertEqual(response.content, b'DTL\n') response = TemplateResponse(request, 'template_tests/using.html', using='jinja2').render() self.assertEqual(response.content, b'Jinja2\n') @ignore_warnings(category=RemovedInDjango110Warning) def test_custom_app(self): self._response('{{ foo }}', current_app="foobar") self.assertEqual(self._request.current_app, 'foobar') def test_pickling(self): # Create a template response. The context is # known to be unpickleable (e.g., a function). response = TemplateResponse(self.factory.get('/'), 'first/test.html', { 'value': 123, 'fn': datetime.now, } ) self.assertRaises(ContentNotRenderedError, pickle.dumps, response) # But if we render the response, we can pickle it. response.render() pickled_response = pickle.dumps(response) unpickled_response = pickle.loads(pickled_response) self.assertEqual(unpickled_response.content, response.content) self.assertEqual(unpickled_response['content-type'], response['content-type']) self.assertEqual(unpickled_response.status_code, response.status_code) # ...and the unpickled response doesn't have the # template-related attributes, so it can't be re-rendered template_attrs = ('template_name', 'context_data', '_post_render_callbacks', '_request', '_current_app') for attr in template_attrs: self.assertFalse(hasattr(unpickled_response, attr)) # ...and requesting any of those attributes raises an exception for attr in template_attrs: with self.assertRaises(AttributeError): getattr(unpickled_response, attr) def test_repickling(self): response = SimpleTemplateResponse('first/test.html', { 'value': 123, 'fn': datetime.now, }) self.assertRaises(ContentNotRenderedError, pickle.dumps, response) response.render() pickled_response = pickle.dumps(response) unpickled_response = pickle.loads(pickled_response) pickle.dumps(unpickled_response) @override_settings( MIDDLEWARE_CLASSES=settings.MIDDLEWARE_CLASSES + [ 'template_tests.test_response.CustomURLConfMiddleware' ], ROOT_URLCONF='template_tests.urls', ) class CustomURLConfTest(SimpleTestCase): def test_custom_urlconf(self): response = self.client.get('/template_response_view/') self.assertEqual(response.status_code, 200) self.assertContains(response, 'This is where you can find the snark: /snark/') @override_settings( CACHE_MIDDLEWARE_SECONDS=2.0, MIDDLEWARE_CLASSES=settings.MIDDLEWARE_CLASSES + [ 'django.middleware.cache.FetchFromCacheMiddleware', 'django.middleware.cache.UpdateCacheMiddleware', ], ROOT_URLCONF='template_tests.alternate_urls', ) class CacheMiddlewareTest(SimpleTestCase): def test_middleware_caching(self): response = self.client.get('/template_response_view/') self.assertEqual(response.status_code, 200) time.sleep(1.0) response2 = self.client.get('/template_response_view/') self.assertEqual(response2.status_code, 200) self.assertEqual(response.content, response2.content) time.sleep(2.0) # Let the cache expire and test again response2 = self.client.get('/template_response_view/') self.assertEqual(response2.status_code, 200) self.assertNotEqual(response.content, response2.content)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5927, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1160, 492, 9470, 12, 28156, 199, 504, 1639, 14, 1160, 14, 1310, 492, 334, 272, 6646, 1763, 5349, 2995, 547, 12, 5870, 31036, 12, 29264, 12, 199, 9, 199, 504, 1639, 14, 396, 492, 334, 272, 18638, 12, 24424, 12, 3686, 63, 5451, 12, 4278, 63, 1751, 12, 199, 9, 199, 504, 1639, 14, 396, 14, 1208, 492, 4409, 63, 12264, 18, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 6019, 3849, 199, 199, 504, 1275, 1208, 492, 24877, 63, 3022, 421, 199, 318, 511, 63, 6459, 8, 1069, 304, 272, 372, 791, 10547, 356, 283, 5066, 936, 199, 396, 63, 6459, 63, 354, 275, 283, 1160, 63, 2219, 14, 396, 63, 1310, 14, 396, 63, 6459, 7, 421, 199, 3, 437, 511, 10816, 626, 25801, 282, 7937, 2851, 8930, 199, 533, 8388, 2632, 8930, 6608, 8, 785, 304, 272, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 1056, 14, 21801, 275, 283, 1160, 63, 2219, 14, 17170, 63, 3603, 7, 421, 199, 533, 5870, 31036, 774, 8, 17968, 304, 339, 347, 485, 1310, 8, 277, 12, 1978, 534, 1421, 297, 627, 589, 12, 1011, 958, 304, 267, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 8, 1160, 9, 267, 372, 5870, 31036, 8, 1160, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 511, 63, 1160, 63, 26702, 4007, 8, 277, 304, 267, 1177, 275, 5870, 31036, 360, 2246, 15, 396, 14, 1360, 358, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 7147, 1978, 60, 78, 358, 398, 7009, 275, 788, 1421, 14, 1360, 297, 283, 4375, 15, 396, 14, 1360, 297, 283, 2246, 15, 396, 14, 1360, 418, 267, 1177, 275, 5870, 31036, 8, 5876, 9, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 11906, 1978, 60, 78, 358, 398, 1177, 275, 291, 423, 1310, 342, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 339, 347, 511, 63, 10306, 63, 66, 11124, 8, 277, 304, 267, 327, 5027, 330, 11124, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 267, 1177, 14, 3352, 342, 267, 291, 14, 1815, 8, 1310, 14, 374, 63, 16841, 9, 339, 347, 511, 63, 3352, 8, 277, 304, 267, 327, 1177, 365, 440, 295, 13, 16841, 1928, 314, 3795, 1240, 267, 1177, 275, 291, 423, 1310, 1252, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 398, 327, 295, 66, 11124, 3181, 1133, 1570, 314, 8018, 1564, 267, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 360, 1700, 3638, 15507, 28404, 267, 1177, 14, 1160, 63, 354, 275, 1978, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 398, 327, 1325, 8018, 1564, 883, 506, 10087, 701, 10250, 267, 327, 4260, 1564, 267, 1177, 14, 1317, 275, 283, 1700, 7, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1700, 358, 339, 347, 511, 63, 12575, 63, 324, 16841, 8, 277, 304, 267, 327, 625, 16841, 1177, 6534, 376, 1919, 641, 8494, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 398, 347, 8494, 837, 288, 367, 671, 315, 1177, 26, 355, 986, 267, 291, 14, 1855, 8, 2714, 1763, 5349, 2995, 547, 12, 8494, 9, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 339, 347, 511, 63, 12575, 63, 16841, 8, 277, 304, 267, 327, 8494, 5419, 367, 8018, 9320, 267, 1177, 275, 291, 423, 1310, 1252, 3352, 342, 267, 522, 275, 359, 88, 367, 671, 315, 1177, 61, 267, 291, 14, 629, 8, 470, 12, 359, 66, 7, 1421, 1105, 339, 347, 511, 63, 1317, 63, 2732, 63, 324, 16841, 8, 277, 304, 267, 327, 625, 16841, 1177, 6534, 376, 1919, 1380, 1564, 365, 13810, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 267, 291, 14, 1855, 8, 2714, 1763, 5349, 2995, 547, 12, 2400, 26, 1177, 14, 1317, 9, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 339, 347, 511, 63, 1317, 63, 2732, 63, 16841, 8, 277, 304, 267, 327, 8018, 1177, 1564, 883, 506, 13810, 267, 1177, 275, 291, 423, 1310, 1252, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 339, 347, 511, 63, 409, 63, 1317, 8, 277, 304, 267, 327, 1564, 883, 506, 10087, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 267, 1177, 14, 1317, 275, 283, 8283, 7, 267, 291, 14, 1815, 8, 1310, 14, 374, 63, 16841, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 1159, 28024, 358, 267, 1177, 14, 1317, 275, 283, 6185, 7, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 6185, 358, 339, 347, 511, 63, 807, 63, 1100, 8, 277, 304, 267, 1177, 275, 291, 423, 1310, 18976, 3925, 3586, 3638, 21620, 23688, 3303, 791, 1421, 356, 283, 1700, 3071, 267, 291, 14, 629, 8, 1310, 14, 1100, 63, 576, 12, 791, 1421, 356, 283, 1700, 3071, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1700, 358, 339, 768, 4247, 63, 5451, 8, 3710, 29, 497, 19797, 6019, 3849, 9, 272, 347, 511, 63, 1100, 63, 842, 8, 277, 304, 267, 1177, 275, 291, 423, 1310, 18976, 3925, 3586, 3638, 21620, 23688, 3303, 9470, 3252, 1421, 356, 283, 1700, 20219, 267, 291, 14, 629, 8, 1310, 14, 1100, 63, 576, 855, 533, 3108, 9470, 9, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1700, 358, 339, 347, 511, 63, 958, 8, 277, 304, 267, 1177, 275, 291, 423, 1310 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5927, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1160, 492, 9470, 12, 28156, 199, 504, 1639, 14, 1160, 14, 1310, 492, 334, 272, 6646, 1763, 5349, 2995, 547, 12, 5870, 31036, 12, 29264, 12, 199, 9, 199, 504, 1639, 14, 396, 492, 334, 272, 18638, 12, 24424, 12, 3686, 63, 5451, 12, 4278, 63, 1751, 12, 199, 9, 199, 504, 1639, 14, 396, 14, 1208, 492, 4409, 63, 12264, 18, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 6019, 3849, 199, 199, 504, 1275, 1208, 492, 24877, 63, 3022, 421, 199, 318, 511, 63, 6459, 8, 1069, 304, 272, 372, 791, 10547, 356, 283, 5066, 936, 199, 396, 63, 6459, 63, 354, 275, 283, 1160, 63, 2219, 14, 396, 63, 1310, 14, 396, 63, 6459, 7, 421, 199, 3, 437, 511, 10816, 626, 25801, 282, 7937, 2851, 8930, 199, 533, 8388, 2632, 8930, 6608, 8, 785, 304, 272, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 1056, 14, 21801, 275, 283, 1160, 63, 2219, 14, 17170, 63, 3603, 7, 421, 199, 533, 5870, 31036, 774, 8, 17968, 304, 339, 347, 485, 1310, 8, 277, 12, 1978, 534, 1421, 297, 627, 589, 12, 1011, 958, 304, 267, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 8, 1160, 9, 267, 372, 5870, 31036, 8, 1160, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 511, 63, 1160, 63, 26702, 4007, 8, 277, 304, 267, 1177, 275, 5870, 31036, 360, 2246, 15, 396, 14, 1360, 358, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 7147, 1978, 60, 78, 358, 398, 7009, 275, 788, 1421, 14, 1360, 297, 283, 4375, 15, 396, 14, 1360, 297, 283, 2246, 15, 396, 14, 1360, 418, 267, 1177, 275, 5870, 31036, 8, 5876, 9, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 11906, 1978, 60, 78, 358, 398, 1177, 275, 291, 423, 1310, 342, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 339, 347, 511, 63, 10306, 63, 66, 11124, 8, 277, 304, 267, 327, 5027, 330, 11124, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 267, 1177, 14, 3352, 342, 267, 291, 14, 1815, 8, 1310, 14, 374, 63, 16841, 9, 339, 347, 511, 63, 3352, 8, 277, 304, 267, 327, 1177, 365, 440, 295, 13, 16841, 1928, 314, 3795, 1240, 267, 1177, 275, 291, 423, 1310, 1252, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 398, 327, 295, 66, 11124, 3181, 1133, 1570, 314, 8018, 1564, 267, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 360, 1700, 3638, 15507, 28404, 267, 1177, 14, 1160, 63, 354, 275, 1978, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 398, 327, 1325, 8018, 1564, 883, 506, 10087, 701, 10250, 267, 327, 4260, 1564, 267, 1177, 14, 1317, 275, 283, 1700, 7, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1700, 358, 339, 347, 511, 63, 12575, 63, 324, 16841, 8, 277, 304, 267, 327, 625, 16841, 1177, 6534, 376, 1919, 641, 8494, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 398, 347, 8494, 837, 288, 367, 671, 315, 1177, 26, 355, 986, 267, 291, 14, 1855, 8, 2714, 1763, 5349, 2995, 547, 12, 8494, 9, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 339, 347, 511, 63, 12575, 63, 16841, 8, 277, 304, 267, 327, 8494, 5419, 367, 8018, 9320, 267, 1177, 275, 291, 423, 1310, 1252, 3352, 342, 267, 522, 275, 359, 88, 367, 671, 315, 1177, 61, 267, 291, 14, 629, 8, 470, 12, 359, 66, 7, 1421, 1105, 339, 347, 511, 63, 1317, 63, 2732, 63, 324, 16841, 8, 277, 304, 267, 327, 625, 16841, 1177, 6534, 376, 1919, 1380, 1564, 365, 13810, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 267, 291, 14, 1855, 8, 2714, 1763, 5349, 2995, 547, 12, 2400, 26, 1177, 14, 1317, 9, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 339, 347, 511, 63, 1317, 63, 2732, 63, 16841, 8, 277, 304, 267, 327, 8018, 1177, 1564, 883, 506, 13810, 267, 1177, 275, 291, 423, 1310, 1252, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1421, 358, 339, 347, 511, 63, 409, 63, 1317, 8, 277, 304, 267, 327, 1564, 883, 506, 10087, 267, 1177, 275, 291, 423, 1310, 342, 267, 291, 14, 3334, 8, 1310, 14, 374, 63, 16841, 9, 267, 1177, 14, 1317, 275, 283, 8283, 7, 267, 291, 14, 1815, 8, 1310, 14, 374, 63, 16841, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 1159, 28024, 358, 267, 1177, 14, 1317, 275, 283, 6185, 7, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 6185, 358, 339, 347, 511, 63, 807, 63, 1100, 8, 277, 304, 267, 1177, 275, 291, 423, 1310, 18976, 3925, 3586, 3638, 21620, 23688, 3303, 791, 1421, 356, 283, 1700, 3071, 267, 291, 14, 629, 8, 1310, 14, 1100, 63, 576, 12, 791, 1421, 356, 283, 1700, 3071, 267, 1177, 14, 3352, 342, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 1700, 358, 339, 768, 4247, 63, 5451, 8, 3710, 29, 497, 19797, 6019, 3849, 9, 272, 347, 511, 63, 1100, 63, 842, 8, 277, 304, 267, 1177, 275, 291, 423, 1310, 18976, 3925, 3586, 3638, 21620, 23688, 3303, 9470, 3252, 1421, 356, 283, 1700, 20219, 267, 291, 14, 629, 8, 1310, 14, 1100, 63, 576, 855, 533, 3108, 9470, 9, 267,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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 ]
mscherer/ansible
lib/ansible/plugins/__init__.py
15
13328
# (c) 2012, Daniel Hokka Zakrisson <daniel@hozac.com> # (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> and others # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import glob import imp import inspect import os import os.path import sys from ansible import constants as C from ansible.utils.display import Display from ansible import errors MODULE_CACHE = {} PATH_CACHE = {} PLUGIN_PATH_CACHE = {} _basedirs = [] def push_basedir(basedir): # avoid pushing the same absolute dir more than once basedir = os.path.realpath(basedir) if basedir not in _basedirs: _basedirs.insert(0, basedir) def get_all_plugin_loaders(): return [(name, obj) for (name, obj) in inspect.getmembers(sys.modules[__name__]) if isinstance(obj, PluginLoader)] class PluginLoader: ''' PluginLoader loads plugins from the configured plugin directories. It searches for plugins by iterating through the combined list of play basedirs, configured paths, and the python path. The first match is used. ''' def __init__(self, class_name, package, config, subdir, aliases={}, required_base_class=None): self.class_name = class_name self.base_class = required_base_class self.package = package self.config = config self.subdir = subdir self.aliases = aliases if not class_name in MODULE_CACHE: MODULE_CACHE[class_name] = {} if not class_name in PATH_CACHE: PATH_CACHE[class_name] = None if not class_name in PLUGIN_PATH_CACHE: PLUGIN_PATH_CACHE[class_name] = {} self._module_cache = MODULE_CACHE[class_name] self._paths = PATH_CACHE[class_name] self._plugin_path_cache = PLUGIN_PATH_CACHE[class_name] self._extra_dirs = [] self._searched_paths = set() def __setstate__(self, data): ''' Deserializer. ''' class_name = data.get('class_name') package = data.get('package') config = data.get('config') subdir = data.get('subdir') aliases = data.get('aliases') base_class = data.get('base_class') PATH_CACHE[class_name] = data.get('PATH_CACHE') PLUGIN_PATH_CACHE[class_name] = data.get('PLUGIN_PATH_CACHE') self.__init__(class_name, package, config, subdir, aliases, base_class) self._extra_dirs = data.get('_extra_dirs', []) self._searched_paths = data.get('_searched_paths', set()) def __getstate__(self): ''' Serializer. ''' return dict( class_name = self.class_name, base_class = self.base_class, package = self.package, config = self.config, subdir = self.subdir, aliases = self.aliases, _extra_dirs = self._extra_dirs, _searched_paths = self._searched_paths, PATH_CACHE = PATH_CACHE[self.class_name], PLUGIN_PATH_CACHE = PLUGIN_PATH_CACHE[self.class_name], ) def print_paths(self): ''' Returns a string suitable for printing of the search path ''' # Uses a list to get the order right ret = [] for i in self._get_paths(): if i not in ret: ret.append(i) return os.pathsep.join(ret) def _all_directories(self, dir): results = [] results.append(dir) for root, subdirs, files in os.walk(dir): if '__init__.py' in files: for x in subdirs: results.append(os.path.join(root,x)) return results def _get_package_paths(self): ''' Gets the path of a Python package ''' paths = [] if not self.package: return [] if not hasattr(self, 'package_path'): m = __import__(self.package) parts = self.package.split('.')[1:] self.package_path = os.path.join(os.path.dirname(m.__file__), *parts) paths.extend(self._all_directories(self.package_path)) return paths def _get_paths(self): ''' Return a list of paths to search for plugins in ''' if self._paths is not None: return self._paths ret = self._extra_dirs[:] for basedir in _basedirs: fullpath = os.path.realpath(os.path.join(basedir, self.subdir)) if os.path.isdir(fullpath): files = glob.glob("%s/*" % fullpath) # allow directories to be two levels deep files2 = glob.glob("%s/*/*" % fullpath) if files2 is not None: files.extend(files2) for file in files: if os.path.isdir(file) and file not in ret: ret.append(file) if fullpath not in ret: ret.append(fullpath) # look in any configured plugin paths, allow one level deep for subcategories if self.config is not None: configured_paths = self.config.split(os.pathsep) for path in configured_paths: path = os.path.realpath(os.path.expanduser(path)) contents = glob.glob("%s/*" % path) + glob.glob("%s/*/*" % path) for c in contents: if os.path.isdir(c) and c not in ret: ret.append(c) if path not in ret: ret.append(path) # look for any plugins installed in the package subtree ret.extend(self._get_package_paths()) # cache and return the result self._paths = ret return ret def add_directory(self, directory, with_subdir=False): ''' Adds an additional directory to the search path ''' directory = os.path.realpath(directory) if directory is not None: if with_subdir: directory = os.path.join(directory, self.subdir) if directory not in self._extra_dirs: # append the directory and invalidate the path cache self._extra_dirs.append(directory) self._paths = None def find_plugin(self, name, suffixes=None): ''' Find a plugin named name ''' if not suffixes: if self.class_name: suffixes = ['.py'] else: suffixes = ['.py', ''] potential_names = frozenset('%s%s' % (name, s) for s in suffixes) for full_name in potential_names: if full_name in self._plugin_path_cache: return self._plugin_path_cache[full_name] found = None for path in [p for p in self._get_paths() if p not in self._searched_paths]: if os.path.isdir(path): try: full_paths = (os.path.join(path, f) for f in os.listdir(path)) except OSError as e: d = Display() d.warning("Error accessing plugin paths: %s" % str(e)) for full_path in (f for f in full_paths if os.path.isfile(f)): for suffix in suffixes: if full_path.endswith(suffix): full_name = os.path.basename(full_path) break else: # Yes, this is a for-else: http://bit.ly/1ElPkyg continue if full_name not in self._plugin_path_cache: self._plugin_path_cache[full_name] = full_path self._searched_paths.add(path) for full_name in potential_names: if full_name in self._plugin_path_cache: return self._plugin_path_cache[full_name] # if nothing is found, try finding alias/deprecated if not name.startswith('_'): for alias_name in ('_%s' % n for n in potential_names): # We've already cached all the paths at this point if alias_name in self._plugin_path_cache: if not os.path.islink(self._plugin_path_cache[alias_name]): d = Display() d.warning('%s has been deprecated, which means ' 'it is kept for backwards compatibility ' 'but usage is discouraged. The module ' 'documentation details page may explain ' 'more about this rationale.' % name.lstrip('_')) return self._plugin_path_cache[alias_name] return None def has_plugin(self, name): ''' Checks if a plugin named name exists ''' return self.find_plugin(name) is not None __contains__ = has_plugin def get(self, name, *args, **kwargs): ''' instantiates a plugin of the given name using arguments ''' if name in self.aliases: name = self.aliases[name] path = self.find_plugin(name) if path is None: return None if path not in self._module_cache: self._module_cache[path] = imp.load_source('.'.join([self.package, name]), path) if kwargs.get('class_only', False): obj = getattr(self._module_cache[path], self.class_name) else: obj = getattr(self._module_cache[path], self.class_name)(*args, **kwargs) if self.base_class and self.base_class not in [base.__name__ for base in obj.__class__.__bases__]: return None return obj def all(self, *args, **kwargs): ''' instantiates all plugins with the same arguments ''' for i in self._get_paths(): matches = glob.glob(os.path.join(i, "*.py")) matches.sort() for path in matches: name, ext = os.path.splitext(os.path.basename(path)) if name.startswith("_"): continue if path not in self._module_cache: self._module_cache[path] = imp.load_source('.'.join([self.package, name]), path) if kwargs.get('class_only', False): obj = getattr(self._module_cache[path], self.class_name) else: obj = getattr(self._module_cache[path], self.class_name)(*args, **kwargs) if self.base_class and self.base_class not in [base.__name__ for base in obj.__class__.__bases__]: continue # set extra info on the module, in case we want it later setattr(obj, '_original_path', path) yield obj action_loader = PluginLoader( 'ActionModule', 'ansible.plugins.action', C.DEFAULT_ACTION_PLUGIN_PATH, 'action_plugins', required_base_class='ActionBase', ) cache_loader = PluginLoader( 'CacheModule', 'ansible.plugins.cache', C.DEFAULT_CACHE_PLUGIN_PATH, 'cache_plugins', ) callback_loader = PluginLoader( 'CallbackModule', 'ansible.plugins.callback', C.DEFAULT_CALLBACK_PLUGIN_PATH, 'callback_plugins', ) connection_loader = PluginLoader( 'Connection', 'ansible.plugins.connections', C.DEFAULT_CONNECTION_PLUGIN_PATH, 'connection_plugins', aliases={'paramiko': 'paramiko_ssh'}, required_base_class='ConnectionBase', ) shell_loader = PluginLoader( 'ShellModule', 'ansible.plugins.shell', 'shell_plugins', 'shell_plugins', ) module_loader = PluginLoader( '', 'ansible.modules', C.DEFAULT_MODULE_PATH, 'library', ) lookup_loader = PluginLoader( 'LookupModule', 'ansible.plugins.lookup', C.DEFAULT_LOOKUP_PLUGIN_PATH, 'lookup_plugins', required_base_class='LookupBase', ) vars_loader = PluginLoader( 'VarsModule', 'ansible.plugins.vars', C.DEFAULT_VARS_PLUGIN_PATH, 'vars_plugins', ) filter_loader = PluginLoader( 'FilterModule', 'ansible.plugins.filter', C.DEFAULT_FILTER_PLUGIN_PATH, 'filter_plugins', ) fragment_loader = PluginLoader( 'ModuleDocFragment', 'ansible.utils.module_docs_fragments', os.path.join(os.path.dirname(__file__), 'module_docs_fragments'), '', ) strategy_loader = PluginLoader( 'StrategyModule', 'ansible.plugins.strategies', None, 'strategy_plugins', required_base_class='StrategyBase', )
gpl-3.0
[ 3, 334, 67, 9, 6029, 12, 24747, 14769, 869, 745, 7351, 3107, 1151, 322, 385, 265, 665, 24863, 14769, 32, 526, 90, 645, 14, 957, 30, 199, 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 436, 11789, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 5739, 199, 646, 1742, 199, 646, 6485, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 984, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 492, 2552, 199, 199, 10001, 63, 8677, 275, 1052, 199, 3243, 63, 8677, 275, 1052, 199, 19108, 63, 3243, 63, 8677, 275, 1052, 199, 63, 1095, 3220, 275, 942, 199, 199, 318, 6675, 63, 12484, 8, 12484, 304, 272, 327, 5126, 6675, 316, 314, 2011, 3679, 2935, 1655, 2419, 5403, 272, 19380, 275, 747, 14, 515, 14, 11091, 8, 12484, 9, 272, 340, 19380, 440, 315, 485, 1095, 3220, 26, 267, 485, 1095, 3220, 14, 3176, 8, 16, 12, 19380, 9, 199, 199, 318, 664, 63, 452, 63, 2718, 63, 16370, 837, 272, 372, 3842, 354, 12, 1559, 9, 367, 334, 354, 12, 1559, 9, 315, 6485, 14, 28719, 8, 1274, 14, 3112, 28894, 354, 363, 566, 340, 1228, 8, 1113, 12, 11349, 5455, 1874, 199, 199, 533, 11349, 5455, 26, 339, 1449, 272, 11349, 5455, 14404, 8963, 687, 314, 7526, 3589, 6602, 14, 339, 2779, 21858, 367, 8963, 701, 25012, 4012, 314, 12149, 769, 402, 272, 5232, 1300, 3220, 12, 7526, 3792, 12, 436, 314, 2366, 931, 14, 272, 710, 1642, 1336, 365, 1202, 14, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 1021, 63, 354, 12, 2559, 12, 1101, 12, 15488, 12, 5481, 10324, 1415, 63, 1095, 63, 533, 29, 403, 304, 398, 291, 14, 533, 63, 354, 260, 275, 1021, 63, 354, 267, 291, 14, 1095, 63, 533, 260, 275, 1415, 63, 1095, 63, 533, 267, 291, 14, 2491, 3322, 275, 2559, 267, 291, 14, 888, 3777, 275, 1101, 267, 291, 14, 10622, 3777, 275, 15488, 267, 291, 14, 8602, 3322, 275, 5481, 398, 340, 440, 1021, 63, 354, 315, 30223, 63, 8677, 26, 288, 30223, 63, 8677, 59, 533, 63, 354, 61, 275, 1052, 267, 340, 440, 1021, 63, 354, 315, 15097, 63, 8677, 26, 288, 15097, 63, 8677, 59, 533, 63, 354, 61, 275, 488, 267, 340, 440, 1021, 63, 354, 315, 10092, 10134, 568, 63, 3243, 63, 8677, 26, 288, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 533, 63, 354, 61, 275, 1052, 398, 291, 423, 578, 63, 1637, 420, 275, 30223, 63, 8677, 59, 533, 63, 354, 61, 267, 291, 423, 3771, 3777, 275, 15097, 63, 8677, 59, 533, 63, 354, 61, 267, 291, 423, 2718, 63, 515, 63, 1637, 275, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 533, 63, 354, 61, 398, 291, 423, 2911, 63, 3220, 275, 942, 267, 291, 423, 1733, 379, 63, 3771, 275, 663, 342, 339, 347, 636, 17212, 721, 277, 12, 666, 304, 267, 1449, 267, 1487, 8349, 14, 267, 1449, 398, 1021, 63, 354, 275, 666, 14, 362, 360, 533, 63, 354, 358, 267, 2559, 259, 275, 666, 14, 362, 360, 2491, 358, 267, 1101, 258, 275, 666, 14, 362, 360, 888, 358, 267, 15488, 258, 275, 666, 14, 362, 360, 10622, 358, 267, 5481, 259, 275, 666, 14, 362, 360, 8602, 358, 267, 1300, 63, 533, 275, 666, 14, 362, 360, 1095, 63, 533, 358, 398, 15097, 63, 8677, 59, 533, 63, 354, 61, 275, 666, 14, 362, 360, 3243, 63, 8677, 358, 267, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 533, 63, 354, 61, 275, 666, 14, 362, 360, 19108, 63, 3243, 63, 8677, 358, 398, 291, 855, 826, 721, 533, 63, 354, 12, 2559, 12, 1101, 12, 15488, 12, 5481, 12, 1300, 63, 533, 9, 267, 291, 423, 2911, 63, 3220, 275, 666, 14, 362, 6412, 2911, 63, 3220, 297, 3073, 267, 291, 423, 1733, 379, 63, 3771, 275, 666, 14, 362, 6412, 1733, 379, 63, 3771, 297, 663, 1012, 339, 347, 636, 16011, 721, 277, 304, 267, 1449, 267, 25555, 14, 267, 1449, 398, 372, 1211, 8, 288, 1021, 63, 354, 263, 275, 291, 14, 533, 63, 354, 12, 288, 1300, 63, 533, 263, 275, 291, 14, 1095, 63, 533, 12, 288, 2559, 3698, 275, 291, 14, 2491, 12, 288, 1101, 3322, 275, 291, 14, 888, 12, 288, 15488, 3322, 275, 291, 14, 10622, 12, 288, 5481, 3698, 275, 291, 14, 8602, 12, 288, 485, 2911, 63, 3220, 755, 275, 291, 423, 2911, 63, 3220, 12, 288, 485, 1733, 379, 63, 3771, 257, 275, 291, 423, 1733, 379, 63, 3771, 12, 288, 15097, 63, 8677, 263, 275, 15097, 63, 8677, 59, 277, 14, 533, 63, 354, 467, 288, 10092, 10134, 568, 63, 3243, 63, 8677, 275, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 277, 14, 533, 63, 354, 467, 267, 776, 339, 347, 870, 63, 3771, 8, 277, 304, 267, 1449, 1803, 282, 1059, 11233, 367, 16116, 402, 314, 2754, 931 ]
[ 334, 67, 9, 6029, 12, 24747, 14769, 869, 745, 7351, 3107, 1151, 322, 385, 265, 665, 24863, 14769, 32, 526, 90, 645, 14, 957, 30, 199, 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 436, 11789, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 5739, 199, 646, 1742, 199, 646, 6485, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 984, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 492, 2552, 199, 199, 10001, 63, 8677, 275, 1052, 199, 3243, 63, 8677, 275, 1052, 199, 19108, 63, 3243, 63, 8677, 275, 1052, 199, 63, 1095, 3220, 275, 942, 199, 199, 318, 6675, 63, 12484, 8, 12484, 304, 272, 327, 5126, 6675, 316, 314, 2011, 3679, 2935, 1655, 2419, 5403, 272, 19380, 275, 747, 14, 515, 14, 11091, 8, 12484, 9, 272, 340, 19380, 440, 315, 485, 1095, 3220, 26, 267, 485, 1095, 3220, 14, 3176, 8, 16, 12, 19380, 9, 199, 199, 318, 664, 63, 452, 63, 2718, 63, 16370, 837, 272, 372, 3842, 354, 12, 1559, 9, 367, 334, 354, 12, 1559, 9, 315, 6485, 14, 28719, 8, 1274, 14, 3112, 28894, 354, 363, 566, 340, 1228, 8, 1113, 12, 11349, 5455, 1874, 199, 199, 533, 11349, 5455, 26, 339, 1449, 272, 11349, 5455, 14404, 8963, 687, 314, 7526, 3589, 6602, 14, 339, 2779, 21858, 367, 8963, 701, 25012, 4012, 314, 12149, 769, 402, 272, 5232, 1300, 3220, 12, 7526, 3792, 12, 436, 314, 2366, 931, 14, 272, 710, 1642, 1336, 365, 1202, 14, 272, 1449, 339, 347, 636, 826, 721, 277, 12, 1021, 63, 354, 12, 2559, 12, 1101, 12, 15488, 12, 5481, 10324, 1415, 63, 1095, 63, 533, 29, 403, 304, 398, 291, 14, 533, 63, 354, 260, 275, 1021, 63, 354, 267, 291, 14, 1095, 63, 533, 260, 275, 1415, 63, 1095, 63, 533, 267, 291, 14, 2491, 3322, 275, 2559, 267, 291, 14, 888, 3777, 275, 1101, 267, 291, 14, 10622, 3777, 275, 15488, 267, 291, 14, 8602, 3322, 275, 5481, 398, 340, 440, 1021, 63, 354, 315, 30223, 63, 8677, 26, 288, 30223, 63, 8677, 59, 533, 63, 354, 61, 275, 1052, 267, 340, 440, 1021, 63, 354, 315, 15097, 63, 8677, 26, 288, 15097, 63, 8677, 59, 533, 63, 354, 61, 275, 488, 267, 340, 440, 1021, 63, 354, 315, 10092, 10134, 568, 63, 3243, 63, 8677, 26, 288, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 533, 63, 354, 61, 275, 1052, 398, 291, 423, 578, 63, 1637, 420, 275, 30223, 63, 8677, 59, 533, 63, 354, 61, 267, 291, 423, 3771, 3777, 275, 15097, 63, 8677, 59, 533, 63, 354, 61, 267, 291, 423, 2718, 63, 515, 63, 1637, 275, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 533, 63, 354, 61, 398, 291, 423, 2911, 63, 3220, 275, 942, 267, 291, 423, 1733, 379, 63, 3771, 275, 663, 342, 339, 347, 636, 17212, 721, 277, 12, 666, 304, 267, 1449, 267, 1487, 8349, 14, 267, 1449, 398, 1021, 63, 354, 275, 666, 14, 362, 360, 533, 63, 354, 358, 267, 2559, 259, 275, 666, 14, 362, 360, 2491, 358, 267, 1101, 258, 275, 666, 14, 362, 360, 888, 358, 267, 15488, 258, 275, 666, 14, 362, 360, 10622, 358, 267, 5481, 259, 275, 666, 14, 362, 360, 8602, 358, 267, 1300, 63, 533, 275, 666, 14, 362, 360, 1095, 63, 533, 358, 398, 15097, 63, 8677, 59, 533, 63, 354, 61, 275, 666, 14, 362, 360, 3243, 63, 8677, 358, 267, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 533, 63, 354, 61, 275, 666, 14, 362, 360, 19108, 63, 3243, 63, 8677, 358, 398, 291, 855, 826, 721, 533, 63, 354, 12, 2559, 12, 1101, 12, 15488, 12, 5481, 12, 1300, 63, 533, 9, 267, 291, 423, 2911, 63, 3220, 275, 666, 14, 362, 6412, 2911, 63, 3220, 297, 3073, 267, 291, 423, 1733, 379, 63, 3771, 275, 666, 14, 362, 6412, 1733, 379, 63, 3771, 297, 663, 1012, 339, 347, 636, 16011, 721, 277, 304, 267, 1449, 267, 25555, 14, 267, 1449, 398, 372, 1211, 8, 288, 1021, 63, 354, 263, 275, 291, 14, 533, 63, 354, 12, 288, 1300, 63, 533, 263, 275, 291, 14, 1095, 63, 533, 12, 288, 2559, 3698, 275, 291, 14, 2491, 12, 288, 1101, 3322, 275, 291, 14, 888, 12, 288, 15488, 3322, 275, 291, 14, 10622, 12, 288, 5481, 3698, 275, 291, 14, 8602, 12, 288, 485, 2911, 63, 3220, 755, 275, 291, 423, 2911, 63, 3220, 12, 288, 485, 1733, 379, 63, 3771, 257, 275, 291, 423, 1733, 379, 63, 3771, 12, 288, 15097, 63, 8677, 263, 275, 15097, 63, 8677, 59, 277, 14, 533, 63, 354, 467, 288, 10092, 10134, 568, 63, 3243, 63, 8677, 275, 10092, 10134, 568, 63, 3243, 63, 8677, 59, 277, 14, 533, 63, 354, 467, 267, 776, 339, 347, 870, 63, 3771, 8, 277, 304, 267, 1449, 1803, 282, 1059, 11233, 367, 16116, 402, 314, 2754, 931, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gauravbose/digital-menu
tests/lookup/tests.py
33
36080
from __future__ import unicode_literals from datetime import datetime from operator import attrgetter from unittest import skipUnless from django.core.exceptions import FieldError from django.db import connection from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature from .models import Article, Author, Game, MyISAMArticle, Player, Season, Tag class LookupTests(TestCase): def setUp(self): # Create a few Authors. self.au1 = Author(name='Author 1') self.au1.save() self.au2 = Author(name='Author 2') self.au2.save() # Create a couple of Articles. self.a1 = Article(headline='Article 1', pub_date=datetime(2005, 7, 26), author=self.au1) self.a1.save() self.a2 = Article(headline='Article 2', pub_date=datetime(2005, 7, 27), author=self.au1) self.a2.save() self.a3 = Article(headline='Article 3', pub_date=datetime(2005, 7, 27), author=self.au1) self.a3.save() self.a4 = Article(headline='Article 4', pub_date=datetime(2005, 7, 28), author=self.au1) self.a4.save() self.a5 = Article(headline='Article 5', pub_date=datetime(2005, 8, 1, 9, 0), author=self.au2) self.a5.save() self.a6 = Article(headline='Article 6', pub_date=datetime(2005, 8, 1, 8, 0), author=self.au2) self.a6.save() self.a7 = Article(headline='Article 7', pub_date=datetime(2005, 7, 27), author=self.au2) self.a7.save() # Create a few Tags. self.t1 = Tag(name='Tag 1') self.t1.save() self.t1.articles.add(self.a1, self.a2, self.a3) self.t2 = Tag(name='Tag 2') self.t2.save() self.t2.articles.add(self.a3, self.a4, self.a5) self.t3 = Tag(name='Tag 3') self.t3.save() self.t3.articles.add(self.a5, self.a6, self.a7) def test_exists(self): # We can use .exists() to check that there are some self.assertTrue(Article.objects.exists()) for a in Article.objects.all(): a.delete() # There should be none now! self.assertFalse(Article.objects.exists()) def test_lookup_int_as_str(self): # Integer value can be queried using string self.assertQuerysetEqual(Article.objects.filter(id__iexact=str(self.a1.id)), ['<Article: Article 1>']) @skipUnlessDBFeature('supports_date_lookup_using_string') def test_lookup_date_as_str(self): # A date lookup can be performed using a string search self.assertQuerysetEqual(Article.objects.filter(pub_date__startswith='2005'), [ '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 7>', '<Article: Article 1>', ]) def test_iterator(self): # Each QuerySet gets iterator(), which is a generator that "lazily" # returns results using database-level iteration. self.assertQuerysetEqual(Article.objects.iterator(), [ 'Article 5', 'Article 6', 'Article 4', 'Article 2', 'Article 3', 'Article 7', 'Article 1', ], transform=attrgetter('headline')) # iterator() can be used on any QuerySet. self.assertQuerysetEqual( Article.objects.filter(headline__endswith='4').iterator(), ['Article 4'], transform=attrgetter('headline')) def test_count(self): # count() returns the number of objects matching search criteria. self.assertEqual(Article.objects.count(), 7) self.assertEqual(Article.objects.filter(pub_date__exact=datetime(2005, 7, 27)).count(), 3) self.assertEqual(Article.objects.filter(headline__startswith='Blah blah').count(), 0) # count() should respect sliced query sets. articles = Article.objects.all() self.assertEqual(articles.count(), 7) self.assertEqual(articles[:4].count(), 4) self.assertEqual(articles[1:100].count(), 6) self.assertEqual(articles[10:100].count(), 0) # Date and date/time lookups can also be done with strings. self.assertEqual(Article.objects.filter(pub_date__exact='2005-07-27 00:00:00').count(), 3) def test_in_bulk(self): # in_bulk() takes a list of IDs and returns a dictionary mapping IDs to objects. arts = Article.objects.in_bulk([self.a1.id, self.a2.id]) self.assertEqual(arts[self.a1.id], self.a1) self.assertEqual(arts[self.a2.id], self.a2) self.assertEqual(Article.objects.in_bulk([self.a3.id]), {self.a3.id: self.a3}) self.assertEqual(Article.objects.in_bulk({self.a3.id}), {self.a3.id: self.a3}) self.assertEqual(Article.objects.in_bulk(frozenset([self.a3.id])), {self.a3.id: self.a3}) self.assertEqual(Article.objects.in_bulk((self.a3.id,)), {self.a3.id: self.a3}) self.assertEqual(Article.objects.in_bulk([1000]), {}) self.assertEqual(Article.objects.in_bulk([]), {}) self.assertEqual(Article.objects.in_bulk(iter([self.a1.id])), {self.a1.id: self.a1}) self.assertEqual(Article.objects.in_bulk(iter([])), {}) self.assertRaises(TypeError, Article.objects.in_bulk) self.assertRaises(TypeError, Article.objects.in_bulk, headline__startswith='Blah') def test_values(self): # values() returns a list of dictionaries instead of object instances -- # and you can specify which fields you want to retrieve. identity = lambda x: x self.assertQuerysetEqual(Article.objects.values('headline'), [ {'headline': 'Article 5'}, {'headline': 'Article 6'}, {'headline': 'Article 4'}, {'headline': 'Article 2'}, {'headline': 'Article 3'}, {'headline': 'Article 7'}, {'headline': 'Article 1'}, ], transform=identity) self.assertQuerysetEqual( Article.objects.filter(pub_date__exact=datetime(2005, 7, 27)).values('id'), [{'id': self.a2.id}, {'id': self.a3.id}, {'id': self.a7.id}], transform=identity) self.assertQuerysetEqual(Article.objects.values('id', 'headline'), [ {'id': self.a5.id, 'headline': 'Article 5'}, {'id': self.a6.id, 'headline': 'Article 6'}, {'id': self.a4.id, 'headline': 'Article 4'}, {'id': self.a2.id, 'headline': 'Article 2'}, {'id': self.a3.id, 'headline': 'Article 3'}, {'id': self.a7.id, 'headline': 'Article 7'}, {'id': self.a1.id, 'headline': 'Article 1'}, ], transform=identity) # You can use values() with iterator() for memory savings, # because iterator() uses database-level iteration. self.assertQuerysetEqual(Article.objects.values('id', 'headline').iterator(), [ {'headline': 'Article 5', 'id': self.a5.id}, {'headline': 'Article 6', 'id': self.a6.id}, {'headline': 'Article 4', 'id': self.a4.id}, {'headline': 'Article 2', 'id': self.a2.id}, {'headline': 'Article 3', 'id': self.a3.id}, {'headline': 'Article 7', 'id': self.a7.id}, {'headline': 'Article 1', 'id': self.a1.id}, ], transform=identity) # The values() method works with "extra" fields specified in extra(select). self.assertQuerysetEqual( Article.objects.extra(select={'id_plus_one': 'id + 1'}).values('id', 'id_plus_one'), [ {'id': self.a5.id, 'id_plus_one': self.a5.id + 1}, {'id': self.a6.id, 'id_plus_one': self.a6.id + 1}, {'id': self.a4.id, 'id_plus_one': self.a4.id + 1}, {'id': self.a2.id, 'id_plus_one': self.a2.id + 1}, {'id': self.a3.id, 'id_plus_one': self.a3.id + 1}, {'id': self.a7.id, 'id_plus_one': self.a7.id + 1}, {'id': self.a1.id, 'id_plus_one': self.a1.id + 1}, ], transform=identity) data = { 'id_plus_one': 'id+1', 'id_plus_two': 'id+2', 'id_plus_three': 'id+3', 'id_plus_four': 'id+4', 'id_plus_five': 'id+5', 'id_plus_six': 'id+6', 'id_plus_seven': 'id+7', 'id_plus_eight': 'id+8', } self.assertQuerysetEqual( Article.objects.filter(id=self.a1.id).extra(select=data).values(*data.keys()), [{ 'id_plus_one': self.a1.id + 1, 'id_plus_two': self.a1.id + 2, 'id_plus_three': self.a1.id + 3, 'id_plus_four': self.a1.id + 4, 'id_plus_five': self.a1.id + 5, 'id_plus_six': self.a1.id + 6, 'id_plus_seven': self.a1.id + 7, 'id_plus_eight': self.a1.id + 8, }], transform=identity) # You can specify fields from forward and reverse relations, just like filter(). self.assertQuerysetEqual( Article.objects.values('headline', 'author__name'), [ {'headline': self.a5.headline, 'author__name': self.au2.name}, {'headline': self.a6.headline, 'author__name': self.au2.name}, {'headline': self.a4.headline, 'author__name': self.au1.name}, {'headline': self.a2.headline, 'author__name': self.au1.name}, {'headline': self.a3.headline, 'author__name': self.au1.name}, {'headline': self.a7.headline, 'author__name': self.au2.name}, {'headline': self.a1.headline, 'author__name': self.au1.name}, ], transform=identity) self.assertQuerysetEqual( Author.objects.values('name', 'article__headline').order_by('name', 'article__headline'), [ {'name': self.au1.name, 'article__headline': self.a1.headline}, {'name': self.au1.name, 'article__headline': self.a2.headline}, {'name': self.au1.name, 'article__headline': self.a3.headline}, {'name': self.au1.name, 'article__headline': self.a4.headline}, {'name': self.au2.name, 'article__headline': self.a5.headline}, {'name': self.au2.name, 'article__headline': self.a6.headline}, {'name': self.au2.name, 'article__headline': self.a7.headline}, ], transform=identity) self.assertQuerysetEqual( Author.objects.values('name', 'article__headline', 'article__tag__name').order_by('name', 'article__headline', 'article__tag__name'), [ {'name': self.au1.name, 'article__headline': self.a1.headline, 'article__tag__name': self.t1.name}, {'name': self.au1.name, 'article__headline': self.a2.headline, 'article__tag__name': self.t1.name}, {'name': self.au1.name, 'article__headline': self.a3.headline, 'article__tag__name': self.t1.name}, {'name': self.au1.name, 'article__headline': self.a3.headline, 'article__tag__name': self.t2.name}, {'name': self.au1.name, 'article__headline': self.a4.headline, 'article__tag__name': self.t2.name}, {'name': self.au2.name, 'article__headline': self.a5.headline, 'article__tag__name': self.t2.name}, {'name': self.au2.name, 'article__headline': self.a5.headline, 'article__tag__name': self.t3.name}, {'name': self.au2.name, 'article__headline': self.a6.headline, 'article__tag__name': self.t3.name}, {'name': self.au2.name, 'article__headline': self.a7.headline, 'article__tag__name': self.t3.name}, ], transform=identity) # However, an exception FieldDoesNotExist will be thrown if you specify # a non-existent field name in values() (a field that is neither in the # model nor in extra(select)). self.assertRaises(FieldError, Article.objects.extra(select={'id_plus_one': 'id + 1'}).values, 'id', 'id_plus_two') # If you don't specify field names to values(), all are returned. self.assertQuerysetEqual(Article.objects.filter(id=self.a5.id).values(), [{ 'id': self.a5.id, 'author_id': self.au2.id, 'headline': 'Article 5', 'pub_date': datetime(2005, 8, 1, 9, 0) }], transform=identity) def test_values_list(self): # values_list() is similar to values(), except that the results are # returned as a list of tuples, rather than a list of dictionaries. # Within each tuple, the order of the elements is the same as the order # of fields in the values_list() call. identity = lambda x: x self.assertQuerysetEqual(Article.objects.values_list('headline'), [ ('Article 5',), ('Article 6',), ('Article 4',), ('Article 2',), ('Article 3',), ('Article 7',), ('Article 1',), ], transform=identity) self.assertQuerysetEqual(Article.objects.values_list('id').order_by('id'), [(self.a1.id,), (self.a2.id,), (self.a3.id,), (self.a4.id,), (self.a5.id,), (self.a6.id,), (self.a7.id,)], transform=identity) self.assertQuerysetEqual( Article.objects.values_list('id', flat=True).order_by('id'), [self.a1.id, self.a2.id, self.a3.id, self.a4.id, self.a5.id, self.a6.id, self.a7.id], transform=identity) self.assertQuerysetEqual( Article.objects.extra(select={'id_plus_one': 'id+1'}) .order_by('id').values_list('id'), [(self.a1.id,), (self.a2.id,), (self.a3.id,), (self.a4.id,), (self.a5.id,), (self.a6.id,), (self.a7.id,)], transform=identity) self.assertQuerysetEqual( Article.objects.extra(select={'id_plus_one': 'id+1'}) .order_by('id').values_list('id_plus_one', 'id'), [ (self.a1.id + 1, self.a1.id), (self.a2.id + 1, self.a2.id), (self.a3.id + 1, self.a3.id), (self.a4.id + 1, self.a4.id), (self.a5.id + 1, self.a5.id), (self.a6.id + 1, self.a6.id), (self.a7.id + 1, self.a7.id) ], transform=identity) self.assertQuerysetEqual( Article.objects.extra(select={'id_plus_one': 'id+1'}) .order_by('id').values_list('id', 'id_plus_one'), [ (self.a1.id, self.a1.id + 1), (self.a2.id, self.a2.id + 1), (self.a3.id, self.a3.id + 1), (self.a4.id, self.a4.id + 1), (self.a5.id, self.a5.id + 1), (self.a6.id, self.a6.id + 1), (self.a7.id, self.a7.id + 1) ], transform=identity) self.assertQuerysetEqual( Author.objects.values_list('name', 'article__headline', 'article__tag__name').order_by('name', 'article__headline', 'article__tag__name'), [ (self.au1.name, self.a1.headline, self.t1.name), (self.au1.name, self.a2.headline, self.t1.name), (self.au1.name, self.a3.headline, self.t1.name), (self.au1.name, self.a3.headline, self.t2.name), (self.au1.name, self.a4.headline, self.t2.name), (self.au2.name, self.a5.headline, self.t2.name), (self.au2.name, self.a5.headline, self.t3.name), (self.au2.name, self.a6.headline, self.t3.name), (self.au2.name, self.a7.headline, self.t3.name), ], transform=identity) self.assertRaises(TypeError, Article.objects.values_list, 'id', 'headline', flat=True) def test_get_next_previous_by(self): # Every DateField and DateTimeField creates get_next_by_FOO() and # get_previous_by_FOO() methods. In the case of identical date values, # these methods will use the ID as a fallback check. This guarantees # that no records are skipped or duplicated. self.assertEqual(repr(self.a1.get_next_by_pub_date()), '<Article: Article 2>') self.assertEqual(repr(self.a2.get_next_by_pub_date()), '<Article: Article 3>') self.assertEqual(repr(self.a2.get_next_by_pub_date(headline__endswith='6')), '<Article: Article 6>') self.assertEqual(repr(self.a3.get_next_by_pub_date()), '<Article: Article 7>') self.assertEqual(repr(self.a4.get_next_by_pub_date()), '<Article: Article 6>') self.assertRaises(Article.DoesNotExist, self.a5.get_next_by_pub_date) self.assertEqual(repr(self.a6.get_next_by_pub_date()), '<Article: Article 5>') self.assertEqual(repr(self.a7.get_next_by_pub_date()), '<Article: Article 4>') self.assertEqual(repr(self.a7.get_previous_by_pub_date()), '<Article: Article 3>') self.assertEqual(repr(self.a6.get_previous_by_pub_date()), '<Article: Article 4>') self.assertEqual(repr(self.a5.get_previous_by_pub_date()), '<Article: Article 6>') self.assertEqual(repr(self.a4.get_previous_by_pub_date()), '<Article: Article 7>') self.assertEqual(repr(self.a3.get_previous_by_pub_date()), '<Article: Article 2>') self.assertEqual(repr(self.a2.get_previous_by_pub_date()), '<Article: Article 1>') def test_escaping(self): # Underscores, percent signs and backslashes have special meaning in the # underlying SQL code, but Django handles the quoting of them automatically. a8 = Article(headline='Article_ with underscore', pub_date=datetime(2005, 11, 20)) a8.save() self.assertQuerysetEqual(Article.objects.filter(headline__startswith='Article'), [ '<Article: Article_ with underscore>', '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 7>', '<Article: Article 1>', ]) self.assertQuerysetEqual(Article.objects.filter(headline__startswith='Article_'), ['<Article: Article_ with underscore>']) a9 = Article(headline='Article% with percent sign', pub_date=datetime(2005, 11, 21)) a9.save() self.assertQuerysetEqual(Article.objects.filter(headline__startswith='Article'), [ '<Article: Article% with percent sign>', '<Article: Article_ with underscore>', '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 7>', '<Article: Article 1>', ]) self.assertQuerysetEqual(Article.objects.filter(headline__startswith='Article%'), ['<Article: Article% with percent sign>']) a10 = Article(headline='Article with \\ backslash', pub_date=datetime(2005, 11, 22)) a10.save() self.assertQuerysetEqual(Article.objects.filter(headline__contains='\\'), ['<Article: Article with \ backslash>']) def test_exclude(self): Article.objects.create(headline='Article_ with underscore', pub_date=datetime(2005, 11, 20)) Article.objects.create(headline='Article% with percent sign', pub_date=datetime(2005, 11, 21)) Article.objects.create(headline='Article with \\ backslash', pub_date=datetime(2005, 11, 22)) # exclude() is the opposite of filter() when doing lookups: self.assertQuerysetEqual( Article.objects.filter(headline__contains='Article').exclude(headline__contains='with'), [ '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 7>', '<Article: Article 1>', ]) self.assertQuerysetEqual(Article.objects.exclude(headline__startswith="Article_"), [ '<Article: Article with \\ backslash>', '<Article: Article% with percent sign>', '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 7>', '<Article: Article 1>', ]) self.assertQuerysetEqual(Article.objects.exclude(headline="Article 7"), [ '<Article: Article with \\ backslash>', '<Article: Article% with percent sign>', '<Article: Article_ with underscore>', '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 1>', ]) def test_none(self): # none() returns a QuerySet that behaves like any other QuerySet object self.assertQuerysetEqual(Article.objects.none(), []) self.assertQuerysetEqual( Article.objects.none().filter(headline__startswith='Article'), []) self.assertQuerysetEqual( Article.objects.filter(headline__startswith='Article').none(), []) self.assertEqual(Article.objects.none().count(), 0) self.assertEqual( Article.objects.none().update(headline="This should not take effect"), 0) self.assertQuerysetEqual( [article for article in Article.objects.none().iterator()], []) def test_in(self): # using __in with an empty list should return an empty query set self.assertQuerysetEqual(Article.objects.filter(id__in=[]), []) self.assertQuerysetEqual(Article.objects.exclude(id__in=[]), [ '<Article: Article 5>', '<Article: Article 6>', '<Article: Article 4>', '<Article: Article 2>', '<Article: Article 3>', '<Article: Article 7>', '<Article: Article 1>', ]) def test_error_messages(self): # Programming errors are pointed out with nice error messages try: Article.objects.filter(pub_date_year='2005').count() self.fail('FieldError not raised') except FieldError as ex: self.assertEqual(str(ex), "Cannot resolve keyword 'pub_date_year' " "into field. Choices are: author, author_id, headline, " "id, pub_date, tag") try: Article.objects.filter(headline__starts='Article') self.fail('FieldError not raised') except FieldError as ex: self.assertEqual( str(ex), "Unsupported lookup 'starts' for CharField " "or join on the field not permitted.") def test_regex(self): # Create some articles with a bit more interesting headlines for testing field lookups: for a in Article.objects.all(): a.delete() now = datetime.now() a1 = Article(pub_date=now, headline='f') a1.save() a2 = Article(pub_date=now, headline='fo') a2.save() a3 = Article(pub_date=now, headline='foo') a3.save() a4 = Article(pub_date=now, headline='fooo') a4.save() a5 = Article(pub_date=now, headline='hey-Foo') a5.save() a6 = Article(pub_date=now, headline='bar') a6.save() a7 = Article(pub_date=now, headline='AbBa') a7.save() a8 = Article(pub_date=now, headline='baz') a8.save() a9 = Article(pub_date=now, headline='baxZ') a9.save() # zero-or-more self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'fo*'), ['<Article: f>', '<Article: fo>', '<Article: foo>', '<Article: fooo>']) self.assertQuerysetEqual(Article.objects.filter(headline__iregex=r'fo*'), [ '<Article: f>', '<Article: fo>', '<Article: foo>', '<Article: fooo>', '<Article: hey-Foo>', ]) # one-or-more self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'fo+'), ['<Article: fo>', '<Article: foo>', '<Article: fooo>']) # wildcard self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'fooo?'), ['<Article: foo>', '<Article: fooo>']) # leading anchor self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'^b'), ['<Article: bar>', '<Article: baxZ>', '<Article: baz>']) self.assertQuerysetEqual(Article.objects.filter(headline__iregex=r'^a'), ['<Article: AbBa>']) # trailing anchor self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'z$'), ['<Article: baz>']) self.assertQuerysetEqual(Article.objects.filter(headline__iregex=r'z$'), ['<Article: baxZ>', '<Article: baz>']) # character sets self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'ba[rz]'), ['<Article: bar>', '<Article: baz>']) self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'ba.[RxZ]'), ['<Article: baxZ>']) self.assertQuerysetEqual(Article.objects.filter(headline__iregex=r'ba[RxZ]'), ['<Article: bar>', '<Article: baxZ>', '<Article: baz>']) # and more articles: a10 = Article(pub_date=now, headline='foobar') a10.save() a11 = Article(pub_date=now, headline='foobaz') a11.save() a12 = Article(pub_date=now, headline='ooF') a12.save() a13 = Article(pub_date=now, headline='foobarbaz') a13.save() a14 = Article(pub_date=now, headline='zoocarfaz') a14.save() a15 = Article(pub_date=now, headline='barfoobaz') a15.save() a16 = Article(pub_date=now, headline='bazbaRFOO') a16.save() # alternation self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'oo(f|b)'), [ '<Article: barfoobaz>', '<Article: foobar>', '<Article: foobarbaz>', '<Article: foobaz>', ]) self.assertQuerysetEqual(Article.objects.filter(headline__iregex=r'oo(f|b)'), [ '<Article: barfoobaz>', '<Article: foobar>', '<Article: foobarbaz>', '<Article: foobaz>', '<Article: ooF>', ]) self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'^foo(f|b)'), ['<Article: foobar>', '<Article: foobarbaz>', '<Article: foobaz>']) # greedy matching self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'b.*az'), [ '<Article: barfoobaz>', '<Article: baz>', '<Article: bazbaRFOO>', '<Article: foobarbaz>', '<Article: foobaz>', ]) self.assertQuerysetEqual(Article.objects.filter(headline__iregex=r'b.*ar'), [ '<Article: bar>', '<Article: barfoobaz>', '<Article: bazbaRFOO>', '<Article: foobar>', '<Article: foobarbaz>', ]) @skipUnlessDBFeature('supports_regex_backreferencing') def test_regex_backreferencing(self): # grouping and backreferences now = datetime.now() a10 = Article(pub_date=now, headline='foobar') a10.save() a11 = Article(pub_date=now, headline='foobaz') a11.save() a12 = Article(pub_date=now, headline='ooF') a12.save() a13 = Article(pub_date=now, headline='foobarbaz') a13.save() a14 = Article(pub_date=now, headline='zoocarfaz') a14.save() a15 = Article(pub_date=now, headline='barfoobaz') a15.save() a16 = Article(pub_date=now, headline='bazbaRFOO') a16.save() self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'b(.).*b\1'), ['<Article: barfoobaz>', '<Article: bazbaRFOO>', '<Article: foobarbaz>']) def test_regex_null(self): """ Ensure that a regex lookup does not fail on null/None values """ Season.objects.create(year=2012, gt=None) self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^$'), []) def test_regex_non_string(self): """ Ensure that a regex lookup does not fail on non-string fields """ Season.objects.create(year=2013, gt=444) self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^444$'), ['<Season: 2013>']) def test_regex_non_ascii(self): """ Ensure that a regex lookup does not trip on non-ASCII characters. """ Player.objects.create(name='\u2660') Player.objects.get(name__regex='\u2660') def test_nonfield_lookups(self): """ Ensure that a lookup query containing non-fields raises the proper exception. """ with self.assertRaises(FieldError): Article.objects.filter(headline__blahblah=99) with self.assertRaises(FieldError): Article.objects.filter(headline__blahblah__exact=99) with self.assertRaises(FieldError): Article.objects.filter(blahblah=99) def test_lookup_collision(self): """ Ensure that genuine field names don't collide with built-in lookup types ('year', 'gt', 'range', 'in' etc.). Refs #11670. """ # Here we're using 'gt' as a code number for the year, e.g. 111=>2009. season_2009 = Season.objects.create(year=2009, gt=111) season_2009.games.create(home="Houston Astros", away="St. Louis Cardinals") season_2010 = Season.objects.create(year=2010, gt=222) season_2010.games.create(home="Houston Astros", away="Chicago Cubs") season_2010.games.create(home="Houston Astros", away="Milwaukee Brewers") season_2010.games.create(home="Houston Astros", away="St. Louis Cardinals") season_2011 = Season.objects.create(year=2011, gt=333) season_2011.games.create(home="Houston Astros", away="St. Louis Cardinals") season_2011.games.create(home="Houston Astros", away="Milwaukee Brewers") hunter_pence = Player.objects.create(name="Hunter Pence") hunter_pence.games = Game.objects.filter(season__year__in=[2009, 2010]) pudge = Player.objects.create(name="Ivan Rodriquez") pudge.games = Game.objects.filter(season__year=2009) pedro_feliz = Player.objects.create(name="Pedro Feliz") pedro_feliz.games = Game.objects.filter(season__year__in=[2011]) johnson = Player.objects.create(name="Johnson") johnson.games = Game.objects.filter(season__year__in=[2011]) # Games in 2010 self.assertEqual(Game.objects.filter(season__year=2010).count(), 3) self.assertEqual(Game.objects.filter(season__year__exact=2010).count(), 3) self.assertEqual(Game.objects.filter(season__gt=222).count(), 3) self.assertEqual(Game.objects.filter(season__gt__exact=222).count(), 3) # Games in 2011 self.assertEqual(Game.objects.filter(season__year=2011).count(), 2) self.assertEqual(Game.objects.filter(season__year__exact=2011).count(), 2) self.assertEqual(Game.objects.filter(season__gt=333).count(), 2) self.assertEqual(Game.objects.filter(season__gt__exact=333).count(), 2) self.assertEqual(Game.objects.filter(season__year__gt=2010).count(), 2) self.assertEqual(Game.objects.filter(season__gt__gt=222).count(), 2) # Games played in 2010 and 2011 self.assertEqual(Game.objects.filter(season__year__in=[2010, 2011]).count(), 5) self.assertEqual(Game.objects.filter(season__year__gt=2009).count(), 5) self.assertEqual(Game.objects.filter(season__gt__in=[222, 333]).count(), 5) self.assertEqual(Game.objects.filter(season__gt__gt=111).count(), 5) # Players who played in 2009 self.assertEqual(Player.objects.filter(games__season__year=2009).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__year__exact=2009).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__gt=111).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__gt__exact=111).distinct().count(), 2) # Players who played in 2010 self.assertEqual(Player.objects.filter(games__season__year=2010).distinct().count(), 1) self.assertEqual(Player.objects.filter(games__season__year__exact=2010).distinct().count(), 1) self.assertEqual(Player.objects.filter(games__season__gt=222).distinct().count(), 1) self.assertEqual(Player.objects.filter(games__season__gt__exact=222).distinct().count(), 1) # Players who played in 2011 self.assertEqual(Player.objects.filter(games__season__year=2011).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__year__exact=2011).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__gt=333).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__year__gt=2010).distinct().count(), 2) self.assertEqual(Player.objects.filter(games__season__gt__gt=222).distinct().count(), 2) class LookupTransactionTests(TransactionTestCase): available_apps = ['lookup'] @skipUnless(connection.vendor == 'mysql', 'requires MySQL') def test_mysql_lookup_search(self): # To use fulltext indexes on MySQL either version 5.6 is needed, or one must use # MyISAM tables. Neither of these combinations is currently available on CI, so # lets manually create a MyISAM table for Article model. with connection.cursor() as cursor: cursor.execute( "CREATE TEMPORARY TABLE myisam_article (" " id INTEGER PRIMARY KEY AUTO_INCREMENT, " " headline VARCHAR(100) NOT NULL " ") ENGINE MYISAM") dr = MyISAMArticle.objects.create(headline='Django Reinhardt') MyISAMArticle.objects.create(headline='Ringo Star') # NOTE: Needs to be created after the article has been saved. cursor.execute( 'CREATE FULLTEXT INDEX myisam_article_ft ON myisam_article (headline)') self.assertQuerysetEqual( MyISAMArticle.objects.filter(headline__search='Reinhardt'), [dr], lambda x: x)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 2197, 492, 2197, 199, 504, 4182, 492, 21829, 199, 504, 2882, 492, 3372, 5524, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 7640, 12, 18244, 1746, 12, 3372, 5524, 18093, 199, 199, 504, 1275, 992, 492, 8281, 12, 6529, 12, 25132, 12, 4932, 1311, 1156, 7221, 12, 25610, 12, 3240, 2660, 12, 8053, 421, 199, 533, 12785, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 327, 2790, 282, 9284, 6642, 14, 267, 291, 14, 3844, 17, 275, 6529, 8, 354, 534, 5949, 413, 358, 267, 291, 14, 3844, 17, 14, 2117, 342, 267, 291, 14, 3844, 18, 275, 6529, 8, 354, 534, 5949, 499, 358, 267, 291, 14, 3844, 18, 14, 2117, 342, 267, 327, 2790, 282, 17535, 402, 8281, 83, 14, 267, 291, 14, 65, 17, 275, 8281, 8, 11268, 534, 7221, 413, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 7875, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 17, 14, 2117, 342, 267, 291, 14, 65, 18, 275, 8281, 8, 11268, 534, 7221, 499, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 18, 14, 2117, 342, 267, 291, 14, 65, 19, 275, 8281, 8, 11268, 534, 7221, 650, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 19, 14, 2117, 342, 267, 291, 14, 65, 20, 275, 8281, 8, 11268, 534, 7221, 841, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 7294, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 20, 14, 2117, 342, 267, 291, 14, 65, 21, 275, 8281, 8, 11268, 534, 7221, 959, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1695, 12, 413, 12, 1749, 12, 378, 395, 4132, 29, 277, 14, 3844, 18, 9, 267, 291, 14, 65, 21, 14, 2117, 342, 267, 291, 14, 65, 22, 275, 8281, 8, 11268, 534, 7221, 1227, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1695, 12, 413, 12, 1695, 12, 378, 395, 4132, 29, 277, 14, 3844, 18, 9, 267, 291, 14, 65, 22, 14, 2117, 342, 267, 291, 14, 65, 23, 275, 8281, 8, 11268, 534, 7221, 1520, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 395, 4132, 29, 277, 14, 3844, 18, 9, 267, 291, 14, 65, 23, 14, 2117, 342, 267, 327, 2790, 282, 9284, 25204, 14, 267, 291, 14, 84, 17, 275, 8053, 8, 354, 534, 1931, 413, 358, 267, 291, 14, 84, 17, 14, 2117, 342, 267, 291, 14, 84, 17, 14, 19813, 14, 525, 8, 277, 14, 65, 17, 12, 291, 14, 65, 18, 12, 291, 14, 65, 19, 9, 267, 291, 14, 84, 18, 275, 8053, 8, 354, 534, 1931, 499, 358, 267, 291, 14, 84, 18, 14, 2117, 342, 267, 291, 14, 84, 18, 14, 19813, 14, 525, 8, 277, 14, 65, 19, 12, 291, 14, 65, 20, 12, 291, 14, 65, 21, 9, 267, 291, 14, 84, 19, 275, 8053, 8, 354, 534, 1931, 650, 358, 267, 291, 14, 84, 19, 14, 2117, 342, 267, 291, 14, 84, 19, 14, 19813, 14, 525, 8, 277, 14, 65, 21, 12, 291, 14, 65, 22, 12, 291, 14, 65, 23, 9, 339, 347, 511, 63, 2444, 8, 277, 304, 267, 327, 2136, 883, 675, 1275, 2444, 342, 370, 1104, 626, 2337, 787, 2005, 267, 291, 14, 1815, 8, 7221, 14, 1462, 14, 2444, 1012, 267, 367, 282, 315, 8281, 14, 1462, 14, 452, 837, 288, 282, 14, 1807, 342, 267, 327, 6006, 1077, 506, 7179, 3063, 1, 267, 291, 14, 3334, 8, 7221, 14, 1462, 14, 2444, 1012, 339, 347, 511, 63, 3892, 63, 442, 63, 305, 63, 495, 8, 277, 304, 267, 327, 7225, 574, 883, 506, 30081, 1808, 1059, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 344, 363, 32344, 29, 495, 8, 277, 14, 65, 17, 14, 344, 1826, 639, 12329, 7221, 26, 8281, 413, 24782, 339, 768, 22424, 360, 9823, 63, 602, 63, 3892, 63, 4941, 63, 875, 358, 272, 347, 511, 63, 3892, 63, 602, 63, 305, 63, 495, 8, 277, 304, 267, 327, 437, 1434, 4237, 883, 506, 10585, 1808, 282, 1059, 2754, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 5645, 63, 602, 363, 2460, 534, 9397, 659, 288, 359, 355, 2650, 7221, 26, 8281, 959, 4206, 355, 2650, 7221, 26, 8281, 1227, 4206, 355, 2650, 7221, 26, 8281, 841, 4206, 355, 2650, 7221, 26, 8281, 499, 4206, 355, 2650, 7221, 26, 8281, 650, 4206, 355, 2650, 7221, 26, 8281, 1520, 4206, 355, 2650, 7221, 26, 8281, 413, 4206, 288, 4794, 339, 347, 511, 63, 5778, 8, 277, 304, 267, 327, 7048, 18397, 7545, 6122, 1062, 1314, 365, 282, 4306, 626, 298, 416, 90, 3444, 2, 267, 327, 2529, 2058, 1808, 3050, 13, 1896, 8494, 14, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 5778, 1062, 288, 359, 355, 283, 7221, 959, 297, 355, 283, 7221, 1227, 297, 355, 283, 7221, 841, 297, 355, 283, 7221, 499, 297, 355, 283, 7221, 650, 297, 355, 283, 7221, 1520, 297, 355, 283, 7221, 413, 297, 288, 2156, 288, 5793, 29, 18600, 360, 11268, 1333, 267, 327, 6122, 342, 883, 506, 1202, 641, 1263, 18397, 14, 267, 291, 14, 7108, 8, 288, 8281, 14, 1462, 14, 1541, 8, 11268, 363, 4130, 534, 20, 1959, 5778, 1062, 288, 788, 7221, 841, 995, 288, 5793, 29, 18600, 360, 11268, 1333, 339, 347, 511, 63, 835, 8, 277, 304, 267, 327, 2338, 342, 2529, 314, 1329, 402, 2251, 4877, 2754, 15647, 14, 267, 291, 14, 629, 8, 7221, 14, 1462, 14, 835, 1062, 1520, 9, 267, 291, 14, 629, 8, 7221, 14, 1462, 14, 1541, 8, 5645, 63, 602, 363, 7327, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 4992, 835, 1062, 650, 9, 267, 291, 14, 629, 8, 7221, 14, 1462, 14 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 2197, 492, 2197, 199, 504, 4182, 492, 21829, 199, 504, 2882, 492, 3372, 5524, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 7640, 12, 18244, 1746, 12, 3372, 5524, 18093, 199, 199, 504, 1275, 992, 492, 8281, 12, 6529, 12, 25132, 12, 4932, 1311, 1156, 7221, 12, 25610, 12, 3240, 2660, 12, 8053, 421, 199, 533, 12785, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 327, 2790, 282, 9284, 6642, 14, 267, 291, 14, 3844, 17, 275, 6529, 8, 354, 534, 5949, 413, 358, 267, 291, 14, 3844, 17, 14, 2117, 342, 267, 291, 14, 3844, 18, 275, 6529, 8, 354, 534, 5949, 499, 358, 267, 291, 14, 3844, 18, 14, 2117, 342, 267, 327, 2790, 282, 17535, 402, 8281, 83, 14, 267, 291, 14, 65, 17, 275, 8281, 8, 11268, 534, 7221, 413, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 7875, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 17, 14, 2117, 342, 267, 291, 14, 65, 18, 275, 8281, 8, 11268, 534, 7221, 499, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 18, 14, 2117, 342, 267, 291, 14, 65, 19, 275, 8281, 8, 11268, 534, 7221, 650, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 19, 14, 2117, 342, 267, 291, 14, 65, 20, 275, 8281, 8, 11268, 534, 7221, 841, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 7294, 395, 4132, 29, 277, 14, 3844, 17, 9, 267, 291, 14, 65, 20, 14, 2117, 342, 267, 291, 14, 65, 21, 275, 8281, 8, 11268, 534, 7221, 959, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1695, 12, 413, 12, 1749, 12, 378, 395, 4132, 29, 277, 14, 3844, 18, 9, 267, 291, 14, 65, 21, 14, 2117, 342, 267, 291, 14, 65, 22, 275, 8281, 8, 11268, 534, 7221, 1227, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1695, 12, 413, 12, 1695, 12, 378, 395, 4132, 29, 277, 14, 3844, 18, 9, 267, 291, 14, 65, 22, 14, 2117, 342, 267, 291, 14, 65, 23, 275, 8281, 8, 11268, 534, 7221, 1520, 297, 7974, 63, 602, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 395, 4132, 29, 277, 14, 3844, 18, 9, 267, 291, 14, 65, 23, 14, 2117, 342, 267, 327, 2790, 282, 9284, 25204, 14, 267, 291, 14, 84, 17, 275, 8053, 8, 354, 534, 1931, 413, 358, 267, 291, 14, 84, 17, 14, 2117, 342, 267, 291, 14, 84, 17, 14, 19813, 14, 525, 8, 277, 14, 65, 17, 12, 291, 14, 65, 18, 12, 291, 14, 65, 19, 9, 267, 291, 14, 84, 18, 275, 8053, 8, 354, 534, 1931, 499, 358, 267, 291, 14, 84, 18, 14, 2117, 342, 267, 291, 14, 84, 18, 14, 19813, 14, 525, 8, 277, 14, 65, 19, 12, 291, 14, 65, 20, 12, 291, 14, 65, 21, 9, 267, 291, 14, 84, 19, 275, 8053, 8, 354, 534, 1931, 650, 358, 267, 291, 14, 84, 19, 14, 2117, 342, 267, 291, 14, 84, 19, 14, 19813, 14, 525, 8, 277, 14, 65, 21, 12, 291, 14, 65, 22, 12, 291, 14, 65, 23, 9, 339, 347, 511, 63, 2444, 8, 277, 304, 267, 327, 2136, 883, 675, 1275, 2444, 342, 370, 1104, 626, 2337, 787, 2005, 267, 291, 14, 1815, 8, 7221, 14, 1462, 14, 2444, 1012, 267, 367, 282, 315, 8281, 14, 1462, 14, 452, 837, 288, 282, 14, 1807, 342, 267, 327, 6006, 1077, 506, 7179, 3063, 1, 267, 291, 14, 3334, 8, 7221, 14, 1462, 14, 2444, 1012, 339, 347, 511, 63, 3892, 63, 442, 63, 305, 63, 495, 8, 277, 304, 267, 327, 7225, 574, 883, 506, 30081, 1808, 1059, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 344, 363, 32344, 29, 495, 8, 277, 14, 65, 17, 14, 344, 1826, 639, 12329, 7221, 26, 8281, 413, 24782, 339, 768, 22424, 360, 9823, 63, 602, 63, 3892, 63, 4941, 63, 875, 358, 272, 347, 511, 63, 3892, 63, 602, 63, 305, 63, 495, 8, 277, 304, 267, 327, 437, 1434, 4237, 883, 506, 10585, 1808, 282, 1059, 2754, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 5645, 63, 602, 363, 2460, 534, 9397, 659, 288, 359, 355, 2650, 7221, 26, 8281, 959, 4206, 355, 2650, 7221, 26, 8281, 1227, 4206, 355, 2650, 7221, 26, 8281, 841, 4206, 355, 2650, 7221, 26, 8281, 499, 4206, 355, 2650, 7221, 26, 8281, 650, 4206, 355, 2650, 7221, 26, 8281, 1520, 4206, 355, 2650, 7221, 26, 8281, 413, 4206, 288, 4794, 339, 347, 511, 63, 5778, 8, 277, 304, 267, 327, 7048, 18397, 7545, 6122, 1062, 1314, 365, 282, 4306, 626, 298, 416, 90, 3444, 2, 267, 327, 2529, 2058, 1808, 3050, 13, 1896, 8494, 14, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 5778, 1062, 288, 359, 355, 283, 7221, 959, 297, 355, 283, 7221, 1227, 297, 355, 283, 7221, 841, 297, 355, 283, 7221, 499, 297, 355, 283, 7221, 650, 297, 355, 283, 7221, 1520, 297, 355, 283, 7221, 413, 297, 288, 2156, 288, 5793, 29, 18600, 360, 11268, 1333, 267, 327, 6122, 342, 883, 506, 1202, 641, 1263, 18397, 14, 267, 291, 14, 7108, 8, 288, 8281, 14, 1462, 14, 1541, 8, 11268, 363, 4130, 534, 20, 1959, 5778, 1062, 288, 788, 7221, 841, 995, 288, 5793, 29, 18600, 360, 11268, 1333, 339, 347, 511, 63, 835, 8, 277, 304, 267, 327, 2338, 342, 2529, 314, 1329, 402, 2251, 4877, 2754, 15647, 14, 267, 291, 14, 629, 8, 7221, 14, 1462, 14, 835, 1062, 1520, 9, 267, 291, 14, 629, 8, 7221, 14, 1462, 14, 1541, 8, 5645, 63, 602, 363, 7327, 29, 2083, 8, 9397, 12, 1520, 12, 8087, 4992, 835, 1062, 650, 9, 267, 291, 14, 629, 8, 7221, 14, 1462, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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riptor_props.py
78
24571
# orm/descriptor_props.py # Copyright (C) 2005-2014 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """Descriptor properties are more "auxiliary" properties that exist as configurational elements, but don't participate as actively in the load/persist ORM loop. """ from .interfaces import MapperProperty, PropComparator from .util import _none_set from . import attributes from .. import util, sql, exc as sa_exc, event, schema from ..sql import expression from . import properties from . import query class DescriptorProperty(MapperProperty): """:class:`.MapperProperty` which proxies access to a user-defined descriptor.""" doc = None def instrument_class(self, mapper): prop = self class _ProxyImpl(object): accepts_scalar_loader = False expire_missing = True collection = False def __init__(self, key): self.key = key if hasattr(prop, 'get_history'): def get_history(self, state, dict_, passive=attributes.PASSIVE_OFF): return prop.get_history(state, dict_, passive) if self.descriptor is None: desc = getattr(mapper.class_, self.key, None) if mapper._is_userland_descriptor(desc): self.descriptor = desc if self.descriptor is None: def fset(obj, value): setattr(obj, self.name, value) def fdel(obj): delattr(obj, self.name) def fget(obj): return getattr(obj, self.name) self.descriptor = property( fget=fget, fset=fset, fdel=fdel, ) proxy_attr = attributes.\ create_proxied_attribute(self.descriptor)\ ( self.parent.class_, self.key, self.descriptor, lambda: self._comparator_factory(mapper), doc=self.doc, original_property=self ) proxy_attr.impl = _ProxyImpl(self.key) mapper.class_manager.instrument_attribute(self.key, proxy_attr) @util.langhelpers.dependency_for("sqlalchemy.orm.properties") class CompositeProperty(DescriptorProperty): """Defines a "composite" mapped attribute, representing a collection of columns as one attribute. :class:`.CompositeProperty` is constructed using the :func:`.composite` function. .. seealso:: :ref:`mapper_composite` """ def __init__(self, class_, *attrs, **kwargs): """Return a composite column-based property for use with a Mapper. See the mapping documentation section :ref:`mapper_composite` for a full usage example. The :class:`.MapperProperty` returned by :func:`.composite` is the :class:`.CompositeProperty`. :param class\_: The "composite type" class. :param \*cols: List of Column objects to be mapped. :param active_history=False: When ``True``, indicates that the "previous" value for a scalar attribute should be loaded when replaced, if not already loaded. See the same flag on :func:`.column_property`. .. versionchanged:: 0.7 This flag specifically becomes meaningful - previously it was a placeholder. :param group: A group name for this property when marked as deferred. :param deferred: When True, the column property is "deferred", meaning that it does not load immediately, and is instead loaded when the attribute is first accessed on an instance. See also :func:`~sqlalchemy.orm.deferred`. :param comparator_factory: a class which extends :class:`.CompositeProperty.Comparator` which provides custom SQL clause generation for comparison operations. :param doc: optional string that will be applied as the doc on the class-bound descriptor. :param info: Optional data dictionary which will be populated into the :attr:`.MapperProperty.info` attribute of this object. .. versionadded:: 0.8 :param extension: an :class:`.AttributeExtension` instance, or list of extensions, which will be prepended to the list of attribute listeners for the resulting descriptor placed on the class. **Deprecated.** Please see :class:`.AttributeEvents`. """ self.attrs = attrs self.composite_class = class_ self.active_history = kwargs.get('active_history', False) self.deferred = kwargs.get('deferred', False) self.group = kwargs.get('group', None) self.comparator_factory = kwargs.pop('comparator_factory', self.__class__.Comparator) if 'info' in kwargs: self.info = kwargs.pop('info') util.set_creation_order(self) self._create_descriptor() def instrument_class(self, mapper): super(CompositeProperty, self).instrument_class(mapper) self._setup_event_handlers() def do_init(self): """Initialization which occurs after the :class:`.CompositeProperty` has been associated with its parent mapper. """ self._setup_arguments_on_columns() def _create_descriptor(self): """Create the Python descriptor that will serve as the access point on instances of the mapped class. """ def fget(instance): dict_ = attributes.instance_dict(instance) state = attributes.instance_state(instance) if self.key not in dict_: # key not present. Iterate through related # attributes, retrieve their values. This # ensures they all load. values = [ getattr(instance, key) for key in self._attribute_keys ] # current expected behavior here is that the composite is # created on access if the object is persistent or if # col attributes have non-None. This would be better # if the composite were created unconditionally, # but that would be a behavioral change. if self.key not in dict_ and ( state.key is not None or not _none_set.issuperset(values) ): dict_[self.key] = self.composite_class(*values) state.manager.dispatch.refresh(state, None, [self.key]) return dict_.get(self.key, None) def fset(instance, value): dict_ = attributes.instance_dict(instance) state = attributes.instance_state(instance) attr = state.manager[self.key] previous = dict_.get(self.key, attributes.NO_VALUE) for fn in attr.dispatch.set: value = fn(state, value, previous, attr.impl) dict_[self.key] = value if value is None: for key in self._attribute_keys: setattr(instance, key, None) else: for key, value in zip( self._attribute_keys, value.__composite_values__()): setattr(instance, key, value) def fdel(instance): state = attributes.instance_state(instance) dict_ = attributes.instance_dict(instance) previous = dict_.pop(self.key, attributes.NO_VALUE) attr = state.manager[self.key] attr.dispatch.remove(state, previous, attr.impl) for key in self._attribute_keys: setattr(instance, key, None) self.descriptor = property(fget, fset, fdel) @util.memoized_property def _comparable_elements(self): return [ getattr(self.parent.class_, prop.key) for prop in self.props ] @util.memoized_property def props(self): props = [] for attr in self.attrs: if isinstance(attr, str): prop = self.parent.get_property(attr, _configure_mappers=False) elif isinstance(attr, schema.Column): prop = self.parent._columntoproperty[attr] elif isinstance(attr, attributes.InstrumentedAttribute): prop = attr.property else: raise sa_exc.ArgumentError( "Composite expects Column objects or mapped " "attributes/attribute names as arguments, got: %r" % (attr,)) props.append(prop) return props @property def columns(self): return [a for a in self.attrs if isinstance(a, schema.Column)] def _setup_arguments_on_columns(self): """Propagate configuration arguments made on this composite to the target columns, for those that apply. """ for prop in self.props: prop.active_history = self.active_history if self.deferred: prop.deferred = self.deferred prop.strategy_class = prop._strategy_lookup( ("deferred", True), ("instrument", True)) prop.group = self.group def _setup_event_handlers(self): """Establish events that populate/expire the composite attribute.""" def load_handler(state, *args): dict_ = state.dict if self.key in dict_: return # if column elements aren't loaded, skip. # __get__() will initiate a load for those # columns for k in self._attribute_keys: if k not in dict_: return #assert self.key not in dict_ dict_[self.key] = self.composite_class( *[state.dict[key] for key in self._attribute_keys] ) def expire_handler(state, keys): if keys is None or set(self._attribute_keys).intersection(keys): state.dict.pop(self.key, None) def insert_update_handler(mapper, connection, state): """After an insert or update, some columns may be expired due to server side defaults, or re-populated due to client side defaults. Pop out the composite value here so that it recreates. """ state.dict.pop(self.key, None) event.listen(self.parent, 'after_insert', insert_update_handler, raw=True) event.listen(self.parent, 'after_update', insert_update_handler, raw=True) event.listen(self.parent, 'load', load_handler, raw=True, propagate=True) event.listen(self.parent, 'refresh', load_handler, raw=True, propagate=True) event.listen(self.parent, 'expire', expire_handler, raw=True, propagate=True) # TODO: need a deserialize hook here @util.memoized_property def _attribute_keys(self): return [ prop.key for prop in self.props ] def get_history(self, state, dict_, passive=attributes.PASSIVE_OFF): """Provided for userland code that uses attributes.get_history().""" added = [] deleted = [] has_history = False for prop in self.props: key = prop.key hist = state.manager[key].impl.get_history(state, dict_) if hist.has_changes(): has_history = True non_deleted = hist.non_deleted() if non_deleted: added.extend(non_deleted) else: added.append(None) if hist.deleted: deleted.extend(hist.deleted) else: deleted.append(None) if has_history: return attributes.History( [self.composite_class(*added)], (), [self.composite_class(*deleted)] ) else: return attributes.History( (), [self.composite_class(*added)], () ) def _comparator_factory(self, mapper): return self.comparator_factory(self, mapper) class CompositeBundle(query.Bundle): def __init__(self, property, expr): self.property = property super(CompositeProperty.CompositeBundle, self).__init__( property.key, *expr) def create_row_processor(self, query, procs, labels): def proc(row, result): return self.property.composite_class(*[proc(row, result) for proc in procs]) return proc class Comparator(PropComparator): """Produce boolean, comparison, and other operators for :class:`.CompositeProperty` attributes. See the example in :ref:`composite_operations` for an overview of usage , as well as the documentation for :class:`.PropComparator`. See also: :class:`.PropComparator` :class:`.ColumnOperators` :ref:`types_operators` :attr:`.TypeEngine.comparator_factory` """ __hash__ = None @property def clauses(self): return self.__clause_element__() def __clause_element__(self): return expression.ClauseList(group=False, *self._comparable_elements) def _query_clause_element(self): return CompositeProperty.CompositeBundle(self.prop, self.__clause_element__()) @util.memoized_property def _comparable_elements(self): if self._adapt_to_entity: return [ getattr( self._adapt_to_entity.entity, prop.key ) for prop in self.prop._comparable_elements ] else: return self.prop._comparable_elements def __eq__(self, other): if other is None: values = [None] * len(self.prop._comparable_elements) else: values = other.__composite_values__() comparisons = [ a == b for a, b in zip(self.prop._comparable_elements, values) ] if self._adapt_to_entity: comparisons = [self.adapter(x) for x in comparisons] return sql.and_(*comparisons) def __ne__(self, other): return sql.not_(self.__eq__(other)) def __str__(self): return str(self.parent.class_.__name__) + "." + self.key @util.langhelpers.dependency_for("sqlalchemy.orm.properties") class ConcreteInheritedProperty(DescriptorProperty): """A 'do nothing' :class:`.MapperProperty` that disables an attribute on a concrete subclass that is only present on the inherited mapper, not the concrete classes' mapper. Cases where this occurs include: * When the superclass mapper is mapped against a "polymorphic union", which includes all attributes from all subclasses. * When a relationship() is configured on an inherited mapper, but not on the subclass mapper. Concrete mappers require that relationship() is configured explicitly on each subclass. """ def _comparator_factory(self, mapper): comparator_callable = None for m in self.parent.iterate_to_root(): p = m._props[self.key] if not isinstance(p, ConcreteInheritedProperty): comparator_callable = p.comparator_factory break return comparator_callable def __init__(self): def warn(): raise AttributeError("Concrete %s does not implement " "attribute %r at the instance level. Add this " "property explicitly to %s." % (self.parent, self.key, self.parent)) class NoninheritedConcreteProp(object): def __set__(s, obj, value): warn() def __delete__(s, obj): warn() def __get__(s, obj, owner): if obj is None: return self.descriptor warn() self.descriptor = NoninheritedConcreteProp() @util.langhelpers.dependency_for("sqlalchemy.orm.properties") class SynonymProperty(DescriptorProperty): def __init__(self, name, map_column=None, descriptor=None, comparator_factory=None, doc=None): """Denote an attribute name as a synonym to a mapped property, in that the attribute will mirror the value and expression behavior of another attribute. :param name: the name of the existing mapped property. This can refer to the string name of any :class:`.MapperProperty` configured on the class, including column-bound attributes and relationships. :param descriptor: a Python :term:`descriptor` that will be used as a getter (and potentially a setter) when this attribute is accessed at the instance level. :param map_column: if ``True``, the :func:`.synonym` construct will locate the existing named :class:`.MapperProperty` based on the attribute name of this :func:`.synonym`, and assign it to a new attribute linked to the name of this :func:`.synonym`. That is, given a mapping like:: class MyClass(Base): __tablename__ = 'my_table' id = Column(Integer, primary_key=True) job_status = Column(String(50)) job_status = synonym("_job_status", map_column=True) The above class ``MyClass`` will now have the ``job_status`` :class:`.Column` object mapped to the attribute named ``_job_status``, and the attribute named ``job_status`` will refer to the synonym itself. This feature is typically used in conjunction with the ``descriptor`` argument in order to link a user-defined descriptor as a "wrapper" for an existing column. :param comparator_factory: A subclass of :class:`.PropComparator` that will provide custom comparison behavior at the SQL expression level. .. note:: For the use case of providing an attribute which redefines both Python-level and SQL-expression level behavior of an attribute, please refer to the Hybrid attribute introduced at :ref:`mapper_hybrids` for a more effective technique. .. seealso:: :ref:`synonyms` - examples of functionality. :ref:`mapper_hybrids` - Hybrids provide a better approach for more complicated attribute-wrapping schemes than synonyms. """ self.name = name self.map_column = map_column self.descriptor = descriptor self.comparator_factory = comparator_factory self.doc = doc or (descriptor and descriptor.__doc__) or None util.set_creation_order(self) # TODO: when initialized, check _proxied_property, # emit a warning if its not a column-based property @util.memoized_property def _proxied_property(self): return getattr(self.parent.class_, self.name).property def _comparator_factory(self, mapper): prop = self._proxied_property if self.comparator_factory: comp = self.comparator_factory(prop, mapper) else: comp = prop.comparator_factory(prop, mapper) return comp def set_parent(self, parent, init): if self.map_column: # implement the 'map_column' option. if self.key not in parent.mapped_table.c: raise sa_exc.ArgumentError( "Can't compile synonym '%s': no column on table " "'%s' named '%s'" % (self.name, parent.mapped_table.description, self.key)) elif parent.mapped_table.c[self.key] in \ parent._columntoproperty and \ parent._columntoproperty[ parent.mapped_table.c[self.key] ].key == self.name: raise sa_exc.ArgumentError( "Can't call map_column=True for synonym %r=%r, " "a ColumnProperty already exists keyed to the name " "%r for column %r" % (self.key, self.name, self.name, self.key) ) p = properties.ColumnProperty(parent.mapped_table.c[self.key]) parent._configure_property( self.name, p, init=init, setparent=True) p._mapped_by_synonym = self.key self.parent = parent @util.langhelpers.dependency_for("sqlalchemy.orm.properties") class ComparableProperty(DescriptorProperty): """Instruments a Python property for use in query expressions.""" def __init__(self, comparator_factory, descriptor=None, doc=None): """Provides a method of applying a :class:`.PropComparator` to any Python descriptor attribute. .. versionchanged:: 0.7 :func:`.comparable_property` is superseded by the :mod:`~sqlalchemy.ext.hybrid` extension. See the example at :ref:`hybrid_custom_comparators`. Allows any Python descriptor to behave like a SQL-enabled attribute when used at the class level in queries, allowing redefinition of expression operator behavior. In the example below we redefine :meth:`.PropComparator.operate` to wrap both sides of an expression in ``func.lower()`` to produce case-insensitive comparison:: from sqlalchemy.orm import comparable_property from sqlalchemy.orm.interfaces import PropComparator from sqlalchemy.sql import func from sqlalchemy import Integer, String, Column from sqlalchemy.ext.declarative import declarative_base class CaseInsensitiveComparator(PropComparator): def __clause_element__(self): return self.prop def operate(self, op, other): return op( func.lower(self.__clause_element__()), func.lower(other) ) Base = declarative_base() class SearchWord(Base): __tablename__ = 'search_word' id = Column(Integer, primary_key=True) word = Column(String) word_insensitive = comparable_property(lambda prop, mapper: CaseInsensitiveComparator(mapper.c.word, mapper) ) A mapping like the above allows the ``word_insensitive`` attribute to render an expression like:: >>> print SearchWord.word_insensitive == "Trucks" lower(search_word.word) = lower(:lower_1) :param comparator_factory: A PropComparator subclass or factory that defines operator behavior for this property. :param descriptor: Optional when used in a ``properties={}`` declaration. The Python descriptor or property to layer comparison behavior on top of. The like-named descriptor will be automatically retrieved from the mapped class if left blank in a ``properties`` declaration. """ self.descriptor = descriptor self.comparator_factory = comparator_factory self.doc = doc or (descriptor and descriptor.__doc__) or None util.set_creation_order(self) def _comparator_factory(self, mapper): return self.comparator_factory(self, mapper)
gpl-3.0
[ 3, 9813, 15, 4120, 63, 6750, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7280, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 4311, 4382, 787, 1655, 298, 10962, 20524, 2, 4382, 199, 9099, 2187, 465, 2897, 279, 4008, 12, 1325, 2793, 1133, 623, 10479, 323, 199, 305, 6633, 5636, 315, 314, 2248, 15, 23619, 23383, 4438, 14, 199, 199, 624, 199, 199, 504, 1275, 7436, 492, 9672, 529, 3697, 12, 2165, 80, 26636, 199, 504, 1275, 1974, 492, 485, 3592, 63, 409, 199, 504, 1275, 492, 3004, 199, 504, 2508, 492, 4884, 12, 3875, 12, 3178, 465, 2937, 63, 2804, 12, 1566, 12, 4177, 199, 504, 2508, 3009, 492, 3965, 199, 504, 1275, 492, 4382, 199, 504, 1275, 492, 1827, 421, 199, 533, 28131, 3697, 8, 11880, 3697, 304, 272, 408, 26, 533, 5026, 11880, 3697, 64, 1314, 14942, 2879, 370, 282, 267, 922, 13, 4037, 5872, 1041, 339, 1382, 275, 488, 339, 347, 14498, 63, 533, 8, 277, 12, 7796, 304, 267, 5931, 275, 291, 398, 1021, 485, 4936, 4748, 8, 785, 304, 288, 11479, 63, 7033, 63, 3422, 275, 756, 288, 16667, 63, 4752, 275, 715, 288, 3245, 275, 756, 953, 347, 636, 826, 721, 277, 12, 790, 304, 355, 291, 14, 498, 275, 790, 953, 340, 2688, 8, 4469, 12, 283, 362, 63, 5570, 735, 355, 347, 664, 63, 5570, 8, 277, 12, 1174, 12, 1211, 3131, 717, 21010, 29, 2987, 14, 29634, 63, 7517, 304, 490, 372, 5931, 14, 362, 63, 5570, 8, 929, 12, 1211, 3131, 21010, 9, 398, 340, 291, 14, 4120, 365, 488, 26, 288, 4328, 275, 2519, 8, 7153, 14, 533, 3131, 291, 14, 498, 12, 488, 9, 288, 340, 7796, 423, 374, 63, 751, 9688, 63, 4120, 8, 3257, 304, 355, 291, 14, 4120, 275, 4328, 398, 340, 291, 14, 4120, 365, 488, 26, 288, 347, 289, 409, 8, 1113, 12, 574, 304, 355, 5371, 8, 1113, 12, 291, 14, 354, 12, 574, 9, 953, 347, 289, 2264, 8, 1113, 304, 355, 24358, 8, 1113, 12, 291, 14, 354, 9, 953, 347, 289, 362, 8, 1113, 304, 355, 372, 2519, 8, 1113, 12, 291, 14, 354, 9, 953, 291, 14, 4120, 275, 3324, 8, 355, 289, 362, 29, 27823, 12, 355, 289, 409, 29, 70, 409, 12, 355, 289, 2264, 29, 70, 2264, 12, 288, 776, 398, 4566, 63, 962, 275, 3004, 3134, 490, 1218, 63, 8221, 5299, 63, 3215, 8, 277, 14, 4120, 2862, 490, 334, 717, 291, 14, 1708, 14, 533, 3131, 717, 291, 14, 498, 12, 717, 291, 14, 4120, 12, 717, 2400, 26, 291, 423, 27417, 63, 3702, 8, 7153, 395, 717, 1382, 29, 277, 14, 1301, 12, 717, 3379, 63, 1829, 29, 277, 490, 776, 267, 4566, 63, 962, 14, 5472, 275, 485, 4936, 4748, 8, 277, 14, 498, 9, 267, 7796, 14, 533, 63, 2609, 14, 13321, 63, 3215, 8, 277, 14, 498, 12, 4566, 63, 962, 9, 421, 199, 32, 1974, 14, 4159, 7546, 14, 8575, 63, 509, 480, 14536, 14, 1025, 14, 3282, 531, 199, 533, 27506, 2124, 3697, 8, 4311, 3697, 304, 272, 408, 23891, 282, 298, 16907, 2, 9994, 2225, 12, 6144, 282, 3245, 272, 402, 4362, 465, 1373, 2225, 14, 339, 520, 533, 5026, 24039, 3697, 64, 365, 14701, 1808, 314, 520, 1532, 5026, 16907, 64, 272, 805, 14, 339, 2508, 19352, 447, 398, 520, 1121, 1705, 7153, 63, 16907, 64, 339, 408, 272, 347, 636, 826, 721, 277, 12, 1021, 3131, 627, 3288, 12, 1011, 958, 304, 267, 408, 1767, 282, 19306, 2763, 13, 6788, 3324, 367, 675, 543, 282, 9672, 529, 14, 398, 1666, 314, 4412, 3794, 3420, 520, 1121, 1705, 7153, 63, 16907, 64, 367, 282, 2615, 267, 4503, 2893, 14, 398, 710, 520, 533, 5026, 11880, 3697, 64, 2138, 701, 520, 1532, 5026, 16907, 64, 267, 365, 314, 520, 533, 5026, 24039, 3697, 2313, 398, 520, 635, 1021, 60, 10388, 881, 710, 298, 16907, 730, 2, 1021, 14, 398, 520, 635, 971, 10, 4574, 26, 881, 3820, 402, 4996, 2251, 370, 506, 9994, 14, 398, 520, 635, 4702, 63, 5570, 29, 797, 26, 881, 3979, 1124, 549, 4542, 9126, 626, 314, 298, 6352, 2, 574, 367, 282, 881, 6917, 2225, 1077, 506, 6511, 1380, 8717, 12, 340, 440, 881, 2575, 6511, 14, 221, 1666, 314, 2011, 3305, 641, 520, 1532, 5026, 2301, 63, 1829, 2313, 8592, 2508, 16434, 447, 378, 14, 23, 1598, 961, 3305, 22543, 15410, 26562, 1598, 446, 10889, 652, 1990, 282, 10069, 14, 398, 520, 635, 1572, 26, 881, 437, 1572, 536, 367, 642, 3324, 1380, 11584, 465, 12309, 14, 398, 520, 635, 12309, 26, 881, 3979, 715, 12, 314, 2763, 3324, 365, 298, 12116, 401, 11150, 626, 652, 1630, 440, 881, 2248, 9939, 12, 436, 365, 3140, 6511, 1380, 314, 2225, 365, 1642, 881, 13810, 641, 376, 1256, 14, 221, 1666, 2597, 520, 1532, 6054, 14536, 14, 1025, 14, 12116, 2313, 398, 520, 635, 32138, 63, 3702, 26, 221, 282, 1021, 1314, 16879, 881, 520, 533, 5026, 24039, 3697, 14, 26636, 64, 1314, 6571, 3537, 5385, 8502, 881, 10152, 367, 9132, 5331, 14, 398, 520, 635, 1382, 26, 881, 2716, 1059, 626, 911, 506, 6781, 465, 314, 1382, 641, 314, 881, 1021, 13, 3556, 5872, 14, 398, 520, 635, 2256, 26, 4879, 666, 2600, 1314, 911, 506, 16460, 1901, 314, 288, 520, 962, 5026, 11880, 3697, 14, 815, 64, 2225, 402, 642, 909, 14, 953, 2508, 7445, 447, 378, 14, 24, 398, 520, 635, 3329, 26, 881, 376, 520, 533, 5026, 1646, 6382, 64, 1256, 12, 881, 503, 769, 402, 5478, 12, 1314, 911, 506, 20247, 370, 314, 769, 402, 881, 2225, 19946, 367, 314, 9183, 5872, 15090, 641, 314, 1021, 14, 881, 1011, 19727, 14, 538, 221, 7754, 1937, 520, 533, 5026, 1646, 11770, 2313, 398, 408, 398, 291, 14, 3288, 275, 3290, 267, 291, 14, 16907, 63, 533, 275, 1021, 63, 267, 291, 14, 2682, 63, 5570, 275, 2074, 14, 362 ]
[ 9813, 15, 4120, 63, 6750, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7280, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 4311, 4382, 787, 1655, 298, 10962, 20524, 2, 4382, 199, 9099, 2187, 465, 2897, 279, 4008, 12, 1325, 2793, 1133, 623, 10479, 323, 199, 305, 6633, 5636, 315, 314, 2248, 15, 23619, 23383, 4438, 14, 199, 199, 624, 199, 199, 504, 1275, 7436, 492, 9672, 529, 3697, 12, 2165, 80, 26636, 199, 504, 1275, 1974, 492, 485, 3592, 63, 409, 199, 504, 1275, 492, 3004, 199, 504, 2508, 492, 4884, 12, 3875, 12, 3178, 465, 2937, 63, 2804, 12, 1566, 12, 4177, 199, 504, 2508, 3009, 492, 3965, 199, 504, 1275, 492, 4382, 199, 504, 1275, 492, 1827, 421, 199, 533, 28131, 3697, 8, 11880, 3697, 304, 272, 408, 26, 533, 5026, 11880, 3697, 64, 1314, 14942, 2879, 370, 282, 267, 922, 13, 4037, 5872, 1041, 339, 1382, 275, 488, 339, 347, 14498, 63, 533, 8, 277, 12, 7796, 304, 267, 5931, 275, 291, 398, 1021, 485, 4936, 4748, 8, 785, 304, 288, 11479, 63, 7033, 63, 3422, 275, 756, 288, 16667, 63, 4752, 275, 715, 288, 3245, 275, 756, 953, 347, 636, 826, 721, 277, 12, 790, 304, 355, 291, 14, 498, 275, 790, 953, 340, 2688, 8, 4469, 12, 283, 362, 63, 5570, 735, 355, 347, 664, 63, 5570, 8, 277, 12, 1174, 12, 1211, 3131, 717, 21010, 29, 2987, 14, 29634, 63, 7517, 304, 490, 372, 5931, 14, 362, 63, 5570, 8, 929, 12, 1211, 3131, 21010, 9, 398, 340, 291, 14, 4120, 365, 488, 26, 288, 4328, 275, 2519, 8, 7153, 14, 533, 3131, 291, 14, 498, 12, 488, 9, 288, 340, 7796, 423, 374, 63, 751, 9688, 63, 4120, 8, 3257, 304, 355, 291, 14, 4120, 275, 4328, 398, 340, 291, 14, 4120, 365, 488, 26, 288, 347, 289, 409, 8, 1113, 12, 574, 304, 355, 5371, 8, 1113, 12, 291, 14, 354, 12, 574, 9, 953, 347, 289, 2264, 8, 1113, 304, 355, 24358, 8, 1113, 12, 291, 14, 354, 9, 953, 347, 289, 362, 8, 1113, 304, 355, 372, 2519, 8, 1113, 12, 291, 14, 354, 9, 953, 291, 14, 4120, 275, 3324, 8, 355, 289, 362, 29, 27823, 12, 355, 289, 409, 29, 70, 409, 12, 355, 289, 2264, 29, 70, 2264, 12, 288, 776, 398, 4566, 63, 962, 275, 3004, 3134, 490, 1218, 63, 8221, 5299, 63, 3215, 8, 277, 14, 4120, 2862, 490, 334, 717, 291, 14, 1708, 14, 533, 3131, 717, 291, 14, 498, 12, 717, 291, 14, 4120, 12, 717, 2400, 26, 291, 423, 27417, 63, 3702, 8, 7153, 395, 717, 1382, 29, 277, 14, 1301, 12, 717, 3379, 63, 1829, 29, 277, 490, 776, 267, 4566, 63, 962, 14, 5472, 275, 485, 4936, 4748, 8, 277, 14, 498, 9, 267, 7796, 14, 533, 63, 2609, 14, 13321, 63, 3215, 8, 277, 14, 498, 12, 4566, 63, 962, 9, 421, 199, 32, 1974, 14, 4159, 7546, 14, 8575, 63, 509, 480, 14536, 14, 1025, 14, 3282, 531, 199, 533, 27506, 2124, 3697, 8, 4311, 3697, 304, 272, 408, 23891, 282, 298, 16907, 2, 9994, 2225, 12, 6144, 282, 3245, 272, 402, 4362, 465, 1373, 2225, 14, 339, 520, 533, 5026, 24039, 3697, 64, 365, 14701, 1808, 314, 520, 1532, 5026, 16907, 64, 272, 805, 14, 339, 2508, 19352, 447, 398, 520, 1121, 1705, 7153, 63, 16907, 64, 339, 408, 272, 347, 636, 826, 721, 277, 12, 1021, 3131, 627, 3288, 12, 1011, 958, 304, 267, 408, 1767, 282, 19306, 2763, 13, 6788, 3324, 367, 675, 543, 282, 9672, 529, 14, 398, 1666, 314, 4412, 3794, 3420, 520, 1121, 1705, 7153, 63, 16907, 64, 367, 282, 2615, 267, 4503, 2893, 14, 398, 710, 520, 533, 5026, 11880, 3697, 64, 2138, 701, 520, 1532, 5026, 16907, 64, 267, 365, 314, 520, 533, 5026, 24039, 3697, 2313, 398, 520, 635, 1021, 60, 10388, 881, 710, 298, 16907, 730, 2, 1021, 14, 398, 520, 635, 971, 10, 4574, 26, 881, 3820, 402, 4996, 2251, 370, 506, 9994, 14, 398, 520, 635, 4702, 63, 5570, 29, 797, 26, 881, 3979, 1124, 549, 4542, 9126, 626, 314, 298, 6352, 2, 574, 367, 282, 881, 6917, 2225, 1077, 506, 6511, 1380, 8717, 12, 340, 440, 881, 2575, 6511, 14, 221, 1666, 314, 2011, 3305, 641, 520, 1532, 5026, 2301, 63, 1829, 2313, 8592, 2508, 16434, 447, 378, 14, 23, 1598, 961, 3305, 22543, 15410, 26562, 1598, 446, 10889, 652, 1990, 282, 10069, 14, 398, 520, 635, 1572, 26, 881, 437, 1572, 536, 367, 642, 3324, 1380, 11584, 465, 12309, 14, 398, 520, 635, 12309, 26, 881, 3979, 715, 12, 314, 2763, 3324, 365, 298, 12116, 401, 11150, 626, 652, 1630, 440, 881, 2248, 9939, 12, 436, 365, 3140, 6511, 1380, 314, 2225, 365, 1642, 881, 13810, 641, 376, 1256, 14, 221, 1666, 2597, 520, 1532, 6054, 14536, 14, 1025, 14, 12116, 2313, 398, 520, 635, 32138, 63, 3702, 26, 221, 282, 1021, 1314, 16879, 881, 520, 533, 5026, 24039, 3697, 14, 26636, 64, 1314, 6571, 3537, 5385, 8502, 881, 10152, 367, 9132, 5331, 14, 398, 520, 635, 1382, 26, 881, 2716, 1059, 626, 911, 506, 6781, 465, 314, 1382, 641, 314, 881, 1021, 13, 3556, 5872, 14, 398, 520, 635, 2256, 26, 4879, 666, 2600, 1314, 911, 506, 16460, 1901, 314, 288, 520, 962, 5026, 11880, 3697, 14, 815, 64, 2225, 402, 642, 909, 14, 953, 2508, 7445, 447, 378, 14, 24, 398, 520, 635, 3329, 26, 881, 376, 520, 533, 5026, 1646, 6382, 64, 1256, 12, 881, 503, 769, 402, 5478, 12, 1314, 911, 506, 20247, 370, 314, 769, 402, 881, 2225, 19946, 367, 314, 9183, 5872, 15090, 641, 314, 1021, 14, 881, 1011, 19727, 14, 538, 221, 7754, 1937, 520, 533, 5026, 1646, 11770, 2313, 398, 408, 398, 291, 14, 3288, 275, 3290, 267, 291, 14, 16907, 63, 533, 275, 1021, 63, 267, 291, 14, 2682, 63, 5570, 275, 2074, 14, 362, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ArcherCraftStore/ArcherVMPeridot
Python/Lib/lib2to3/fixes/fix_print.py
164
2854
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for print. Change: 'print' into 'print()' 'print ...' into 'print(...)' 'print ... ,' into 'print(..., end=" ")' 'print >>x, ...' into 'print(..., file=x)' No changes are applied if print_function is imported from __future__ """ # Local imports from .. import patcomp from .. import pytree from ..pgen2 import token from .. import fixer_base from ..fixer_util import Name, Call, Comma, String, is_tuple parend_expr = patcomp.compile_pattern( """atom< '(' [atom|STRING|NAME] ')' >""" ) class FixPrint(fixer_base.BaseFix): BM_compatible = True PATTERN = """ simple_stmt< any* bare='print' any* > | print_stmt """ def transform(self, node, results): assert results bare_print = results.get("bare") if bare_print: # Special-case print all by itself bare_print.replace(Call(Name("print"), [], prefix=bare_print.prefix)) return assert node.children[0] == Name("print") args = node.children[1:] if len(args) == 1 and parend_expr.match(args[0]): # We don't want to keep sticking parens around an # already-parenthesised expression. return sep = end = file = None if args and args[-1] == Comma(): args = args[:-1] end = " " if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, ">>"): assert len(args) >= 2 file = args[1].clone() args = args[3:] # Strip a possible comma after the file expression # Now synthesize a print(args, sep=..., end=..., file=...) node. l_args = [arg.clone() for arg in args] if l_args: l_args[0].prefix = "" if sep is not None or end is not None or file is not None: if sep is not None: self.add_kwarg(l_args, "sep", String(repr(sep))) if end is not None: self.add_kwarg(l_args, "end", String(repr(end))) if file is not None: self.add_kwarg(l_args, "file", file) n_stmt = Call(Name("print"), l_args) n_stmt.prefix = node.prefix return n_stmt def add_kwarg(self, l_nodes, s_kwd, n_expr): # XXX All this prefix-setting may lose comments (though rarely) n_expr.prefix = "" n_argument = pytree.Node(self.syms.argument, (Name(s_kwd), pytree.Leaf(token.EQUAL, "="), n_expr)) if l_nodes: l_nodes.append(Comma()) n_argument.prefix = " " l_nodes.append(n_argument)
apache-2.0
[ 3, 1898, 8315, 4475, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 199, 624, 11985, 281, 367, 870, 14, 199, 199, 4001, 26, 272, 283, 1361, 7, 3515, 1901, 283, 1361, 11716, 272, 283, 1361, 2263, 7, 420, 1901, 283, 1361, 29195, 3171, 272, 283, 1361, 2263, 20606, 259, 1901, 283, 1361, 8, 11577, 1284, 628, 298, 3171, 272, 283, 1361, 4331, 88, 12, 2263, 7, 1901, 283, 1361, 8, 11577, 570, 29, 88, 3171, 199, 199, 1944, 4493, 787, 6781, 340, 870, 63, 1593, 365, 8439, 687, 636, 2443, 363, 199, 199, 624, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 12713, 863, 199, 504, 2508, 492, 23353, 199, 504, 2508, 80, 2268, 18, 492, 1526, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 2812, 12, 6523, 12, 5429, 391, 12, 2624, 12, 365, 63, 2960, 421, 199, 9575, 68, 63, 3684, 275, 12713, 863, 14, 2014, 63, 3401, 8, 1598, 408, 4188, 28, 16746, 359, 4188, 92, 5353, 92, 2339, 61, 16107, 690, 624, 1598, 776, 421, 199, 533, 14811, 5375, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 339, 31467, 7689, 275, 408, 1598, 3486, 63, 9649, 28, 1263, 10, 18753, 534, 1361, 7, 1263, 10, 690, 1204, 870, 63, 9649, 1598, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 702, 2058, 398, 18753, 63, 1361, 275, 2058, 14, 362, 480, 14890, 531, 398, 340, 18753, 63, 1361, 26, 288, 327, 12568, 13, 2546, 870, 1006, 701, 6337, 288, 18753, 63, 1361, 14, 1814, 8, 2176, 8, 985, 480, 1361, 1288, 990, 3044, 2403, 29, 14890, 63, 1361, 14, 1861, 430, 288, 372, 267, 702, 1031, 14, 3223, 59, 16, 61, 508, 2812, 480, 1361, 531, 267, 1249, 275, 1031, 14, 3223, 59, 17, 2938, 267, 340, 822, 8, 589, 9, 508, 413, 436, 13566, 68, 63, 3684, 14, 1431, 8, 589, 59, 16, 4682, 288, 327, 2136, 2793, 1133, 2934, 370, 4215, 29404, 316, 32029, 6818, 376, 288, 327, 2575, 13, 9575, 1589, 338, 939, 3965, 14, 288, 372, 398, 7375, 275, 1284, 275, 570, 275, 488, 267, 340, 1249, 436, 1249, 1988, 17, 61, 508, 5429, 391, 837, 288, 1249, 275, 1249, 4439, 17, 61, 288, 1284, 275, 298, 298, 267, 340, 1249, 436, 1249, 59, 16, 61, 508, 23353, 14, 20475, 8, 1418, 14, 12811, 18013, 12, 298, 1140, 2349, 288, 702, 822, 8, 589, 9, 2356, 499, 288, 570, 275, 1249, 59, 17, 1055, 6311, 342, 288, 1249, 275, 1249, 59, 19, 2938, 327, 19828, 282, 3962, 10029, 2410, 314, 570, 3965, 267, 327, 7356, 9560, 1589, 890, 282, 870, 8, 589, 12, 7375, 29, 11577, 1284, 29, 11577, 570, 29, 11965, 1031, 14, 267, 634, 63, 589, 275, 359, 1273, 14, 6311, 342, 367, 1680, 315, 1249, 61, 267, 340, 634, 63, 589, 26, 288, 634, 63, 589, 59, 16, 1055, 1861, 275, 3087, 267, 340, 7375, 365, 440, 488, 503, 1284, 365, 440, 488, 503, 570, 365, 440, 488, 26, 288, 340, 7375, 365, 440, 488, 26, 355, 291, 14, 525, 63, 12745, 8, 76, 63, 589, 12, 298, 4127, 401, 2624, 8, 2722, 8, 4127, 1724, 288, 340, 1284, 365, 440, 488, 26, 355, 291, 14, 525, 63, 12745, 8, 76, 63, 589, 12, 298, 500, 401, 2624, 8, 2722, 8, 500, 1724, 288, 340, 570, 365, 440, 488, 26, 355, 291, 14, 525, 63, 12745, 8, 76, 63, 589, 12, 298, 493, 401, 570, 9, 267, 302, 63, 9649, 275, 6523, 8, 985, 480, 1361, 1288, 634, 63, 589, 9, 267, 302, 63, 9649, 14, 1861, 275, 1031, 14, 1861, 267, 372, 302, 63, 9649, 339, 347, 1050, 63, 12745, 8, 277, 12, 634, 63, 2415, 12, 308, 63, 829, 68, 12, 302, 63, 3684, 304, 267, 327, 5787, 2900, 642, 2403, 13, 6031, 1443, 27332, 6786, 334, 15401, 24063, 590, 9, 267, 302, 63, 3684, 14, 1861, 275, 3087, 267, 302, 63, 2094, 275, 23353, 14, 1716, 8, 277, 14, 13807, 14, 2094, 12, 639, 334, 985, 8, 83, 63, 829, 68, 395, 3303, 23353, 14, 20475, 8, 1418, 14, 16352, 12, 22250, 395, 3303, 302, 63, 3684, 430, 267, 340, 634, 63, 2415, 26, 288, 634, 63, 2415, 14, 740, 8, 25732, 1012, 288, 302, 63, 2094, 14, 1861, 275, 298, 298, 267, 634, 63, 2415, 14, 740, 8, 78, 63, 2094, 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 ]
[ 1898, 8315, 4475, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 199, 624, 11985, 281, 367, 870, 14, 199, 199, 4001, 26, 272, 283, 1361, 7, 3515, 1901, 283, 1361, 11716, 272, 283, 1361, 2263, 7, 420, 1901, 283, 1361, 29195, 3171, 272, 283, 1361, 2263, 20606, 259, 1901, 283, 1361, 8, 11577, 1284, 628, 298, 3171, 272, 283, 1361, 4331, 88, 12, 2263, 7, 1901, 283, 1361, 8, 11577, 570, 29, 88, 3171, 199, 199, 1944, 4493, 787, 6781, 340, 870, 63, 1593, 365, 8439, 687, 636, 2443, 363, 199, 199, 624, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 12713, 863, 199, 504, 2508, 492, 23353, 199, 504, 2508, 80, 2268, 18, 492, 1526, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 2812, 12, 6523, 12, 5429, 391, 12, 2624, 12, 365, 63, 2960, 421, 199, 9575, 68, 63, 3684, 275, 12713, 863, 14, 2014, 63, 3401, 8, 1598, 408, 4188, 28, 16746, 359, 4188, 92, 5353, 92, 2339, 61, 16107, 690, 624, 1598, 776, 421, 199, 533, 14811, 5375, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 339, 31467, 7689, 275, 408, 1598, 3486, 63, 9649, 28, 1263, 10, 18753, 534, 1361, 7, 1263, 10, 690, 1204, 870, 63, 9649, 1598, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 702, 2058, 398, 18753, 63, 1361, 275, 2058, 14, 362, 480, 14890, 531, 398, 340, 18753, 63, 1361, 26, 288, 327, 12568, 13, 2546, 870, 1006, 701, 6337, 288, 18753, 63, 1361, 14, 1814, 8, 2176, 8, 985, 480, 1361, 1288, 990, 3044, 2403, 29, 14890, 63, 1361, 14, 1861, 430, 288, 372, 267, 702, 1031, 14, 3223, 59, 16, 61, 508, 2812, 480, 1361, 531, 267, 1249, 275, 1031, 14, 3223, 59, 17, 2938, 267, 340, 822, 8, 589, 9, 508, 413, 436, 13566, 68, 63, 3684, 14, 1431, 8, 589, 59, 16, 4682, 288, 327, 2136, 2793, 1133, 2934, 370, 4215, 29404, 316, 32029, 6818, 376, 288, 327, 2575, 13, 9575, 1589, 338, 939, 3965, 14, 288, 372, 398, 7375, 275, 1284, 275, 570, 275, 488, 267, 340, 1249, 436, 1249, 1988, 17, 61, 508, 5429, 391, 837, 288, 1249, 275, 1249, 4439, 17, 61, 288, 1284, 275, 298, 298, 267, 340, 1249, 436, 1249, 59, 16, 61, 508, 23353, 14, 20475, 8, 1418, 14, 12811, 18013, 12, 298, 1140, 2349, 288, 702, 822, 8, 589, 9, 2356, 499, 288, 570, 275, 1249, 59, 17, 1055, 6311, 342, 288, 1249, 275, 1249, 59, 19, 2938, 327, 19828, 282, 3962, 10029, 2410, 314, 570, 3965, 267, 327, 7356, 9560, 1589, 890, 282, 870, 8, 589, 12, 7375, 29, 11577, 1284, 29, 11577, 570, 29, 11965, 1031, 14, 267, 634, 63, 589, 275, 359, 1273, 14, 6311, 342, 367, 1680, 315, 1249, 61, 267, 340, 634, 63, 589, 26, 288, 634, 63, 589, 59, 16, 1055, 1861, 275, 3087, 267, 340, 7375, 365, 440, 488, 503, 1284, 365, 440, 488, 503, 570, 365, 440, 488, 26, 288, 340, 7375, 365, 440, 488, 26, 355, 291, 14, 525, 63, 12745, 8, 76, 63, 589, 12, 298, 4127, 401, 2624, 8, 2722, 8, 4127, 1724, 288, 340, 1284, 365, 440, 488, 26, 355, 291, 14, 525, 63, 12745, 8, 76, 63, 589, 12, 298, 500, 401, 2624, 8, 2722, 8, 500, 1724, 288, 340, 570, 365, 440, 488, 26, 355, 291, 14, 525, 63, 12745, 8, 76, 63, 589, 12, 298, 493, 401, 570, 9, 267, 302, 63, 9649, 275, 6523, 8, 985, 480, 1361, 1288, 634, 63, 589, 9, 267, 302, 63, 9649, 14, 1861, 275, 1031, 14, 1861, 267, 372, 302, 63, 9649, 339, 347, 1050, 63, 12745, 8, 277, 12, 634, 63, 2415, 12, 308, 63, 829, 68, 12, 302, 63, 3684, 304, 267, 327, 5787, 2900, 642, 2403, 13, 6031, 1443, 27332, 6786, 334, 15401, 24063, 590, 9, 267, 302, 63, 3684, 14, 1861, 275, 3087, 267, 302, 63, 2094, 275, 23353, 14, 1716, 8, 277, 14, 13807, 14, 2094, 12, 639, 334, 985, 8, 83, 63, 829, 68, 395, 3303, 23353, 14, 20475, 8, 1418, 14, 16352, 12, 22250, 395, 3303, 302, 63, 3684, 430, 267, 340, 634, 63, 2415, 26, 288, 634, 63, 2415, 14, 740, 8, 25732, 1012, 288, 302, 63, 2094, 14, 1861, 275, 298, 298, 267, 634, 63, 2415, 14, 740, 8, 78, 63, 2094, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
NiclasEriksen/py-towerwars
src/numpy/distutils/intelccompiler.py
59
1775
from __future__ import division, absolute_import, print_function from distutils.unixccompiler import UnixCCompiler from numpy.distutils.exec_command import find_executable class IntelCCompiler(UnixCCompiler): """ A modified Intel compiler compatible with an gcc built Python.""" compiler_type = 'intel' cc_exe = 'icc' cc_args = 'fPIC' def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__ (self, verbose, dry_run, force) self.cc_exe = 'icc -fPIC' compiler = self.cc_exe self.set_executables(compiler=compiler, compiler_so=compiler, compiler_cxx=compiler, linker_exe=compiler, linker_so=compiler + ' -shared') class IntelItaniumCCompiler(IntelCCompiler): compiler_type = 'intele' # On Itanium, the Intel Compiler used to be called ecc, let's search for # it (now it's also icc, so ecc is last in the search). for cc_exe in map(find_executable, ['icc', 'ecc']): if cc_exe: break class IntelEM64TCCompiler(UnixCCompiler): """ A modified Intel x86_64 compiler compatible with a 64bit gcc built Python. """ compiler_type = 'intelem' cc_exe = 'icc -m64 -fPIC' cc_args = "-fPIC" def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__ (self, verbose, dry_run, force) self.cc_exe = 'icc -m64 -fPIC' compiler = self.cc_exe self.set_executables(compiler=compiler, compiler_so=compiler, compiler_cxx=compiler, linker_exe=compiler, linker_so=compiler + ' -shared')
cc0-1.0
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 504, 7065, 14, 11864, 67, 5772, 492, 13074, 30926, 199, 504, 2680, 14, 13350, 14, 1628, 63, 1531, 492, 2342, 63, 5904, 199, 199, 533, 20619, 30926, 8, 21607, 30926, 304, 272, 408, 437, 6042, 20619, 6365, 9025, 543, 376, 19443, 6137, 2018, 1041, 272, 6365, 63, 466, 275, 283, 22264, 7, 272, 7429, 63, 5803, 275, 283, 530, 67, 7, 272, 7429, 63, 589, 275, 283, 70, 26769, 7, 339, 347, 636, 826, 363, 334, 277, 12, 3376, 29, 16, 12, 9951, 63, 1065, 29, 16, 12, 3542, 29, 16, 304, 267, 13074, 30926, 855, 826, 363, 334, 277, 12, 3376, 12, 9951, 63, 1065, 12, 3542, 9, 267, 291, 14, 2055, 63, 5803, 275, 283, 530, 67, 446, 70, 26769, 7, 267, 6365, 275, 291, 14, 2055, 63, 5803, 267, 291, 14, 409, 63, 5904, 83, 8, 5772, 29, 5772, 12, 2490, 6365, 63, 1152, 29, 5772, 12, 2490, 6365, 63, 9634, 29, 5772, 12, 2490, 17261, 63, 5803, 29, 5772, 12, 2490, 17261, 63, 1152, 29, 5772, 435, 283, 446, 5555, 358, 199, 199, 533, 20619, 7940, 290, 5170, 30926, 8, 27528, 30926, 304, 272, 6365, 63, 466, 275, 283, 5707, 274, 7, 339, 327, 4068, 2779, 290, 5170, 12, 314, 20619, 27154, 1202, 370, 506, 2797, 325, 2055, 12, 4691, 1159, 2754, 367, 272, 327, 652, 334, 2131, 652, 1159, 2597, 284, 2055, 12, 880, 325, 2055, 365, 2061, 315, 314, 2754, 680, 272, 367, 7429, 63, 5803, 315, 2341, 8, 1623, 63, 5904, 12, 788, 530, 67, 297, 283, 825, 67, 9090, 267, 340, 7429, 63, 5803, 26, 288, 2059, 199, 199, 533, 20619, 2769, 772, 5708, 9131, 8, 21607, 30926, 304, 272, 408, 437, 6042, 20619, 671, 1184, 63, 772, 6365, 9025, 543, 282, 5049, 2075, 19443, 6137, 2018, 14, 272, 408, 272, 6365, 63, 466, 275, 283, 5707, 3701, 7, 272, 7429, 63, 5803, 275, 283, 530, 67, 446, 77, 772, 446, 70, 26769, 7, 272, 7429, 63, 589, 275, 3905, 70, 26769, 2, 272, 347, 636, 826, 363, 334, 277, 12, 3376, 29, 16, 12, 9951, 63, 1065, 29, 16, 12, 3542, 29, 16, 304, 267, 13074, 30926, 855, 826, 363, 334, 277, 12, 3376, 12, 9951, 63, 1065, 12, 3542, 9, 267, 291, 14, 2055, 63, 5803, 275, 283, 530, 67, 446, 77, 772, 446, 70, 26769, 7, 267, 6365, 275, 291, 14, 2055, 63, 5803, 267, 291, 14, 409, 63, 5904, 83, 8, 5772, 29, 5772, 12, 2490, 6365, 63, 1152, 29, 5772, 12, 2490, 6365, 63, 9634, 29, 5772, 12, 2490, 17261, 63, 5803, 29, 5772, 12, 2490, 17261, 63, 1152, 29, 5772, 435, 283, 446, 5555, 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 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 504, 7065, 14, 11864, 67, 5772, 492, 13074, 30926, 199, 504, 2680, 14, 13350, 14, 1628, 63, 1531, 492, 2342, 63, 5904, 199, 199, 533, 20619, 30926, 8, 21607, 30926, 304, 272, 408, 437, 6042, 20619, 6365, 9025, 543, 376, 19443, 6137, 2018, 1041, 272, 6365, 63, 466, 275, 283, 22264, 7, 272, 7429, 63, 5803, 275, 283, 530, 67, 7, 272, 7429, 63, 589, 275, 283, 70, 26769, 7, 339, 347, 636, 826, 363, 334, 277, 12, 3376, 29, 16, 12, 9951, 63, 1065, 29, 16, 12, 3542, 29, 16, 304, 267, 13074, 30926, 855, 826, 363, 334, 277, 12, 3376, 12, 9951, 63, 1065, 12, 3542, 9, 267, 291, 14, 2055, 63, 5803, 275, 283, 530, 67, 446, 70, 26769, 7, 267, 6365, 275, 291, 14, 2055, 63, 5803, 267, 291, 14, 409, 63, 5904, 83, 8, 5772, 29, 5772, 12, 2490, 6365, 63, 1152, 29, 5772, 12, 2490, 6365, 63, 9634, 29, 5772, 12, 2490, 17261, 63, 5803, 29, 5772, 12, 2490, 17261, 63, 1152, 29, 5772, 435, 283, 446, 5555, 358, 199, 199, 533, 20619, 7940, 290, 5170, 30926, 8, 27528, 30926, 304, 272, 6365, 63, 466, 275, 283, 5707, 274, 7, 339, 327, 4068, 2779, 290, 5170, 12, 314, 20619, 27154, 1202, 370, 506, 2797, 325, 2055, 12, 4691, 1159, 2754, 367, 272, 327, 652, 334, 2131, 652, 1159, 2597, 284, 2055, 12, 880, 325, 2055, 365, 2061, 315, 314, 2754, 680, 272, 367, 7429, 63, 5803, 315, 2341, 8, 1623, 63, 5904, 12, 788, 530, 67, 297, 283, 825, 67, 9090, 267, 340, 7429, 63, 5803, 26, 288, 2059, 199, 199, 533, 20619, 2769, 772, 5708, 9131, 8, 21607, 30926, 304, 272, 408, 437, 6042, 20619, 671, 1184, 63, 772, 6365, 9025, 543, 282, 5049, 2075, 19443, 6137, 2018, 14, 272, 408, 272, 6365, 63, 466, 275, 283, 5707, 3701, 7, 272, 7429, 63, 5803, 275, 283, 530, 67, 446, 77, 772, 446, 70, 26769, 7, 272, 7429, 63, 589, 275, 3905, 70, 26769, 2, 272, 347, 636, 826, 363, 334, 277, 12, 3376, 29, 16, 12, 9951, 63, 1065, 29, 16, 12, 3542, 29, 16, 304, 267, 13074, 30926, 855, 826, 363, 334, 277, 12, 3376, 12, 9951, 63, 1065, 12, 3542, 9, 267, 291, 14, 2055, 63, 5803, 275, 283, 530, 67, 446, 77, 772, 446, 70, 26769, 7, 267, 6365, 275, 291, 14, 2055, 63, 5803, 267, 291, 14, 409, 63, 5904, 83, 8, 5772, 29, 5772, 12, 2490, 6365, 63, 1152, 29, 5772, 12, 2490, 6365, 63, 9634, 29, 5772, 12, 2490, 17261, 63, 5803, 29, 5772, 12, 2490, 17261, 63, 1152, 29, 5772, 435, 283, 446, 5555, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sandan/sqlalchemy
examples/association/proxied_association.py
30
3324
"""proxied_association.py same example as basic_association, adding in usage of :mod:`sqlalchemy.ext.associationproxy` to make explicit references to ``OrderItem`` optional. """ from datetime import datetime from sqlalchemy import (create_engine, MetaData, Table, Column, Integer, String, DateTime, Float, ForeignKey, and_) from sqlalchemy.orm import mapper, relationship, Session from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.associationproxy import association_proxy Base = declarative_base() class Order(Base): __tablename__ = 'order' order_id = Column(Integer, primary_key=True) customer_name = Column(String(30), nullable=False) order_date = Column(DateTime, nullable=False, default=datetime.now()) order_items = relationship("OrderItem", cascade="all, delete-orphan", backref='order') items = association_proxy("order_items", "item") def __init__(self, customer_name): self.customer_name = customer_name class Item(Base): __tablename__ = 'item' item_id = Column(Integer, primary_key=True) description = Column(String(30), nullable=False) price = Column(Float, nullable=False) def __init__(self, description, price): self.description = description self.price = price def __repr__(self): return 'Item(%r, %r)' % ( self.description, self.price ) class OrderItem(Base): __tablename__ = 'orderitem' order_id = Column(Integer, ForeignKey('order.order_id'), primary_key=True) item_id = Column(Integer, ForeignKey('item.item_id'), primary_key=True) price = Column(Float, nullable=False) def __init__(self, item, price=None): self.item = item self.price = price or item.price item = relationship(Item, lazy='joined') if __name__ == '__main__': engine = create_engine('sqlite://') Base.metadata.create_all(engine) session = Session(engine) # create catalog tshirt, mug, hat, crowbar = ( Item('SA T-Shirt', 10.99), Item('SA Mug', 6.50), Item('SA Hat', 8.99), Item('MySQL Crowbar', 16.99) ) session.add_all([tshirt, mug, hat, crowbar]) session.commit() # create an order order = Order('john smith') # add items via the association proxy. # the OrderItem is created automatically. order.items.append(mug) order.items.append(hat) # add an OrderItem explicitly. order.order_items.append(OrderItem(crowbar, 10.99)) session.add(order) session.commit() # query the order, print items order = session.query(Order).filter_by(customer_name='john smith').one() # print items based on the OrderItem collection directly print([(assoc.item.description, assoc.price, assoc.item.price) for assoc in order.order_items]) # print items based on the "proxied" items collection print([(item.description, item.price) for item in order.items]) # print customers who bought 'MySQL Crowbar' on sale orders = session.query(Order).\ join('order_items', 'item').\ filter(Item.description == 'MySQL Crowbar').\ filter(Item.price > OrderItem.price) print([o.customer_name for o in orders])
mit
[ 624, 8221, 5299, 63, 20252, 14, 647, 199, 199, 7191, 2893, 465, 5678, 63, 20252, 12, 7791, 315, 199, 3807, 402, 520, 1494, 1705, 14536, 14, 832, 14, 20252, 3280, 64, 370, 1852, 5027, 6941, 199, 475, 1124, 4738, 2081, 1040, 2716, 14, 421, 199, 624, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 8335, 492, 334, 981, 63, 3908, 12, 24905, 12, 6957, 12, 4996, 12, 7225, 12, 272, 2624, 12, 13686, 12, 11140, 12, 12718, 12, 436, 4602, 199, 504, 8335, 14, 1025, 492, 7796, 12, 8931, 12, 8596, 199, 504, 8335, 14, 832, 14, 12164, 1905, 492, 30191, 63, 1095, 199, 504, 8335, 14, 832, 14, 20252, 3280, 492, 20640, 63, 3280, 199, 199, 1563, 275, 30191, 63, 1095, 342, 199, 199, 533, 9240, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 1648, 7, 339, 1865, 63, 344, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 15229, 63, 354, 275, 4996, 8, 1558, 8, 1216, 395, 7854, 29, 797, 9, 272, 1865, 63, 602, 275, 4996, 8, 3926, 12, 7854, 29, 797, 12, 849, 29, 2083, 14, 2131, 1012, 272, 1865, 63, 1744, 275, 8931, 480, 4738, 2081, 401, 22809, 628, 452, 12, 3145, 13, 22161, 401, 1169, 23412, 534, 1648, 358, 272, 2974, 275, 20640, 63, 3280, 480, 1648, 63, 1744, 401, 298, 1053, 531, 339, 347, 636, 826, 721, 277, 12, 15229, 63, 354, 304, 267, 291, 14, 10178, 63, 354, 275, 15229, 63, 354, 199, 199, 533, 7020, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 1053, 7, 272, 1242, 63, 344, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 1369, 275, 4996, 8, 1558, 8, 1216, 395, 7854, 29, 797, 9, 272, 8033, 275, 4996, 8, 5136, 12, 7854, 29, 797, 9, 339, 347, 636, 826, 721, 277, 12, 1369, 12, 8033, 304, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 4777, 275, 8033, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 2081, 4042, 82, 12, 450, 82, 3171, 450, 334, 490, 291, 14, 1802, 12, 291, 14, 4777, 355, 776, 199, 199, 533, 9240, 2081, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 269, 9910, 563, 7, 272, 1865, 63, 344, 275, 4996, 8, 2674, 12, 12718, 360, 1648, 14, 1648, 63, 344, 659, 5062, 63, 498, 29, 549, 9, 272, 1242, 63, 344, 275, 4996, 8, 2674, 12, 12718, 360, 1053, 14, 1053, 63, 344, 659, 5062, 63, 498, 29, 549, 9, 272, 8033, 275, 4996, 8, 5136, 12, 7854, 29, 797, 9, 339, 347, 636, 826, 721, 277, 12, 1242, 12, 8033, 29, 403, 304, 267, 291, 14, 1053, 275, 1242, 267, 291, 14, 4777, 275, 8033, 503, 1242, 14, 4777, 272, 1242, 275, 8931, 8, 2081, 12, 9617, 534, 11806, 358, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 6869, 275, 1218, 63, 3908, 360, 10659, 921, 358, 272, 3523, 14, 2343, 14, 981, 63, 452, 8, 3908, 9, 339, 2351, 275, 8596, 8, 3908, 9, 339, 327, 1218, 10594, 272, 307, 609, 8401, 12, 333, 1518, 12, 394, 292, 12, 286, 1143, 1700, 275, 334, 267, 7020, 360, 4251, 377, 13, 2662, 8401, 297, 1616, 14, 1020, 395, 267, 7020, 360, 4251, 603, 1518, 297, 1227, 14, 1400, 395, 267, 7020, 360, 4251, 13002, 297, 1695, 14, 1020, 395, 267, 7020, 360, 20784, 445, 1143, 1700, 297, 3193, 14, 1020, 9, 272, 776, 272, 2351, 14, 525, 63, 452, 779, 84, 609, 8401, 12, 333, 1518, 12, 394, 292, 12, 286, 1143, 1700, 566, 272, 2351, 14, 3543, 342, 339, 327, 1218, 376, 1865, 272, 1865, 275, 9240, 360, 20216, 4383, 448, 358, 339, 327, 1050, 2974, 4799, 314, 20640, 4566, 14, 272, 327, 314, 9240, 2081, 365, 2737, 5847, 14, 272, 1865, 14, 1744, 14, 740, 8, 77, 1518, 9, 272, 1865, 14, 1744, 14, 740, 8, 8554, 9, 339, 327, 1050, 376, 9240, 2081, 7662, 14, 272, 1865, 14, 1648, 63, 1744, 14, 740, 8, 4738, 2081, 8, 67, 1143, 1700, 12, 1616, 14, 1020, 430, 339, 2351, 14, 525, 8, 1648, 9, 272, 2351, 14, 3543, 342, 339, 327, 1827, 314, 1865, 12, 870, 2974, 272, 1865, 275, 2351, 14, 1131, 8, 4738, 680, 1541, 63, 991, 8, 10178, 63, 354, 534, 20216, 4383, 448, 1959, 368, 342, 339, 327, 870, 2974, 4079, 641, 314, 9240, 2081, 3245, 5370, 272, 870, 7694, 16824, 14, 1053, 14, 1802, 12, 22149, 14, 4777, 12, 22149, 14, 1053, 14, 4777, 9, 1779, 367, 22149, 315, 1865, 14, 1648, 63, 1744, 566, 339, 327, 870, 2974, 4079, 641, 314, 298, 8221, 5299, 2, 2974, 3245, 272, 870, 7694, 1053, 14, 1802, 12, 1242, 14, 4777, 9, 1779, 367, 1242, 315, 1865, 14, 1744, 566, 339, 327, 870, 286, 28078, 3963, 330, 20816, 283, 20784, 445, 1143, 1700, 7, 641, 13590, 272, 15460, 275, 2351, 14, 1131, 8, 4738, 12013, 490, 4263, 360, 1648, 63, 1744, 297, 283, 1053, 1959, 60, 490, 2457, 8, 2081, 14, 1802, 508, 283, 20784, 445, 1143, 1700, 1959, 60, 490, 2457, 8, 2081, 14, 4777, 690, 9240, 2081, 14, 4777, 9, 272, 870, 779, 79, 14, 10178, 63, 354, 367, 312, 315, 15460, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8221, 5299, 63, 20252, 14, 647, 199, 199, 7191, 2893, 465, 5678, 63, 20252, 12, 7791, 315, 199, 3807, 402, 520, 1494, 1705, 14536, 14, 832, 14, 20252, 3280, 64, 370, 1852, 5027, 6941, 199, 475, 1124, 4738, 2081, 1040, 2716, 14, 421, 199, 624, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 8335, 492, 334, 981, 63, 3908, 12, 24905, 12, 6957, 12, 4996, 12, 7225, 12, 272, 2624, 12, 13686, 12, 11140, 12, 12718, 12, 436, 4602, 199, 504, 8335, 14, 1025, 492, 7796, 12, 8931, 12, 8596, 199, 504, 8335, 14, 832, 14, 12164, 1905, 492, 30191, 63, 1095, 199, 504, 8335, 14, 832, 14, 20252, 3280, 492, 20640, 63, 3280, 199, 199, 1563, 275, 30191, 63, 1095, 342, 199, 199, 533, 9240, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 1648, 7, 339, 1865, 63, 344, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 15229, 63, 354, 275, 4996, 8, 1558, 8, 1216, 395, 7854, 29, 797, 9, 272, 1865, 63, 602, 275, 4996, 8, 3926, 12, 7854, 29, 797, 12, 849, 29, 2083, 14, 2131, 1012, 272, 1865, 63, 1744, 275, 8931, 480, 4738, 2081, 401, 22809, 628, 452, 12, 3145, 13, 22161, 401, 1169, 23412, 534, 1648, 358, 272, 2974, 275, 20640, 63, 3280, 480, 1648, 63, 1744, 401, 298, 1053, 531, 339, 347, 636, 826, 721, 277, 12, 15229, 63, 354, 304, 267, 291, 14, 10178, 63, 354, 275, 15229, 63, 354, 199, 199, 533, 7020, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 1053, 7, 272, 1242, 63, 344, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 1369, 275, 4996, 8, 1558, 8, 1216, 395, 7854, 29, 797, 9, 272, 8033, 275, 4996, 8, 5136, 12, 7854, 29, 797, 9, 339, 347, 636, 826, 721, 277, 12, 1369, 12, 8033, 304, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 4777, 275, 8033, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 2081, 4042, 82, 12, 450, 82, 3171, 450, 334, 490, 291, 14, 1802, 12, 291, 14, 4777, 355, 776, 199, 199, 533, 9240, 2081, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 269, 9910, 563, 7, 272, 1865, 63, 344, 275, 4996, 8, 2674, 12, 12718, 360, 1648, 14, 1648, 63, 344, 659, 5062, 63, 498, 29, 549, 9, 272, 1242, 63, 344, 275, 4996, 8, 2674, 12, 12718, 360, 1053, 14, 1053, 63, 344, 659, 5062, 63, 498, 29, 549, 9, 272, 8033, 275, 4996, 8, 5136, 12, 7854, 29, 797, 9, 339, 347, 636, 826, 721, 277, 12, 1242, 12, 8033, 29, 403, 304, 267, 291, 14, 1053, 275, 1242, 267, 291, 14, 4777, 275, 8033, 503, 1242, 14, 4777, 272, 1242, 275, 8931, 8, 2081, 12, 9617, 534, 11806, 358, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 6869, 275, 1218, 63, 3908, 360, 10659, 921, 358, 272, 3523, 14, 2343, 14, 981, 63, 452, 8, 3908, 9, 339, 2351, 275, 8596, 8, 3908, 9, 339, 327, 1218, 10594, 272, 307, 609, 8401, 12, 333, 1518, 12, 394, 292, 12, 286, 1143, 1700, 275, 334, 267, 7020, 360, 4251, 377, 13, 2662, 8401, 297, 1616, 14, 1020, 395, 267, 7020, 360, 4251, 603, 1518, 297, 1227, 14, 1400, 395, 267, 7020, 360, 4251, 13002, 297, 1695, 14, 1020, 395, 267, 7020, 360, 20784, 445, 1143, 1700, 297, 3193, 14, 1020, 9, 272, 776, 272, 2351, 14, 525, 63, 452, 779, 84, 609, 8401, 12, 333, 1518, 12, 394, 292, 12, 286, 1143, 1700, 566, 272, 2351, 14, 3543, 342, 339, 327, 1218, 376, 1865, 272, 1865, 275, 9240, 360, 20216, 4383, 448, 358, 339, 327, 1050, 2974, 4799, 314, 20640, 4566, 14, 272, 327, 314, 9240, 2081, 365, 2737, 5847, 14, 272, 1865, 14, 1744, 14, 740, 8, 77, 1518, 9, 272, 1865, 14, 1744, 14, 740, 8, 8554, 9, 339, 327, 1050, 376, 9240, 2081, 7662, 14, 272, 1865, 14, 1648, 63, 1744, 14, 740, 8, 4738, 2081, 8, 67, 1143, 1700, 12, 1616, 14, 1020, 430, 339, 2351, 14, 525, 8, 1648, 9, 272, 2351, 14, 3543, 342, 339, 327, 1827, 314, 1865, 12, 870, 2974, 272, 1865, 275, 2351, 14, 1131, 8, 4738, 680, 1541, 63, 991, 8, 10178, 63, 354, 534, 20216, 4383, 448, 1959, 368, 342, 339, 327, 870, 2974, 4079, 641, 314, 9240, 2081, 3245, 5370, 272, 870, 7694, 16824, 14, 1053, 14, 1802, 12, 22149, 14, 4777, 12, 22149, 14, 1053, 14, 4777, 9, 1779, 367, 22149, 315, 1865, 14, 1648, 63, 1744, 566, 339, 327, 870, 2974, 4079, 641, 314, 298, 8221, 5299, 2, 2974, 3245, 272, 870, 7694, 1053, 14, 1802, 12, 1242, 14, 4777, 9, 1779, 367, 1242, 315, 1865, 14, 1744, 566, 339, 327, 870, 286, 28078, 3963, 330, 20816, 283, 20784, 445, 1143, 1700, 7, 641, 13590, 272, 15460, 275, 2351, 14, 1131, 8, 4738, 12013, 490, 4263, 360, 1648, 63, 1744, 297, 283, 1053, 1959, 60, 490, 2457, 8, 2081, 14, 1802, 508, 283, 20784, 445, 1143, 1700, 1959, 60, 490, 2457, 8, 2081, 14, 4777, 690, 9240, 2081, 14, 4777, 9, 272, 870, 779, 79, 14, 10178, 63, 354, 367, 312, 315, 15460, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dwightgunning/django
django/views/generic/detail.py
306
6922
from __future__ import unicode_literals from django.core.exceptions import ImproperlyConfigured from django.db import models from django.http import Http404 from django.utils.translation import ugettext as _ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View class SingleObjectMixin(ContextMixin): """ Provides the ability to retrieve a single object for further manipulation. """ model = None queryset = None slug_field = 'slug' context_object_name = None slug_url_kwarg = 'slug' pk_url_kwarg = 'pk' query_pk_and_slug = False def get_object(self, queryset=None): """ Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `slug` argument in the URLconf, but subclasses can override this to return any object. """ # Use a custom queryset if provided; this is required for subclasses # like DateDetailView if queryset is None: queryset = self.get_queryset() # Next, try looking up by primary key. pk = self.kwargs.get(self.pk_url_kwarg) slug = self.kwargs.get(self.slug_url_kwarg) if pk is not None: queryset = queryset.filter(pk=pk) # Next, try looking up by slug. if slug is not None and (pk is None or self.query_pk_and_slug): slug_field = self.get_slug_field() queryset = queryset.filter(**{slug_field: slug}) # If none of those are defined, it's an error. if pk is None and slug is None: raise AttributeError("Generic detail view %s must be called with " "either an object pk or a slug." % self.__class__.__name__) try: # Get the single item from the filtered queryset obj = queryset.get() except queryset.model.DoesNotExist: raise Http404(_("No %(verbose_name)s found matching the query") % {'verbose_name': queryset.model._meta.verbose_name}) return obj def get_queryset(self): """ Return the `QuerySet` that will be used to look up the object. Note that this method is called by the default implementation of `get_object` and may not be called if `get_object` is overridden. """ if self.queryset is None: if self.model: return self.model._default_manager.all() else: raise ImproperlyConfigured( "%(cls)s is missing a QuerySet. Define " "%(cls)s.model, %(cls)s.queryset, or override " "%(cls)s.get_queryset()." % { 'cls': self.__class__.__name__ } ) return self.queryset.all() def get_slug_field(self): """ Get the name of a slug field to be used to look up by slug. """ return self.slug_field def get_context_object_name(self, obj): """ Get the name to use for the object. """ if self.context_object_name: return self.context_object_name elif isinstance(obj, models.Model): if self.object._deferred: obj = obj._meta.proxy_for_model return obj._meta.model_name else: return None def get_context_data(self, **kwargs): """ Insert the single object into the context dict. """ context = {} if self.object: context['object'] = self.object context_object_name = self.get_context_object_name(self.object) if context_object_name: context[context_object_name] = self.object context.update(kwargs) return super(SingleObjectMixin, self).get_context_data(**context) class BaseDetailView(SingleObjectMixin, View): """ A base view for displaying a single object """ def get(self, request, *args, **kwargs): self.object = self.get_object() context = self.get_context_data(object=self.object) return self.render_to_response(context) class SingleObjectTemplateResponseMixin(TemplateResponseMixin): template_name_field = None template_name_suffix = '_detail' def get_template_names(self): """ Return a list of template names to be used for the request. May not be called if render_to_response is overridden. Returns the following list: * the value of ``template_name`` on the view (if provided) * the contents of the ``template_name_field`` field on the object instance that the view is operating upon (if available) * ``<app_label>/<model_name><template_name_suffix>.html`` """ try: names = super(SingleObjectTemplateResponseMixin, self).get_template_names() except ImproperlyConfigured: # If template_name isn't specified, it's not a problem -- # we just start with an empty list. names = [] # If self.template_name_field is set, grab the value of the field # of that name from the object; this is the most specific template # name, if given. if self.object and self.template_name_field: name = getattr(self.object, self.template_name_field, None) if name: names.insert(0, name) # The least-specific option is the default <app>/<model>_detail.html; # only use this if the object in question is a model. if isinstance(self.object, models.Model): object_meta = self.object._meta if self.object._deferred: object_meta = self.object._meta.proxy_for_model._meta names.append("%s/%s%s.html" % ( object_meta.app_label, object_meta.model_name, self.template_name_suffix )) elif hasattr(self, 'model') and self.model is not None and issubclass(self.model, models.Model): names.append("%s/%s%s.html" % ( self.model._meta.app_label, self.model._meta.model_name, self.template_name_suffix )) # If we still haven't managed to find any template names, we should # re-raise the ImproperlyConfigured to alert the user. if not names: raise return names class DetailView(SingleObjectTemplateResponseMixin, BaseDetailView): """ Render a "detail" view of an object. By default this is a model instance looked up from `self.queryset`, but the view will support display of *any* object by overriding `self.get_object()`. """
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 6767, 14, 1095, 492, 9470, 4256, 12, 29264, 4256, 12, 10935, 421, 199, 533, 13050, 1692, 4256, 8, 2998, 4256, 304, 272, 408, 272, 21552, 314, 21255, 370, 8044, 282, 2849, 909, 367, 9848, 26212, 14, 272, 408, 272, 1402, 275, 488, 272, 7594, 275, 488, 272, 8889, 63, 698, 275, 283, 5464, 7, 272, 1067, 63, 785, 63, 354, 275, 488, 272, 8889, 63, 633, 63, 12745, 275, 283, 5464, 7, 272, 3803, 63, 633, 63, 12745, 275, 283, 2051, 7, 272, 1827, 63, 2051, 63, 460, 63, 5464, 275, 756, 339, 347, 664, 63, 785, 8, 277, 12, 7594, 29, 403, 304, 267, 408, 267, 1803, 314, 909, 314, 2455, 365, 20589, 14, 398, 4885, 849, 642, 5074, 658, 277, 14, 7924, 64, 436, 282, 658, 2051, 64, 503, 658, 5464, 64, 1423, 267, 315, 314, 2851, 2190, 12, 1325, 9180, 883, 4278, 642, 370, 372, 1263, 909, 14, 267, 408, 267, 327, 3645, 282, 3537, 7594, 340, 2741, 27, 642, 365, 1415, 367, 9180, 267, 327, 2839, 6148, 28539, 267, 340, 7594, 365, 488, 26, 288, 7594, 275, 291, 14, 362, 63, 7924, 342, 398, 327, 16840, 12, 862, 10023, 1536, 701, 5062, 790, 14, 267, 3803, 275, 291, 14, 958, 14, 362, 8, 277, 14, 2051, 63, 633, 63, 12745, 9, 267, 8889, 275, 291, 14, 958, 14, 362, 8, 277, 14, 5464, 63, 633, 63, 12745, 9, 267, 340, 3803, 365, 440, 488, 26, 288, 7594, 275, 7594, 14, 1541, 8, 2051, 29, 2051, 9, 398, 327, 16840, 12, 862, 10023, 1536, 701, 8889, 14, 267, 340, 8889, 365, 440, 488, 436, 334, 2051, 365, 488, 503, 291, 14, 1131, 63, 2051, 63, 460, 63, 5464, 304, 288, 8889, 63, 698, 275, 291, 14, 362, 63, 5464, 63, 698, 342, 288, 7594, 275, 7594, 14, 1541, 25679, 5464, 63, 698, 26, 8889, 1552, 398, 327, 982, 7179, 402, 5204, 787, 3247, 12, 652, 1159, 376, 1125, 14, 267, 340, 3803, 365, 488, 436, 8889, 365, 488, 26, 288, 746, 4281, 480, 9417, 10093, 2455, 450, 83, 1471, 506, 2797, 543, 298, 639, 298, 22051, 376, 909, 3803, 503, 282, 8889, 2122, 639, 450, 291, 855, 533, 4914, 354, 3368, 398, 862, 26, 288, 327, 2372, 314, 2849, 1242, 687, 314, 9806, 7594, 288, 1559, 275, 7594, 14, 362, 342, 267, 871, 7594, 14, 1238, 14, 7400, 26, 288, 746, 4760, 5188, 6115, 1944, 2818, 3832, 63, 354, 9, 83, 1911, 4877, 314, 1827, 531, 450, 2079, 791, 3832, 63, 354, 356, 7594, 14, 1238, 423, 2024, 14, 3832, 63, 354, 1552, 267, 372, 1559, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 408, 267, 1432, 314, 658, 13689, 64, 626, 911, 506, 1202, 370, 3648, 1536, 314, 909, 14, 398, 3390, 626, 642, 1083, 365, 2797, 701, 314, 849, 4514, 402, 267, 658, 362, 63, 785, 64, 436, 1443, 440, 506, 2797, 340, 658, 362, 63, 785, 64, 365, 10087, 14, 267, 408, 267, 340, 291, 14, 7924, 365, 488, 26, 288, 340, 291, 14, 1238, 26, 355, 372, 291, 14, 1238, 423, 885, 63, 2609, 14, 452, 342, 288, 587, 26, 355, 746, 11897, 8, 490, 11792, 1886, 9, 83, 365, 4124, 282, 18397, 14, 13930, 298, 490, 11792, 1886, 9, 83, 14, 1238, 12, 2818, 1886, 9, 83, 14, 7924, 12, 503, 4278, 298, 490, 11792, 1886, 9, 83, 14, 362, 63, 7924, 1252, 2, 450, 469, 717, 283, 1886, 356, 291, 855, 533, 4914, 354, 363, 490, 789, 355, 776, 267, 372, 291, 14, 7924, 14, 452, 342, 339, 347, 664, 63, 5464, 63, 698, 8, 277, 304, 267, 408, 267, 2372, 314, 536, 402, 282, 8889, 901, 370, 506, 1202, 370, 3648, 1536, 701, 8889, 14, 267, 408, 267, 372, 291, 14, 5464, 63, 698, 339, 347, 664, 63, 1100, 63, 785, 63, 354, 8, 277, 12, 1559, 304, 267, 408, 267, 2372, 314, 536, 370, 675, 367, 314, 909, 14, 267, 408, 267, 340, 291, 14, 1100, 63, 785, 63, 354, 26, 288, 372, 291, 14, 1100, 63, 785, 63, 354, 267, 916, 1228, 8, 1113, 12, 1709, 14, 1685, 304, 288, 340, 291, 14, 785, 423, 12116, 26, 355, 1559, 275, 1559, 423, 2024, 14, 3280, 63, 509, 63, 1238, 288, 372, 1559, 423, 2024, 14, 1238, 63, 354, 267, 587, 26, 288, 372, 488, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 15496, 314, 2849, 909, 1901, 314, 1067, 1211, 14, 267, 408, 267, 1067, 275, 1052, 267, 340, 291, 14, 785, 26, 288, 1067, 459, 785, 418, 275, 291, 14, 785, 288, 1067, 63, 785, 63, 354, 275, 291, 14, 362, 63, 1100, 63, 785, 63, 354, 8, 277, 14, 785, 9, 288, 340, 1067, 63, 785, 63, 354, 26, 355, 1067, 59, 1100, 63, 785, 63, 354, 61, 275, 291, 14, 785, 267, 1067, 14, 873, 8, 958, 9, 267, 372, 1613, 8, 7200, 1692, 4256, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 1100, 9, 421, 199, 533, 3523, 28539, 8, 7200, 1692, 4256, 12, 10935, 304, 272, 408, 272, 437, 1300, 2455, 367, 20589, 282, 2849, 909, 272, 408, 272, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 785, 275, 291, 14, 362, 63, 785, 342, 267, 1067, 275, 291, 14, 362, 63, 1100, 63, 576, 8, 785, 29, 277, 14, 785, 9, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 1100, 9, 421, 199, 533, 13050, 1692, 31036, 4256, 8, 31036, 4256, 304, 272, 1978, 63, 354, 63, 698, 275, 488, 272, 1978, 63, 354, 63, 4511, 275, 2513, 5506, 7, 339, 347, 664, 63, 1160, 63, 1247, 8, 277, 304, 267, 408, 267, 1432, 282, 769, 402, 1978, 1561, 370, 506, 1202, 367, 314, 1056, 14, 10162, 440, 506, 267, 2797, 340, 3795, 63, 475, 63 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 6767, 14, 1095, 492, 9470, 4256, 12, 29264, 4256, 12, 10935, 421, 199, 533, 13050, 1692, 4256, 8, 2998, 4256, 304, 272, 408, 272, 21552, 314, 21255, 370, 8044, 282, 2849, 909, 367, 9848, 26212, 14, 272, 408, 272, 1402, 275, 488, 272, 7594, 275, 488, 272, 8889, 63, 698, 275, 283, 5464, 7, 272, 1067, 63, 785, 63, 354, 275, 488, 272, 8889, 63, 633, 63, 12745, 275, 283, 5464, 7, 272, 3803, 63, 633, 63, 12745, 275, 283, 2051, 7, 272, 1827, 63, 2051, 63, 460, 63, 5464, 275, 756, 339, 347, 664, 63, 785, 8, 277, 12, 7594, 29, 403, 304, 267, 408, 267, 1803, 314, 909, 314, 2455, 365, 20589, 14, 398, 4885, 849, 642, 5074, 658, 277, 14, 7924, 64, 436, 282, 658, 2051, 64, 503, 658, 5464, 64, 1423, 267, 315, 314, 2851, 2190, 12, 1325, 9180, 883, 4278, 642, 370, 372, 1263, 909, 14, 267, 408, 267, 327, 3645, 282, 3537, 7594, 340, 2741, 27, 642, 365, 1415, 367, 9180, 267, 327, 2839, 6148, 28539, 267, 340, 7594, 365, 488, 26, 288, 7594, 275, 291, 14, 362, 63, 7924, 342, 398, 327, 16840, 12, 862, 10023, 1536, 701, 5062, 790, 14, 267, 3803, 275, 291, 14, 958, 14, 362, 8, 277, 14, 2051, 63, 633, 63, 12745, 9, 267, 8889, 275, 291, 14, 958, 14, 362, 8, 277, 14, 5464, 63, 633, 63, 12745, 9, 267, 340, 3803, 365, 440, 488, 26, 288, 7594, 275, 7594, 14, 1541, 8, 2051, 29, 2051, 9, 398, 327, 16840, 12, 862, 10023, 1536, 701, 8889, 14, 267, 340, 8889, 365, 440, 488, 436, 334, 2051, 365, 488, 503, 291, 14, 1131, 63, 2051, 63, 460, 63, 5464, 304, 288, 8889, 63, 698, 275, 291, 14, 362, 63, 5464, 63, 698, 342, 288, 7594, 275, 7594, 14, 1541, 25679, 5464, 63, 698, 26, 8889, 1552, 398, 327, 982, 7179, 402, 5204, 787, 3247, 12, 652, 1159, 376, 1125, 14, 267, 340, 3803, 365, 488, 436, 8889, 365, 488, 26, 288, 746, 4281, 480, 9417, 10093, 2455, 450, 83, 1471, 506, 2797, 543, 298, 639, 298, 22051, 376, 909, 3803, 503, 282, 8889, 2122, 639, 450, 291, 855, 533, 4914, 354, 3368, 398, 862, 26, 288, 327, 2372, 314, 2849, 1242, 687, 314, 9806, 7594, 288, 1559, 275, 7594, 14, 362, 342, 267, 871, 7594, 14, 1238, 14, 7400, 26, 288, 746, 4760, 5188, 6115, 1944, 2818, 3832, 63, 354, 9, 83, 1911, 4877, 314, 1827, 531, 450, 2079, 791, 3832, 63, 354, 356, 7594, 14, 1238, 423, 2024, 14, 3832, 63, 354, 1552, 267, 372, 1559, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 408, 267, 1432, 314, 658, 13689, 64, 626, 911, 506, 1202, 370, 3648, 1536, 314, 909, 14, 398, 3390, 626, 642, 1083, 365, 2797, 701, 314, 849, 4514, 402, 267, 658, 362, 63, 785, 64, 436, 1443, 440, 506, 2797, 340, 658, 362, 63, 785, 64, 365, 10087, 14, 267, 408, 267, 340, 291, 14, 7924, 365, 488, 26, 288, 340, 291, 14, 1238, 26, 355, 372, 291, 14, 1238, 423, 885, 63, 2609, 14, 452, 342, 288, 587, 26, 355, 746, 11897, 8, 490, 11792, 1886, 9, 83, 365, 4124, 282, 18397, 14, 13930, 298, 490, 11792, 1886, 9, 83, 14, 1238, 12, 2818, 1886, 9, 83, 14, 7924, 12, 503, 4278, 298, 490, 11792, 1886, 9, 83, 14, 362, 63, 7924, 1252, 2, 450, 469, 717, 283, 1886, 356, 291, 855, 533, 4914, 354, 363, 490, 789, 355, 776, 267, 372, 291, 14, 7924, 14, 452, 342, 339, 347, 664, 63, 5464, 63, 698, 8, 277, 304, 267, 408, 267, 2372, 314, 536, 402, 282, 8889, 901, 370, 506, 1202, 370, 3648, 1536, 701, 8889, 14, 267, 408, 267, 372, 291, 14, 5464, 63, 698, 339, 347, 664, 63, 1100, 63, 785, 63, 354, 8, 277, 12, 1559, 304, 267, 408, 267, 2372, 314, 536, 370, 675, 367, 314, 909, 14, 267, 408, 267, 340, 291, 14, 1100, 63, 785, 63, 354, 26, 288, 372, 291, 14, 1100, 63, 785, 63, 354, 267, 916, 1228, 8, 1113, 12, 1709, 14, 1685, 304, 288, 340, 291, 14, 785, 423, 12116, 26, 355, 1559, 275, 1559, 423, 2024, 14, 3280, 63, 509, 63, 1238, 288, 372, 1559, 423, 2024, 14, 1238, 63, 354, 267, 587, 26, 288, 372, 488, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 15496, 314, 2849, 909, 1901, 314, 1067, 1211, 14, 267, 408, 267, 1067, 275, 1052, 267, 340, 291, 14, 785, 26, 288, 1067, 459, 785, 418, 275, 291, 14, 785, 288, 1067, 63, 785, 63, 354, 275, 291, 14, 362, 63, 1100, 63, 785, 63, 354, 8, 277, 14, 785, 9, 288, 340, 1067, 63, 785, 63, 354, 26, 355, 1067, 59, 1100, 63, 785, 63, 354, 61, 275, 291, 14, 785, 267, 1067, 14, 873, 8, 958, 9, 267, 372, 1613, 8, 7200, 1692, 4256, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 1100, 9, 421, 199, 533, 3523, 28539, 8, 7200, 1692, 4256, 12, 10935, 304, 272, 408, 272, 437, 1300, 2455, 367, 20589, 282, 2849, 909, 272, 408, 272, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 785, 275, 291, 14, 362, 63, 785, 342, 267, 1067, 275, 291, 14, 362, 63, 1100, 63, 576, 8, 785, 29, 277, 14, 785, 9, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 1100, 9, 421, 199, 533, 13050, 1692, 31036, 4256, 8, 31036, 4256, 304, 272, 1978, 63, 354, 63, 698, 275, 488, 272, 1978, 63, 354, 63, 4511, 275, 2513, 5506, 7, 339, 347, 664, 63, 1160, 63, 1247, 8, 277, 304, 267, 408, 267, 1432, 282, 769, 402, 1978, 1561, 370, 506, 1202, 367, 314, 1056, 14, 10162, 440, 506, 267, 2797, 340, 3795, 63, 475, 63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 1, 1, 1 ]
njwilson23/scipy
scipy/stats/__init__.py
27
8924
""" ========================================== Statistical functions (:mod:`scipy.stats`) ========================================== .. module:: scipy.stats This module contains a large number of probability distributions as well as a growing library of statistical functions. Each univariate distribution is an instance of a subclass of `rv_continuous` (`rv_discrete` for discrete distributions): .. autosummary:: :toctree: generated/ rv_continuous rv_discrete Continuous distributions ======================== .. autosummary:: :toctree: generated/ alpha -- Alpha anglit -- Anglit arcsine -- Arcsine beta -- Beta betaprime -- Beta Prime bradford -- Bradford burr -- Burr cauchy -- Cauchy chi -- Chi chi2 -- Chi-squared cosine -- Cosine dgamma -- Double Gamma dweibull -- Double Weibull erlang -- Erlang expon -- Exponential exponnorm -- Exponentially Modified Normal exponweib -- Exponentiated Weibull exponpow -- Exponential Power f -- F (Snecdor F) fatiguelife -- Fatigue Life (Birnbaum-Saunders) fisk -- Fisk foldcauchy -- Folded Cauchy foldnorm -- Folded Normal frechet_r -- Frechet Right Sided, Extreme Value Type II (Extreme LB) or weibull_min frechet_l -- Frechet Left Sided, Weibull_max genlogistic -- Generalized Logistic gennorm -- Generalized normal genpareto -- Generalized Pareto genexpon -- Generalized Exponential genextreme -- Generalized Extreme Value gausshyper -- Gauss Hypergeometric gamma -- Gamma gengamma -- Generalized gamma genhalflogistic -- Generalized Half Logistic gilbrat -- Gilbrat gompertz -- Gompertz (Truncated Gumbel) gumbel_r -- Right Sided Gumbel, Log-Weibull, Fisher-Tippett, Extreme Value Type I gumbel_l -- Left Sided Gumbel, etc. halfcauchy -- Half Cauchy halflogistic -- Half Logistic halfnorm -- Half Normal halfgennorm -- Generalized Half Normal hypsecant -- Hyperbolic Secant invgamma -- Inverse Gamma invgauss -- Inverse Gaussian invweibull -- Inverse Weibull johnsonsb -- Johnson SB johnsonsu -- Johnson SU ksone -- Kolmogorov-Smirnov one-sided (no stats) kstwobign -- Kolmogorov-Smirnov two-sided test for Large N (no stats) laplace -- Laplace levy -- Levy levy_l levy_stable logistic -- Logistic loggamma -- Log-Gamma loglaplace -- Log-Laplace (Log Double Exponential) lognorm -- Log-Normal lomax -- Lomax (Pareto of the second kind) maxwell -- Maxwell mielke -- Mielke's Beta-Kappa nakagami -- Nakagami ncx2 -- Non-central chi-squared ncf -- Non-central F nct -- Non-central Student's T norm -- Normal (Gaussian) pareto -- Pareto pearson3 -- Pearson type III powerlaw -- Power-function powerlognorm -- Power log normal powernorm -- Power normal rdist -- R-distribution reciprocal -- Reciprocal rayleigh -- Rayleigh rice -- Rice recipinvgauss -- Reciprocal Inverse Gaussian semicircular -- Semicircular t -- Student's T triang -- Triangular truncexpon -- Truncated Exponential truncnorm -- Truncated Normal tukeylambda -- Tukey-Lambda uniform -- Uniform vonmises -- Von-Mises (Circular) vonmises_line -- Von-Mises (Line) wald -- Wald weibull_min -- Minimum Weibull (see Frechet) weibull_max -- Maximum Weibull (see Frechet) wrapcauchy -- Wrapped Cauchy Multivariate distributions ========================== .. autosummary:: :toctree: generated/ multivariate_normal -- Multivariate normal distribution dirichlet -- Dirichlet wishart -- Wishart invwishart -- Inverse Wishart Discrete distributions ====================== .. autosummary:: :toctree: generated/ bernoulli -- Bernoulli binom -- Binomial boltzmann -- Boltzmann (Truncated Discrete Exponential) dlaplace -- Discrete Laplacian geom -- Geometric hypergeom -- Hypergeometric logser -- Logarithmic (Log-Series, Series) nbinom -- Negative Binomial planck -- Planck (Discrete Exponential) poisson -- Poisson randint -- Discrete Uniform skellam -- Skellam zipf -- Zipf Statistical functions ===================== Several of these functions have a similar version in scipy.stats.mstats which work for masked arrays. .. autosummary:: :toctree: generated/ describe -- Descriptive statistics gmean -- Geometric mean hmean -- Harmonic mean kurtosis -- Fisher or Pearson kurtosis kurtosistest -- mode -- Modal value moment -- Central moment normaltest -- skew -- Skewness skewtest -- kstat -- kstatvar -- tmean -- Truncated arithmetic mean tvar -- Truncated variance tmin -- tmax -- tstd -- tsem -- nanmean -- Mean, ignoring NaN values nanstd -- Standard deviation, ignoring NaN values nanmedian -- Median, ignoring NaN values variation -- Coefficient of variation find_repeats trim_mean .. autosummary:: :toctree: generated/ cumfreq histogram2 histogram itemfreq percentileofscore scoreatpercentile relfreq .. autosummary:: :toctree: generated/ binned_statistic -- Compute a binned statistic for a set of data. binned_statistic_2d -- Compute a 2-D binned statistic for a set of data. binned_statistic_dd -- Compute a d-D binned statistic for a set of data. .. autosummary:: :toctree: generated/ obrientransform signaltonoise bayes_mvs mvsdist sem zmap zscore .. autosummary:: :toctree: generated/ sigmaclip threshold trimboth trim1 .. autosummary:: :toctree: generated/ f_oneway pearsonr spearmanr pointbiserialr kendalltau linregress theilslopes f_value .. autosummary:: :toctree: generated/ ttest_1samp ttest_ind ttest_ind_from_stats ttest_rel kstest chisquare power_divergence ks_2samp mannwhitneyu tiecorrect rankdata ranksums wilcoxon kruskal friedmanchisquare combine_pvalues ss square_of_sums jarque_bera .. autosummary:: :toctree: generated/ ansari bartlett levene shapiro anderson anderson_ksamp binom_test fligner median_test mood .. autosummary:: :toctree: generated/ boxcox boxcox_normmax boxcox_llf entropy .. autosummary:: :toctree: generated/ chisqprob betai Circular statistical functions ============================== .. autosummary:: :toctree: generated/ circmean circvar circstd Contingency table functions =========================== .. autosummary:: :toctree: generated/ chi2_contingency contingency.expected_freq contingency.margins fisher_exact Plot-tests ========== .. autosummary:: :toctree: generated/ ppcc_max ppcc_plot probplot boxcox_normplot Masked statistics functions =========================== .. toctree:: stats.mstats Univariate and multivariate kernel density estimation (:mod:`scipy.stats.kde`) ============================================================================== .. autosummary:: :toctree: generated/ gaussian_kde For many more stat related functions install the software R and the interface package rpy. """ from __future__ import division, print_function, absolute_import from .stats import * from .distributions import * from .morestats import * from ._binned_statistic import * from .kde import gaussian_kde from . import mstats from .contingency import chi2_contingency from ._multivariate import * #remove vonmises_cython from __all__, I don't know why it is included __all__ = [s for s in dir() if not (s.startswith('_') or s.endswith('cython'))] from numpy.testing import Tester test = Tester().test
bsd-3-clause
[ 624, 199, 2486, 17575, 199, 3391, 30364, 3423, 18479, 1494, 1705, 14248, 14, 3200, 10522, 199, 2486, 17575, 199, 199, 703, 859, 447, 7026, 14, 3200, 199, 199, 2765, 859, 3509, 282, 7031, 1329, 402, 12224, 10208, 465, 199, 20501, 465, 282, 20772, 316, 3555, 402, 8753, 270, 2652, 3423, 14, 199, 199, 22321, 17225, 18449, 4084, 365, 376, 1256, 402, 282, 5516, 402, 658, 6310, 63, 23458, 64, 199, 8, 64, 6310, 63, 23591, 64, 367, 24635, 10208, 304, 199, 199, 703, 26651, 29309, 447, 2043, 520, 475, 16970, 26, 4046, 15, 8410, 4336, 63, 23458, 2043, 4336, 63, 23591, 199, 199, 24593, 7514, 10208, 199, 1280, 763, 199, 199, 703, 26651, 29309, 447, 2043, 520, 475, 16970, 26, 4046, 15, 8410, 5131, 3777, 1553, 32657, 2043, 14550, 1051, 3322, 1553, 1626, 71, 1051, 2043, 601, 1259, 1132, 3698, 1553, 437, 1195, 83, 1132, 2043, 8201, 4519, 1553, 29521, 2043, 2907, 439, 322, 278, 260, 1553, 29521, 8538, 278, 2043, 330, 9525, 18090, 3515, 1553, 699, 9525, 18090, 2043, 330, 300, 82, 4519, 1553, 699, 300, 82, 2043, 1704, 30074, 3322, 1553, 8790, 30074, 2043, 23275, 5185, 1553, 2799, 73, 2043, 23275, 18, 4519, 1553, 2799, 73, 13, 12973, 2043, 28188, 3322, 1553, 445, 736, 1132, 2043, 366, 7325, 3322, 1553, 22945, 598, 4746, 2043, 366, 1129, 20587, 3515, 1553, 22945, 2136, 20587, 2043, 9266, 4159, 3322, 1553, 221, 23223, 2043, 444, 678, 3777, 1553, 1316, 11819, 2043, 444, 678, 4791, 260, 1553, 1316, 10995, 9406, 22016, 11514, 2043, 444, 678, 1129, 1892, 260, 1553, 1316, 10995, 280, 972, 2136, 20587, 2043, 444, 678, 8278, 3515, 1553, 1316, 11819, 18879, 2043, 289, 463, 1553, 481, 334, 51, 685, 2866, 269, 481, 9, 2043, 1433, 17277, 310, 13602, 755, 1553, 481, 2159, 71, 310, 491, 16839, 334, 34, 723, 78, 2470, 453, 13, 12226, 7138, 83, 9, 2043, 289, 28600, 4519, 1553, 481, 28600, 2043, 20675, 696, 30074, 263, 1553, 481, 393, 770, 8790, 30074, 2043, 1699, 4272, 1025, 3515, 1553, 481, 393, 770, 11514, 2043, 20673, 335, 386, 63, 82, 260, 1553, 481, 264, 335, 386, 20854, 428, 73, 770, 12, 7255, 17817, 1594, 2434, 473, 41, 334, 4942, 17817, 491, 34, 9, 503, 781, 20587, 63, 827, 2043, 20673, 335, 386, 63, 76, 260, 1553, 481, 264, 335, 386, 29350, 428, 73, 770, 12, 2136, 20587, 63, 988, 2043, 3805, 23452, 755, 1553, 1696, 1759, 5297, 6937, 2043, 3805, 4791, 3698, 1553, 1696, 1759, 3293, 2043, 3805, 4096, 475, 260, 1553, 1696, 1759, 510, 1530, 475, 2043, 3805, 476, 678, 3515, 1553, 1696, 1759, 1316, 11819, 2043, 3805, 832, 17817, 263, 1553, 1696, 1759, 7255, 17817, 1594, 2043, 486, 23822, 9547, 263, 1553, 598, 23822, 21344, 31509, 2043, 10169, 3777, 1553, 598, 4746, 2043, 3805, 7325, 3515, 1553, 1696, 1759, 10169, 2043, 3805, 10220, 23452, 257, 1553, 1696, 1759, 869, 7411, 5297, 6937, 2043, 486, 382, 3289, 292, 3698, 1553, 598, 382, 3289, 292, 2043, 2621, 311, 281, 3903, 3515, 1553, 3971, 311, 281, 3903, 334, 20460, 3153, 598, 4295, 352, 9, 2043, 486, 4295, 352, 63, 82, 3515, 1553, 20854, 428, 73, 770, 598, 4295, 352, 12, 5297, 13, 24689, 12, 481, 2453, 281, 13, 15915, 321, 6215, 12, 7255, 17817, 1594, 2434, 473, 2043, 486, 4295, 352, 63, 76, 3515, 1553, 29350, 428, 73, 770, 598, 4295, 352, 12, 5423, 14, 2043, 12995, 696, 30074, 263, 1553, 869, 7411, 8790, 30074, 2043, 12995, 23452, 420, 1553, 869, 7411, 5297, 6937, 2043, 12995, 4791, 3515, 1553, 869, 7411, 11514, 2043, 12995, 2268, 4791, 755, 1553, 1696, 1759, 869, 7411, 11514, 2043, 30716, 3321, 867, 260, 1553, 21344, 9670, 9433, 867, 2043, 4572, 7325, 3515, 1553, 1010, 2077, 598, 4746, 2043, 4572, 25898, 3515, 1553, 1010, 2077, 17131, 2043, 4572, 1129, 20587, 263, 1553, 1010, 2077, 2136, 20587, 2043, 5225, 25338, 4654, 66, 260, 1553, 7135, 25338, 265, 26811, 2043, 5225, 25338, 4654, 85, 260, 1553, 7135, 25338, 265, 5698, 2043, 15357, 368, 3777, 1553, 1804, 393, 573, 2904, 8822, 13, 16782, 723, 30442, 1373, 13, 31851, 334, 889, 5020, 9, 2043, 1022, 270, 32517, 1030, 260, 1553, 1804, 393, 573, 2904, 8822, 13, 16782, 723, 30442, 2877, 13, 31851, 511, 367, 29095, 653, 334, 889, 5020, 9, 2043, 1127, 2778, 3698, 1553, 491, 439, 1071, 2043, 1026, 16091, 4519, 1553, 491, 6857, 89, 2043, 1026, 16091, 63, 76, 2043, 1026, 16091, 63, 11989, 2043, 30360, 3515, 1553, 5297, 6937, 2043, 943, 7325, 3515, 1553, 5297, 13, 15091, 2043, 943, 416, 2778, 263, 1553, 5297, 13, 44, 439, 1071, 334, 2445, 22945, 1316, 11819, 9, 2043, 560, 784, 1025, 3698, 1553, 5297, 13, 6241, 2043, 560, 988, 3777, 1553, 3835, 988, 334, 23936, 402, 314, 3499, 4928, 9, 2043, 1390, 20501, 3698, 1553, 8228, 20501, 2043, 10684, 352, 415, 3322, 1553, 603, 14769, 415, 1159, 29521, 13, 43, 15999, 2043, 302, 1151, 643, 13496, 3515, 1553, 653, 1151, 643, 13496, 2043, 302, 11859, 18, 4519, 1553, 10172, 13, 16067, 23275, 13, 12973, 2043, 302, 2177, 5185, 1553, 10172, 13, 16067, 481, 2043, 302, 319, 5185, 1553, 10172, 13, 16067, 17246, 1159, 377, 2043, 6316, 4519, 1553, 11514, 334, 26756, 9, 2043, 691, 264, 475, 3322, 1553, 510, 1530, 475, 2043, 299, 2210, 834, 19, 3515, 1553, 510, 2210, 834, 730, 473, 8921, 2043, 7074, 22277, 3515, 1553, 18879, 13, 1593, 2043, 7074, 320, 784, 1025, 420, 1553, 18879, 943, 3293, 2043, 7074, 4791, 260, 1553, 18879, 3293, 2043, 519, 2686, 3777, 1553, 820, 13, 4972, 2043, 295, 31846, 263, 1553, 799, 31846, 2043, 660, 1775, 2056, 3515, 1553, 30703, 274, 2056, 2043, 8012, 301, 4519, 1553, 820, 1885, 2043, 295, 6237, 5350, 25898, 258, 1553, 799, 31846, 1010, 2077, 17131, 2043, 542, 15003, 24998, 420, 1553, 3240, 15003, 24998, 2043, 307, 463, 1553, 17246, 1159, 377, 2043, 3229, 621, 3322, 1553, 12480, 11572, 2043, 8181, 301, 88, 678, 263, 1553, 25594, 3153, 1316, 11819, 2043, 8181, 67, 4791, 260, 1553, 25594, 3153, 11514, 2043, 30799, 498, 2734, 755, 1553, 377, 85, 498, 13, 21350, 2043, 14818, 3698, 1553, 1910, 8241, 2043, 373, 265, 77, 1388, 3515, 1553, 812, 265, 13, 45, 1388, 334, 35, 24998, 9, 2043, 373, 265, 77, 1388, 63 ]
[ 199, 2486, 17575, 199, 3391, 30364, 3423, 18479, 1494, 1705, 14248, 14, 3200, 10522, 199, 2486, 17575, 199, 199, 703, 859, 447, 7026, 14, 3200, 199, 199, 2765, 859, 3509, 282, 7031, 1329, 402, 12224, 10208, 465, 199, 20501, 465, 282, 20772, 316, 3555, 402, 8753, 270, 2652, 3423, 14, 199, 199, 22321, 17225, 18449, 4084, 365, 376, 1256, 402, 282, 5516, 402, 658, 6310, 63, 23458, 64, 199, 8, 64, 6310, 63, 23591, 64, 367, 24635, 10208, 304, 199, 199, 703, 26651, 29309, 447, 2043, 520, 475, 16970, 26, 4046, 15, 8410, 4336, 63, 23458, 2043, 4336, 63, 23591, 199, 199, 24593, 7514, 10208, 199, 1280, 763, 199, 199, 703, 26651, 29309, 447, 2043, 520, 475, 16970, 26, 4046, 15, 8410, 5131, 3777, 1553, 32657, 2043, 14550, 1051, 3322, 1553, 1626, 71, 1051, 2043, 601, 1259, 1132, 3698, 1553, 437, 1195, 83, 1132, 2043, 8201, 4519, 1553, 29521, 2043, 2907, 439, 322, 278, 260, 1553, 29521, 8538, 278, 2043, 330, 9525, 18090, 3515, 1553, 699, 9525, 18090, 2043, 330, 300, 82, 4519, 1553, 699, 300, 82, 2043, 1704, 30074, 3322, 1553, 8790, 30074, 2043, 23275, 5185, 1553, 2799, 73, 2043, 23275, 18, 4519, 1553, 2799, 73, 13, 12973, 2043, 28188, 3322, 1553, 445, 736, 1132, 2043, 366, 7325, 3322, 1553, 22945, 598, 4746, 2043, 366, 1129, 20587, 3515, 1553, 22945, 2136, 20587, 2043, 9266, 4159, 3322, 1553, 221, 23223, 2043, 444, 678, 3777, 1553, 1316, 11819, 2043, 444, 678, 4791, 260, 1553, 1316, 10995, 9406, 22016, 11514, 2043, 444, 678, 1129, 1892, 260, 1553, 1316, 10995, 280, 972, 2136, 20587, 2043, 444, 678, 8278, 3515, 1553, 1316, 11819, 18879, 2043, 289, 463, 1553, 481, 334, 51, 685, 2866, 269, 481, 9, 2043, 1433, 17277, 310, 13602, 755, 1553, 481, 2159, 71, 310, 491, 16839, 334, 34, 723, 78, 2470, 453, 13, 12226, 7138, 83, 9, 2043, 289, 28600, 4519, 1553, 481, 28600, 2043, 20675, 696, 30074, 263, 1553, 481, 393, 770, 8790, 30074, 2043, 1699, 4272, 1025, 3515, 1553, 481, 393, 770, 11514, 2043, 20673, 335, 386, 63, 82, 260, 1553, 481, 264, 335, 386, 20854, 428, 73, 770, 12, 7255, 17817, 1594, 2434, 473, 41, 334, 4942, 17817, 491, 34, 9, 503, 781, 20587, 63, 827, 2043, 20673, 335, 386, 63, 76, 260, 1553, 481, 264, 335, 386, 29350, 428, 73, 770, 12, 2136, 20587, 63, 988, 2043, 3805, 23452, 755, 1553, 1696, 1759, 5297, 6937, 2043, 3805, 4791, 3698, 1553, 1696, 1759, 3293, 2043, 3805, 4096, 475, 260, 1553, 1696, 1759, 510, 1530, 475, 2043, 3805, 476, 678, 3515, 1553, 1696, 1759, 1316, 11819, 2043, 3805, 832, 17817, 263, 1553, 1696, 1759, 7255, 17817, 1594, 2043, 486, 23822, 9547, 263, 1553, 598, 23822, 21344, 31509, 2043, 10169, 3777, 1553, 598, 4746, 2043, 3805, 7325, 3515, 1553, 1696, 1759, 10169, 2043, 3805, 10220, 23452, 257, 1553, 1696, 1759, 869, 7411, 5297, 6937, 2043, 486, 382, 3289, 292, 3698, 1553, 598, 382, 3289, 292, 2043, 2621, 311, 281, 3903, 3515, 1553, 3971, 311, 281, 3903, 334, 20460, 3153, 598, 4295, 352, 9, 2043, 486, 4295, 352, 63, 82, 3515, 1553, 20854, 428, 73, 770, 598, 4295, 352, 12, 5297, 13, 24689, 12, 481, 2453, 281, 13, 15915, 321, 6215, 12, 7255, 17817, 1594, 2434, 473, 2043, 486, 4295, 352, 63, 76, 3515, 1553, 29350, 428, 73, 770, 598, 4295, 352, 12, 5423, 14, 2043, 12995, 696, 30074, 263, 1553, 869, 7411, 8790, 30074, 2043, 12995, 23452, 420, 1553, 869, 7411, 5297, 6937, 2043, 12995, 4791, 3515, 1553, 869, 7411, 11514, 2043, 12995, 2268, 4791, 755, 1553, 1696, 1759, 869, 7411, 11514, 2043, 30716, 3321, 867, 260, 1553, 21344, 9670, 9433, 867, 2043, 4572, 7325, 3515, 1553, 1010, 2077, 598, 4746, 2043, 4572, 25898, 3515, 1553, 1010, 2077, 17131, 2043, 4572, 1129, 20587, 263, 1553, 1010, 2077, 2136, 20587, 2043, 5225, 25338, 4654, 66, 260, 1553, 7135, 25338, 265, 26811, 2043, 5225, 25338, 4654, 85, 260, 1553, 7135, 25338, 265, 5698, 2043, 15357, 368, 3777, 1553, 1804, 393, 573, 2904, 8822, 13, 16782, 723, 30442, 1373, 13, 31851, 334, 889, 5020, 9, 2043, 1022, 270, 32517, 1030, 260, 1553, 1804, 393, 573, 2904, 8822, 13, 16782, 723, 30442, 2877, 13, 31851, 511, 367, 29095, 653, 334, 889, 5020, 9, 2043, 1127, 2778, 3698, 1553, 491, 439, 1071, 2043, 1026, 16091, 4519, 1553, 491, 6857, 89, 2043, 1026, 16091, 63, 76, 2043, 1026, 16091, 63, 11989, 2043, 30360, 3515, 1553, 5297, 6937, 2043, 943, 7325, 3515, 1553, 5297, 13, 15091, 2043, 943, 416, 2778, 263, 1553, 5297, 13, 44, 439, 1071, 334, 2445, 22945, 1316, 11819, 9, 2043, 560, 784, 1025, 3698, 1553, 5297, 13, 6241, 2043, 560, 988, 3777, 1553, 3835, 988, 334, 23936, 402, 314, 3499, 4928, 9, 2043, 1390, 20501, 3698, 1553, 8228, 20501, 2043, 10684, 352, 415, 3322, 1553, 603, 14769, 415, 1159, 29521, 13, 43, 15999, 2043, 302, 1151, 643, 13496, 3515, 1553, 653, 1151, 643, 13496, 2043, 302, 11859, 18, 4519, 1553, 10172, 13, 16067, 23275, 13, 12973, 2043, 302, 2177, 5185, 1553, 10172, 13, 16067, 481, 2043, 302, 319, 5185, 1553, 10172, 13, 16067, 17246, 1159, 377, 2043, 6316, 4519, 1553, 11514, 334, 26756, 9, 2043, 691, 264, 475, 3322, 1553, 510, 1530, 475, 2043, 299, 2210, 834, 19, 3515, 1553, 510, 2210, 834, 730, 473, 8921, 2043, 7074, 22277, 3515, 1553, 18879, 13, 1593, 2043, 7074, 320, 784, 1025, 420, 1553, 18879, 943, 3293, 2043, 7074, 4791, 260, 1553, 18879, 3293, 2043, 519, 2686, 3777, 1553, 820, 13, 4972, 2043, 295, 31846, 263, 1553, 799, 31846, 2043, 660, 1775, 2056, 3515, 1553, 30703, 274, 2056, 2043, 8012, 301, 4519, 1553, 820, 1885, 2043, 295, 6237, 5350, 25898, 258, 1553, 799, 31846, 1010, 2077, 17131, 2043, 542, 15003, 24998, 420, 1553, 3240, 15003, 24998, 2043, 307, 463, 1553, 17246, 1159, 377, 2043, 3229, 621, 3322, 1553, 12480, 11572, 2043, 8181, 301, 88, 678, 263, 1553, 25594, 3153, 1316, 11819, 2043, 8181, 67, 4791, 260, 1553, 25594, 3153, 11514, 2043, 30799, 498, 2734, 755, 1553, 377, 85, 498, 13, 21350, 2043, 14818, 3698, 1553, 1910, 8241, 2043, 373, 265, 77, 1388, 3515, 1553, 812, 265, 13, 45, 1388, 334, 35, 24998, 9, 2043, 373, 265, 77, 1388, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
yqm/sl4a
python/src/Lib/distutils/command/build_py.py
52
16702
"""distutils.command.build_py Implements the Distutils 'build_py' command.""" # This module should be kept compatible with Python 2.1. __revision__ = "$Id: build_py.py 65742 2008-08-17 04:16:04Z brett.cannon $" import string, os from types import * from glob import glob from distutils.core import Command from distutils.errors import * from distutils.util import convert_path from distutils import log class build_py (Command): description = "\"build\" pure Python modules (copy to build directory)" user_options = [ ('build-lib=', 'd', "directory to \"build\" (copy) to"), ('compile', 'c', "compile .py to .pyc"), ('no-compile', None, "don't compile .py files [default]"), ('optimize=', 'O', "also compile with optimization: -O1 for \"python -O\", " "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), ('force', 'f', "forcibly build everything (ignore file timestamps)"), ] boolean_options = ['compile', 'force'] negative_opt = {'no-compile' : 'compile'} def initialize_options (self): self.build_lib = None self.py_modules = None self.package = None self.package_data = None self.package_dir = None self.compile = 0 self.optimize = 0 self.force = None def finalize_options (self): self.set_undefined_options('build', ('build_lib', 'build_lib'), ('force', 'force')) # Get the distribution options that are aliases for build_py # options -- list of packages and list of modules. self.packages = self.distribution.packages self.py_modules = self.distribution.py_modules self.package_data = self.distribution.package_data self.package_dir = {} if self.distribution.package_dir: for name, path in self.distribution.package_dir.items(): self.package_dir[name] = convert_path(path) self.data_files = self.get_data_files() # Ick, copied straight from install_lib.py (fancy_getopt needs a # type system! Hell, *everything* needs a type system!!!) if type(self.optimize) is not IntType: try: self.optimize = int(self.optimize) assert 0 <= self.optimize <= 2 except (ValueError, AssertionError): raise DistutilsOptionError, "optimize must be 0, 1, or 2" def run (self): # XXX copy_file by default preserves atime and mtime. IMHO this is # the right thing to do, but perhaps it should be an option -- in # particular, a site administrator might want installed files to # reflect the time of installation rather than the last # modification time before the installed release. # XXX copy_file by default preserves mode, which appears to be the # wrong thing to do: if a file is read-only in the working # directory, we want it to be installed read/write so that the next # installation of the same module distribution can overwrite it # without problems. (This might be a Unix-specific issue.) Thus # we turn off 'preserve_mode' when copying to the build directory, # since the build directory is supposed to be exactly what the # installation will look like (ie. we preserve mode when # installing). # Two options control which modules will be installed: 'packages' # and 'py_modules'. The former lets us work with whole packages, not # specifying individual modules at all; the latter is for # specifying modules one-at-a-time. if self.py_modules: self.build_modules() if self.packages: self.build_packages() self.build_package_data() self.byte_compile(self.get_outputs(include_bytecode=0)) # run () def get_data_files (self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" data = [] if not self.packages: return data for package in self.packages: # Locate package source directory src_dir = self.get_package_dir(package) # Compute package build directory build_dir = os.path.join(*([self.build_lib] + package.split('.'))) # Length of path to strip from found files plen = 0 if src_dir: plen = len(src_dir)+1 # Strip directory from globbed filenames filenames = [ file[plen:] for file in self.find_data_files(package, src_dir) ] data.append((package, src_dir, build_dir, filenames)) return data def find_data_files (self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" globs = (self.package_data.get('', []) + self.package_data.get(package, [])) files = [] for pattern in globs: # Each pattern has to be converted to a platform-specific path filelist = glob(os.path.join(src_dir, convert_path(pattern))) # Files that match more than one pattern are only added once files.extend([fn for fn in filelist if fn not in files]) return files def build_package_data (self): """Copy data files into build directory""" lastdir = None for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) self.mkpath(os.path.dirname(target)) self.copy_file(os.path.join(src_dir, filename), target, preserve_mode=False) def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any).""" path = string.split(package, '.') if not self.package_dir: if path: return apply(os.path.join, path) else: return '' else: tail = [] while path: try: pdir = self.package_dir[string.join(path, '.')] except KeyError: tail.insert(0, path[-1]) del path[-1] else: tail.insert(0, pdir) return os.path.join(*tail) else: # Oops, got all the way through 'path' without finding a # match in package_dir. If package_dir defines a directory # for the root (nameless) package, then fallback on it; # otherwise, we might as well have not consulted # package_dir at all, as we just use the directory implied # by 'tail' (which should be the same as the original value # of 'path' at this point). pdir = self.package_dir.get('') if pdir is not None: tail.insert(0, pdir) if tail: return apply(os.path.join, tail) else: return '' # get_package_dir () def check_package (self, package, package_dir): # Empty dir name means current directory, which we can probably # assume exists. Also, os.path.exists and isdir don't know about # my "empty string means current dir" convention, so we have to # circumvent them. if package_dir != "": if not os.path.exists(package_dir): raise DistutilsFileError, \ "package directory '%s' does not exist" % package_dir if not os.path.isdir(package_dir): raise DistutilsFileError, \ ("supposed package directory '%s' exists, " + "but is not a directory") % package_dir # Require __init__.py for all but the "root package" if package: init_py = os.path.join(package_dir, "__init__.py") if os.path.isfile(init_py): return init_py else: log.warn(("package init file '%s' not found " + "(or not a regular file)"), init_py) # Either not in a package at all (__init__.py not expected), or # __init__.py doesn't exist -- so don't return the filename. return None # check_package () def check_module (self, module, module_file): if not os.path.isfile(module_file): log.warn("file %s (for module %s) not found", module_file, module) return 0 else: return 1 # check_module () def find_package_modules (self, package, package_dir): self.check_package(package, package_dir) module_files = glob(os.path.join(package_dir, "*.py")) modules = [] setup_script = os.path.abspath(self.distribution.script_name) for f in module_files: abs_f = os.path.abspath(f) if abs_f != setup_script: module = os.path.splitext(os.path.basename(f))[0] modules.append((package, module, f)) else: self.debug_print("excluding %s" % setup_script) return modules def find_modules (self): """Finds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. """ # Map package names to tuples of useful info about the package: # (package_dir, checked) # package_dir - the directory where we'll find source files for # this package # checked - true if we have checked that the package directory # is valid (exists, contains __init__.py, ... ?) packages = {} # List of (package, module, filename) tuples to return modules = [] # We treat modules-in-packages almost the same as toplevel modules, # just the "package" for a toplevel is empty (either an empty # string or empty list, depending on context). Differences: # - don't check for __init__.py in directory for empty package for module in self.py_modules: path = string.split(module, '.') package = string.join(path[0:-1], '.') module_base = path[-1] try: (package_dir, checked) = packages[package] except KeyError: package_dir = self.get_package_dir(package) checked = 0 if not checked: init_py = self.check_package(package, package_dir) packages[package] = (package_dir, 1) if init_py: modules.append((package, "__init__", init_py)) # XXX perhaps we should also check for just .pyc files # (so greedy closed-source bastards can distribute Python # modules too) module_file = os.path.join(package_dir, module_base + ".py") if not self.check_module(module, module_file): continue modules.append((package, module_base, module_file)) return modules # find_modules () def find_all_modules (self): """Compute the list of all modules that will be built, whether they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.""" modules = [] if self.py_modules: modules.extend(self.find_modules()) if self.packages: for package in self.packages: package_dir = self.get_package_dir(package) m = self.find_package_modules(package, package_dir) modules.extend(m) return modules # find_all_modules () def get_source_files (self): modules = self.find_all_modules() filenames = [] for module in modules: filenames.append(module[-1]) return filenames def get_module_outfile (self, build_dir, package, module): outfile_path = [build_dir] + list(package) + [module + ".py"] return os.path.join(*outfile_path) def get_outputs (self, include_bytecode=1): modules = self.find_all_modules() outputs = [] for (package, module, module_file) in modules: package = string.split(package, '.') filename = self.get_module_outfile(self.build_lib, package, module) outputs.append(filename) if include_bytecode: if self.compile: outputs.append(filename + "c") if self.optimize > 0: outputs.append(filename + "o") outputs += [ os.path.join(build_dir, filename) for package, src_dir, build_dir, filenames in self.data_files for filename in filenames ] return outputs def build_module (self, module, module_file, package): if type(package) is StringType: package = string.split(package, '.') elif type(package) not in (ListType, TupleType): raise TypeError, \ "'package' must be a string (dot-separated), list, or tuple" # Now put the module source file into the "build" area -- this is # easy, we just copy it somewhere under self.build_lib (the build # directory for Python source). outfile = self.get_module_outfile(self.build_lib, package, module) dir = os.path.dirname(outfile) self.mkpath(dir) return self.copy_file(module_file, outfile, preserve_mode=0) def build_modules (self): modules = self.find_modules() for (package, module, module_file) in modules: # Now "build" the module -- ie. copy the source file to # self.build_lib (the build directory for Python source). # (Actually, it gets copied to the directory for this package # under self.build_lib.) self.build_module(module, module_file, package) # build_modules () def build_packages (self): for package in self.packages: # Get list of (package, module, module_file) tuples based on # scanning the package directory. 'package' is only included # in the tuple so that 'find_modules()' and # 'find_package_tuples()' have a consistent interface; it's # ignored here (apart from a sanity check). Also, 'module' is # the *unqualified* module name (ie. no dots, no package -- we # already know its package!), and 'module_file' is the path to # the .py file, relative to the current directory # (ie. including 'package_dir'). package_dir = self.get_package_dir(package) modules = self.find_package_modules(package, package_dir) # Now loop over the modules we found, "building" each one (just # copy it to self.build_lib). for (package_, module, module_file) in modules: assert package == package_ self.build_module(module, module_file, package) # build_packages () def byte_compile (self, files): from distutils.util import byte_compile prefix = self.build_lib if prefix[-1] != os.sep: prefix = prefix + os.sep # XXX this code is essentially the same as the 'byte_compile() # method of the "install_lib" command, except for the determination # of the 'prefix' string. Hmmm. if self.compile: byte_compile(files, optimize=0, force=self.force, prefix=prefix, dry_run=self.dry_run) if self.optimize > 0: byte_compile(files, optimize=self.optimize, force=self.force, prefix=prefix, dry_run=self.dry_run) # class build_py
apache-2.0
[ 624, 13350, 14, 1531, 14, 1506, 63, 647, 199, 199, 29452, 314, 12577, 283, 1506, 63, 647, 7, 1414, 1041, 199, 199, 3, 961, 859, 1077, 506, 16204, 9025, 543, 2018, 499, 14, 17, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 1900, 63, 647, 14, 647, 1227, 10950, 18, 9079, 13, 2036, 13, 1196, 28527, 26, 975, 26, 966, 58, 330, 3292, 84, 14, 67, 1189, 265, 2672, 2, 199, 199, 646, 1059, 12, 747, 199, 504, 2943, 492, 627, 199, 504, 5739, 492, 5739, 199, 199, 504, 7065, 14, 1018, 492, 5817, 199, 504, 7065, 14, 2550, 492, 627, 199, 504, 7065, 14, 1974, 492, 3957, 63, 515, 199, 504, 7065, 492, 943, 199, 199, 533, 1900, 63, 647, 334, 3110, 304, 339, 1369, 275, 30768, 1506, 4451, 15111, 2018, 4621, 334, 1574, 370, 1900, 2082, 2924, 339, 922, 63, 1419, 275, 359, 267, 661, 1506, 13, 773, 4009, 283, 68, 297, 298, 3619, 370, 8441, 1506, 4451, 334, 1574, 9, 370, 1288, 267, 661, 2014, 297, 283, 67, 297, 298, 2014, 1275, 647, 370, 1275, 11357, 1288, 267, 661, 889, 13, 2014, 297, 488, 12, 298, 13196, 1133, 6555, 1275, 647, 1584, 359, 885, 31937, 267, 661, 13416, 4009, 283, 47, 297, 268, 298, 12344, 6555, 543, 13712, 26, 446, 47, 17, 367, 8441, 1548, 446, 47, 20756, 298, 268, 3905, 47, 18, 367, 8441, 1548, 446, 5757, 20756, 436, 446, 47, 16, 370, 3507, 359, 885, 26, 446, 47, 16, 31937, 267, 661, 3990, 297, 283, 70, 297, 298, 509, 559, 66, 590, 1900, 8137, 334, 4247, 570, 22496, 13185, 267, 1622, 339, 5046, 63, 1419, 275, 788, 2014, 297, 283, 3990, 418, 272, 6946, 63, 2992, 275, 791, 889, 13, 2014, 7, 520, 283, 2014, 936, 2378, 347, 8265, 63, 1419, 334, 277, 304, 267, 291, 14, 1506, 63, 773, 275, 488, 267, 291, 14, 647, 63, 3112, 275, 488, 267, 291, 14, 2491, 275, 488, 267, 291, 14, 2491, 63, 576, 275, 488, 267, 291, 14, 2491, 63, 694, 275, 488, 267, 291, 14, 2014, 275, 378, 267, 291, 14, 13416, 275, 378, 267, 291, 14, 3990, 275, 488, 339, 347, 17284, 63, 1419, 334, 277, 304, 267, 291, 14, 409, 63, 10705, 63, 1419, 360, 1506, 297, 3521, 661, 1506, 63, 773, 297, 283, 1506, 63, 773, 659, 3521, 661, 3990, 297, 283, 3990, 1333, 398, 327, 2372, 314, 4084, 1511, 626, 787, 5481, 367, 1900, 63, 647, 267, 327, 1511, 1553, 769, 402, 6117, 436, 769, 402, 4621, 14, 267, 291, 14, 5154, 275, 291, 14, 4972, 14, 5154, 267, 291, 14, 647, 63, 3112, 275, 291, 14, 4972, 14, 647, 63, 3112, 267, 291, 14, 2491, 63, 576, 275, 291, 14, 4972, 14, 2491, 63, 576, 267, 291, 14, 2491, 63, 694, 275, 1052, 267, 340, 291, 14, 4972, 14, 2491, 63, 694, 26, 288, 367, 536, 12, 931, 315, 291, 14, 4972, 14, 2491, 63, 694, 14, 1744, 837, 355, 291, 14, 2491, 63, 694, 59, 354, 61, 275, 3957, 63, 515, 8, 515, 9, 267, 291, 14, 576, 63, 1725, 275, 291, 14, 362, 63, 576, 63, 1725, 342, 398, 327, 473, 346, 12, 8876, 23669, 687, 3907, 63, 773, 14, 647, 334, 25352, 63, 18907, 4839, 282, 267, 327, 730, 2656, 1, 221, 869, 1697, 12, 627, 14287, 2127, 10, 4839, 282, 730, 2656, 21512, 9, 267, 340, 730, 8, 277, 14, 13416, 9, 365, 440, 9805, 804, 26, 288, 862, 26, 355, 291, 14, 13416, 275, 1109, 8, 277, 14, 13416, 9, 355, 702, 378, 2695, 291, 14, 13416, 2695, 499, 288, 871, 334, 3393, 12, 9070, 304, 355, 746, 31484, 12, 298, 13416, 1471, 506, 378, 12, 413, 12, 503, 499, 2, 339, 347, 1255, 334, 277, 304, 398, 327, 5787, 1331, 63, 493, 701, 849, 876, 20603, 282, 521, 436, 15005, 14, 221, 18211, 2979, 642, 365, 267, 327, 314, 2451, 8377, 370, 886, 12, 1325, 25358, 652, 1077, 506, 376, 945, 1553, 315, 267, 327, 6770, 12, 282, 4770, 31056, 5594, 2934, 4903, 1584, 370, 267, 327, 16806, 314, 900, 402, 12096, 7830, 2419, 314, 2061, 267, 327, 7100, 900, 2544, 314, 4903, 4683, 14, 398, 327, 5787, 1331, 63, 493, 701, 849, 876, 20603, 818, 12, 1314, 11337, 370, 506, 314, 267, 327, 6835, 8377, 370, 886, 26, 340, 282, 570, 365, 1586, 13, 2118, 315, 314, 6449, 267, 327, 2082, 12, 781, 2934, 652, 370, 506, 4903, 1586, 15, 952, 880, 626, 314, 2163, 267, 327, 12096, 402, 314, 2011, 859, 4084, 883, 8970, 652, 267, 327, 1928, 8826, 14, 221, 334, 2765, 5594, 506, 282, 13074, 13, 6100, 4976, 4959, 221, 20227, 267, 327, 781, 7485, 2331, 283, 17053, 63, 632, 7, 1380, 16743, 370, 314, 1900, 2082, 12, 267, 327, 3967, 314, 1900, 2082, 365, 20042, 370, 506, 8840, 4052, 314, 267, 327, 12096, 911, 3648, 2839, 334, 1873, 14, 781, 11211, 818, 1380, 267, 327, 22200, 680, 398, 327, 16853, 1511, 3304, 1314, 4621, 911, 506, 4903, 26, 283, 5154, 7, 267, 327, 436, 283, 647, 63, 3112, 1370, 221, 710, 26610, 19083, 2739, 1736, 543, 8852, 6117, 12, 440, 267, 327, 9176, 8212, 4621, 737, 1006, 27, 314, 19045, 365, 367, 267, 327, 9176, 4621, 1373, 13, 292, 13, 65, 13, 521, 14, 398, 340, 291, 14, 647, 63, 3112, 26, 288, 291, 14, 1506, 63, 3112, 342, 267, 340, 291, 14, 5154, 26, 288, 291, 14, 1506, 63, 5154, 342, 288, 291, 14, 1506, 63, 2491, 63, 576, 342, 398, 291, 14, 4414, 63, 2014, 8, 277, 14, 362, 63, 4467, 8, 2613, 63, 19812, 29, 16, 430, 339, 327, 1255, 6248, 339, 347, 664, 63, 576, 63, 1725, 334, 277, 304, 267, 408, 6864, 769, 402, 8189, 2491, 12, 2164, 63, 694, 12, 1506, 63, 694, 12, 10309, 3171, 6346, 624, 267, 666, 275, 942, 267, 340, 440, 291, 14, 5154, 26, 288, 372, 666, 267, 367, 2559, 315, 291, 14, 5154, 26, 288, 327, 6263, 323, 2559, 1350, 2082, 288, 2928, 63, 694, 275, 291, 14, 362, 63, 2491, 63, 694, 8, 2491, 9, 953, 327, 8354, 2559, 1900, 2082, 288, 1900, 63, 694, 275, 747, 14 ]
[ 13350, 14, 1531, 14, 1506, 63, 647, 199, 199, 29452, 314, 12577, 283, 1506, 63, 647, 7, 1414, 1041, 199, 199, 3, 961, 859, 1077, 506, 16204, 9025, 543, 2018, 499, 14, 17, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 1900, 63, 647, 14, 647, 1227, 10950, 18, 9079, 13, 2036, 13, 1196, 28527, 26, 975, 26, 966, 58, 330, 3292, 84, 14, 67, 1189, 265, 2672, 2, 199, 199, 646, 1059, 12, 747, 199, 504, 2943, 492, 627, 199, 504, 5739, 492, 5739, 199, 199, 504, 7065, 14, 1018, 492, 5817, 199, 504, 7065, 14, 2550, 492, 627, 199, 504, 7065, 14, 1974, 492, 3957, 63, 515, 199, 504, 7065, 492, 943, 199, 199, 533, 1900, 63, 647, 334, 3110, 304, 339, 1369, 275, 30768, 1506, 4451, 15111, 2018, 4621, 334, 1574, 370, 1900, 2082, 2924, 339, 922, 63, 1419, 275, 359, 267, 661, 1506, 13, 773, 4009, 283, 68, 297, 298, 3619, 370, 8441, 1506, 4451, 334, 1574, 9, 370, 1288, 267, 661, 2014, 297, 283, 67, 297, 298, 2014, 1275, 647, 370, 1275, 11357, 1288, 267, 661, 889, 13, 2014, 297, 488, 12, 298, 13196, 1133, 6555, 1275, 647, 1584, 359, 885, 31937, 267, 661, 13416, 4009, 283, 47, 297, 268, 298, 12344, 6555, 543, 13712, 26, 446, 47, 17, 367, 8441, 1548, 446, 47, 20756, 298, 268, 3905, 47, 18, 367, 8441, 1548, 446, 5757, 20756, 436, 446, 47, 16, 370, 3507, 359, 885, 26, 446, 47, 16, 31937, 267, 661, 3990, 297, 283, 70, 297, 298, 509, 559, 66, 590, 1900, 8137, 334, 4247, 570, 22496, 13185, 267, 1622, 339, 5046, 63, 1419, 275, 788, 2014, 297, 283, 3990, 418, 272, 6946, 63, 2992, 275, 791, 889, 13, 2014, 7, 520, 283, 2014, 936, 2378, 347, 8265, 63, 1419, 334, 277, 304, 267, 291, 14, 1506, 63, 773, 275, 488, 267, 291, 14, 647, 63, 3112, 275, 488, 267, 291, 14, 2491, 275, 488, 267, 291, 14, 2491, 63, 576, 275, 488, 267, 291, 14, 2491, 63, 694, 275, 488, 267, 291, 14, 2014, 275, 378, 267, 291, 14, 13416, 275, 378, 267, 291, 14, 3990, 275, 488, 339, 347, 17284, 63, 1419, 334, 277, 304, 267, 291, 14, 409, 63, 10705, 63, 1419, 360, 1506, 297, 3521, 661, 1506, 63, 773, 297, 283, 1506, 63, 773, 659, 3521, 661, 3990, 297, 283, 3990, 1333, 398, 327, 2372, 314, 4084, 1511, 626, 787, 5481, 367, 1900, 63, 647, 267, 327, 1511, 1553, 769, 402, 6117, 436, 769, 402, 4621, 14, 267, 291, 14, 5154, 275, 291, 14, 4972, 14, 5154, 267, 291, 14, 647, 63, 3112, 275, 291, 14, 4972, 14, 647, 63, 3112, 267, 291, 14, 2491, 63, 576, 275, 291, 14, 4972, 14, 2491, 63, 576, 267, 291, 14, 2491, 63, 694, 275, 1052, 267, 340, 291, 14, 4972, 14, 2491, 63, 694, 26, 288, 367, 536, 12, 931, 315, 291, 14, 4972, 14, 2491, 63, 694, 14, 1744, 837, 355, 291, 14, 2491, 63, 694, 59, 354, 61, 275, 3957, 63, 515, 8, 515, 9, 267, 291, 14, 576, 63, 1725, 275, 291, 14, 362, 63, 576, 63, 1725, 342, 398, 327, 473, 346, 12, 8876, 23669, 687, 3907, 63, 773, 14, 647, 334, 25352, 63, 18907, 4839, 282, 267, 327, 730, 2656, 1, 221, 869, 1697, 12, 627, 14287, 2127, 10, 4839, 282, 730, 2656, 21512, 9, 267, 340, 730, 8, 277, 14, 13416, 9, 365, 440, 9805, 804, 26, 288, 862, 26, 355, 291, 14, 13416, 275, 1109, 8, 277, 14, 13416, 9, 355, 702, 378, 2695, 291, 14, 13416, 2695, 499, 288, 871, 334, 3393, 12, 9070, 304, 355, 746, 31484, 12, 298, 13416, 1471, 506, 378, 12, 413, 12, 503, 499, 2, 339, 347, 1255, 334, 277, 304, 398, 327, 5787, 1331, 63, 493, 701, 849, 876, 20603, 282, 521, 436, 15005, 14, 221, 18211, 2979, 642, 365, 267, 327, 314, 2451, 8377, 370, 886, 12, 1325, 25358, 652, 1077, 506, 376, 945, 1553, 315, 267, 327, 6770, 12, 282, 4770, 31056, 5594, 2934, 4903, 1584, 370, 267, 327, 16806, 314, 900, 402, 12096, 7830, 2419, 314, 2061, 267, 327, 7100, 900, 2544, 314, 4903, 4683, 14, 398, 327, 5787, 1331, 63, 493, 701, 849, 876, 20603, 818, 12, 1314, 11337, 370, 506, 314, 267, 327, 6835, 8377, 370, 886, 26, 340, 282, 570, 365, 1586, 13, 2118, 315, 314, 6449, 267, 327, 2082, 12, 781, 2934, 652, 370, 506, 4903, 1586, 15, 952, 880, 626, 314, 2163, 267, 327, 12096, 402, 314, 2011, 859, 4084, 883, 8970, 652, 267, 327, 1928, 8826, 14, 221, 334, 2765, 5594, 506, 282, 13074, 13, 6100, 4976, 4959, 221, 20227, 267, 327, 781, 7485, 2331, 283, 17053, 63, 632, 7, 1380, 16743, 370, 314, 1900, 2082, 12, 267, 327, 3967, 314, 1900, 2082, 365, 20042, 370, 506, 8840, 4052, 314, 267, 327, 12096, 911, 3648, 2839, 334, 1873, 14, 781, 11211, 818, 1380, 267, 327, 22200, 680, 398, 327, 16853, 1511, 3304, 1314, 4621, 911, 506, 4903, 26, 283, 5154, 7, 267, 327, 436, 283, 647, 63, 3112, 1370, 221, 710, 26610, 19083, 2739, 1736, 543, 8852, 6117, 12, 440, 267, 327, 9176, 8212, 4621, 737, 1006, 27, 314, 19045, 365, 367, 267, 327, 9176, 4621, 1373, 13, 292, 13, 65, 13, 521, 14, 398, 340, 291, 14, 647, 63, 3112, 26, 288, 291, 14, 1506, 63, 3112, 342, 267, 340, 291, 14, 5154, 26, 288, 291, 14, 1506, 63, 5154, 342, 288, 291, 14, 1506, 63, 2491, 63, 576, 342, 398, 291, 14, 4414, 63, 2014, 8, 277, 14, 362, 63, 4467, 8, 2613, 63, 19812, 29, 16, 430, 339, 327, 1255, 6248, 339, 347, 664, 63, 576, 63, 1725, 334, 277, 304, 267, 408, 6864, 769, 402, 8189, 2491, 12, 2164, 63, 694, 12, 1506, 63, 694, 12, 10309, 3171, 6346, 624, 267, 666, 275, 942, 267, 340, 440, 291, 14, 5154, 26, 288, 372, 666, 267, 367, 2559, 315, 291, 14, 5154, 26, 288, 327, 6263, 323, 2559, 1350, 2082, 288, 2928, 63, 694, 275, 291, 14, 362, 63, 2491, 63, 694, 8, 2491, 9, 953, 327, 8354, 2559, 1900, 2082, 288, 1900, 63, 694, 275, 747, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
TeamExodus/external_chromium_org
tools/json_schema_compiler/cpp_util_test.py
96
2096
#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import unittest from cpp_util import ( Classname, CloseNamespace, GenerateIfndefName, OpenNamespace) class CppUtilTest(unittest.TestCase): def testClassname(self): self.assertEquals('Permissions', Classname('permissions')) self.assertEquals('UpdateAllTheThings', Classname('updateAllTheThings')) self.assertEquals('Aa_Bb_Cc', Classname('aa.bb.cc')) def testNamespaceDeclaration(self): self.assertEquals('namespace foo {', OpenNamespace('foo').Render()) self.assertEquals('} // namespace foo', CloseNamespace('foo').Render()) self.assertEquals( 'namespace extensions {\n' 'namespace foo {', OpenNamespace('extensions::foo').Render()) self.assertEquals( '} // namespace foo\n' '} // namespace extensions', CloseNamespace('extensions::foo').Render()) self.assertEquals( 'namespace extensions {\n' 'namespace gen {\n' 'namespace api {', OpenNamespace('extensions::gen::api').Render()) self.assertEquals( '} // namespace api\n' '} // namespace gen\n' '} // namespace extensions', CloseNamespace('extensions::gen::api').Render()) self.assertEquals( 'namespace extensions {\n' 'namespace gen {\n' 'namespace api {\n' 'namespace foo {', OpenNamespace('extensions::gen::api::foo').Render()) self.assertEquals( '} // namespace foo\n' '} // namespace api\n' '} // namespace gen\n' '} // namespace extensions', CloseNamespace('extensions::gen::api::foo').Render()) def testGenerateIfndefName(self): self.assertEquals('FOO_BAR_BAZ_H__', GenerateIfndefName('foo\\bar\\baz.h')) self.assertEquals('FOO_BAR_BAZ_H__', GenerateIfndefName('foo/bar/baz.h')) if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 504, 7246, 63, 1974, 492, 334, 272, 8089, 354, 12, 15524, 8814, 12, 7958, 41, 2324, 318, 985, 12, 3232, 8814, 9, 199, 199, 533, 445, 802, 9562, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 2543, 354, 8, 277, 304, 272, 291, 14, 2947, 360, 17004, 297, 8089, 354, 360, 6060, 1333, 272, 291, 14, 2947, 360, 4152, 2422, 1918, 2719, 780, 297, 267, 8089, 354, 360, 873, 2422, 1918, 2719, 780, 1333, 272, 291, 14, 2947, 360, 33, 65, 63, 30814, 63, 21426, 297, 8089, 354, 360, 2158, 14, 2501, 14, 2055, 1333, 819, 347, 511, 8814, 17737, 8, 277, 304, 272, 291, 14, 2947, 360, 3251, 3925, 469, 297, 1993, 3232, 8814, 360, 1421, 1959, 9216, 1012, 272, 291, 14, 2947, 360, 93, 221, 5001, 3231, 3925, 297, 1993, 15524, 8814, 360, 1421, 1959, 9216, 1012, 339, 291, 14, 2947, 8, 267, 283, 3251, 5478, 9459, 78, 7, 267, 283, 3251, 3925, 469, 297, 267, 3232, 8814, 360, 5359, 447, 1421, 1959, 9216, 1012, 272, 291, 14, 2947, 8, 267, 28544, 221, 5001, 3231, 3925, 60, 78, 7, 267, 28544, 221, 5001, 3231, 5478, 297, 267, 15524, 8814, 360, 5359, 447, 1421, 1959, 9216, 1012, 339, 291, 14, 2947, 8, 267, 283, 3251, 5478, 9459, 78, 7, 267, 283, 3251, 3805, 9459, 78, 7, 267, 283, 3251, 2986, 469, 297, 267, 3232, 8814, 360, 5359, 447, 2268, 447, 1246, 1959, 9216, 1012, 272, 291, 14, 2947, 8, 267, 28544, 221, 5001, 3231, 2986, 60, 78, 7, 267, 28544, 221, 5001, 3231, 3805, 60, 78, 7, 267, 28544, 221, 5001, 3231, 5478, 297, 267, 15524, 8814, 360, 5359, 447, 2268, 447, 1246, 1959, 9216, 1012, 339, 291, 14, 2947, 8, 267, 283, 3251, 5478, 9459, 78, 7, 267, 283, 3251, 3805, 9459, 78, 7, 267, 283, 3251, 2986, 9459, 78, 7, 267, 283, 3251, 3925, 469, 297, 267, 3232, 8814, 360, 5359, 447, 2268, 447, 1246, 447, 1421, 1959, 9216, 1012, 272, 291, 14, 2947, 8, 267, 28544, 221, 5001, 3231, 3925, 60, 78, 7, 267, 28544, 221, 5001, 3231, 2986, 60, 78, 7, 267, 28544, 221, 5001, 3231, 3805, 60, 78, 7, 267, 28544, 221, 5001, 3231, 5478, 297, 267, 15524, 8814, 360, 5359, 447, 2268, 447, 1246, 447, 1421, 1959, 9216, 1012, 819, 347, 511, 6864, 41, 2324, 318, 985, 8, 277, 304, 272, 291, 14, 2947, 360, 13046, 63, 13895, 63, 4134, 58, 63, 40, 7500, 7958, 41, 2324, 318, 985, 360, 1421, 1103, 1700, 1103, 6185, 14, 72, 1333, 272, 291, 14, 2947, 360, 13046, 63, 13895, 63, 4134, 58, 63, 40, 7500, 7958, 41, 2324, 318, 985, 360, 1421, 15, 1700, 15, 6185, 14, 72, 1333, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 504, 7246, 63, 1974, 492, 334, 272, 8089, 354, 12, 15524, 8814, 12, 7958, 41, 2324, 318, 985, 12, 3232, 8814, 9, 199, 199, 533, 445, 802, 9562, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 2543, 354, 8, 277, 304, 272, 291, 14, 2947, 360, 17004, 297, 8089, 354, 360, 6060, 1333, 272, 291, 14, 2947, 360, 4152, 2422, 1918, 2719, 780, 297, 267, 8089, 354, 360, 873, 2422, 1918, 2719, 780, 1333, 272, 291, 14, 2947, 360, 33, 65, 63, 30814, 63, 21426, 297, 8089, 354, 360, 2158, 14, 2501, 14, 2055, 1333, 819, 347, 511, 8814, 17737, 8, 277, 304, 272, 291, 14, 2947, 360, 3251, 3925, 469, 297, 1993, 3232, 8814, 360, 1421, 1959, 9216, 1012, 272, 291, 14, 2947, 360, 93, 221, 5001, 3231, 3925, 297, 1993, 15524, 8814, 360, 1421, 1959, 9216, 1012, 339, 291, 14, 2947, 8, 267, 283, 3251, 5478, 9459, 78, 7, 267, 283, 3251, 3925, 469, 297, 267, 3232, 8814, 360, 5359, 447, 1421, 1959, 9216, 1012, 272, 291, 14, 2947, 8, 267, 28544, 221, 5001, 3231, 3925, 60, 78, 7, 267, 28544, 221, 5001, 3231, 5478, 297, 267, 15524, 8814, 360, 5359, 447, 1421, 1959, 9216, 1012, 339, 291, 14, 2947, 8, 267, 283, 3251, 5478, 9459, 78, 7, 267, 283, 3251, 3805, 9459, 78, 7, 267, 283, 3251, 2986, 469, 297, 267, 3232, 8814, 360, 5359, 447, 2268, 447, 1246, 1959, 9216, 1012, 272, 291, 14, 2947, 8, 267, 28544, 221, 5001, 3231, 2986, 60, 78, 7, 267, 28544, 221, 5001, 3231, 3805, 60, 78, 7, 267, 28544, 221, 5001, 3231, 5478, 297, 267, 15524, 8814, 360, 5359, 447, 2268, 447, 1246, 1959, 9216, 1012, 339, 291, 14, 2947, 8, 267, 283, 3251, 5478, 9459, 78, 7, 267, 283, 3251, 3805, 9459, 78, 7, 267, 283, 3251, 2986, 9459, 78, 7, 267, 283, 3251, 3925, 469, 297, 267, 3232, 8814, 360, 5359, 447, 2268, 447, 1246, 447, 1421, 1959, 9216, 1012, 272, 291, 14, 2947, 8, 267, 28544, 221, 5001, 3231, 3925, 60, 78, 7, 267, 28544, 221, 5001, 3231, 2986, 60, 78, 7, 267, 28544, 221, 5001, 3231, 3805, 60, 78, 7, 267, 28544, 221, 5001, 3231, 5478, 297, 267, 15524, 8814, 360, 5359, 447, 2268, 447, 1246, 447, 1421, 1959, 9216, 1012, 819, 347, 511, 6864, 41, 2324, 318, 985, 8, 277, 304, 272, 291, 14, 2947, 360, 13046, 63, 13895, 63, 4134, 58, 63, 40, 7500, 7958, 41, 2324, 318, 985, 360, 1421, 1103, 1700, 1103, 6185, 14, 72, 1333, 272, 291, 14, 2947, 360, 13046, 63, 13895, 63, 4134, 58, 63, 40, 7500, 7958, 41, 2324, 318, 985, 360, 1421, 15, 1700, 15, 6185, 14, 72, 1333, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zeroSteiner/boltons
boltons/formatutils.py
1
11298
# -*- coding: utf-8 -*- """`PEP 3101`_ introduced the :meth:`str.format` method, and what would later be called "new-style" string formatting. For the sake of explicit correctness, it is probably best to refer to Python's dual string formatting capabilities as *bracket-style* and *percent-style*. There is overlap, but one does not replace the other. * Bracket-style is more pluggable, slower, and uses a method. * Percent-style is simpler, faster, and uses an operator. Bracket-style formatting brought with it a much more powerful toolbox, but it was far from a full one. :meth:`str.format` uses `more powerful syntax`_, but `the tools and idioms`_ for working with that syntax are not well-developed nor well-advertised. ``formatutils`` adds several functions for working with bracket-style format strings: * :class:`DeferredValue`: Defer fetching or calculating a value until format time. * :func:`get_format_args`: Parse the positional and keyword arguments out of a format string. * :func:`tokenize_format_str`: Tokenize a format string into literals and :class:`BaseFormatField` objects. * :func:`construct_format_field_str`: Assists in progammatic construction of format strings. * :func:`infer_positional_format_args`: Converts anonymous references in 2.7+ format strings to explicit positional arguments suitable for usage with Python 2.6. .. _more powerful syntax: https://docs.python.org/2/library/string.html#format-string-syntax .. _the tools and idioms: https://docs.python.org/2/library/string.html#string-formatting .. _PEP 3101: https://www.python.org/dev/peps/pep-3101/ """ # TODO: also include percent-formatting utils? # TODO: include lithoxyl.formatters.Formatter (or some adaptation)? from __future__ import print_function import re from string import Formatter __all__ = ['DeferredValue', 'get_format_args', 'tokenize_format_str', 'construct_format_field_str', 'infer_positional_format_args', 'BaseFormatField'] _pos_farg_re = re.compile('({{)|' # escaped open-brace '(}})|' # escaped close-brace '({[:!.\[}])') # anon positional format arg def construct_format_field_str(fname, fspec, conv): """ Constructs a format field string from the field name, spec, and conversion character (``fname``, ``fspec``, ``conv``). See Python String Formatting for more info. """ if fname is None: return '' ret = '{' + fname if conv: ret += '!' + conv if fspec: ret += ':' + fspec ret += '}' return ret def split_format_str(fstr): """Does very basic spliting of a format string, returns a list of strings. For full tokenization, see :func:`tokenize_format_str`. """ ret = [] for lit, fname, fspec, conv in Formatter().parse(fstr): if fname is None: ret.append((lit, None)) continue field_str = construct_format_field_str(fname, fspec, conv) ret.append((lit, field_str)) return ret def infer_positional_format_args(fstr): """Takes format strings with anonymous positional arguments, (e.g., "{}" and {:d}), and converts them into numbered ones for explicitness and compatibility with 2.6. Returns a string with the inferred positional arguments. """ # TODO: memoize ret, max_anon = '', 0 # look for {: or {! or {. or {[ or {} start, end, prev_end = 0, 0, 0 for match in _pos_farg_re.finditer(fstr): start, end, group = match.start(), match.end(), match.group() if prev_end < start: ret += fstr[prev_end:start] prev_end = end if group == '{{' or group == '}}': ret += group continue ret += '{%s%s' % (max_anon, group[1:]) max_anon += 1 ret += fstr[prev_end:] return ret # This approach is hardly exhaustive but it works for most builtins _INTCHARS = 'bcdoxXn' _FLOATCHARS = 'eEfFgGn%' _TYPE_MAP = dict([(x, int) for x in _INTCHARS] + [(x, float) for x in _FLOATCHARS]) _TYPE_MAP['s'] = str def get_format_args(fstr): """ Turn a format string into two lists of arguments referenced by the format string. One is positional arguments, and the other is named arguments. Each element of the list includes the name and the nominal type of the field. # >>> get_format_args("{noun} is {1:d} years old{punct}") # ([(1, <type 'int'>)], [('noun', <type 'str'>), ('punct', <type 'str'>)]) # XXX: Py3k >>> get_format_args("{noun} is {1:d} years old{punct}") == \ ([(1, int)], [('noun', str), ('punct', str)]) True """ # TODO: memoize formatter = Formatter() fargs, fkwargs, _dedup = [], [], set() def _add_arg(argname, type_char='s'): if argname not in _dedup: _dedup.add(argname) argtype = _TYPE_MAP.get(type_char, str) # TODO: unicode try: fargs.append((int(argname), argtype)) except ValueError: fkwargs.append((argname, argtype)) for lit, fname, fspec, conv in formatter.parse(fstr): if fname is not None: type_char = fspec[-1:] fname_list = re.split('[.[]', fname) if len(fname_list) > 1: raise ValueError('encountered compound format arg: %r' % fname) try: base_fname = fname_list[0] assert base_fname except (IndexError, AssertionError): raise ValueError('encountered anonymous positional argument') _add_arg(fname, type_char) for sublit, subfname, _, _ in formatter.parse(fspec): # TODO: positional and anon args not allowed here. if subfname is not None: _add_arg(subfname) return fargs, fkwargs def tokenize_format_str(fstr, resolve_pos=True): """Takes a format string, turns it into a list of alternating string literals and :class:`BaseFormatField` tokens. By default, also infers anonymous positional references into explict, numbered positional references. To disable this behavior set *resolve_pos* to ``False``. """ ret = [] if resolve_pos: fstr = infer_positional_format_args(fstr) formatter = Formatter() for lit, fname, fspec, conv in formatter.parse(fstr): if lit: ret.append(lit) if fname is None: continue ret.append(BaseFormatField(fname, fspec, conv)) return ret class BaseFormatField(object): """A class representing a reference to an argument inside of a bracket-style format string. For instance, in ``"{greeting}, world!"``, there is a field named "greeting". These fields can have many options applied to them. See the Python docs on `Format String Syntax`_ for the full details. .. _Format String Syntax: https://docs.python.org/2/library/string.html#string-formatting """ def __init__(self, fname, fspec='', conv=None): self.set_fname(fname) self.set_fspec(fspec) self.set_conv(conv) def set_fname(self, fname): "Set the field name." path_list = re.split('[.[]', fname) # TODO self.base_name = path_list[0] self.fname = fname self.subpath = path_list[1:] self.is_positional = not self.base_name or self.base_name.isdigit() def set_fspec(self, fspec): "Set the field spec." fspec = fspec or '' subfields = [] for sublit, subfname, _, _ in Formatter().parse(fspec): if subfname is not None: subfields.append(subfname) self.subfields = subfields self.fspec = fspec self.type_char = fspec[-1:] self.type_func = _TYPE_MAP.get(self.type_char, str) def set_conv(self, conv): """There are only two built-in converters: ``s`` and ``r``. They are somewhat rare and appearlike ``"{ref!r}"``.""" # TODO self.conv = conv self.conv_func = None # TODO @property def fstr(self): "The current state of the field in string format." return construct_format_field_str(self.fname, self.fspec, self.conv) def __repr__(self): cn = self.__class__.__name__ args = [self.fname] if self.conv is not None: args.extend([self.fspec, self.conv]) elif self.fspec != '': args.append(self.fspec) args_repr = ', '.join([repr(a) for a in args]) return '%s(%s)' % (cn, args_repr) def __str__(self): return self.fstr _UNSET = object() class DeferredValue(object): """:class:`DeferredValue` is a wrapper type, used to defer computing values which would otherwise be expensive to stringify and format. This is most valuable in areas like logging, where one would not want to waste time formatting a value for a log message which will subsequently be filtered because the message's log level was DEBUG and the logger was set to only emit CRITICAL messages. The :class:``DeferredValue`` is initialized with a callable that takes no arguments and returns the value, which can be of any type. By default DeferredValue only calls that callable once, and future references will get a cached value. This behavior can be disabled by setting *cache_value* to ``False``. Args: func (function): A callable that takes no arguments and computes the value being represented. cache_value (bool): Whether subsequent usages will call *func* again. Defaults to ``True``. >>> import sys >>> dv = DeferredValue(lambda: len(sys._current_frames())) >>> output = "works great in all {0} threads!".format(dv) PROTIP: To keep lines shorter, use: ``from formatutils import DeferredValue as DV`` """ def __init__(self, func, cache_value=True): self.func = func self.cache_value = True self._value = _UNSET def get_value(self): """Computes, optionally caches, and returns the value of the *func*. If ``get_value()`` has been called before, a cached value may be returned depending on the *cache_value* option passed to the constructor. """ if self._value is not _UNSET and self.cache_value: value = self._value else: value = self.func() if self.cache_value: self._value = value return value def __int__(self): return int(self.get_value()) def __float__(self): return float(self.get_value()) def __str__(self): return str(self.get_value()) def __unicode__(self): return unicode(self.get_value()) def __repr__(self): return repr(self.get_value()) def __format__(self, fmt): value = self.get_value() pt = fmt[-1:] # presentation type type_conv = _TYPE_MAP.get(pt, str) try: return value.__format__(fmt) except (ValueError, TypeError): # TODO: this may be overkill return type_conv(value).__format__(fmt) # end formatutils.py
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 64, 25633, 650, 4893, 18417, 21399, 314, 520, 5247, 1705, 495, 14, 908, 64, 1083, 12, 436, 4052, 199, 2027, 854, 2945, 506, 2797, 298, 1222, 13, 2487, 2, 1059, 10803, 14, 2104, 314, 308, 1728, 402, 199, 10306, 29102, 12, 652, 365, 8646, 5526, 370, 10618, 370, 2018, 1159, 21164, 199, 875, 10803, 14918, 465, 627, 14594, 13, 2487, 10, 436, 199, 10, 7045, 13, 2487, 4856, 6006, 365, 15145, 12, 1325, 1373, 1630, 440, 3350, 314, 199, 1848, 14, 819, 627, 32377, 2284, 13, 2487, 365, 1655, 14202, 16725, 12, 26200, 12, 436, 4440, 282, 1083, 14, 523, 627, 3492, 2946, 13, 2487, 365, 28293, 12, 12930, 12, 436, 4440, 376, 4182, 14, 199, 199, 29418, 13, 2487, 10803, 330, 7930, 913, 543, 652, 282, 8298, 1655, 7074, 1893, 4744, 1977, 12, 199, 7911, 652, 1990, 12474, 687, 282, 2615, 1373, 14, 520, 5247, 1705, 495, 14, 908, 64, 4440, 658, 6878, 7074, 1893, 199, 7093, 64, 3131, 1325, 658, 1589, 7249, 436, 284, 328, 22491, 18417, 367, 6449, 543, 199, 9099, 6302, 787, 440, 5521, 13, 271, 27813, 6590, 5521, 13, 24576, 939, 14, 199, 199, 1040, 908, 1208, 1040, 9584, 9978, 3423, 367, 6449, 543, 14540, 13, 2487, 199, 908, 3326, 26, 819, 627, 520, 533, 1705, 9937, 1110, 8340, 1487, 2412, 21239, 503, 26079, 282, 574, 272, 5133, 1475, 900, 14, 523, 627, 520, 1532, 1705, 362, 63, 908, 63, 589, 8340, 6077, 314, 11333, 436, 4252, 272, 2368, 734, 402, 282, 1475, 1059, 14, 523, 627, 520, 1532, 1705, 15246, 63, 908, 63, 495, 8340, 8767, 794, 282, 1475, 1059, 1901, 272, 18041, 436, 520, 533, 1705, 1563, 3484, 792, 64, 2251, 14, 523, 627, 520, 1532, 1705, 8514, 63, 908, 63, 698, 63, 495, 8340, 3709, 338, 10329, 315, 13205, 455, 3889, 272, 14538, 402, 1475, 3326, 14, 523, 627, 520, 1532, 1705, 14578, 63, 17867, 63, 908, 63, 589, 8340, 19107, 16535, 272, 6941, 315, 499, 14, 23, 11, 1475, 3326, 370, 5027, 11333, 2368, 272, 11233, 367, 4503, 543, 2018, 499, 14, 22, 14, 199, 199, 703, 485, 6878, 7074, 1893, 6302, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 908, 13, 875, 13, 7093, 199, 703, 485, 1589, 7249, 436, 284, 328, 22491, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 875, 13, 20034, 199, 703, 485, 25633, 650, 4893, 26, 4178, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 2192, 614, 15, 199, 624, 199, 3, 3254, 26, 2597, 2387, 8878, 13, 20034, 3778, 31, 199, 3, 3254, 26, 2387, 1212, 273, 79, 1702, 76, 14, 24270, 14, 7772, 334, 269, 2005, 19520, 425, 5547, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 295, 199, 504, 1059, 492, 31084, 421, 199, 363, 452, 363, 275, 788, 9937, 1110, 297, 283, 362, 63, 908, 63, 589, 297, 283, 15246, 63, 908, 63, 495, 297, 1779, 283, 8514, 63, 908, 63, 698, 63, 495, 297, 283, 14578, 63, 17867, 63, 908, 63, 589, 297, 1779, 283, 1563, 3484, 792, 418, 421, 199, 63, 1712, 63, 70, 1273, 63, 264, 275, 295, 14, 2014, 360, 2561, 91, 9, 5227, 260, 327, 11077, 1551, 13, 22359, 2079, 8189, 19575, 5227, 260, 327, 11077, 4002, 13, 22359, 2079, 283, 2561, 1491, 1, 3134, 59, 29810, 358, 221, 327, 24757, 11333, 1475, 1680, 421, 199, 318, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 304, 272, 408, 272, 9215, 83, 282, 1475, 901, 1059, 687, 314, 901, 536, 12, 3158, 12, 436, 272, 8603, 4528, 15693, 5252, 4542, 1124, 70, 1650, 4542, 1124, 5598, 20008, 1666, 2018, 272, 2624, 9701, 1337, 367, 1655, 2256, 14, 272, 408, 272, 340, 6748, 365, 488, 26, 267, 372, 2125, 272, 2203, 275, 26109, 435, 6748, 272, 340, 8260, 26, 267, 2203, 847, 29376, 435, 8260, 272, 340, 289, 1650, 26, 267, 2203, 847, 10871, 435, 289, 1650, 272, 2203, 847, 23618, 272, 372, 2203, 421, 199, 318, 3715, 63, 908, 63, 495, 8, 70, 495, 304, 272, 408, 6586, 7437, 5678, 3715, 316, 402, 282, 1475, 1059, 12, 2529, 282, 769, 402, 272, 3326, 14, 2104, 2615, 1526, 2072, 12, 1937, 520, 1532, 1705, 15246, 63, 908, 63, 495, 2313, 339, 408, 272, 2203, 275, 942, 339, 367, 28649, 12, 6748, 12, 289, 1650, 12, 8260, 315, 31084, 1252, 1122, 8, 70, 495, 304, 267, 340, 6748, 365, 488, 26, 288, 2203, 14, 740, 1332, 1051, 12, 488, 430, 288, 1980, 267, 901, 63, 495, 275, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 9, 267, 2203, 14, 740, 1332, 1051, 12, 901, 63, 495, 430, 272, 372, 2203, 421, 199, 318, 18538, 63, 17867, 63, 908, 63, 589, 8, 70, 495, 304, 272, 408, 32488, 1475, 3326, 543, 16535, 11333, 2368, 12, 334, 69, 14, 71, 2020, 272, 28168, 436, 19850, 68, 8688, 436, 15373, 3062, 1901, 1967, 18897, 7869, 367, 5027, 4171, 436, 272, 7163, 543, 499, 14, 22, 14, 339, 1803, 282, 1059, 543, 314, 22515, 11333, 2368, 14, 272, 408, 272, 327, 3254, 26, 11955, 794, 272, 2203, 12, 1390, 63, 21009, 275, 3260, 378, 272, 327, 3648, 367, 19850, 503, 18776, 503, 469, 14, 503, 469, 59, 503, 1052, 272, 1343, 12, 1284, 12, 5071, 63, 500, 275, 378, 12, 378, 12, 378, 272, 367, 1336, 315, 485, 1712, 63, 70, 1273, 63, 264, 14, 19373, 8, 70, 495, 304, 267, 1343, 12, 1284, 12, 1572, 275, 1336, 14, 928, 1062, 1336, 14, 500, 1062, 1336, 14, 923, 342, 267, 340, 5071, 63, 500, 665, 1343, 26, 288, 2203, 847, 289, 495, 59, 5701, 63, 500, 26, 928, 61, 267, 5071, 63, 500, 275, 1284, 267, 340, 1572, 508, 5041, 1445, 503, 1572, 508, 283, 4863, 356, 288, 2203, 847, 1572, 288, 1980, 267, 2203, 847, 12100, 83, 5, 83, 7, 450, 334, 988, 63, 21009, 12, 1572, 59, 17, 5728, 267, 1390, 63, 21009, 847 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 64, 25633, 650, 4893, 18417, 21399, 314, 520, 5247, 1705, 495, 14, 908, 64, 1083, 12, 436, 4052, 199, 2027, 854, 2945, 506, 2797, 298, 1222, 13, 2487, 2, 1059, 10803, 14, 2104, 314, 308, 1728, 402, 199, 10306, 29102, 12, 652, 365, 8646, 5526, 370, 10618, 370, 2018, 1159, 21164, 199, 875, 10803, 14918, 465, 627, 14594, 13, 2487, 10, 436, 199, 10, 7045, 13, 2487, 4856, 6006, 365, 15145, 12, 1325, 1373, 1630, 440, 3350, 314, 199, 1848, 14, 819, 627, 32377, 2284, 13, 2487, 365, 1655, 14202, 16725, 12, 26200, 12, 436, 4440, 282, 1083, 14, 523, 627, 3492, 2946, 13, 2487, 365, 28293, 12, 12930, 12, 436, 4440, 376, 4182, 14, 199, 199, 29418, 13, 2487, 10803, 330, 7930, 913, 543, 652, 282, 8298, 1655, 7074, 1893, 4744, 1977, 12, 199, 7911, 652, 1990, 12474, 687, 282, 2615, 1373, 14, 520, 5247, 1705, 495, 14, 908, 64, 4440, 658, 6878, 7074, 1893, 199, 7093, 64, 3131, 1325, 658, 1589, 7249, 436, 284, 328, 22491, 18417, 367, 6449, 543, 199, 9099, 6302, 787, 440, 5521, 13, 271, 27813, 6590, 5521, 13, 24576, 939, 14, 199, 199, 1040, 908, 1208, 1040, 9584, 9978, 3423, 367, 6449, 543, 14540, 13, 2487, 199, 908, 3326, 26, 819, 627, 520, 533, 1705, 9937, 1110, 8340, 1487, 2412, 21239, 503, 26079, 282, 574, 272, 5133, 1475, 900, 14, 523, 627, 520, 1532, 1705, 362, 63, 908, 63, 589, 8340, 6077, 314, 11333, 436, 4252, 272, 2368, 734, 402, 282, 1475, 1059, 14, 523, 627, 520, 1532, 1705, 15246, 63, 908, 63, 495, 8340, 8767, 794, 282, 1475, 1059, 1901, 272, 18041, 436, 520, 533, 1705, 1563, 3484, 792, 64, 2251, 14, 523, 627, 520, 1532, 1705, 8514, 63, 908, 63, 698, 63, 495, 8340, 3709, 338, 10329, 315, 13205, 455, 3889, 272, 14538, 402, 1475, 3326, 14, 523, 627, 520, 1532, 1705, 14578, 63, 17867, 63, 908, 63, 589, 8340, 19107, 16535, 272, 6941, 315, 499, 14, 23, 11, 1475, 3326, 370, 5027, 11333, 2368, 272, 11233, 367, 4503, 543, 2018, 499, 14, 22, 14, 199, 199, 703, 485, 6878, 7074, 1893, 6302, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 908, 13, 875, 13, 7093, 199, 703, 485, 1589, 7249, 436, 284, 328, 22491, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 875, 13, 20034, 199, 703, 485, 25633, 650, 4893, 26, 4178, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 2192, 614, 15, 199, 624, 199, 3, 3254, 26, 2597, 2387, 8878, 13, 20034, 3778, 31, 199, 3, 3254, 26, 2387, 1212, 273, 79, 1702, 76, 14, 24270, 14, 7772, 334, 269, 2005, 19520, 425, 5547, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 295, 199, 504, 1059, 492, 31084, 421, 199, 363, 452, 363, 275, 788, 9937, 1110, 297, 283, 362, 63, 908, 63, 589, 297, 283, 15246, 63, 908, 63, 495, 297, 1779, 283, 8514, 63, 908, 63, 698, 63, 495, 297, 283, 14578, 63, 17867, 63, 908, 63, 589, 297, 1779, 283, 1563, 3484, 792, 418, 421, 199, 63, 1712, 63, 70, 1273, 63, 264, 275, 295, 14, 2014, 360, 2561, 91, 9, 5227, 260, 327, 11077, 1551, 13, 22359, 2079, 8189, 19575, 5227, 260, 327, 11077, 4002, 13, 22359, 2079, 283, 2561, 1491, 1, 3134, 59, 29810, 358, 221, 327, 24757, 11333, 1475, 1680, 421, 199, 318, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 304, 272, 408, 272, 9215, 83, 282, 1475, 901, 1059, 687, 314, 901, 536, 12, 3158, 12, 436, 272, 8603, 4528, 15693, 5252, 4542, 1124, 70, 1650, 4542, 1124, 5598, 20008, 1666, 2018, 272, 2624, 9701, 1337, 367, 1655, 2256, 14, 272, 408, 272, 340, 6748, 365, 488, 26, 267, 372, 2125, 272, 2203, 275, 26109, 435, 6748, 272, 340, 8260, 26, 267, 2203, 847, 29376, 435, 8260, 272, 340, 289, 1650, 26, 267, 2203, 847, 10871, 435, 289, 1650, 272, 2203, 847, 23618, 272, 372, 2203, 421, 199, 318, 3715, 63, 908, 63, 495, 8, 70, 495, 304, 272, 408, 6586, 7437, 5678, 3715, 316, 402, 282, 1475, 1059, 12, 2529, 282, 769, 402, 272, 3326, 14, 2104, 2615, 1526, 2072, 12, 1937, 520, 1532, 1705, 15246, 63, 908, 63, 495, 2313, 339, 408, 272, 2203, 275, 942, 339, 367, 28649, 12, 6748, 12, 289, 1650, 12, 8260, 315, 31084, 1252, 1122, 8, 70, 495, 304, 267, 340, 6748, 365, 488, 26, 288, 2203, 14, 740, 1332, 1051, 12, 488, 430, 288, 1980, 267, 901, 63, 495, 275, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 9, 267, 2203, 14, 740, 1332, 1051, 12, 901, 63, 495, 430, 272, 372, 2203, 421, 199, 318, 18538, 63, 17867, 63, 908, 63, 589, 8, 70, 495, 304, 272, 408, 32488, 1475, 3326, 543, 16535, 11333, 2368, 12, 334, 69, 14, 71, 2020, 272, 28168, 436, 19850, 68, 8688, 436, 15373, 3062, 1901, 1967, 18897, 7869, 367, 5027, 4171, 436, 272, 7163, 543, 499, 14, 22, 14, 339, 1803, 282, 1059, 543, 314, 22515, 11333, 2368, 14, 272, 408, 272, 327, 3254, 26, 11955, 794, 272, 2203, 12, 1390, 63, 21009, 275, 3260, 378, 272, 327, 3648, 367, 19850, 503, 18776, 503, 469, 14, 503, 469, 59, 503, 1052, 272, 1343, 12, 1284, 12, 5071, 63, 500, 275, 378, 12, 378, 12, 378, 272, 367, 1336, 315, 485, 1712, 63, 70, 1273, 63, 264, 14, 19373, 8, 70, 495, 304, 267, 1343, 12, 1284, 12, 1572, 275, 1336, 14, 928, 1062, 1336, 14, 500, 1062, 1336, 14, 923, 342, 267, 340, 5071, 63, 500, 665, 1343, 26, 288, 2203, 847, 289, 495, 59, 5701, 63, 500, 26, 928, 61, 267, 5071, 63, 500, 275, 1284, 267, 340, 1572, 508, 5041, 1445, 503, 1572, 508, 283, 4863, 356, 288, 2203, 847, 1572, 288, 1980, 267, 2203, 847, 12100, 83, 5, 83, 7, 450, 334, 988, 63, 21009, 12, 1572, 59, 17, 5728, 267, 1390, 63, 21009, 847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 1, 1, 1 ]
etos/django
django/core/management/commands/inspectdb.py
20
12852
import keyword import re from collections import OrderedDict from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS, connections from django.db.models.constants import LOOKUP_SEP class Command(BaseCommand): help = "Introspects the database tables in the given database and outputs a Django model module." requires_system_checks = False stealth_options = ('table_name_filter', ) db_module = 'django.db' def add_arguments(self, parser): parser.add_argument( 'table', action='store', nargs='*', type=str, help='Selects what tables or views should be introspected.', ) parser.add_argument( '--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to introspect. Defaults to using the "default" database.', ) def handle(self, **options): try: for line in self.handle_inspection(options): self.stdout.write("%s\n" % line) except NotImplementedError: raise CommandError("Database inspection isn't supported for the currently selected database backend.") def handle_inspection(self, options): connection = connections[options['database']] # 'table_name_filter' is a stealth option table_name_filter = options.get('table_name_filter') def table2model(table_name): return re.sub(r'[^a-zA-Z0-9]', '', table_name.title()) def strip_prefix(s): return s[1:] if s.startswith("u'") else s with connection.cursor() as cursor: yield "# This is an auto-generated Django model module." yield "# You'll have to do the following manually to clean this up:" yield "# * Rearrange models' order" yield "# * Make sure each model has one field with primary_key=True" yield "# * Make sure each ForeignKey has `on_delete` set to the desired behavior." yield ( "# * Remove `managed = False` lines if you wish to allow " "Django to create, modify, and delete the table" ) yield "# Feel free to rename the models, but don't rename db_table values or field names." yield 'from %s import models' % self.db_module known_models = [] tables_to_introspect = options['table'] or connection.introspection.table_names(cursor) for table_name in tables_to_introspect: if table_name_filter is not None and callable(table_name_filter): if not table_name_filter(table_name): continue try: try: relations = connection.introspection.get_relations(cursor, table_name) except NotImplementedError: relations = {} try: constraints = connection.introspection.get_constraints(cursor, table_name) except NotImplementedError: constraints = {} primary_key_column = connection.introspection.get_primary_key_column(cursor, table_name) unique_columns = [ c['columns'][0] for c in constraints.values() if c['unique'] and len(c['columns']) == 1 ] table_description = connection.introspection.get_table_description(cursor, table_name) except Exception as e: yield "# Unable to inspect table '%s'" % table_name yield "# The error was: %s" % e continue yield '' yield '' yield 'class %s(models.Model):' % table2model(table_name) known_models.append(table2model(table_name)) used_column_names = [] # Holds column names used in the table so far column_to_field_name = {} # Maps column names to names of model fields for row in table_description: comment_notes = [] # Holds Field notes, to be displayed in a Python comment. extra_params = OrderedDict() # Holds Field parameters such as 'db_column'. column_name = row[0] is_relation = column_name in relations att_name, params, notes = self.normalize_col_name( column_name, used_column_names, is_relation) extra_params.update(params) comment_notes.extend(notes) used_column_names.append(att_name) column_to_field_name[column_name] = att_name # Add primary_key and unique, if necessary. if column_name == primary_key_column: extra_params['primary_key'] = True elif column_name in unique_columns: extra_params['unique'] = True if is_relation: rel_to = ( "self" if relations[column_name][1] == table_name else table2model(relations[column_name][1]) ) if rel_to in known_models: field_type = 'ForeignKey(%s' % rel_to else: field_type = "ForeignKey('%s'" % rel_to else: # Calling `get_field_type` to get the field type string and any # additional parameters and notes. field_type, field_params, field_notes = self.get_field_type(connection, table_name, row) extra_params.update(field_params) comment_notes.extend(field_notes) field_type += '(' # Don't output 'id = meta.AutoField(primary_key=True)', because # that's assumed if it doesn't exist. if att_name == 'id' and extra_params == {'primary_key': True}: if field_type == 'AutoField(': continue elif field_type == 'IntegerField(' and not connection.features.can_introspect_autofield: comment_notes.append('AutoField?') # Add 'null' and 'blank', if the 'null_ok' flag was present in the # table description. if row[6]: # If it's NULL... if field_type == 'BooleanField(': field_type = 'NullBooleanField(' else: extra_params['blank'] = True extra_params['null'] = True field_desc = '%s = %s%s' % ( att_name, # Custom fields will have a dotted path '' if '.' in field_type else 'models.', field_type, ) if field_type.startswith('ForeignKey('): field_desc += ', models.DO_NOTHING' if extra_params: if not field_desc.endswith('('): field_desc += ', ' field_desc += ', '.join( '%s=%s' % (k, strip_prefix(repr(v))) for k, v in extra_params.items()) field_desc += ')' if comment_notes: field_desc += ' # ' + ' '.join(comment_notes) yield ' %s' % field_desc for meta_line in self.get_meta(table_name, constraints, column_to_field_name): yield meta_line def normalize_col_name(self, col_name, used_column_names, is_relation): """ Modify the column name to make it Python-compatible as a field name """ field_params = {} field_notes = [] new_name = col_name.lower() if new_name != col_name: field_notes.append('Field name made lowercase.') if is_relation: if new_name.endswith('_id'): new_name = new_name[:-3] else: field_params['db_column'] = col_name new_name, num_repl = re.subn(r'\W', '_', new_name) if num_repl > 0: field_notes.append('Field renamed to remove unsuitable characters.') if new_name.find(LOOKUP_SEP) >= 0: while new_name.find(LOOKUP_SEP) >= 0: new_name = new_name.replace(LOOKUP_SEP, '_') if col_name.lower().find(LOOKUP_SEP) >= 0: # Only add the comment if the double underscore was in the original name field_notes.append("Field renamed because it contained more than one '_' in a row.") if new_name.startswith('_'): new_name = 'field%s' % new_name field_notes.append("Field renamed because it started with '_'.") if new_name.endswith('_'): new_name = '%sfield' % new_name field_notes.append("Field renamed because it ended with '_'.") if keyword.iskeyword(new_name): new_name += '_field' field_notes.append('Field renamed because it was a Python reserved word.') if new_name[0].isdigit(): new_name = 'number_%s' % new_name field_notes.append("Field renamed because it wasn't a valid Python identifier.") if new_name in used_column_names: num = 0 while '%s_%d' % (new_name, num) in used_column_names: num += 1 new_name = '%s_%d' % (new_name, num) field_notes.append('Field renamed because of name conflict.') if col_name != new_name and field_notes: field_params['db_column'] = col_name return new_name, field_params, field_notes def get_field_type(self, connection, table_name, row): """ Given the database connection, the table name, and the cursor row description, this routine will return the given field type name, as well as any additional keyword parameters and notes for the field. """ field_params = OrderedDict() field_notes = [] try: field_type = connection.introspection.get_field_type(row[1], row) except KeyError: field_type = 'TextField' field_notes.append('This field type is a guess.') # This is a hook for data_types_reverse to return a tuple of # (field_type, field_params_dict). if type(field_type) is tuple: field_type, new_params = field_type field_params.update(new_params) # Add max_length for all CharFields. if field_type == 'CharField' and row[3]: field_params['max_length'] = int(row[3]) if field_type == 'DecimalField': if row[4] is None or row[5] is None: field_notes.append( 'max_digits and decimal_places have been guessed, as this ' 'database handles decimal fields as float') field_params['max_digits'] = row[4] if row[4] is not None else 10 field_params['decimal_places'] = row[5] if row[5] is not None else 5 else: field_params['max_digits'] = row[4] field_params['decimal_places'] = row[5] return field_type, field_params, field_notes def get_meta(self, table_name, constraints, column_to_field_name): """ Return a sequence comprising the lines of code necessary to construct the inner Meta class for the model corresponding to the given database table name. """ unique_together = [] for index, params in constraints.items(): if params['unique']: columns = params['columns'] if len(columns) > 1: # we do not want to include the u"" or u'' prefix # so we build the string rather than interpolate the tuple tup = '(' + ', '.join("'%s'" % column_to_field_name[c] for c in columns) + ')' unique_together.append(tup) meta = ["", " class Meta:", " managed = False", " db_table = '%s'" % table_name] if unique_together: tup = '(' + ', '.join(unique_together) + ',)' meta += [" unique_together = %s" % tup] return meta
bsd-3-clause
[ 646, 4252, 199, 646, 295, 199, 504, 5055, 492, 8773, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 6947, 199, 504, 1639, 14, 697, 14, 992, 14, 5559, 492, 3412, 3593, 2160, 63, 20848, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 3241, 21302, 83, 314, 3050, 6716, 315, 314, 1627, 3050, 436, 4704, 282, 5634, 1402, 859, 2122, 272, 5074, 63, 2253, 63, 8625, 275, 756, 272, 20345, 6130, 63, 1419, 275, 661, 1224, 63, 354, 63, 1541, 297, 776, 272, 1592, 63, 578, 275, 283, 1176, 14, 697, 7, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 8, 288, 283, 1224, 297, 1595, 534, 1617, 297, 9237, 534, 7693, 730, 29, 495, 12, 288, 1720, 534, 5446, 83, 4052, 6716, 503, 6858, 1077, 506, 1109, 4796, 1043, 3130, 267, 776, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 4659, 297, 1595, 534, 1617, 297, 2053, 534, 4659, 297, 849, 29, 3472, 63, 2846, 63, 12644, 12, 288, 1720, 534, 46, 676, 262, 2335, 282, 3050, 370, 1109, 21302, 14, 7827, 370, 1808, 314, 298, 885, 2, 3050, 3130, 267, 776, 339, 347, 2429, 8, 277, 12, 1011, 1419, 304, 267, 862, 26, 288, 367, 1004, 315, 291, 14, 2479, 63, 25098, 8, 1419, 304, 355, 291, 14, 2703, 14, 952, 3647, 83, 60, 78, 2, 450, 1004, 9, 267, 871, 4279, 26, 288, 746, 14393, 480, 7243, 5261, 10303, 5712, 1133, 3748, 367, 314, 5544, 4895, 3050, 4865, 2685, 339, 347, 2429, 63, 25098, 8, 277, 12, 1511, 304, 267, 1950, 275, 6947, 59, 1419, 459, 4659, 6538, 267, 327, 283, 1224, 63, 354, 63, 1541, 7, 365, 282, 20345, 6130, 945, 267, 1817, 63, 354, 63, 1541, 275, 1511, 14, 362, 360, 1224, 63, 354, 63, 1541, 358, 398, 347, 1817, 18, 1238, 8, 1224, 63, 354, 304, 288, 372, 295, 14, 954, 8, 82, 16122, 65, 13, 6353, 13, 58, 16, 13, 25, 4300, 3260, 1817, 63, 354, 14, 1213, 1012, 398, 347, 6202, 63, 1861, 8, 83, 304, 288, 372, 308, 59, 17, 2938, 340, 308, 14, 2460, 480, 85, 9859, 587, 308, 398, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 1995, 5426, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2122, 288, 1995, 5426, 2047, 7171, 1172, 370, 886, 314, 2569, 10250, 370, 3633, 642, 1536, 5424, 288, 1995, 5426, 257, 627, 799, 285, 1842, 1709, 7, 1865, 2, 288, 1995, 5426, 257, 627, 4155, 3238, 1924, 1402, 965, 1373, 901, 543, 5062, 63, 498, 29, 549, 2, 288, 1995, 5426, 257, 627, 4155, 3238, 1924, 12718, 965, 658, 265, 63, 1807, 64, 663, 370, 314, 6387, 5953, 2122, 288, 1995, 334, 355, 5426, 257, 627, 5852, 658, 11122, 275, 756, 64, 2385, 340, 1265, 13809, 370, 2040, 298, 355, 298, 9323, 370, 1218, 12, 2811, 12, 436, 3145, 314, 1817, 2, 288, 776, 288, 1995, 5426, 7949, 352, 2867, 370, 11441, 314, 1709, 12, 1325, 2793, 1133, 11441, 1592, 63, 1224, 1338, 503, 901, 1561, 2122, 288, 1995, 283, 504, 450, 83, 492, 1709, 7, 450, 291, 14, 697, 63, 578, 288, 6040, 63, 992, 275, 942, 288, 6716, 63, 475, 63, 29553, 275, 1511, 459, 1224, 418, 503, 1950, 14, 21627, 14, 1224, 63, 1247, 8, 3937, 9, 953, 367, 1817, 63, 354, 315, 6716, 63, 475, 63, 29553, 26, 355, 340, 1817, 63, 354, 63, 1541, 365, 440, 488, 436, 4550, 8, 1224, 63, 354, 63, 1541, 304, 490, 340, 440, 1817, 63, 354, 63, 1541, 8, 1224, 63, 354, 304, 717, 1980, 355, 862, 26, 490, 862, 26, 717, 16109, 275, 1950, 14, 21627, 14, 362, 63, 15741, 8, 3937, 12, 1817, 63, 354, 9, 490, 871, 4279, 26, 717, 16109, 275, 1052, 490, 862, 26, 717, 9565, 275, 1950, 14, 21627, 14, 362, 63, 9882, 8, 3937, 12, 1817, 63, 354, 9, 490, 871, 4279, 26, 717, 9565, 275, 1052, 490, 5062, 63, 498, 63, 2301, 275, 1950, 14, 21627, 14, 362, 63, 3327, 63, 498, 63, 2301, 8, 3937, 12, 1817, 63, 354, 9, 490, 3747, 63, 3406, 275, 359, 717, 286, 459, 3406, 3488, 16, 61, 367, 286, 315, 9565, 14, 1459, 342, 717, 340, 286, 459, 3235, 418, 436, 822, 8, 67, 459, 3406, 1105, 508, 413, 490, 1622, 490, 1817, 63, 1802, 275, 1950, 14, 21627, 14, 362, 63, 1224, 63, 1802, 8, 3937, 12, 1817, 63, 354, 9, 355, 871, 2186, 465, 325, 26, 490, 1995, 5426, 30849, 370, 6485, 1817, 1543, 83, 4065, 450, 1817, 63, 354, 490, 1995, 5426, 710, 1125, 1990, 26, 450, 83, 2, 450, 325, 490, 1980, 2234, 1995, 2125, 355, 1995, 2125, 355, 1995, 283, 533, 450, 83, 8, 992, 14, 1685, 304, 7, 450, 1817, 18, 1238, 8, 1224, 63, 354, 9, 355, 6040, 63, 992, 14, 740, 8, 1224, 18, 1238, 8, 1224, 63, 354, 430, 355, 1202, 63, 2301, 63, 1247, 275, 942, 221, 327, 869, 8250, 2763, 1561, 1202, 315, 314, 1817, 880, 12474, 355, 2763, 63, 475, 63, 698, 63, 354, 275, 1052, 221, 327, 23673, 2763, 1561, 370, 1561, 402, 1402, 1504, 355, 367, 1962, 315, 1817, 63, 1802, 26, 490, 3721, 63, 5983, 275, 942, 221, 327, 869, 8250, 5024, 12681, 12, 370, 506, 9080, 315, 282, 2018, 3721, 14, 490, 2402, 63, 1162, 275, 8773, 342, 221, 327, 869, 8250, 5024, 2633, 4066, 465, 283, 697, 63, 2301, 1370, 490, 2763, 63, 354, 275, 1962, 59, 16, 61, 490, 365, 63, 5690, 275, 2763, 63, 354, 315, 16109, 4951, 15115, 63, 354, 12, 1862, 12, 12681, 275, 291, 14, 7721, 63, 761, 63, 354, 8, 717, 2763, 63, 354, 12, 1202, 63, 2301, 63, 1247, 12, 365, 63, 5690, 9, 490, 2402, 63, 1162, 14, 873, 8, 1162, 9, 490, 3721, 63, 5983, 14, 2880, 8, 5983, 9, 4951, 1202, 63, 2301, 63, 1247, 14, 740, 8, 6796, 63, 354, 9, 490, 2763, 63, 475, 63, 698, 63, 354, 59, 2301, 63, 354, 61, 275, 15115, 63, 354, 4951, 327, 2654 ]
[ 4252, 199, 646, 295, 199, 504, 5055, 492, 8773, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 6947, 199, 504, 1639, 14, 697, 14, 992, 14, 5559, 492, 3412, 3593, 2160, 63, 20848, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 3241, 21302, 83, 314, 3050, 6716, 315, 314, 1627, 3050, 436, 4704, 282, 5634, 1402, 859, 2122, 272, 5074, 63, 2253, 63, 8625, 275, 756, 272, 20345, 6130, 63, 1419, 275, 661, 1224, 63, 354, 63, 1541, 297, 776, 272, 1592, 63, 578, 275, 283, 1176, 14, 697, 7, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 8, 288, 283, 1224, 297, 1595, 534, 1617, 297, 9237, 534, 7693, 730, 29, 495, 12, 288, 1720, 534, 5446, 83, 4052, 6716, 503, 6858, 1077, 506, 1109, 4796, 1043, 3130, 267, 776, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 4659, 297, 1595, 534, 1617, 297, 2053, 534, 4659, 297, 849, 29, 3472, 63, 2846, 63, 12644, 12, 288, 1720, 534, 46, 676, 262, 2335, 282, 3050, 370, 1109, 21302, 14, 7827, 370, 1808, 314, 298, 885, 2, 3050, 3130, 267, 776, 339, 347, 2429, 8, 277, 12, 1011, 1419, 304, 267, 862, 26, 288, 367, 1004, 315, 291, 14, 2479, 63, 25098, 8, 1419, 304, 355, 291, 14, 2703, 14, 952, 3647, 83, 60, 78, 2, 450, 1004, 9, 267, 871, 4279, 26, 288, 746, 14393, 480, 7243, 5261, 10303, 5712, 1133, 3748, 367, 314, 5544, 4895, 3050, 4865, 2685, 339, 347, 2429, 63, 25098, 8, 277, 12, 1511, 304, 267, 1950, 275, 6947, 59, 1419, 459, 4659, 6538, 267, 327, 283, 1224, 63, 354, 63, 1541, 7, 365, 282, 20345, 6130, 945, 267, 1817, 63, 354, 63, 1541, 275, 1511, 14, 362, 360, 1224, 63, 354, 63, 1541, 358, 398, 347, 1817, 18, 1238, 8, 1224, 63, 354, 304, 288, 372, 295, 14, 954, 8, 82, 16122, 65, 13, 6353, 13, 58, 16, 13, 25, 4300, 3260, 1817, 63, 354, 14, 1213, 1012, 398, 347, 6202, 63, 1861, 8, 83, 304, 288, 372, 308, 59, 17, 2938, 340, 308, 14, 2460, 480, 85, 9859, 587, 308, 398, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 1995, 5426, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2122, 288, 1995, 5426, 2047, 7171, 1172, 370, 886, 314, 2569, 10250, 370, 3633, 642, 1536, 5424, 288, 1995, 5426, 257, 627, 799, 285, 1842, 1709, 7, 1865, 2, 288, 1995, 5426, 257, 627, 4155, 3238, 1924, 1402, 965, 1373, 901, 543, 5062, 63, 498, 29, 549, 2, 288, 1995, 5426, 257, 627, 4155, 3238, 1924, 12718, 965, 658, 265, 63, 1807, 64, 663, 370, 314, 6387, 5953, 2122, 288, 1995, 334, 355, 5426, 257, 627, 5852, 658, 11122, 275, 756, 64, 2385, 340, 1265, 13809, 370, 2040, 298, 355, 298, 9323, 370, 1218, 12, 2811, 12, 436, 3145, 314, 1817, 2, 288, 776, 288, 1995, 5426, 7949, 352, 2867, 370, 11441, 314, 1709, 12, 1325, 2793, 1133, 11441, 1592, 63, 1224, 1338, 503, 901, 1561, 2122, 288, 1995, 283, 504, 450, 83, 492, 1709, 7, 450, 291, 14, 697, 63, 578, 288, 6040, 63, 992, 275, 942, 288, 6716, 63, 475, 63, 29553, 275, 1511, 459, 1224, 418, 503, 1950, 14, 21627, 14, 1224, 63, 1247, 8, 3937, 9, 953, 367, 1817, 63, 354, 315, 6716, 63, 475, 63, 29553, 26, 355, 340, 1817, 63, 354, 63, 1541, 365, 440, 488, 436, 4550, 8, 1224, 63, 354, 63, 1541, 304, 490, 340, 440, 1817, 63, 354, 63, 1541, 8, 1224, 63, 354, 304, 717, 1980, 355, 862, 26, 490, 862, 26, 717, 16109, 275, 1950, 14, 21627, 14, 362, 63, 15741, 8, 3937, 12, 1817, 63, 354, 9, 490, 871, 4279, 26, 717, 16109, 275, 1052, 490, 862, 26, 717, 9565, 275, 1950, 14, 21627, 14, 362, 63, 9882, 8, 3937, 12, 1817, 63, 354, 9, 490, 871, 4279, 26, 717, 9565, 275, 1052, 490, 5062, 63, 498, 63, 2301, 275, 1950, 14, 21627, 14, 362, 63, 3327, 63, 498, 63, 2301, 8, 3937, 12, 1817, 63, 354, 9, 490, 3747, 63, 3406, 275, 359, 717, 286, 459, 3406, 3488, 16, 61, 367, 286, 315, 9565, 14, 1459, 342, 717, 340, 286, 459, 3235, 418, 436, 822, 8, 67, 459, 3406, 1105, 508, 413, 490, 1622, 490, 1817, 63, 1802, 275, 1950, 14, 21627, 14, 362, 63, 1224, 63, 1802, 8, 3937, 12, 1817, 63, 354, 9, 355, 871, 2186, 465, 325, 26, 490, 1995, 5426, 30849, 370, 6485, 1817, 1543, 83, 4065, 450, 1817, 63, 354, 490, 1995, 5426, 710, 1125, 1990, 26, 450, 83, 2, 450, 325, 490, 1980, 2234, 1995, 2125, 355, 1995, 2125, 355, 1995, 283, 533, 450, 83, 8, 992, 14, 1685, 304, 7, 450, 1817, 18, 1238, 8, 1224, 63, 354, 9, 355, 6040, 63, 992, 14, 740, 8, 1224, 18, 1238, 8, 1224, 63, 354, 430, 355, 1202, 63, 2301, 63, 1247, 275, 942, 221, 327, 869, 8250, 2763, 1561, 1202, 315, 314, 1817, 880, 12474, 355, 2763, 63, 475, 63, 698, 63, 354, 275, 1052, 221, 327, 23673, 2763, 1561, 370, 1561, 402, 1402, 1504, 355, 367, 1962, 315, 1817, 63, 1802, 26, 490, 3721, 63, 5983, 275, 942, 221, 327, 869, 8250, 5024, 12681, 12, 370, 506, 9080, 315, 282, 2018, 3721, 14, 490, 2402, 63, 1162, 275, 8773, 342, 221, 327, 869, 8250, 5024, 2633, 4066, 465, 283, 697, 63, 2301, 1370, 490, 2763, 63, 354, 275, 1962, 59, 16, 61, 490, 365, 63, 5690, 275, 2763, 63, 354, 315, 16109, 4951, 15115, 63, 354, 12, 1862, 12, 12681, 275, 291, 14, 7721, 63, 761, 63, 354, 8, 717, 2763, 63, 354, 12, 1202, 63, 2301, 63, 1247, 12, 365, 63, 5690, 9, 490, 2402, 63, 1162, 14, 873, 8, 1162, 9, 490, 3721, 63, 5983, 14, 2880, 8, 5983, 9, 4951, 1202, 63, 2301, 63, 1247, 14, 740, 8, 6796, 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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 ]
iandees/all-the-places
locations/spiders/sunloan.py
1
2377
# -*- coding: utf-8 -*- import scrapy import json import re from locations.items import GeojsonPointItem DAYS={ 'Monday':'Mo', 'Tuesday':'Tu', 'Wednesday':'We', 'Friday':'Fr', 'Thursday':'Th', 'Saturday':'Sa', 'Sunday':'Su', } class SunLoanSpider(scrapy.Spider): name = "sunloan" allowed_domains = ["sunloan.com"] start_urls = ( 'https://www.sunloan.com/locations/', ) download_delay = 0.5 def parse(self, response): urls = response.xpath('//div[@id="custom-locations-2"]//div[@class="location-box"]/div/p/strong/a/@href').extract() for url in urls: yield scrapy.Request(response.urljoin(url), callback=self.parse_store) def parse_store(self, response): try: data = response.xpath('//script[contains(text(),"latitude")]/text()').extract_first() data = json.loads(data) except TypeError: return except json.JSONDecodeError: data = data.replace('"hasMap": \r\n', '') data = json.loads(data) if not data: return properties = { 'lat' : float(data['geo']['latitude']), 'lon' : float(data['geo']['longitude']), 'website' : response.url, 'ref' : response.url, 'addr_full' : data['address']['streetAddress'], 'city' : data['address']['addressLocality'], 'state' : data['address']['addressRegion'], 'postcode' : data['address']['postalCode'], 'country' : 'US', 'name' : data['name'], } try: hours = data['openingHours'] if hours: properties['opening_hours'] = hours except: pass yield GeojsonPointItem(**properties) # yield GeojsonPointItem( # lat=float(data['geo']['latitude']), # lon=float(data['geo']['longitude']), # website=response.url, # ref=response.url, # #opening_hours=data['openingHours'], # addr_full=data['address']['streetAddress'], # city=data['address']['addressLocality'], # state=data['address']['addressRegion'], # postcode=data['address']['postalCode'], # country='US', # name=data['name'], # )
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 18918, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 9918, 14, 1744, 492, 8875, 1001, 3428, 2081, 199, 199, 25683, 3126, 272, 283, 6671, 2977, 5242, 3716, 297, 272, 283, 52, 10138, 2977, 5242, 30669, 297, 272, 283, 55, 379, 17775, 2977, 5242, 6004, 297, 272, 283, 22533, 2977, 5242, 13848, 297, 272, 283, 2719, 21050, 2977, 5242, 2719, 297, 272, 283, 22332, 300, 2977, 5242, 12226, 297, 272, 283, 51, 24759, 5242, 27032, 297, 199, 93, 199, 199, 533, 25625, 2041, 290, 25157, 8, 26442, 14, 25157, 304, 272, 536, 275, 298, 11846, 320, 290, 2, 272, 4370, 63, 9756, 275, 2097, 11846, 320, 290, 14, 957, 937, 272, 1343, 63, 3603, 275, 334, 267, 283, 2859, 921, 1544, 14, 11846, 320, 290, 14, 957, 15, 8022, 3678, 272, 776, 272, 5235, 63, 5814, 275, 378, 14, 21, 2378, 347, 2198, 8, 277, 12, 1177, 304, 267, 8187, 275, 1177, 14, 8006, 15079, 3015, 14251, 344, 628, 4229, 13, 8022, 13, 18, 937, 501, 3015, 14251, 533, 628, 1985, 13, 1977, 937, 15, 3015, 15, 80, 15, 9370, 15, 65, 15, 32, 6399, 1959, 5005, 342, 398, 367, 1166, 315, 8187, 26, 288, 1995, 18918, 14, 2017, 8, 1310, 14, 17755, 8, 633, 395, 3233, 29, 277, 14, 1122, 63, 1617, 9, 2378, 347, 2198, 63, 1617, 8, 277, 12, 1177, 304, 267, 862, 26, 288, 666, 275, 1177, 14, 8006, 15079, 1579, 59, 6134, 8, 505, 1062, 2, 13331, 11323, 15, 505, 342, 1959, 5005, 63, 2246, 342, 288, 666, 275, 2022, 14, 3640, 8, 576, 9, 267, 871, 3146, 26, 288, 372, 267, 871, 2022, 14, 6243, 12620, 26, 288, 666, 275, 666, 14, 1814, 14088, 1989, 2956, 582, 971, 82, 60, 78, 297, 4074, 288, 666, 275, 2022, 14, 3640, 8, 576, 9, 267, 340, 440, 666, 26, 288, 372, 398, 4382, 275, 469, 288, 283, 4452, 7, 520, 2069, 8, 576, 459, 6721, 2545, 13331, 3815, 288, 283, 5298, 7, 520, 2069, 8, 576, 459, 6721, 2545, 13803, 3815, 288, 283, 7360, 7, 520, 1177, 14, 633, 12, 288, 283, 1121, 7, 520, 1177, 14, 633, 12, 288, 283, 2697, 63, 2861, 7, 520, 666, 459, 1562, 2545, 20451, 1476, 995, 288, 283, 3690, 7, 520, 666, 459, 1562, 2545, 1562, 5339, 1209, 995, 288, 283, 929, 7, 520, 666, 459, 1562, 2545, 1562, 10708, 995, 288, 283, 1932, 600, 7, 520, 666, 459, 1562, 2545, 31580, 3034, 995, 288, 283, 6063, 7, 520, 283, 1668, 297, 288, 283, 354, 7, 520, 666, 459, 354, 995, 267, 789, 398, 862, 26, 288, 10857, 275, 666, 459, 21849, 30927, 418, 288, 340, 10857, 26, 355, 4382, 459, 21849, 63, 8419, 418, 275, 10857, 267, 871, 26, 288, 986, 398, 1995, 8875, 1001, 3428, 2081, 3682, 3282, 9, 398, 327, 1995, 8875, 1001, 3428, 2081, 8, 267, 327, 258, 8396, 29, 1609, 8, 576, 459, 6721, 2545, 13331, 3815, 267, 327, 258, 6132, 29, 1609, 8, 576, 459, 6721, 2545, 13803, 3815, 267, 327, 258, 10691, 29, 1310, 14, 633, 12, 267, 327, 258, 2984, 29, 1310, 14, 633, 12, 267, 327, 258, 327, 21849, 63, 8419, 29, 576, 459, 21849, 30927, 995, 267, 327, 258, 5552, 63, 2861, 29, 576, 459, 1562, 2545, 20451, 1476, 995, 267, 327, 258, 14492, 29, 576, 459, 1562, 2545, 1562, 5339, 1209, 995, 267, 327, 258, 1174, 29, 576, 459, 1562, 2545, 1562, 10708, 995, 267, 327, 258, 2963, 600, 29, 576, 459, 1562, 2545, 31580, 3034, 995, 267, 327, 258, 9023, 534, 1668, 297, 267, 327, 258, 536, 29, 576, 459, 354, 995, 267, 327, 776, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 18918, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 9918, 14, 1744, 492, 8875, 1001, 3428, 2081, 199, 199, 25683, 3126, 272, 283, 6671, 2977, 5242, 3716, 297, 272, 283, 52, 10138, 2977, 5242, 30669, 297, 272, 283, 55, 379, 17775, 2977, 5242, 6004, 297, 272, 283, 22533, 2977, 5242, 13848, 297, 272, 283, 2719, 21050, 2977, 5242, 2719, 297, 272, 283, 22332, 300, 2977, 5242, 12226, 297, 272, 283, 51, 24759, 5242, 27032, 297, 199, 93, 199, 199, 533, 25625, 2041, 290, 25157, 8, 26442, 14, 25157, 304, 272, 536, 275, 298, 11846, 320, 290, 2, 272, 4370, 63, 9756, 275, 2097, 11846, 320, 290, 14, 957, 937, 272, 1343, 63, 3603, 275, 334, 267, 283, 2859, 921, 1544, 14, 11846, 320, 290, 14, 957, 15, 8022, 3678, 272, 776, 272, 5235, 63, 5814, 275, 378, 14, 21, 2378, 347, 2198, 8, 277, 12, 1177, 304, 267, 8187, 275, 1177, 14, 8006, 15079, 3015, 14251, 344, 628, 4229, 13, 8022, 13, 18, 937, 501, 3015, 14251, 533, 628, 1985, 13, 1977, 937, 15, 3015, 15, 80, 15, 9370, 15, 65, 15, 32, 6399, 1959, 5005, 342, 398, 367, 1166, 315, 8187, 26, 288, 1995, 18918, 14, 2017, 8, 1310, 14, 17755, 8, 633, 395, 3233, 29, 277, 14, 1122, 63, 1617, 9, 2378, 347, 2198, 63, 1617, 8, 277, 12, 1177, 304, 267, 862, 26, 288, 666, 275, 1177, 14, 8006, 15079, 1579, 59, 6134, 8, 505, 1062, 2, 13331, 11323, 15, 505, 342, 1959, 5005, 63, 2246, 342, 288, 666, 275, 2022, 14, 3640, 8, 576, 9, 267, 871, 3146, 26, 288, 372, 267, 871, 2022, 14, 6243, 12620, 26, 288, 666, 275, 666, 14, 1814, 14088, 1989, 2956, 582, 971, 82, 60, 78, 297, 4074, 288, 666, 275, 2022, 14, 3640, 8, 576, 9, 267, 340, 440, 666, 26, 288, 372, 398, 4382, 275, 469, 288, 283, 4452, 7, 520, 2069, 8, 576, 459, 6721, 2545, 13331, 3815, 288, 283, 5298, 7, 520, 2069, 8, 576, 459, 6721, 2545, 13803, 3815, 288, 283, 7360, 7, 520, 1177, 14, 633, 12, 288, 283, 1121, 7, 520, 1177, 14, 633, 12, 288, 283, 2697, 63, 2861, 7, 520, 666, 459, 1562, 2545, 20451, 1476, 995, 288, 283, 3690, 7, 520, 666, 459, 1562, 2545, 1562, 5339, 1209, 995, 288, 283, 929, 7, 520, 666, 459, 1562, 2545, 1562, 10708, 995, 288, 283, 1932, 600, 7, 520, 666, 459, 1562, 2545, 31580, 3034, 995, 288, 283, 6063, 7, 520, 283, 1668, 297, 288, 283, 354, 7, 520, 666, 459, 354, 995, 267, 789, 398, 862, 26, 288, 10857, 275, 666, 459, 21849, 30927, 418, 288, 340, 10857, 26, 355, 4382, 459, 21849, 63, 8419, 418, 275, 10857, 267, 871, 26, 288, 986, 398, 1995, 8875, 1001, 3428, 2081, 3682, 3282, 9, 398, 327, 1995, 8875, 1001, 3428, 2081, 8, 267, 327, 258, 8396, 29, 1609, 8, 576, 459, 6721, 2545, 13331, 3815, 267, 327, 258, 6132, 29, 1609, 8, 576, 459, 6721, 2545, 13803, 3815, 267, 327, 258, 10691, 29, 1310, 14, 633, 12, 267, 327, 258, 2984, 29, 1310, 14, 633, 12, 267, 327, 258, 327, 21849, 63, 8419, 29, 576, 459, 21849, 30927, 995, 267, 327, 258, 5552, 63, 2861, 29, 576, 459, 1562, 2545, 20451, 1476, 995, 267, 327, 258, 14492, 29, 576, 459, 1562, 2545, 1562, 5339, 1209, 995, 267, 327, 258, 1174, 29, 576, 459, 1562, 2545, 1562, 10708, 995, 267, 327, 258, 2963, 600, 29, 576, 459, 1562, 2545, 31580, 3034, 995, 267, 327, 258, 9023, 534, 1668, 297, 267, 327, 258, 536, 29, 576, 459, 354, 995, 267, 327, 776, 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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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 ]
zsdonghao/tensorlayer
setup.py
1
5906
#!/usr/bin/env python import codecs import os import sys os.environ['TENSORLAYER_PACKAGE_BUILDING'] = 'True' try: from setuptools import find_packages, setup, Extension from setuptools.command.build_ext import build_ext except ImportError: from distutils.core import ( setup, find_packages ) from tensorlayer import ( __contact_emails__, __contact_names__, __description__, __download_url__, __homepage__, __keywords__, __license__, __package_name__, __repository_url__, __version__ ) # =================== Reading Readme file as TXT files =================== if os.path.exists('README.rst'): # codec is used for consistent encoding long_description = codecs.open( os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.rst'), 'r', 'utf-8' ).read() else: long_description = 'See ' + __homepage__ # ======================= Reading Requirements files as TXT files ======================= def req_file(filename, folder="requirements"): with open(os.path.join(folder, filename)) as f: content = f.readlines() # you may also want to remove whitespace characters # Example: `\n` at the end of each line return [x.strip() for x in content] # ======================= Defining the requirements var ======================= install_requires = req_file("requirements.txt") extras_require = { # User packages 'tf_cpu': req_file("requirements_tf_cpu.txt"), 'tf_gpu': req_file("requirements_tf_gpu.txt"), 'extra': req_file("requirements_extra.txt"), # Contrib Packages 'contrib_loggers': req_file("requirements_contrib_loggers.txt"), # Dev Packages 'test': req_file("requirements_test.txt"), 'dev': req_file("requirements_dev.txt"), 'doc': req_file("requirements_doc.txt"), 'db': req_file("requirements_db.txt"), } extras_require['all'] = sum([extras_require.get(key) for key in ['extra', 'contrib_loggers']], list()) extras_require['all_cpu'] = sum([extras_require.get(key) for key in ['all', 'tf_cpu']], list()) extras_require['all_gpu'] = sum([extras_require.get(key) for key in ['all', 'tf_gpu']], list()) extras_require['all_dev'] = sum([extras_require.get(key) for key in ['all', 'db', 'dev', 'doc', 'test']], list()) extras_require['all_cpu_dev'] = sum([extras_require.get(key) for key in ['all_dev', 'tf_cpu']], list()) extras_require['all_gpu_dev'] = sum([extras_require.get(key) for key in ['all_dev', 'tf_gpu']], list()) cmdclass = dict() ext_modules = [] # Readthedocs requires TF 1.5.0 to build properly if 'READTHEDOCS' in os.environ: ext_modules = [ Extension('install_requirements_for_rtd', []), ] class custom_build_ext(build_ext): def build_extensions(self): os.system('./scripts/install-requirements-for-rtd.sh %s' % os.path.dirname(sys.executable)) cmdclass = {'build_ext': custom_build_ext} # ======================= Define the package setup ======================= setup( name=__package_name__, # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html version=__version__, description=__description__, long_description=long_description, # The project's main homepage. url=__repository_url__, download_url=__download_url__, # Author details author=__contact_names__, author_email=__contact_emails__, # maintainer Details maintainer=__contact_names__, maintainer_email=__contact_emails__, # The licence under which the project is released license=__license__, classifiers=[ # How mature is this project? Common values are # 1 - Planning # 2 - Pre-Alpha # 3 - Alpha # 4 - Beta # 5 - Production/Stable # 6 - Mature # 7 - Inactive 'Development Status :: 5 - Production/Stable', # Indicate who your project is intended for 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'Intended Audience :: Information Technology', # Indicate what your project relates to 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Image Recognition', 'Topic :: Scientific/Engineering :: Artificial Intelligence', 'Topic :: Software Development :: Libraries', 'Topic :: Utilities', # Pick your license as you wish (should match "license" above) 'License :: OSI Approved :: Apache Software License', # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', # Additionnal Settings 'Environment :: Console', 'Natural Language :: English', 'Operating System :: OS Independent', ], keywords=__keywords__, packages=find_packages(), # List run-time dependencies here. These will be installed by pip when # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html install_requires=install_requires, cmdclass=cmdclass, # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax, # $ pip install -e .[test] extras_require=extras_require, ext_modules=ext_modules, scripts=[ 'tl', ], )
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 6010, 199, 646, 747, 199, 646, 984, 199, 199, 736, 14, 2314, 459, 52, 17850, 24167, 63, 19265, 63, 8248, 1206, 418, 275, 283, 549, 7, 421, 199, 893, 26, 272, 687, 9116, 492, 2342, 63, 5154, 12, 3272, 12, 13282, 272, 687, 9116, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 199, 199, 2590, 3545, 26, 272, 687, 7065, 14, 1018, 492, 334, 267, 3272, 12, 267, 2342, 63, 5154, 272, 776, 421, 199, 504, 2345, 1897, 492, 334, 272, 636, 7811, 63, 14170, 3108, 272, 636, 7811, 63, 1247, 3108, 272, 636, 1802, 3108, 272, 636, 4249, 63, 633, 3108, 272, 636, 25539, 3108, 272, 636, 7511, 3108, 272, 636, 1682, 3108, 272, 636, 2491, 63, 354, 3108, 272, 636, 8421, 63, 633, 3108, 272, 636, 1023, 363, 199, 9, 421, 199, 3, 16248, 389, 799, 5384, 5574, 278, 570, 465, 377, 18926, 1584, 16248, 389, 199, 199, 692, 747, 14, 515, 14, 2444, 360, 18195, 14, 8332, 735, 272, 327, 9076, 365, 1202, 367, 12137, 2644, 272, 1846, 63, 1802, 275, 6010, 14, 1490, 8, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 283, 18195, 14, 8332, 659, 267, 283, 82, 297, 283, 1624, 13, 24, 7, 272, 7092, 739, 342, 199, 199, 2836, 26, 272, 1846, 63, 1802, 275, 283, 9295, 283, 435, 636, 25539, 363, 199, 199, 3, 16248, 23476, 799, 5384, 18513, 1470, 1584, 465, 377, 18926, 1584, 16248, 23476, 421, 199, 318, 2648, 63, 493, 8, 1501, 12, 4922, 628, 7538, 2349, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 3741, 12, 1788, 430, 465, 289, 26, 267, 1564, 275, 289, 14, 9684, 342, 272, 327, 1265, 1443, 2597, 2934, 370, 2813, 8139, 4110, 272, 327, 5679, 26, 29520, 78, 64, 737, 314, 1284, 402, 1924, 1004, 272, 372, 359, 88, 14, 1913, 342, 367, 671, 315, 1564, 61, 199, 199, 3, 16248, 23476, 1487, 2408, 316, 314, 9760, 2729, 16248, 23476, 421, 199, 3174, 63, 6537, 275, 2648, 63, 493, 480, 7538, 14, 2424, 531, 199, 199, 9975, 63, 4365, 275, 469, 272, 327, 2876, 6117, 272, 283, 3249, 63, 3541, 356, 2648, 63, 493, 480, 7538, 63, 3249, 63, 3541, 14, 2424, 1288, 272, 283, 3249, 63, 6477, 356, 2648, 63, 493, 480, 7538, 63, 3249, 63, 6477, 14, 2424, 1288, 272, 283, 2911, 356, 2648, 63, 493, 480, 7538, 63, 2911, 14, 2424, 1288, 339, 327, 13370, 9954, 7441, 272, 283, 2828, 63, 22771, 356, 2648, 63, 493, 480, 7538, 63, 2828, 63, 22771, 14, 2424, 1288, 339, 327, 29314, 9954, 7441, 272, 283, 396, 356, 2648, 63, 493, 480, 7538, 63, 396, 14, 2424, 1288, 272, 283, 2374, 356, 2648, 63, 493, 480, 7538, 63, 2374, 14, 2424, 1288, 272, 283, 1301, 356, 2648, 63, 493, 480, 7538, 63, 1301, 14, 2424, 1288, 272, 283, 697, 356, 2648, 63, 493, 480, 7538, 63, 697, 14, 2424, 1288, 199, 93, 199, 199, 9975, 63, 4365, 459, 452, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 2911, 297, 283, 2828, 63, 22771, 2157, 769, 1012, 199, 199, 9975, 63, 4365, 459, 452, 63, 3541, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 297, 283, 3249, 63, 3541, 2157, 769, 1012, 199, 9975, 63, 4365, 459, 452, 63, 6477, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 297, 283, 3249, 63, 6477, 2157, 769, 1012, 199, 199, 9975, 63, 4365, 459, 452, 63, 2374, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 297, 283, 697, 297, 283, 2374, 297, 283, 1301, 297, 283, 396, 2157, 769, 1012, 199, 9975, 63, 4365, 459, 452, 63, 3541, 63, 2374, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 63, 2374, 297, 283, 3249, 63, 3541, 2157, 769, 1012, 199, 9975, 63, 4365, 459, 452, 63, 6477, 63, 2374, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 63, 2374, 297, 283, 3249, 63, 6477, 2157, 769, 1012, 421, 199, 1760, 533, 275, 1211, 342, 199, 832, 63, 3112, 275, 942, 421, 199, 3, 5574, 22618, 5074, 21721, 413, 14, 21, 14, 16, 370, 1900, 7684, 199, 692, 283, 5670, 2080, 1149, 47, 3298, 7, 315, 747, 14, 2314, 26, 272, 1599, 63, 3112, 275, 359, 267, 13282, 360, 3174, 63, 7538, 63, 509, 63, 29048, 297, 14431, 272, 1622, 339, 1021, 3537, 63, 1506, 63, 832, 8, 1506, 63, 832, 304, 267, 347, 1900, 63, 5359, 8, 277, 304, 288, 747, 14, 2253, 17371, 6429, 15, 3174, 13, 7538, 13, 509, 13, 29048, 14, 609, 450, 83, 7, 450, 1993, 747, 14, 515, 14, 3475, 8, 1274, 14, 5904, 430, 339, 2088, 533, 275, 791, 1506, 63, 832, 356, 3537, 63, 1506, 63, 832, 93, 421, 199, 3, 16248, 23476, 13930, 314, 2559, 3272, 16248, 23476, 421, 199, 2758, 8, 272, 536, 18971, 2491, 63, 354, 3108, 339, 327, 5444, 1356, 1077, 1013, 590, 543, 13663, 14162, 14, 221, 2104, 282, 16582, 641, 2849, 13, 83, 567, 4477, 272, 327, 314, 1015, 9371, 3272, 14, 647, 436, 314, 2199, 1233, 12, 1937, 272, 327, 4178, 921, 27796, 14, 1548, 14, 1308, 15, 287, 15, 7410, 15, 4780, 63, 1365, 63, 1023, 14, 1360, 272, 1015, 18971, 1023, 3108, 339, 1369, 18971, 1802, 3108, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 339, 327, 710, 2199, 1159, 2446, 26586, 14, 272, 1166, 18971, 8421, 63, 633, 3108, 272, 5235, 63, 633, 18971, 4249, 63, 633, 3108, 339, 327, 6529, 2436, 272, 4132, 18971, 7811, 63, 1247, 3108, 272, 4132, 63, 2123, 18971, 7811, 63, 14170, 3108, 339, 327, 11075, 281, 15621, 272, 11075, 281, 18971, 7811, 63, 1247, 3108, 272, 11075, 281, 63, 2123, 18971, 7811, 63, 14170, 3108, 339, 327, 710, 23854, 4894, 1334, 1314, 314, 2199, 365, 14286, 272 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 6010, 199, 646, 747, 199, 646, 984, 199, 199, 736, 14, 2314, 459, 52, 17850, 24167, 63, 19265, 63, 8248, 1206, 418, 275, 283, 549, 7, 421, 199, 893, 26, 272, 687, 9116, 492, 2342, 63, 5154, 12, 3272, 12, 13282, 272, 687, 9116, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 199, 199, 2590, 3545, 26, 272, 687, 7065, 14, 1018, 492, 334, 267, 3272, 12, 267, 2342, 63, 5154, 272, 776, 421, 199, 504, 2345, 1897, 492, 334, 272, 636, 7811, 63, 14170, 3108, 272, 636, 7811, 63, 1247, 3108, 272, 636, 1802, 3108, 272, 636, 4249, 63, 633, 3108, 272, 636, 25539, 3108, 272, 636, 7511, 3108, 272, 636, 1682, 3108, 272, 636, 2491, 63, 354, 3108, 272, 636, 8421, 63, 633, 3108, 272, 636, 1023, 363, 199, 9, 421, 199, 3, 16248, 389, 799, 5384, 5574, 278, 570, 465, 377, 18926, 1584, 16248, 389, 199, 199, 692, 747, 14, 515, 14, 2444, 360, 18195, 14, 8332, 735, 272, 327, 9076, 365, 1202, 367, 12137, 2644, 272, 1846, 63, 1802, 275, 6010, 14, 1490, 8, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 283, 18195, 14, 8332, 659, 267, 283, 82, 297, 283, 1624, 13, 24, 7, 272, 7092, 739, 342, 199, 199, 2836, 26, 272, 1846, 63, 1802, 275, 283, 9295, 283, 435, 636, 25539, 363, 199, 199, 3, 16248, 23476, 799, 5384, 18513, 1470, 1584, 465, 377, 18926, 1584, 16248, 23476, 421, 199, 318, 2648, 63, 493, 8, 1501, 12, 4922, 628, 7538, 2349, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 3741, 12, 1788, 430, 465, 289, 26, 267, 1564, 275, 289, 14, 9684, 342, 272, 327, 1265, 1443, 2597, 2934, 370, 2813, 8139, 4110, 272, 327, 5679, 26, 29520, 78, 64, 737, 314, 1284, 402, 1924, 1004, 272, 372, 359, 88, 14, 1913, 342, 367, 671, 315, 1564, 61, 199, 199, 3, 16248, 23476, 1487, 2408, 316, 314, 9760, 2729, 16248, 23476, 421, 199, 3174, 63, 6537, 275, 2648, 63, 493, 480, 7538, 14, 2424, 531, 199, 199, 9975, 63, 4365, 275, 469, 272, 327, 2876, 6117, 272, 283, 3249, 63, 3541, 356, 2648, 63, 493, 480, 7538, 63, 3249, 63, 3541, 14, 2424, 1288, 272, 283, 3249, 63, 6477, 356, 2648, 63, 493, 480, 7538, 63, 3249, 63, 6477, 14, 2424, 1288, 272, 283, 2911, 356, 2648, 63, 493, 480, 7538, 63, 2911, 14, 2424, 1288, 339, 327, 13370, 9954, 7441, 272, 283, 2828, 63, 22771, 356, 2648, 63, 493, 480, 7538, 63, 2828, 63, 22771, 14, 2424, 1288, 339, 327, 29314, 9954, 7441, 272, 283, 396, 356, 2648, 63, 493, 480, 7538, 63, 396, 14, 2424, 1288, 272, 283, 2374, 356, 2648, 63, 493, 480, 7538, 63, 2374, 14, 2424, 1288, 272, 283, 1301, 356, 2648, 63, 493, 480, 7538, 63, 1301, 14, 2424, 1288, 272, 283, 697, 356, 2648, 63, 493, 480, 7538, 63, 697, 14, 2424, 1288, 199, 93, 199, 199, 9975, 63, 4365, 459, 452, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 2911, 297, 283, 2828, 63, 22771, 2157, 769, 1012, 199, 199, 9975, 63, 4365, 459, 452, 63, 3541, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 297, 283, 3249, 63, 3541, 2157, 769, 1012, 199, 9975, 63, 4365, 459, 452, 63, 6477, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 297, 283, 3249, 63, 6477, 2157, 769, 1012, 199, 199, 9975, 63, 4365, 459, 452, 63, 2374, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 297, 283, 697, 297, 283, 2374, 297, 283, 1301, 297, 283, 396, 2157, 769, 1012, 199, 9975, 63, 4365, 459, 452, 63, 3541, 63, 2374, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 63, 2374, 297, 283, 3249, 63, 3541, 2157, 769, 1012, 199, 9975, 63, 4365, 459, 452, 63, 6477, 63, 2374, 418, 275, 3089, 779, 9975, 63, 4365, 14, 362, 8, 498, 9, 367, 790, 315, 788, 452, 63, 2374, 297, 283, 3249, 63, 6477, 2157, 769, 1012, 421, 199, 1760, 533, 275, 1211, 342, 199, 832, 63, 3112, 275, 942, 421, 199, 3, 5574, 22618, 5074, 21721, 413, 14, 21, 14, 16, 370, 1900, 7684, 199, 692, 283, 5670, 2080, 1149, 47, 3298, 7, 315, 747, 14, 2314, 26, 272, 1599, 63, 3112, 275, 359, 267, 13282, 360, 3174, 63, 7538, 63, 509, 63, 29048, 297, 14431, 272, 1622, 339, 1021, 3537, 63, 1506, 63, 832, 8, 1506, 63, 832, 304, 267, 347, 1900, 63, 5359, 8, 277, 304, 288, 747, 14, 2253, 17371, 6429, 15, 3174, 13, 7538, 13, 509, 13, 29048, 14, 609, 450, 83, 7, 450, 1993, 747, 14, 515, 14, 3475, 8, 1274, 14, 5904, 430, 339, 2088, 533, 275, 791, 1506, 63, 832, 356, 3537, 63, 1506, 63, 832, 93, 421, 199, 3, 16248, 23476, 13930, 314, 2559, 3272, 16248, 23476, 421, 199, 2758, 8, 272, 536, 18971, 2491, 63, 354, 3108, 339, 327, 5444, 1356, 1077, 1013, 590, 543, 13663, 14162, 14, 221, 2104, 282, 16582, 641, 2849, 13, 83, 567, 4477, 272, 327, 314, 1015, 9371, 3272, 14, 647, 436, 314, 2199, 1233, 12, 1937, 272, 327, 4178, 921, 27796, 14, 1548, 14, 1308, 15, 287, 15, 7410, 15, 4780, 63, 1365, 63, 1023, 14, 1360, 272, 1015, 18971, 1023, 3108, 339, 1369, 18971, 1802, 3108, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 339, 327, 710, 2199, 1159, 2446, 26586, 14, 272, 1166, 18971, 8421, 63, 633, 3108, 272, 5235, 63, 633, 18971, 4249, 63, 633, 3108, 339, 327, 6529, 2436, 272, 4132, 18971, 7811, 63, 1247, 3108, 272, 4132, 63, 2123, 18971, 7811, 63, 14170, 3108, 339, 327, 11075, 281, 15621, 272, 11075, 281, 18971, 7811, 63, 1247, 3108, 272, 11075, 281, 63, 2123, 18971, 7811, 63, 14170, 3108, 339, 327, 710, 23854, 4894, 1334, 1314, 314, 2199, 365, 14286, 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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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 ]
kidmaple/CoolWall
user/python/Lib/test/re_tests.py
6
29675
#!/usr/bin/env python # -*- mode: python -*- # Re test suite and benchmark suite v1.5 # The 3 possible outcomes for each pattern [SUCCEED, FAIL, SYNTAX_ERROR] = range(3) # Benchmark suite (needs expansion) # # The benchmark suite does not test correctness, just speed. The # first element of each tuple is the regex pattern; the second is a # string to match it against. The benchmarking code will embed the # second string inside several sizes of padding, to test how regex # matching performs on large strings. benchmarks = [ # test common prefix ('Python|Perl', 'Perl'), # Alternation ('(Python|Perl)', 'Perl'), # Grouped alternation ('Python|Perl|Tcl', 'Perl'), # Alternation ('(Python|Perl|Tcl)', 'Perl'), # Grouped alternation ('(Python)\\1', 'PythonPython'), # Backreference ('([0a-z][a-z0-9]*,)+', 'a5,b7,c9,'), # Disable the fastmap optimization ('([a-z][a-z0-9]*,)+', 'a5,b7,c9,'), # A few sets ('Python', 'Python'), # Simple text literal ('.*Python', 'Python'), # Bad text literal ('.*Python.*', 'Python'), # Worse text literal ('.*(Python)', 'Python'), # Bad text literal with grouping ] # Test suite (for verifying correctness) # # The test suite is a list of 5- or 3-tuples. The 5 parts of a # complete tuple are: # element 0: a string containing the pattern # 1: the string to match against the pattern # 2: the expected result (SUCCEED, FAIL, SYNTAX_ERROR) # 3: a string that will be eval()'ed to produce a test string. # This is an arbitrary Python expression; the available # variables are "found" (the whole match), and "g1", "g2", ... # up to "g99" contain the contents of each group, or the # string 'None' if the group wasn't given a value, or the # string 'Error' if the group index was out of range; # also "groups", the return value of m.group() (a tuple). # 4: The expected result of evaluating the expression. # If the two don't match, an error is reported. # # If the regex isn't expected to work, the latter two elements can be omitted. tests = [ # Test ?P< and ?P= extensions ('(?P<foo_123', '', SYNTAX_ERROR), # Unterminated group identifier ('(?P<1>a)', '', SYNTAX_ERROR), # Begins with a digit ('(?P<!>a)', '', SYNTAX_ERROR), # Begins with an illegal char ('(?P<foo!>a)', '', SYNTAX_ERROR), # Begins with an illegal char # Same tests, for the ?P= form ('(?P<foo_123>a)(?P=foo_123', 'aa', SYNTAX_ERROR), ('(?P<foo_123>a)(?P=1)', 'aa', SYNTAX_ERROR), ('(?P<foo_123>a)(?P=!)', 'aa', SYNTAX_ERROR), ('(?P<foo_123>a)(?P=foo_124', 'aa', SYNTAX_ERROR), # Backref to undefined group ('(?P<foo_123>a)', 'a', SUCCEED, 'g1', 'a'), ('(?P<foo_123>a)(?P=foo_123)', 'aa', SUCCEED, 'g1', 'a'), # Test octal escapes ('\\1', 'a', SYNTAX_ERROR), # Backreference ('[\\1]', '\1', SUCCEED, 'found', '\1'), # Character ('\\09', chr(0) + '9', SUCCEED, 'found', chr(0) + '9'), ('\\141', 'a', SUCCEED, 'found', 'a'), ('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', SUCCEED, 'found+"-"+g11', 'abcdefghijklk9-k'), # Test \0 is handled everywhere (r'\0', '\0', SUCCEED, 'found', '\0'), (r'[\0a]', '\0', SUCCEED, 'found', '\0'), (r'[a\0]', '\0', SUCCEED, 'found', '\0'), (r'[^a\0]', '\0', FAIL), # Test various letter escapes (r'\a[\b]\f\n\r\t\v', '\a\b\f\n\r\t\v', SUCCEED, 'found', '\a\b\f\n\r\t\v'), (r'[\a][\b][\f][\n][\r][\t][\v]', '\a\b\f\n\r\t\v', SUCCEED, 'found', '\a\b\f\n\r\t\v'), # NOTE: not an error under PCRE/PRE: # (r'\u', '', SYNTAX_ERROR), # A Perl escape (r'\c\e\g\h\i\j\k\m\o\p\q\y\z', 'ceghijkmopqyz', SUCCEED, 'found', 'ceghijkmopqyz'), (r'\xff', '\377', SUCCEED, 'found', chr(255)), # new \x semantics (r'\x00ffffffffffffff', '\377', FAIL, 'found', chr(255)), (r'\x00f', '\017', FAIL, 'found', chr(15)), (r'\x00fe', '\376', FAIL, 'found', chr(254)), # (r'\x00ffffffffffffff', '\377', SUCCEED, 'found', chr(255)), # (r'\x00f', '\017', SUCCEED, 'found', chr(15)), # (r'\x00fe', '\376', SUCCEED, 'found', chr(254)), (r"^\w+=(\\[\000-\277]|[^\n\\])*", "SRC=eval.c g.c blah blah blah \\\\\n\tapes.c", SUCCEED, 'found', "SRC=eval.c g.c blah blah blah \\\\"), # Test that . only matches \n in DOTALL mode ('a.b', 'acb', SUCCEED, 'found', 'acb'), ('a.b', 'a\nb', FAIL), ('a.*b', 'acc\nccb', FAIL), ('a.{4,5}b', 'acc\nccb', FAIL), ('a.b', 'a\rb', SUCCEED, 'found', 'a\rb'), ('a.b(?s)', 'a\nb', SUCCEED, 'found', 'a\nb'), ('a.*(?s)b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'), ('(?s)a.{4,5}b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'), ('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'), (')', '', SYNTAX_ERROR), # Unmatched right bracket ('', '', SUCCEED, 'found', ''), # Empty pattern ('abc', 'abc', SUCCEED, 'found', 'abc'), ('abc', 'xbc', FAIL), ('abc', 'axc', FAIL), ('abc', 'abx', FAIL), ('abc', 'xabcy', SUCCEED, 'found', 'abc'), ('abc', 'ababc', SUCCEED, 'found', 'abc'), ('ab*c', 'abc', SUCCEED, 'found', 'abc'), ('ab*bc', 'abc', SUCCEED, 'found', 'abc'), ('ab*bc', 'abbc', SUCCEED, 'found', 'abbc'), ('ab*bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab+bc', 'abbc', SUCCEED, 'found', 'abbc'), ('ab+bc', 'abc', FAIL), ('ab+bc', 'abq', FAIL), ('ab+bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab?bc', 'abbc', SUCCEED, 'found', 'abbc'), ('ab?bc', 'abc', SUCCEED, 'found', 'abc'), ('ab?bc', 'abbbbc', FAIL), ('ab?c', 'abc', SUCCEED, 'found', 'abc'), ('^abc$', 'abc', SUCCEED, 'found', 'abc'), ('^abc$', 'abcc', FAIL), ('^abc', 'abcc', SUCCEED, 'found', 'abc'), ('^abc$', 'aabc', FAIL), ('abc$', 'aabc', SUCCEED, 'found', 'abc'), ('^', 'abc', SUCCEED, 'found+"-"', '-'), ('$', 'abc', SUCCEED, 'found+"-"', '-'), ('a.c', 'abc', SUCCEED, 'found', 'abc'), ('a.c', 'axc', SUCCEED, 'found', 'axc'), ('a.*c', 'axyzc', SUCCEED, 'found', 'axyzc'), ('a.*c', 'axyzd', FAIL), ('a[bc]d', 'abc', FAIL), ('a[bc]d', 'abd', SUCCEED, 'found', 'abd'), ('a[b-d]e', 'abd', FAIL), ('a[b-d]e', 'ace', SUCCEED, 'found', 'ace'), ('a[b-d]', 'aac', SUCCEED, 'found', 'ac'), ('a[-b]', 'a-', SUCCEED, 'found', 'a-'), ('a[\\-b]', 'a-', SUCCEED, 'found', 'a-'), # NOTE: not an error under PCRE/PRE: # ('a[b-]', 'a-', SYNTAX_ERROR), ('a[]b', '-', SYNTAX_ERROR), ('a[', '-', SYNTAX_ERROR), ('a\\', '-', SYNTAX_ERROR), ('abc)', '-', SYNTAX_ERROR), ('(abc', '-', SYNTAX_ERROR), ('a]', 'a]', SUCCEED, 'found', 'a]'), ('a[]]b', 'a]b', SUCCEED, 'found', 'a]b'), ('a[\]]b', 'a]b', SUCCEED, 'found', 'a]b'), ('a[^bc]d', 'aed', SUCCEED, 'found', 'aed'), ('a[^bc]d', 'abd', FAIL), ('a[^-b]c', 'adc', SUCCEED, 'found', 'adc'), ('a[^-b]c', 'a-c', FAIL), ('a[^]b]c', 'a]c', FAIL), ('a[^]b]c', 'adc', SUCCEED, 'found', 'adc'), ('\\ba\\b', 'a-', SUCCEED, '"-"', '-'), ('\\ba\\b', '-a', SUCCEED, '"-"', '-'), ('\\ba\\b', '-a-', SUCCEED, '"-"', '-'), ('\\by\\b', 'xy', FAIL), ('\\by\\b', 'yz', FAIL), ('\\by\\b', 'xyz', FAIL), ('x\\b', 'xyz', FAIL), ('x\\B', 'xyz', SUCCEED, '"-"', '-'), ('\\Bz', 'xyz', SUCCEED, '"-"', '-'), ('z\\B', 'xyz', FAIL), ('\\Bx', 'xyz', FAIL), ('\\Ba\\B', 'a-', FAIL, '"-"', '-'), ('\\Ba\\B', '-a', FAIL, '"-"', '-'), ('\\Ba\\B', '-a-', FAIL, '"-"', '-'), ('\\By\\B', 'xy', FAIL), ('\\By\\B', 'yz', FAIL), ('\\By\\b', 'xy', SUCCEED, '"-"', '-'), ('\\by\\B', 'yz', SUCCEED, '"-"', '-'), ('\\By\\B', 'xyz', SUCCEED, '"-"', '-'), ('ab|cd', 'abc', SUCCEED, 'found', 'ab'), ('ab|cd', 'abcd', SUCCEED, 'found', 'ab'), ('()ef', 'def', SUCCEED, 'found+"-"+g1', 'ef-'), ('$b', 'b', FAIL), ('a\\(b', 'a(b', SUCCEED, 'found+"-"+g1', 'a(b-Error'), ('a\\(*b', 'ab', SUCCEED, 'found', 'ab'), ('a\\(*b', 'a((b', SUCCEED, 'found', 'a((b'), ('a\\\\b', 'a\\b', SUCCEED, 'found', 'a\\b'), ('((a))', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'a-a-a'), ('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'), ('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'), ('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), ('(a+|b)+', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), ('(a+|b)?', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'), (')(', '-', SYNTAX_ERROR), ('[^ab]*', 'cde', SUCCEED, 'found', 'cde'), ('abc', '', FAIL), ('a*', '', SUCCEED, 'found', ''), ('a|b|c|d|e', 'e', SUCCEED, 'found', 'e'), ('(a|b|c|d|e)f', 'ef', SUCCEED, 'found+"-"+g1', 'ef-e'), ('abcd*efg', 'abcdefg', SUCCEED, 'found', 'abcdefg'), ('ab*', 'xabyabbbz', SUCCEED, 'found', 'ab'), ('ab*', 'xayabbbz', SUCCEED, 'found', 'a'), ('(ab|cd)e', 'abcde', SUCCEED, 'found+"-"+g1', 'cde-cd'), ('[abhgefdc]ij', 'hij', SUCCEED, 'found', 'hij'), ('^(ab|cd)e', 'abcde', FAIL, 'xg1y', 'xy'), ('(abc|)ef', 'abcdef', SUCCEED, 'found+"-"+g1', 'ef-'), ('(a|b)c*d', 'abcd', SUCCEED, 'found+"-"+g1', 'bcd-b'), ('(ab|ab*)bc', 'abc', SUCCEED, 'found+"-"+g1', 'abc-a'), ('a([bc]*)c*', 'abc', SUCCEED, 'found+"-"+g1', 'abc-bc'), ('a([bc]*)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), ('a([bc]+)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), ('a([bc]*)(c+d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'), ('a[bcd]*dcdcde', 'adcdcde', SUCCEED, 'found', 'adcdcde'), ('a[bcd]+dcdcde', 'adcdcde', FAIL), ('(ab|a)b*c', 'abc', SUCCEED, 'found+"-"+g1', 'abc-ab'), ('((a)(b)c)(d)', 'abcd', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'), ('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED, 'found', 'alpha'), ('^a(bc+|b[eh])g|.h$', 'abh', SUCCEED, 'found+"-"+g1', 'bh-None'), ('(bc+d$|ef*g.|h?i(j|k))', 'effgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), ('(bc+d$|ef*g.|h?i(j|k))', 'ij', SUCCEED, 'found+"-"+g1+"-"+g2', 'ij-ij-j'), ('(bc+d$|ef*g.|h?i(j|k))', 'effg', FAIL), ('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', FAIL), ('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), ('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'), ('multiple words of text', 'uh-uh', FAIL), ('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'), ('(.*)c(.*)', 'abcde', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'), ('\\((.*), (.*)\\)', '(a, b)', SUCCEED, 'g2+"-"+g1', 'b-a'), ('[k]', 'ab', FAIL), ('a[-]?c', 'ac', SUCCEED, 'found', 'ac'), ('(abc)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), ('([a-c]*)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), ('^(.+)?B', 'AB', SUCCEED, 'g1', 'A'), ('(a+).\\1$', 'aaaaa', SUCCEED, 'found+"-"+g1', 'aaaaa-aa'), ('^(a+).\\1$', 'aaaa', FAIL), ('(abc)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'), ('([a-c]+)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'), ('(a)\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'), ('(a+)\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'), ('(a+)+\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'), ('(a).+\\1', 'aba', SUCCEED, 'found+"-"+g1', 'aba-a'), ('(a)ba*\\1', 'aba', SUCCEED, 'found+"-"+g1', 'aba-a'), ('(aa|a)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'), ('(a|aa)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'), ('(a+)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'), ('([abc]*)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'), ('(a)(b)c|ab', 'ab', SUCCEED, 'found+"-"+g1+"-"+g2', 'ab-None-None'), ('(a)+x', 'aaax', SUCCEED, 'found+"-"+g1', 'aaax-a'), ('([ac])+x', 'aacx', SUCCEED, 'found+"-"+g1', 'aacx-c'), ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', SUCCEED, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/'), ('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', SUCCEED, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah'), ('([^N]*N)+', 'abNNxyzN', SUCCEED, 'found+"-"+g1', 'abNNxyzN-xyzN'), ('([^N]*N)+', 'abNNxyz', SUCCEED, 'found+"-"+g1', 'abNN-N'), ('([abc]*)x', 'abcx', SUCCEED, 'found+"-"+g1', 'abcx-abc'), ('([abc]*)x', 'abc', FAIL), ('([xyz]*)x', 'abcx', SUCCEED, 'found+"-"+g1', 'x-'), ('(a)+b|aac', 'aac', SUCCEED, 'found+"-"+g1', 'aac-None'), # Test symbolic groups ('(?P<i d>aaa)a', 'aaaa', SYNTAX_ERROR), ('(?P<id>aaa)a', 'aaaa', SUCCEED, 'found+"-"+id', 'aaaa-aaa'), ('(?P<id>aa)(?P=id)', 'aaaa', SUCCEED, 'found+"-"+id', 'aaaa-aa'), ('(?P<id>aa)(?P=xd)', 'aaaa', SYNTAX_ERROR), # Test octal escapes/memory references ('\\1', 'a', SYNTAX_ERROR), ('\\09', chr(0) + '9', SUCCEED, 'found', chr(0) + '9'), ('\\141', 'a', SUCCEED, 'found', 'a'), ('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', SUCCEED, 'found+"-"+g11', 'abcdefghijklk9-k'), # All tests from Perl ('abc', 'abc', SUCCEED, 'found', 'abc'), ('abc', 'xbc', FAIL), ('abc', 'axc', FAIL), ('abc', 'abx', FAIL), ('abc', 'xabcy', SUCCEED, 'found', 'abc'), ('abc', 'ababc', SUCCEED, 'found', 'abc'), ('ab*c', 'abc', SUCCEED, 'found', 'abc'), ('ab*bc', 'abc', SUCCEED, 'found', 'abc'), ('ab*bc', 'abbc', SUCCEED, 'found', 'abbc'), ('ab*bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab{0,}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab+bc', 'abbc', SUCCEED, 'found', 'abbc'), ('ab+bc', 'abc', FAIL), ('ab+bc', 'abq', FAIL), ('ab{1,}bc', 'abq', FAIL), ('ab+bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab{1,}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab{1,3}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab{3,4}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), ('ab{4,5}bc', 'abbbbc', FAIL), ('ab?bc', 'abbc', SUCCEED, 'found', 'abbc'), ('ab?bc', 'abc', SUCCEED, 'found', 'abc'), ('ab{0,1}bc', 'abc', SUCCEED, 'found', 'abc'), ('ab?bc', 'abbbbc', FAIL), ('ab?c', 'abc', SUCCEED, 'found', 'abc'), ('ab{0,1}c', 'abc', SUCCEED, 'found', 'abc'), ('^abc$', 'abc', SUCCEED, 'found', 'abc'), ('^abc$', 'abcc', FAIL), ('^abc', 'abcc', SUCCEED, 'found', 'abc'), ('^abc$', 'aabc', FAIL), ('abc$', 'aabc', SUCCEED, 'found', 'abc'), ('^', 'abc', SUCCEED, 'found', ''), ('$', 'abc', SUCCEED, 'found', ''), ('a.c', 'abc', SUCCEED, 'found', 'abc'), ('a.c', 'axc', SUCCEED, 'found', 'axc'), ('a.*c', 'axyzc', SUCCEED, 'found', 'axyzc'), ('a.*c', 'axyzd', FAIL), ('a[bc]d', 'abc', FAIL), ('a[bc]d', 'abd', SUCCEED, 'found', 'abd'), ('a[b-d]e', 'abd', FAIL), ('a[b-d]e', 'ace', SUCCEED, 'found', 'ace'), ('a[b-d]', 'aac', SUCCEED, 'found', 'ac'), ('a[-b]', 'a-', SUCCEED, 'found', 'a-'), ('a[b-]', 'a-', SUCCEED, 'found', 'a-'), ('a[b-a]', '-', SYNTAX_ERROR), ('a[]b', '-', SYNTAX_ERROR), ('a[', '-', SYNTAX_ERROR), ('a]', 'a]', SUCCEED, 'found', 'a]'), ('a[]]b', 'a]b', SUCCEED, 'found', 'a]b'), ('a[^bc]d', 'aed', SUCCEED, 'found', 'aed'), ('a[^bc]d', 'abd', FAIL), ('a[^-b]c', 'adc', SUCCEED, 'found', 'adc'), ('a[^-b]c', 'a-c', FAIL), ('a[^]b]c', 'a]c', FAIL), ('a[^]b]c', 'adc', SUCCEED, 'found', 'adc'), ('ab|cd', 'abc', SUCCEED, 'found', 'ab'), ('ab|cd', 'abcd', SUCCEED, 'found', 'ab'), ('()ef', 'def', SUCCEED, 'found+"-"+g1', 'ef-'), ('*a', '-', SYNTAX_ERROR), ('(*)b', '-', SYNTAX_ERROR), ('$b', 'b', FAIL), ('a\\', '-', SYNTAX_ERROR), ('a\\(b', 'a(b', SUCCEED, 'found+"-"+g1', 'a(b-Error'), ('a\\(*b', 'ab', SUCCEED, 'found', 'ab'), ('a\\(*b', 'a((b', SUCCEED, 'found', 'a((b'), ('a\\\\b', 'a\\b', SUCCEED, 'found', 'a\\b'), ('abc)', '-', SYNTAX_ERROR), ('(abc', '-', SYNTAX_ERROR), ('((a))', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'a-a-a'), ('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'), ('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'), ('a{1,}b{1,}c', 'aabbabc', SUCCEED, 'found', 'abc'), ('a**', '-', SYNTAX_ERROR), ('a.+?c', 'abcabc', SUCCEED, 'found', 'abc'), ('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), ('(a+|b){0,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), ('(a+|b)+', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), ('(a+|b){1,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), ('(a+|b)?', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'), ('(a+|b){0,1}', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'), (')(', '-', SYNTAX_ERROR), ('[^ab]*', 'cde', SUCCEED, 'found', 'cde'), ('abc', '', FAIL), ('a*', '', SUCCEED, 'found', ''), ('([abc])*d', 'abbbcd', SUCCEED, 'found+"-"+g1', 'abbbcd-c'), ('([abc])*bcd', 'abcd', SUCCEED, 'found+"-"+g1', 'abcd-a'), ('a|b|c|d|e', 'e', SUCCEED, 'found', 'e'), ('(a|b|c|d|e)f', 'ef', SUCCEED, 'found+"-"+g1', 'ef-e'), ('abcd*efg', 'abcdefg', SUCCEED, 'found', 'abcdefg'), ('ab*', 'xabyabbbz', SUCCEED, 'found', 'ab'), ('ab*', 'xayabbbz', SUCCEED, 'found', 'a'), ('(ab|cd)e', 'abcde', SUCCEED, 'found+"-"+g1', 'cde-cd'), ('[abhgefdc]ij', 'hij', SUCCEED, 'found', 'hij'), ('^(ab|cd)e', 'abcde', FAIL), ('(abc|)ef', 'abcdef', SUCCEED, 'found+"-"+g1', 'ef-'), ('(a|b)c*d', 'abcd', SUCCEED, 'found+"-"+g1', 'bcd-b'), ('(ab|ab*)bc', 'abc', SUCCEED, 'found+"-"+g1', 'abc-a'), ('a([bc]*)c*', 'abc', SUCCEED, 'found+"-"+g1', 'abc-bc'), ('a([bc]*)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), ('a([bc]+)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), ('a([bc]*)(c+d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'), ('a[bcd]*dcdcde', 'adcdcde', SUCCEED, 'found', 'adcdcde'), ('a[bcd]+dcdcde', 'adcdcde', FAIL), ('(ab|a)b*c', 'abc', SUCCEED, 'found+"-"+g1', 'abc-ab'), ('((a)(b)c)(d)', 'abcd', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'), ('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED, 'found', 'alpha'), ('^a(bc+|b[eh])g|.h$', 'abh', SUCCEED, 'found+"-"+g1', 'bh-None'), ('(bc+d$|ef*g.|h?i(j|k))', 'effgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), ('(bc+d$|ef*g.|h?i(j|k))', 'ij', SUCCEED, 'found+"-"+g1+"-"+g2', 'ij-ij-j'), ('(bc+d$|ef*g.|h?i(j|k))', 'effg', FAIL), ('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', FAIL), ('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), ('((((((((((a))))))))))', 'a', SUCCEED, 'g10', 'a'), ('((((((((((a))))))))))\\10', 'aa', SUCCEED, 'found', 'aa'), # Python does not have the same rules for \\41 so this is a syntax error # ('((((((((((a))))))))))\\41', 'aa', FAIL), # ('((((((((((a))))))))))\\41', 'a!', SUCCEED, 'found', 'a!'), ('((((((((((a))))))))))\\41', '', SYNTAX_ERROR), ('(?i)((((((((((a))))))))))\\41', '', SYNTAX_ERROR), ('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'), ('multiple words of text', 'uh-uh', FAIL), ('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'), ('(.*)c(.*)', 'abcde', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'), ('\\((.*), (.*)\\)', '(a, b)', SUCCEED, 'g2+"-"+g1', 'b-a'), ('[k]', 'ab', FAIL), ('a[-]?c', 'ac', SUCCEED, 'found', 'ac'), ('(abc)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), ('([a-c]*)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), ('(?i)abc', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)abc', 'XBC', FAIL), ('(?i)abc', 'AXC', FAIL), ('(?i)abc', 'ABX', FAIL), ('(?i)abc', 'XABCY', SUCCEED, 'found', 'ABC'), ('(?i)abc', 'ABABC', SUCCEED, 'found', 'ABC'), ('(?i)ab*c', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)ab*bc', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)ab*bc', 'ABBC', SUCCEED, 'found', 'ABBC'), ('(?i)ab*?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), ('(?i)ab{0,}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), ('(?i)ab+?bc', 'ABBC', SUCCEED, 'found', 'ABBC'), ('(?i)ab+bc', 'ABC', FAIL), ('(?i)ab+bc', 'ABQ', FAIL), ('(?i)ab{1,}bc', 'ABQ', FAIL), ('(?i)ab+bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), ('(?i)ab{1,}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), ('(?i)ab{1,3}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), ('(?i)ab{3,4}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), ('(?i)ab{4,5}?bc', 'ABBBBC', FAIL), ('(?i)ab??bc', 'ABBC', SUCCEED, 'found', 'ABBC'), ('(?i)ab??bc', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)ab{0,1}?bc', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)ab??bc', 'ABBBBC', FAIL), ('(?i)ab??c', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)ab{0,1}?c', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)^abc$', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)^abc$', 'ABCC', FAIL), ('(?i)^abc', 'ABCC', SUCCEED, 'found', 'ABC'), ('(?i)^abc$', 'AABC', FAIL), ('(?i)abc$', 'AABC', SUCCEED, 'found', 'ABC'), ('(?i)^', 'ABC', SUCCEED, 'found', ''), ('(?i)$', 'ABC', SUCCEED, 'found', ''), ('(?i)a.c', 'ABC', SUCCEED, 'found', 'ABC'), ('(?i)a.c', 'AXC', SUCCEED, 'found', 'AXC'), ('(?i)a.*?c', 'AXYZC', SUCCEED, 'found', 'AXYZC'), ('(?i)a.*c', 'AXYZD', FAIL), ('(?i)a[bc]d', 'ABC', FAIL), ('(?i)a[bc]d', 'ABD', SUCCEED, 'found', 'ABD'), ('(?i)a[b-d]e', 'ABD', FAIL), ('(?i)a[b-d]e', 'ACE', SUCCEED, 'found', 'ACE'), ('(?i)a[b-d]', 'AAC', SUCCEED, 'found', 'AC'), ('(?i)a[-b]', 'A-', SUCCEED, 'found', 'A-'), ('(?i)a[b-]', 'A-', SUCCEED, 'found', 'A-'), ('(?i)a[b-a]', '-', SYNTAX_ERROR), ('(?i)a[]b', '-', SYNTAX_ERROR), ('(?i)a[', '-', SYNTAX_ERROR), ('(?i)a]', 'A]', SUCCEED, 'found', 'A]'), ('(?i)a[]]b', 'A]B', SUCCEED, 'found', 'A]B'), ('(?i)a[^bc]d', 'AED', SUCCEED, 'found', 'AED'), ('(?i)a[^bc]d', 'ABD', FAIL), ('(?i)a[^-b]c', 'ADC', SUCCEED, 'found', 'ADC'), ('(?i)a[^-b]c', 'A-C', FAIL), ('(?i)a[^]b]c', 'A]C', FAIL), ('(?i)a[^]b]c', 'ADC', SUCCEED, 'found', 'ADC'), ('(?i)ab|cd', 'ABC', SUCCEED, 'found', 'AB'), ('(?i)ab|cd', 'ABCD', SUCCEED, 'found', 'AB'), ('(?i)()ef', 'DEF', SUCCEED, 'found+"-"+g1', 'EF-'), ('(?i)*a', '-', SYNTAX_ERROR), ('(?i)(*)b', '-', SYNTAX_ERROR), ('(?i)$b', 'B', FAIL), ('(?i)a\\', '-', SYNTAX_ERROR), ('(?i)a\\(b', 'A(B', SUCCEED, 'found+"-"+g1', 'A(B-Error'), ('(?i)a\\(*b', 'AB', SUCCEED, 'found', 'AB'), ('(?i)a\\(*b', 'A((B', SUCCEED, 'found', 'A((B'), ('(?i)a\\\\b', 'A\\B', SUCCEED, 'found', 'A\\B'), ('(?i)abc)', '-', SYNTAX_ERROR), ('(?i)(abc', '-', SYNTAX_ERROR), ('(?i)((a))', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'A-A-A'), ('(?i)(a)b(c)', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABC-A-C'), ('(?i)a+b+c', 'AABBABC', SUCCEED, 'found', 'ABC'), ('(?i)a{1,}b{1,}c', 'AABBABC', SUCCEED, 'found', 'ABC'), ('(?i)a**', '-', SYNTAX_ERROR), ('(?i)a.+?c', 'ABCABC', SUCCEED, 'found', 'ABC'), ('(?i)a.*?c', 'ABCABC', SUCCEED, 'found', 'ABC'), ('(?i)a.{0,5}?c', 'ABCABC', SUCCEED, 'found', 'ABC'), ('(?i)(a+|b)*', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), ('(?i)(a+|b){0,}', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), ('(?i)(a+|b)+', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), ('(?i)(a+|b){1,}', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), ('(?i)(a+|b)?', 'AB', SUCCEED, 'found+"-"+g1', 'A-A'), ('(?i)(a+|b){0,1}', 'AB', SUCCEED, 'found+"-"+g1', 'A-A'), ('(?i)(a+|b){0,1}?', 'AB', SUCCEED, 'found+"-"+g1', '-None'), ('(?i))(', '-', SYNTAX_ERROR), ('(?i)[^ab]*', 'CDE', SUCCEED, 'found', 'CDE'), ('(?i)abc', '', FAIL), ('(?i)a*', '', SUCCEED, 'found', ''), ('(?i)([abc])*d', 'ABBBCD', SUCCEED, 'found+"-"+g1', 'ABBBCD-C'), ('(?i)([abc])*bcd', 'ABCD', SUCCEED, 'found+"-"+g1', 'ABCD-A'), ('(?i)a|b|c|d|e', 'E', SUCCEED, 'found', 'E'), ('(?i)(a|b|c|d|e)f', 'EF', SUCCEED, 'found+"-"+g1', 'EF-E'), ('(?i)abcd*efg', 'ABCDEFG', SUCCEED, 'found', 'ABCDEFG'), ('(?i)ab*', 'XABYABBBZ', SUCCEED, 'found', 'AB'), ('(?i)ab*', 'XAYABBBZ', SUCCEED, 'found', 'A'), ('(?i)(ab|cd)e', 'ABCDE', SUCCEED, 'found+"-"+g1', 'CDE-CD'), ('(?i)[abhgefdc]ij', 'HIJ', SUCCEED, 'found', 'HIJ'), ('(?i)^(ab|cd)e', 'ABCDE', FAIL), ('(?i)(abc|)ef', 'ABCDEF', SUCCEED, 'found+"-"+g1', 'EF-'), ('(?i)(a|b)c*d', 'ABCD', SUCCEED, 'found+"-"+g1', 'BCD-B'), ('(?i)(ab|ab*)bc', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-A'), ('(?i)a([bc]*)c*', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-BC'), ('(?i)a([bc]*)(c*d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-BC-D'), ('(?i)a([bc]+)(c*d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-BC-D'), ('(?i)a([bc]*)(c+d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-B-CD'), ('(?i)a[bcd]*dcdcde', 'ADCDCDE', SUCCEED, 'found', 'ADCDCDE'), ('(?i)a[bcd]+dcdcde', 'ADCDCDE', FAIL), ('(?i)(ab|a)b*c', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-AB'), ('(?i)((a)(b)c)(d)', 'ABCD', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'ABC-A-B-D'), ('(?i)[a-zA-Z_][a-zA-Z0-9_]*', 'ALPHA', SUCCEED, 'found', 'ALPHA'), ('(?i)^a(bc+|b[eh])g|.h$', 'ABH', SUCCEED, 'found+"-"+g1', 'BH-None'), ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFGZ', SUCCEED, 'found+"-"+g1+"-"+g2', 'EFFGZ-EFFGZ-None'), ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'IJ', SUCCEED, 'found+"-"+g1+"-"+g2', 'IJ-IJ-J'), ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFG', FAIL), ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'BCDD', FAIL), ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'REFFGZ', SUCCEED, 'found+"-"+g1+"-"+g2', 'EFFGZ-EFFGZ-None'), ('(?i)((((((((((a))))))))))', 'A', SUCCEED, 'g10', 'A'), ('(?i)((((((((((a))))))))))\\10', 'AA', SUCCEED, 'found', 'AA'), #('(?i)((((((((((a))))))))))\\41', 'AA', FAIL), #('(?i)((((((((((a))))))))))\\41', 'A!', SUCCEED, 'found', 'A!'), ('(?i)(((((((((a)))))))))', 'A', SUCCEED, 'found', 'A'), ('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))', 'A', SUCCEED, 'g1', 'A'), ('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))', 'C', SUCCEED, 'g1', 'C'), ('(?i)multiple words of text', 'UH-UH', FAIL), ('(?i)multiple words', 'MULTIPLE WORDS, YEAH', SUCCEED, 'found', 'MULTIPLE WORDS'), ('(?i)(.*)c(.*)', 'ABCDE', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCDE-AB-DE'), ('(?i)\\((.*), (.*)\\)', '(A, B)', SUCCEED, 'g2+"-"+g1', 'B-A'), ('(?i)[k]', 'AB', FAIL), # ('(?i)abcd', 'ABCD', SUCCEED, 'found+"-"+\\found+"-"+\\\\found', 'ABCD-$&-\\ABCD'), # ('(?i)a(bc)d', 'ABCD', SUCCEED, 'g1+"-"+\\g1+"-"+\\\\g1', 'BC-$1-\\BC'), ('(?i)a[-]?c', 'AC', SUCCEED, 'found', 'AC'), ('(?i)(abc)\\1', 'ABCABC', SUCCEED, 'g1', 'ABC'), ('(?i)([a-c]*)\\1', 'ABCABC', SUCCEED, 'g1', 'ABC'), ('a(?!b).', 'abad', SUCCEED, 'found', 'ad'), ('a(?=d).', 'abad', SUCCEED, 'found', 'ad'), ('a(?=c|d).', 'abad', SUCCEED, 'found', 'ad'), ('a(?:b|c|d)(.)', 'ace', SUCCEED, 'g1', 'e'), ('a(?:b|c|d)*(.)', 'ace', SUCCEED, 'g1', 'e'), ('a(?:b|c|d)+?(.)', 'ace', SUCCEED, 'g1', 'e'), ('a(?:b|(c|e){1,2}?|d)+?(.)', 'ace', SUCCEED, 'g1 + g2', 'ce'), ('^(.+)?B', 'AB', SUCCEED, 'g1', 'A'), # Comments using the (?#...) syntax ('w(?# comment', 'w', SYNTAX_ERROR), ('w(?# comment 1)xy(?# comment 2)z', 'wxyz', SUCCEED, 'found', 'wxyz'), # Check odd placement of embedded pattern modifiers # not an error under PCRE/PRE: ('w(?i)', 'W', SUCCEED, 'found', 'W'), # ('w(?i)', 'W', SYNTAX_ERROR), # Comments using the x embedded pattern modifier ("""(?x)w# comment 1 x y # comment 2 z""", 'wxyz', SUCCEED, 'found', 'wxyz'), # using the m embedded pattern modifier ('^abc', """jkl abc xyz""", FAIL), ('(?m)^abc', """jkl abc xyz""", SUCCEED, 'found', 'abc'), ('(?m)abc$', """jkl xyzabc 123""", SUCCEED, 'found', 'abc'), # using the s embedded pattern modifier ('a.b', 'a\nb', FAIL), ('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'), # test \w, etc. both inside and outside character classes ('\\w+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'), ('[\\w]+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'), ('\\D+', '1234abc5678', SUCCEED, 'found', 'abc'), ('[\\D]+', '1234abc5678', SUCCEED, 'found', 'abc'), ('[\\da-fA-F]+', '123abc', SUCCEED, 'found', '123abc'), # not an error under PCRE/PRE: # ('[\\d-x]', '-', SYNTAX_ERROR), (r'([\s]*)([\S]*)([\s]*)', ' testing!1972', SUCCEED, 'g3+g2+g1', 'testing!1972 '), (r'(\s*)(\S*)(\s*)', ' testing!1972', SUCCEED, 'g3+g2+g1', 'testing!1972 '), (r'\xff', '\377', SUCCEED, 'found', chr(255)), # new \x semantics (r'\x00ff', '\377', FAIL, 'found', chr(255)), # (r'\x00ff', '\377', SUCCEED, 'found', chr(255)), (r'\t\n\v\r\f\a\g', '\t\n\v\r\f\ag', SUCCEED, 'found', '\t\n\v\r\f\ag'), ('\t\n\v\r\f\a\g', '\t\n\v\r\f\ag', SUCCEED, 'found', '\t\n\v\r\f\ag'), (r'\t\n\v\r\f\a', '\t\n\v\r\f\a', SUCCEED, 'found', chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)), (r'[\t][\n][\v][\r][\f][\b]', '\t\n\v\r\f\b', SUCCEED, 'found', '\t\n\v\r\f\b'), # # post-1.5.2 additions # xmllib problem (r'(([a-z]+):)?([a-z]+)$', 'smil', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-smil'), # bug 111869 (PRE/PCRE fails on this one, SRE doesn't) (r'.*d', 'abc\nabd', SUCCEED, 'found', 'abd'), # bug 112468: various expected syntax errors ('(', '', SYNTAX_ERROR), ('[\\41]', '!', SUCCEED, 'found', '!'), # bug 114033: nothing to repeat (r'(x?)?', 'x', SUCCEED, 'found', 'x'), # bug 115040: rescan if flags are modified inside pattern (r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'), # bug 115618: negative lookahead (r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'), # bug 116251: character class bug (r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'), ]
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 818, 26, 2366, 1882, 199, 199, 3, 799, 511, 5241, 436, 12338, 5241, 373, 17, 14, 21, 199, 199, 3, 710, 650, 3962, 15955, 83, 367, 1924, 3851, 199, 59, 6195, 8890, 12, 10341, 12, 25486, 63, 3170, 61, 275, 1425, 8, 19, 9, 199, 199, 3, 27067, 5241, 334, 10065, 14819, 9, 199, 3, 199, 3, 710, 12338, 5241, 1630, 440, 511, 29102, 12, 2951, 8112, 14, 221, 710, 199, 3, 1642, 1819, 402, 1924, 2008, 365, 314, 5163, 3851, 27, 314, 3499, 365, 282, 199, 3, 1059, 370, 1336, 652, 6169, 14, 221, 710, 12338, 316, 1233, 911, 6441, 314, 199, 3, 3499, 1059, 6272, 9978, 10627, 402, 6273, 12, 370, 511, 4212, 5163, 199, 3, 4877, 18628, 641, 7031, 3326, 14, 199, 199, 11861, 83, 275, 359, 339, 327, 511, 2863, 2403, 272, 661, 4718, 92, 2623, 76, 297, 283, 2623, 76, 659, 259, 327, 17669, 425, 272, 23845, 4718, 92, 2623, 76, 3196, 283, 2623, 76, 659, 221, 327, 598, 11330, 8679, 425, 339, 661, 4718, 92, 2623, 76, 92, 29175, 297, 283, 2623, 76, 659, 263, 327, 17669, 425, 272, 23845, 4718, 92, 2623, 76, 92, 29175, 3196, 283, 2623, 76, 659, 420, 327, 598, 11330, 8679, 425, 339, 23845, 4718, 22532, 17, 297, 283, 4718, 4718, 659, 259, 327, 10257, 4443, 272, 661, 779, 16, 65, 13, 90, 1527, 65, 13, 90, 16, 13, 25, 3672, 4258, 7386, 283, 65, 21, 12, 66, 23, 12, 67, 25, 12, 659, 327, 17534, 314, 7377, 1130, 13712, 272, 661, 779, 65, 13, 90, 1527, 65, 13, 90, 16, 13, 25, 3672, 4258, 7386, 283, 65, 21, 12, 66, 23, 12, 67, 25, 12, 659, 327, 437, 9284, 5951, 339, 661, 4718, 297, 283, 4718, 659, 5185, 327, 5870, 1318, 8785, 272, 661, 2795, 4718, 297, 283, 4718, 659, 3777, 327, 8857, 1318, 8785, 272, 661, 2795, 4718, 16110, 283, 4718, 659, 3698, 327, 644, 9050, 1318, 8785, 272, 661, 2795, 8, 4718, 3196, 283, 4718, 659, 3698, 327, 8857, 1318, 8785, 543, 17786, 199, 199, 61, 199, 199, 3, 1379, 5241, 334, 509, 31866, 29102, 9, 199, 3, 199, 3, 710, 511, 5241, 365, 282, 769, 402, 959, 13, 503, 650, 13, 11760, 14, 221, 710, 959, 4184, 402, 282, 199, 3, 4890, 2008, 787, 26, 199, 3, 1819, 378, 26, 282, 1059, 3035, 314, 3851, 199, 3, 260, 413, 26, 314, 1059, 370, 1336, 6169, 314, 3851, 199, 3, 260, 499, 26, 314, 1420, 754, 334, 6195, 8890, 12, 10341, 12, 25486, 63, 3170, 9, 199, 3, 260, 650, 26, 282, 1059, 626, 911, 506, 3468, 11716, 379, 370, 7389, 282, 511, 1059, 14, 199, 3, 3322, 961, 365, 376, 9697, 2018, 3965, 27, 314, 2808, 199, 3, 3322, 2860, 787, 298, 4214, 2, 334, 1589, 8852, 1336, 395, 436, 298, 71, 17, 401, 298, 71, 18, 401, 2263, 199, 3, 3322, 1536, 370, 298, 71, 1020, 2, 1395, 314, 4072, 402, 1924, 1572, 12, 503, 314, 199, 3, 3322, 1059, 283, 403, 7, 340, 314, 1572, 17373, 1133, 1627, 282, 574, 12, 503, 314, 199, 3, 3322, 1059, 283, 547, 7, 340, 314, 1572, 1478, 1990, 734, 402, 1425, 27, 199, 3, 3322, 2597, 298, 2634, 401, 314, 372, 574, 402, 333, 14, 923, 342, 334, 65, 2008, 680, 199, 3, 260, 841, 26, 710, 1420, 754, 402, 27083, 314, 3965, 14, 199, 3, 3322, 982, 314, 2877, 2793, 1133, 1336, 12, 376, 1125, 365, 14581, 14, 199, 3, 199, 3, 982, 314, 5163, 5712, 1133, 1420, 370, 1736, 12, 314, 19045, 2877, 4008, 883, 506, 11684, 14, 199, 199, 2219, 275, 359, 272, 327, 1379, 5805, 48, 28, 436, 5805, 48, 29, 5478, 272, 15950, 48, 28, 1421, 63, 4288, 297, 3260, 25486, 63, 3170, 395, 420, 327, 1910, 18375, 1572, 5148, 272, 15950, 48, 28, 17, 30, 65, 3196, 3260, 25486, 63, 3170, 395, 260, 327, 25754, 83, 543, 282, 10964, 272, 15950, 48, 11230, 30, 65, 3196, 3260, 25486, 63, 3170, 395, 260, 327, 25754, 83, 543, 376, 20282, 1495, 272, 15950, 48, 28, 1421, 1, 30, 65, 3196, 3260, 25486, 63, 3170, 395, 420, 327, 25754, 83, 543, 376, 20282, 1495, 339, 327, 14766, 2295, 12, 367, 314, 5805, 48, 29, 1824, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1421, 63, 4288, 297, 283, 2158, 297, 25486, 63, 3170, 395, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 17, 3196, 283, 2158, 297, 25486, 63, 3170, 395, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1, 3196, 283, 2158, 297, 25486, 63, 3170, 395, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1421, 63, 7214, 297, 283, 2158, 297, 25486, 63, 3170, 395, 221, 327, 10257, 1121, 370, 10942, 1572, 339, 15950, 48, 28, 1421, 63, 4288, 30, 65, 3196, 283, 65, 297, 8955, 12, 283, 71, 17, 297, 283, 65, 659, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1421, 63, 4288, 3196, 283, 2158, 297, 8955, 12, 283, 71, 17, 297, 283, 65, 659, 339, 327, 1379, 30100, 24644, 272, 661, 1103, 17, 297, 283, 65, 297, 25486, 63, 3170, 395, 259, 327, 10257, 4443, 272, 23734, 1103, 17, 4300, 1557, 17, 297, 8955, 12, 283, 4214, 297, 1557, 17, 659, 221, 327, 17660, 272, 661, 1103, 1643, 297, 8678, 8, 16, 9, 435, 283, 25, 297, 8955, 12, 283, 4214, 297, 8678, 8, 16, 9, 435, 283, 25, 659, 272, 661, 1103, 12735, 297, 283, 65, 297, 8955, 12, 283, 4214, 297, 283, 65, 659, 272, 23845, 65, 5130, 66, 5130, 67, 5130, 68, 5130, 69, 5130, 70, 5130, 71, 5130, 72, 5130, 73, 5130, 74, 5130, 75, 5130, 76, 22532, 7119, 297, 283, 18677, 9503, 75, 25, 297, 8955, 12, 283, 4214, 15200, 71, 845, 297, 283, 18677, 9503, 75, 25, 13, 75, 659, 339, 327, 1379, 971, 16, 365, 8860, 4036, 4509, 272, 334, 82, 1154, 16, 297, 1557, 16, 297, 8955, 12, 283, 4214, 297, 1557, 16, 659, 272, 334, 82, 22123, 16, 65, 4300, 1557, 16 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 818, 26, 2366, 1882, 199, 199, 3, 799, 511, 5241, 436, 12338, 5241, 373, 17, 14, 21, 199, 199, 3, 710, 650, 3962, 15955, 83, 367, 1924, 3851, 199, 59, 6195, 8890, 12, 10341, 12, 25486, 63, 3170, 61, 275, 1425, 8, 19, 9, 199, 199, 3, 27067, 5241, 334, 10065, 14819, 9, 199, 3, 199, 3, 710, 12338, 5241, 1630, 440, 511, 29102, 12, 2951, 8112, 14, 221, 710, 199, 3, 1642, 1819, 402, 1924, 2008, 365, 314, 5163, 3851, 27, 314, 3499, 365, 282, 199, 3, 1059, 370, 1336, 652, 6169, 14, 221, 710, 12338, 316, 1233, 911, 6441, 314, 199, 3, 3499, 1059, 6272, 9978, 10627, 402, 6273, 12, 370, 511, 4212, 5163, 199, 3, 4877, 18628, 641, 7031, 3326, 14, 199, 199, 11861, 83, 275, 359, 339, 327, 511, 2863, 2403, 272, 661, 4718, 92, 2623, 76, 297, 283, 2623, 76, 659, 259, 327, 17669, 425, 272, 23845, 4718, 92, 2623, 76, 3196, 283, 2623, 76, 659, 221, 327, 598, 11330, 8679, 425, 339, 661, 4718, 92, 2623, 76, 92, 29175, 297, 283, 2623, 76, 659, 263, 327, 17669, 425, 272, 23845, 4718, 92, 2623, 76, 92, 29175, 3196, 283, 2623, 76, 659, 420, 327, 598, 11330, 8679, 425, 339, 23845, 4718, 22532, 17, 297, 283, 4718, 4718, 659, 259, 327, 10257, 4443, 272, 661, 779, 16, 65, 13, 90, 1527, 65, 13, 90, 16, 13, 25, 3672, 4258, 7386, 283, 65, 21, 12, 66, 23, 12, 67, 25, 12, 659, 327, 17534, 314, 7377, 1130, 13712, 272, 661, 779, 65, 13, 90, 1527, 65, 13, 90, 16, 13, 25, 3672, 4258, 7386, 283, 65, 21, 12, 66, 23, 12, 67, 25, 12, 659, 327, 437, 9284, 5951, 339, 661, 4718, 297, 283, 4718, 659, 5185, 327, 5870, 1318, 8785, 272, 661, 2795, 4718, 297, 283, 4718, 659, 3777, 327, 8857, 1318, 8785, 272, 661, 2795, 4718, 16110, 283, 4718, 659, 3698, 327, 644, 9050, 1318, 8785, 272, 661, 2795, 8, 4718, 3196, 283, 4718, 659, 3698, 327, 8857, 1318, 8785, 543, 17786, 199, 199, 61, 199, 199, 3, 1379, 5241, 334, 509, 31866, 29102, 9, 199, 3, 199, 3, 710, 511, 5241, 365, 282, 769, 402, 959, 13, 503, 650, 13, 11760, 14, 221, 710, 959, 4184, 402, 282, 199, 3, 4890, 2008, 787, 26, 199, 3, 1819, 378, 26, 282, 1059, 3035, 314, 3851, 199, 3, 260, 413, 26, 314, 1059, 370, 1336, 6169, 314, 3851, 199, 3, 260, 499, 26, 314, 1420, 754, 334, 6195, 8890, 12, 10341, 12, 25486, 63, 3170, 9, 199, 3, 260, 650, 26, 282, 1059, 626, 911, 506, 3468, 11716, 379, 370, 7389, 282, 511, 1059, 14, 199, 3, 3322, 961, 365, 376, 9697, 2018, 3965, 27, 314, 2808, 199, 3, 3322, 2860, 787, 298, 4214, 2, 334, 1589, 8852, 1336, 395, 436, 298, 71, 17, 401, 298, 71, 18, 401, 2263, 199, 3, 3322, 1536, 370, 298, 71, 1020, 2, 1395, 314, 4072, 402, 1924, 1572, 12, 503, 314, 199, 3, 3322, 1059, 283, 403, 7, 340, 314, 1572, 17373, 1133, 1627, 282, 574, 12, 503, 314, 199, 3, 3322, 1059, 283, 547, 7, 340, 314, 1572, 1478, 1990, 734, 402, 1425, 27, 199, 3, 3322, 2597, 298, 2634, 401, 314, 372, 574, 402, 333, 14, 923, 342, 334, 65, 2008, 680, 199, 3, 260, 841, 26, 710, 1420, 754, 402, 27083, 314, 3965, 14, 199, 3, 3322, 982, 314, 2877, 2793, 1133, 1336, 12, 376, 1125, 365, 14581, 14, 199, 3, 199, 3, 982, 314, 5163, 5712, 1133, 1420, 370, 1736, 12, 314, 19045, 2877, 4008, 883, 506, 11684, 14, 199, 199, 2219, 275, 359, 272, 327, 1379, 5805, 48, 28, 436, 5805, 48, 29, 5478, 272, 15950, 48, 28, 1421, 63, 4288, 297, 3260, 25486, 63, 3170, 395, 420, 327, 1910, 18375, 1572, 5148, 272, 15950, 48, 28, 17, 30, 65, 3196, 3260, 25486, 63, 3170, 395, 260, 327, 25754, 83, 543, 282, 10964, 272, 15950, 48, 11230, 30, 65, 3196, 3260, 25486, 63, 3170, 395, 260, 327, 25754, 83, 543, 376, 20282, 1495, 272, 15950, 48, 28, 1421, 1, 30, 65, 3196, 3260, 25486, 63, 3170, 395, 420, 327, 25754, 83, 543, 376, 20282, 1495, 339, 327, 14766, 2295, 12, 367, 314, 5805, 48, 29, 1824, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1421, 63, 4288, 297, 283, 2158, 297, 25486, 63, 3170, 395, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 17, 3196, 283, 2158, 297, 25486, 63, 3170, 395, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1, 3196, 283, 2158, 297, 25486, 63, 3170, 395, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1421, 63, 7214, 297, 283, 2158, 297, 25486, 63, 3170, 395, 221, 327, 10257, 1121, 370, 10942, 1572, 339, 15950, 48, 28, 1421, 63, 4288, 30, 65, 3196, 283, 65, 297, 8955, 12, 283, 71, 17, 297, 283, 65, 659, 272, 15950, 48, 28, 1421, 63, 4288, 30, 65, 18168, 48, 29, 1421, 63, 4288, 3196, 283, 2158, 297, 8955, 12, 283, 71, 17, 297, 283, 65, 659, 339, 327, 1379, 30100, 24644, 272, 661, 1103, 17, 297, 283, 65, 297, 25486, 63, 3170, 395, 259, 327, 10257, 4443, 272, 23734, 1103, 17, 4300, 1557, 17, 297, 8955, 12, 283, 4214, 297, 1557, 17, 659, 221, 327, 17660, 272, 661, 1103, 1643, 297, 8678, 8, 16, 9, 435, 283, 25, 297, 8955, 12, 283, 4214, 297, 8678, 8, 16, 9, 435, 283, 25, 659, 272, 661, 1103, 12735, 297, 283, 65, 297, 8955, 12, 283, 4214, 297, 283, 65, 659, 272, 23845, 65, 5130, 66, 5130, 67, 5130, 68, 5130, 69, 5130, 70, 5130, 71, 5130, 72, 5130, 73, 5130, 74, 5130, 75, 5130, 76, 22532, 7119, 297, 283, 18677, 9503, 75, 25, 297, 8955, 12, 283, 4214, 15200, 71, 845, 297, 283, 18677, 9503, 75, 25, 13, 75, 659, 339, 327, 1379, 971, 16, 365, 8860, 4036, 4509, 272, 334, 82, 1154, 16, 297, 1557, 16, 297, 8955, 12, 283, 4214, 297, 1557, 16, 659, 272, 334, 82, 22123, 16, 65, 4300, 1557, 16, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
ModdedPA/android_external_chromium_org
chrome/test/chromedriver/client/chromedriver.py
29
8385
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import command_executor from command_executor import Command from webelement import WebElement class ChromeDriverException(Exception): pass class NoSuchElement(ChromeDriverException): pass class NoSuchFrame(ChromeDriverException): pass class UnknownCommand(ChromeDriverException): pass class StaleElementReference(ChromeDriverException): pass class UnknownError(ChromeDriverException): pass class JavaScriptError(ChromeDriverException): pass class XPathLookupError(ChromeDriverException): pass class NoSuchWindow(ChromeDriverException): pass class InvalidCookieDomain(ChromeDriverException): pass class ScriptTimeout(ChromeDriverException): pass class InvalidSelector(ChromeDriverException): pass class SessionNotCreatedException(ChromeDriverException): pass class NoSuchSession(ChromeDriverException): pass def _ExceptionForResponse(response): exception_class_map = { 7: NoSuchElement, 8: NoSuchFrame, 9: UnknownCommand, 10: StaleElementReference, 13: UnknownError, 17: JavaScriptError, 19: XPathLookupError, 23: NoSuchWindow, 24: InvalidCookieDomain, 28: ScriptTimeout, 32: InvalidSelector, 33: SessionNotCreatedException, 100: NoSuchSession } status = response['status'] msg = response['value']['message'] return exception_class_map.get(status, ChromeDriverException)(msg) class ChromeDriver(object): """Starts and controls a single Chrome instance on this machine.""" def __init__(self, server_url, chrome_binary=None, android_package=None, chrome_switches=None, chrome_extensions=None, chrome_log_path=None): self._executor = command_executor.CommandExecutor(server_url) options = {} if android_package: options['androidPackage'] = android_package elif chrome_binary: options['binary'] = chrome_binary if chrome_switches: assert type(chrome_switches) is list options['args'] = chrome_switches if chrome_extensions: assert type(chrome_extensions) is list options['extensions'] = chrome_extensions if chrome_log_path: assert type(chrome_log_path) is str options['logPath'] = chrome_log_path params = { 'desiredCapabilities': { 'chromeOptions': options } } self._session_id = self._executor.Execute( Command.NEW_SESSION, params)['sessionId'] def _WrapValue(self, value): """Wrap value from client side for chromedriver side.""" if isinstance(value, dict): converted = {} for key, val in value.items(): converted[key] = self._WrapValue(val) return converted elif isinstance(value, WebElement): return {'ELEMENT': value._id} elif isinstance(value, list): return list(self._WrapValue(item) for item in value) else: return value def _UnwrapValue(self, value): """Unwrap value from chromedriver side for client side.""" if isinstance(value, dict): if (len(value) == 1 and 'ELEMENT' in value and isinstance(value['ELEMENT'], basestring)): return WebElement(self, value['ELEMENT']) else: unwraped = {} for key, val in value.items(): unwraped[key] = self._UnwrapValue(val) return unwraped elif isinstance(value, list): return list(self._UnwrapValue(item) for item in value) else: return value def ExecuteCommand(self, command, params={}): params['sessionId'] = self._session_id params = self._WrapValue(params) response = self._executor.Execute(command, params) if response['status'] != 0: raise _ExceptionForResponse(response) return self._UnwrapValue(response['value']) def GetWindowHandles(self): return self.ExecuteCommand(Command.GET_WINDOW_HANDLES) def SwitchToWindow(self, handle_or_name): self.ExecuteCommand(Command.SWITCH_TO_WINDOW, {'name': handle_or_name}) def GetCurrentWindowHandle(self): return self.ExecuteCommand(Command.GET_CURRENT_WINDOW_HANDLE) def CloseWindow(self): self.ExecuteCommand(Command.CLOSE) def Load(self, url): self.ExecuteCommand(Command.GET, {'url': url}) def ExecuteScript(self, script, *args): converted_args = list(args) return self.ExecuteCommand( Command.EXECUTE_SCRIPT, {'script': script, 'args': converted_args}) def ExecuteAsyncScript(self, script, *args): converted_args = list(args) return self.ExecuteCommand( Command.EXECUTE_ASYNC_SCRIPT, {'script': script, 'args': converted_args}) def SwitchToFrame(self, id_or_name): self.ExecuteCommand(Command.SWITCH_TO_FRAME, {'id': id_or_name}) def SwitchToFrameByIndex(self, index): self.SwitchToFrame(index) def SwitchToMainFrame(self): self.SwitchToFrame(None) def GetTitle(self): return self.ExecuteCommand(Command.GET_TITLE) def GetPageSource(self): return self.ExecuteCommand(Command.GET_PAGE_SOURCE) def FindElement(self, strategy, target): return self.ExecuteCommand( Command.FIND_ELEMENT, {'using': strategy, 'value': target}) def FindElements(self, strategy, target): return self.ExecuteCommand( Command.FIND_ELEMENTS, {'using': strategy, 'value': target}) def SetTimeout(self, type, timeout): return self.ExecuteCommand( Command.SET_TIMEOUT, {'type' : type, 'ms': timeout}) def GetCurrentUrl(self): return self.ExecuteCommand(Command.GET_CURRENT_URL) def GoBack(self): return self.ExecuteCommand(Command.GO_BACK) def GoForward(self): return self.ExecuteCommand(Command.GO_FORWARD) def Refresh(self): return self.ExecuteCommand(Command.REFRESH) def MouseMoveTo(self, element=None, x_offset=None, y_offset=None): params = {} if element is not None: params['element'] = element._id if x_offset is not None: params['xoffset'] = x_offset if y_offset is not None: params['yoffset'] = y_offset self.ExecuteCommand(Command.MOUSE_MOVE_TO, params) def MouseClick(self, button=0): self.ExecuteCommand(Command.MOUSE_CLICK, {'button': button}) def MouseButtonDown(self, button=0): self.ExecuteCommand(Command.MOUSE_BUTTON_DOWN, {'button': button}) def MouseButtonUp(self, button=0): self.ExecuteCommand(Command.MOUSE_BUTTON_UP, {'button': button}) def MouseDoubleClick(self, button=0): self.ExecuteCommand(Command.MOUSE_DOUBLE_CLICK, {'button': button}) def GetCookies(self): return self.ExecuteCommand(Command.GET_COOKIES) def AddCookie(self, cookie): self.ExecuteCommand(Command.ADD_COOKIE, {'cookie': cookie}) def DeleteCookie(self, name): self.ExecuteCommand(Command.DELETE_COOKIE, {'name': name}) def DeleteAllCookies(self): self.ExecuteCommand(Command.DELETE_ALL_COOKIES) def IsAlertOpen(self): return self.ExecuteCommand(Command.GET_ALERT) def GetAlertMessage(self): return self.ExecuteCommand(Command.GET_ALERT_TEXT) def HandleAlert(self, accept, prompt_text=''): if prompt_text: self.ExecuteCommand(Command.SET_ALERT_VALUE, {'text': prompt_text}) if accept: cmd = Command.ACCEPT_ALERT else: cmd = Command.DISMISS_ALERT self.ExecuteCommand(cmd) def IsLoading(self): return self.ExecuteCommand(Command.IS_LOADING) def GetWindowPosition(self): position = self.ExecuteCommand(Command.GET_WINDOW_POSITION, {'windowHandle': 'current'}) return [position['x'], position['y']] def SetWindowPosition(self, x, y): self.ExecuteCommand(Command.SET_WINDOW_POSITION, {'windowHandle': 'current', 'x': x, 'y': y}) def GetWindowSize(self): size = self.ExecuteCommand(Command.GET_WINDOW_SIZE, {'windowHandle': 'current'}) return [size['width'], size['height']] def SetWindowSize(self, width, height): self.ExecuteCommand( Command.SET_WINDOW_SIZE, {'windowHandle': 'current', 'width': width, 'height': height}) def MaximizeWindow(self): self.ExecuteCommand(Command.MAXIMIZE_WINDOW, {'windowHandle': 'current'}) def Quit(self): """Quits the browser and ends the session.""" self.ExecuteCommand(Command.QUIT)
bsd-3-clause
[ 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 1414, 63, 13471, 199, 504, 1414, 63, 13471, 492, 5817, 199, 504, 781, 1235, 968, 492, 6001, 2162, 421, 199, 533, 16776, 6158, 1726, 8, 1726, 304, 523, 986, 199, 533, 23798, 2162, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 23798, 3160, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 14831, 3110, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 7083, 274, 2162, 5083, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 14831, 547, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 15250, 547, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 1323, 2042, 32060, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 23798, 4301, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 6378, 7810, 7705, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 14914, 6372, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 6378, 11212, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 8596, 1763, 10502, 1726, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 23798, 4434, 8, 18083, 6158, 1726, 304, 523, 986, 199, 199, 318, 485, 1726, 1858, 2364, 8, 1310, 304, 523, 1919, 63, 533, 63, 1130, 275, 469, 272, 1520, 26, 23798, 2162, 12, 272, 1695, 26, 23798, 3160, 12, 272, 1749, 26, 14831, 3110, 12, 272, 1616, 26, 7083, 274, 2162, 5083, 12, 272, 4944, 26, 14831, 547, 12, 272, 5557, 26, 15250, 547, 12, 272, 5851, 26, 1323, 2042, 32060, 12, 272, 6546, 26, 23798, 4301, 12, 272, 5504, 26, 6378, 7810, 7705, 12, 272, 7294, 26, 14914, 6372, 12, 272, 4337, 26, 6378, 11212, 12, 272, 9404, 26, 8596, 1763, 10502, 1726, 12, 272, 2948, 26, 23798, 4434, 523, 789, 523, 2004, 275, 1177, 459, 1205, 418, 523, 1499, 275, 1177, 459, 585, 2545, 1188, 418, 523, 372, 1919, 63, 533, 63, 1130, 14, 362, 8, 1205, 12, 16776, 6158, 1726, 5130, 1328, 9, 421, 199, 533, 16776, 6158, 8, 785, 304, 523, 408, 32142, 436, 13467, 282, 2849, 16776, 1256, 641, 642, 6844, 1041, 819, 347, 636, 826, 721, 277, 12, 1654, 63, 633, 12, 18221, 63, 3008, 29, 403, 12, 15516, 63, 2491, 29, 403, 12, 2049, 18221, 63, 32332, 29, 403, 12, 18221, 63, 5359, 29, 403, 12, 2049, 18221, 63, 793, 63, 515, 29, 403, 304, 272, 291, 423, 13471, 275, 1414, 63, 13471, 14, 3110, 16752, 8, 1000, 63, 633, 9, 339, 1511, 275, 1052, 272, 340, 15516, 63, 2491, 26, 489, 1511, 459, 6238, 8599, 418, 275, 15516, 63, 2491, 272, 916, 18221, 63, 3008, 26, 489, 1511, 459, 3008, 418, 275, 18221, 63, 3008, 339, 340, 18221, 63, 32332, 26, 489, 702, 730, 8, 9887, 63, 32332, 9, 365, 769, 489, 1511, 459, 589, 418, 275, 18221, 63, 32332, 339, 340, 18221, 63, 5359, 26, 489, 702, 730, 8, 9887, 63, 5359, 9, 365, 769, 489, 1511, 459, 5359, 418, 275, 18221, 63, 5359, 339, 340, 18221, 63, 793, 63, 515, 26, 489, 702, 730, 8, 9887, 63, 793, 63, 515, 9, 365, 620, 489, 1511, 459, 793, 2042, 418, 275, 18221, 63, 793, 63, 515, 339, 1862, 275, 469, 489, 283, 16035, 17006, 356, 469, 267, 283, 9887, 4558, 356, 1511, 489, 789, 272, 789, 339, 291, 423, 1730, 63, 344, 275, 291, 423, 13471, 14, 12049, 8, 267, 5817, 14, 11365, 63, 12763, 12, 1862, 11820, 1730, 1304, 418, 819, 347, 485, 15991, 1110, 8, 277, 12, 574, 304, 272, 408, 15991, 574, 687, 1890, 5366, 367, 18221, 3090, 5366, 1041, 272, 340, 1228, 8, 585, 12, 1211, 304, 489, 6702, 275, 1052, 489, 367, 790, 12, 1139, 315, 574, 14, 1744, 837, 267, 6702, 59, 498, 61, 275, 291, 423, 15991, 1110, 8, 637, 9, 489, 372, 6702, 272, 916, 1228, 8, 585, 12, 6001, 2162, 304, 489, 372, 791, 12535, 356, 574, 423, 344, 93, 272, 916, 1228, 8, 585, 12, 769, 304, 489, 372, 769, 8, 277, 423, 15991, 1110, 8, 1053, 9, 367, 1242, 315, 574, 9, 272, 587, 26, 489, 372, 574, 819, 347, 485, 1358, 3823, 1110, 8, 277, 12, 574, 304, 272, 408, 1358, 3823, 574, 687, 18221, 3090, 5366, 367, 1890, 5366, 1041, 272, 340, 1228, 8, 585, 12, 1211, 304, 489, 340, 334, 552, 8, 585, 9, 508, 413, 436, 283, 12535, 7, 315, 574, 881, 436, 1228, 8, 585, 459, 12535, 995, 7116, 2298, 267, 372, 6001, 2162, 8, 277, 12, 574, 459, 12535, 1105, 489, 587, 26, 267, 625, 87, 345, 1915, 275, 1052, 267, 367, 790, 12, 1139, 315, 574, 14, 1744, 837, 881, 625, 87, 345, 1915, 59, 498, 61, 275, 291, 423, 1358, 3823, 1110, 8, 637, 9, 267, 372, 625, 87, 345, 1915, 272, 916, 1228, 8, 585, 12, 769, 304, 489, 372, 769, 8, 277, 423, 1358, 3823, 1110, 8, 1053, 9, 367, 1242, 315, 574, 9, 272, 587, 26, 489, 372, 574, 819, 347, 17009, 3110, 8, 277, 12, 1414, 12, 1862, 16420, 272, 1862, 459, 1730, 1304, 418, 275, 291, 423, 1730, 63, 344, 272, 1862, 275, 291, 423, 15991, 1110, 8, 1162, 9, 272, 1177, 275, 291, 423, 13471, 14, 12049, 8, 1531, 12, 1862, 9, 272, 340, 1177, 459, 1205, 418, 1137, 378, 26, 489, 746, 485, 1726, 1858, 2364, 8, 1310, 9, 272, 372, 291, 423, 1358, 3823, 1110, 8, 1310, 459, 585, 1105, 819, 347, 2372, 4301, 23555, 8, 277, 304, 272, 372, 291, 14, 12049, 3110, 8, 3110, 14, 2970, 63, 15480, 63, 10854, 11344, 9, 819, 347, 17711, 1378, 4301, 8, 277, 12, 2429, 63, 269, 63, 354, 304, 272, 291, 14, 12049, 3110, 8, 3110, 14, 18079, 63, 2566, 63, 15480, 12, 791, 354, 356, 2429, 63, 269, 63, 354, 1552, 819, 347, 2372, 5639, 4301, 5940, 8, 277, 304, 272, 372, 291, 14, 12049, 3110, 8, 3110, 14, 2970, 63, 14211, 63, 15480, 63, 15885, 9, 819, 347, 15524, 4301, 8, 277, 304, 272, 291, 14, 12049, 3110 ]
[ 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 1414, 63, 13471, 199, 504, 1414, 63, 13471, 492, 5817, 199, 504, 781, 1235, 968, 492, 6001, 2162, 421, 199, 533, 16776, 6158, 1726, 8, 1726, 304, 523, 986, 199, 533, 23798, 2162, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 23798, 3160, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 14831, 3110, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 7083, 274, 2162, 5083, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 14831, 547, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 15250, 547, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 1323, 2042, 32060, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 23798, 4301, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 6378, 7810, 7705, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 14914, 6372, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 6378, 11212, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 8596, 1763, 10502, 1726, 8, 18083, 6158, 1726, 304, 523, 986, 199, 533, 23798, 4434, 8, 18083, 6158, 1726, 304, 523, 986, 199, 199, 318, 485, 1726, 1858, 2364, 8, 1310, 304, 523, 1919, 63, 533, 63, 1130, 275, 469, 272, 1520, 26, 23798, 2162, 12, 272, 1695, 26, 23798, 3160, 12, 272, 1749, 26, 14831, 3110, 12, 272, 1616, 26, 7083, 274, 2162, 5083, 12, 272, 4944, 26, 14831, 547, 12, 272, 5557, 26, 15250, 547, 12, 272, 5851, 26, 1323, 2042, 32060, 12, 272, 6546, 26, 23798, 4301, 12, 272, 5504, 26, 6378, 7810, 7705, 12, 272, 7294, 26, 14914, 6372, 12, 272, 4337, 26, 6378, 11212, 12, 272, 9404, 26, 8596, 1763, 10502, 1726, 12, 272, 2948, 26, 23798, 4434, 523, 789, 523, 2004, 275, 1177, 459, 1205, 418, 523, 1499, 275, 1177, 459, 585, 2545, 1188, 418, 523, 372, 1919, 63, 533, 63, 1130, 14, 362, 8, 1205, 12, 16776, 6158, 1726, 5130, 1328, 9, 421, 199, 533, 16776, 6158, 8, 785, 304, 523, 408, 32142, 436, 13467, 282, 2849, 16776, 1256, 641, 642, 6844, 1041, 819, 347, 636, 826, 721, 277, 12, 1654, 63, 633, 12, 18221, 63, 3008, 29, 403, 12, 15516, 63, 2491, 29, 403, 12, 2049, 18221, 63, 32332, 29, 403, 12, 18221, 63, 5359, 29, 403, 12, 2049, 18221, 63, 793, 63, 515, 29, 403, 304, 272, 291, 423, 13471, 275, 1414, 63, 13471, 14, 3110, 16752, 8, 1000, 63, 633, 9, 339, 1511, 275, 1052, 272, 340, 15516, 63, 2491, 26, 489, 1511, 459, 6238, 8599, 418, 275, 15516, 63, 2491, 272, 916, 18221, 63, 3008, 26, 489, 1511, 459, 3008, 418, 275, 18221, 63, 3008, 339, 340, 18221, 63, 32332, 26, 489, 702, 730, 8, 9887, 63, 32332, 9, 365, 769, 489, 1511, 459, 589, 418, 275, 18221, 63, 32332, 339, 340, 18221, 63, 5359, 26, 489, 702, 730, 8, 9887, 63, 5359, 9, 365, 769, 489, 1511, 459, 5359, 418, 275, 18221, 63, 5359, 339, 340, 18221, 63, 793, 63, 515, 26, 489, 702, 730, 8, 9887, 63, 793, 63, 515, 9, 365, 620, 489, 1511, 459, 793, 2042, 418, 275, 18221, 63, 793, 63, 515, 339, 1862, 275, 469, 489, 283, 16035, 17006, 356, 469, 267, 283, 9887, 4558, 356, 1511, 489, 789, 272, 789, 339, 291, 423, 1730, 63, 344, 275, 291, 423, 13471, 14, 12049, 8, 267, 5817, 14, 11365, 63, 12763, 12, 1862, 11820, 1730, 1304, 418, 819, 347, 485, 15991, 1110, 8, 277, 12, 574, 304, 272, 408, 15991, 574, 687, 1890, 5366, 367, 18221, 3090, 5366, 1041, 272, 340, 1228, 8, 585, 12, 1211, 304, 489, 6702, 275, 1052, 489, 367, 790, 12, 1139, 315, 574, 14, 1744, 837, 267, 6702, 59, 498, 61, 275, 291, 423, 15991, 1110, 8, 637, 9, 489, 372, 6702, 272, 916, 1228, 8, 585, 12, 6001, 2162, 304, 489, 372, 791, 12535, 356, 574, 423, 344, 93, 272, 916, 1228, 8, 585, 12, 769, 304, 489, 372, 769, 8, 277, 423, 15991, 1110, 8, 1053, 9, 367, 1242, 315, 574, 9, 272, 587, 26, 489, 372, 574, 819, 347, 485, 1358, 3823, 1110, 8, 277, 12, 574, 304, 272, 408, 1358, 3823, 574, 687, 18221, 3090, 5366, 367, 1890, 5366, 1041, 272, 340, 1228, 8, 585, 12, 1211, 304, 489, 340, 334, 552, 8, 585, 9, 508, 413, 436, 283, 12535, 7, 315, 574, 881, 436, 1228, 8, 585, 459, 12535, 995, 7116, 2298, 267, 372, 6001, 2162, 8, 277, 12, 574, 459, 12535, 1105, 489, 587, 26, 267, 625, 87, 345, 1915, 275, 1052, 267, 367, 790, 12, 1139, 315, 574, 14, 1744, 837, 881, 625, 87, 345, 1915, 59, 498, 61, 275, 291, 423, 1358, 3823, 1110, 8, 637, 9, 267, 372, 625, 87, 345, 1915, 272, 916, 1228, 8, 585, 12, 769, 304, 489, 372, 769, 8, 277, 423, 1358, 3823, 1110, 8, 1053, 9, 367, 1242, 315, 574, 9, 272, 587, 26, 489, 372, 574, 819, 347, 17009, 3110, 8, 277, 12, 1414, 12, 1862, 16420, 272, 1862, 459, 1730, 1304, 418, 275, 291, 423, 1730, 63, 344, 272, 1862, 275, 291, 423, 15991, 1110, 8, 1162, 9, 272, 1177, 275, 291, 423, 13471, 14, 12049, 8, 1531, 12, 1862, 9, 272, 340, 1177, 459, 1205, 418, 1137, 378, 26, 489, 746, 485, 1726, 1858, 2364, 8, 1310, 9, 272, 372, 291, 423, 1358, 3823, 1110, 8, 1310, 459, 585, 1105, 819, 347, 2372, 4301, 23555, 8, 277, 304, 272, 372, 291, 14, 12049, 3110, 8, 3110, 14, 2970, 63, 15480, 63, 10854, 11344, 9, 819, 347, 17711, 1378, 4301, 8, 277, 12, 2429, 63, 269, 63, 354, 304, 272, 291, 14, 12049, 3110, 8, 3110, 14, 18079, 63, 2566, 63, 15480, 12, 791, 354, 356, 2429, 63, 269, 63, 354, 1552, 819, 347, 2372, 5639, 4301, 5940, 8, 277, 304, 272, 372, 291, 14, 12049, 3110, 8, 3110, 14, 2970, 63, 14211, 63, 15480, 63, 15885, 9, 819, 347, 15524, 4301, 8, 277, 304, 272, 291, 14, 12049, 3110, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cherez/youtube-dl
youtube_dl/postprocessor/embedthumbnail.py
109
3507
# -*- coding: utf-8 -*- from __future__ import unicode_literals import os import subprocess from .ffmpeg import FFmpegPostProcessor from ..utils import ( check_executable, encodeArgument, encodeFilename, PostProcessingError, prepend_extension, shell_quote ) class EmbedThumbnailPPError(PostProcessingError): pass class EmbedThumbnailPP(FFmpegPostProcessor): def __init__(self, downloader=None, already_have_thumbnail=False): super(EmbedThumbnailPP, self).__init__(downloader) self._already_have_thumbnail = already_have_thumbnail def run(self, info): filename = info['filepath'] temp_filename = prepend_extension(filename, 'temp') if not info.get('thumbnails'): raise EmbedThumbnailPPError('Thumbnail was not found. Nothing to do.') thumbnail_filename = info['thumbnails'][-1]['filename'] if not os.path.exists(encodeFilename(thumbnail_filename)): self._downloader.report_warning( 'Skipping embedding the thumbnail because the file is missing.') return [], info if info['ext'] == 'mp3': options = [ '-c', 'copy', '-map', '0', '-map', '1', '-metadata:s:v', 'title="Album cover"', '-metadata:s:v', 'comment="Cover (Front)"'] self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename) self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options) if not self._already_have_thumbnail: os.remove(encodeFilename(thumbnail_filename)) os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) elif info['ext'] in ['m4a', 'mp4']: if not check_executable('AtomicParsley', ['-v']): raise EmbedThumbnailPPError('AtomicParsley was not found. Please install.') cmd = [encodeFilename('AtomicParsley', True), encodeFilename(filename, True), encodeArgument('--artwork'), encodeFilename(thumbnail_filename, True), encodeArgument('-o'), encodeFilename(temp_filename, True)] self._downloader.to_screen('[atomicparsley] Adding thumbnail to "%s"' % filename) if self._downloader.params.get('verbose', False): self._downloader.to_screen('[debug] AtomicParsley command line: %s' % shell_quote(cmd)) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode != 0: msg = stderr.decode('utf-8', 'replace').strip() raise EmbedThumbnailPPError(msg) if not self._already_have_thumbnail: os.remove(encodeFilename(thumbnail_filename)) # for formats that don't support thumbnails (like 3gp) AtomicParsley # won't create to the temporary file if b'No changes' in stdout: self._downloader.report_warning('The file format doesn\'t support embedding a thumbnail') else: os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) else: raise EmbedThumbnailPPError('Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.') return [], info
unlicense
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 421, 199, 646, 747, 199, 646, 3873, 199, 199, 504, 1275, 27648, 492, 25046, 16801, 6564, 10438, 199, 199, 504, 2508, 1208, 492, 334, 272, 1104, 63, 5904, 12, 272, 3752, 5201, 12, 272, 3752, 8117, 12, 272, 7711, 9589, 547, 12, 272, 18213, 63, 3435, 12, 272, 5218, 63, 3513, 199, 9, 421, 199, 533, 24297, 2719, 5820, 7701, 547, 8, 6564, 9589, 547, 304, 272, 986, 421, 199, 533, 24297, 2719, 5820, 7701, 8, 1665, 16801, 6564, 10438, 304, 272, 347, 636, 826, 721, 277, 12, 3224, 3422, 29, 403, 12, 2575, 63, 7804, 63, 8311, 29, 797, 304, 267, 1613, 8, 13200, 2719, 5820, 7701, 12, 291, 2843, 826, 721, 22846, 9, 267, 291, 423, 14039, 63, 7804, 63, 8311, 275, 2575, 63, 7804, 63, 8311, 339, 347, 1255, 8, 277, 12, 2256, 304, 267, 1788, 275, 2256, 459, 7218, 418, 267, 2388, 63, 1501, 275, 18213, 63, 3435, 8, 1501, 12, 283, 808, 358, 398, 340, 440, 2256, 14, 362, 360, 8311, 83, 735, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 2719, 5820, 1990, 440, 1911, 14, 20550, 370, 886, 2659, 398, 10062, 63, 1501, 275, 2256, 459, 8311, 83, 31942, 17, 2733, 1501, 418, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 2143, 8117, 8, 8311, 63, 1501, 2298, 288, 291, 423, 22846, 14, 3070, 63, 3764, 8, 355, 283, 18297, 12452, 314, 10062, 2952, 314, 570, 365, 4124, 2659, 288, 372, 990, 2256, 398, 340, 2256, 459, 832, 418, 508, 283, 311, 19, 356, 288, 1511, 275, 359, 355, 2475, 67, 297, 283, 1574, 297, 2475, 1130, 297, 283, 16, 297, 2475, 1130, 297, 283, 17, 297, 355, 2475, 2343, 26, 83, 26, 86, 297, 283, 1213, 628, 26369, 8486, 6949, 2475, 2343, 26, 83, 26, 86, 297, 283, 3349, 628, 31048, 334, 17607, 2924, 418, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 27648, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 291, 14, 1065, 63, 27648, 63, 6048, 63, 1725, 779, 1501, 12, 10062, 63, 1501, 467, 2388, 63, 1501, 12, 1511, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 288, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 398, 916, 2256, 459, 832, 418, 315, 788, 77, 20, 65, 297, 283, 311, 20, 2565, 288, 340, 440, 1104, 63, 5904, 360, 31931, 1262, 83, 15515, 297, 11573, 86, 9090, 355, 746, 24297, 2719, 5820, 7701, 547, 360, 31931, 1262, 83, 15515, 1990, 440, 1911, 14, 7754, 3907, 2659, 953, 2088, 275, 359, 2143, 8117, 360, 31931, 1262, 83, 15515, 297, 715, 395, 673, 3752, 8117, 8, 1501, 12, 715, 395, 673, 3752, 5201, 4517, 580, 800, 659, 673, 3752, 8117, 8, 8311, 63, 1501, 12, 715, 395, 673, 3752, 5201, 3654, 79, 659, 673, 3752, 8117, 8, 808, 63, 1501, 12, 715, 1874, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 10910, 21152, 15515, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 340, 291, 423, 22846, 14, 1162, 14, 362, 360, 3832, 297, 756, 304, 355, 291, 423, 22846, 14, 475, 63, 5410, 11894, 1757, 61, 18840, 530, 1262, 83, 15515, 1414, 1004, 26, 450, 83, 7, 450, 5218, 63, 3513, 8, 1760, 430, 953, 299, 275, 3873, 14, 7942, 8, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 288, 3839, 12, 4635, 275, 299, 14, 10664, 342, 953, 340, 299, 14, 9913, 1137, 378, 26, 355, 1499, 275, 4635, 14, 2708, 360, 1624, 13, 24, 297, 283, 1814, 1959, 1913, 342, 355, 746, 24297, 2719, 5820, 7701, 547, 8, 1328, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 327, 367, 6752, 626, 2793, 1133, 2291, 10062, 83, 334, 2930, 650, 4927, 9, 18840, 530, 1262, 83, 15515, 288, 327, 7859, 1133, 1218, 370, 314, 7937, 570, 288, 340, 330, 7, 1944, 4493, 7, 315, 3839, 26, 355, 291, 423, 22846, 14, 3070, 63, 3764, 360, 1918, 570, 1475, 3181, 3985, 84, 2291, 12452, 282, 10062, 358, 288, 587, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 355, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 267, 587, 26, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 5903, 6118, 19, 436, 333, 20, 65, 15, 311, 20, 787, 3748, 367, 10062, 12452, 367, 3063, 2659, 398, 372, 990, 2256, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 636, 2443, 363, 492, 2649, 63, 5955, 421, 199, 646, 747, 199, 646, 3873, 199, 199, 504, 1275, 27648, 492, 25046, 16801, 6564, 10438, 199, 199, 504, 2508, 1208, 492, 334, 272, 1104, 63, 5904, 12, 272, 3752, 5201, 12, 272, 3752, 8117, 12, 272, 7711, 9589, 547, 12, 272, 18213, 63, 3435, 12, 272, 5218, 63, 3513, 199, 9, 421, 199, 533, 24297, 2719, 5820, 7701, 547, 8, 6564, 9589, 547, 304, 272, 986, 421, 199, 533, 24297, 2719, 5820, 7701, 8, 1665, 16801, 6564, 10438, 304, 272, 347, 636, 826, 721, 277, 12, 3224, 3422, 29, 403, 12, 2575, 63, 7804, 63, 8311, 29, 797, 304, 267, 1613, 8, 13200, 2719, 5820, 7701, 12, 291, 2843, 826, 721, 22846, 9, 267, 291, 423, 14039, 63, 7804, 63, 8311, 275, 2575, 63, 7804, 63, 8311, 339, 347, 1255, 8, 277, 12, 2256, 304, 267, 1788, 275, 2256, 459, 7218, 418, 267, 2388, 63, 1501, 275, 18213, 63, 3435, 8, 1501, 12, 283, 808, 358, 398, 340, 440, 2256, 14, 362, 360, 8311, 83, 735, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 2719, 5820, 1990, 440, 1911, 14, 20550, 370, 886, 2659, 398, 10062, 63, 1501, 275, 2256, 459, 8311, 83, 31942, 17, 2733, 1501, 418, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 2143, 8117, 8, 8311, 63, 1501, 2298, 288, 291, 423, 22846, 14, 3070, 63, 3764, 8, 355, 283, 18297, 12452, 314, 10062, 2952, 314, 570, 365, 4124, 2659, 288, 372, 990, 2256, 398, 340, 2256, 459, 832, 418, 508, 283, 311, 19, 356, 288, 1511, 275, 359, 355, 2475, 67, 297, 283, 1574, 297, 2475, 1130, 297, 283, 16, 297, 2475, 1130, 297, 283, 17, 297, 355, 2475, 2343, 26, 83, 26, 86, 297, 283, 1213, 628, 26369, 8486, 6949, 2475, 2343, 26, 83, 26, 86, 297, 283, 3349, 628, 31048, 334, 17607, 2924, 418, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 27648, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 291, 14, 1065, 63, 27648, 63, 6048, 63, 1725, 779, 1501, 12, 10062, 63, 1501, 467, 2388, 63, 1501, 12, 1511, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 288, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 398, 916, 2256, 459, 832, 418, 315, 788, 77, 20, 65, 297, 283, 311, 20, 2565, 288, 340, 440, 1104, 63, 5904, 360, 31931, 1262, 83, 15515, 297, 11573, 86, 9090, 355, 746, 24297, 2719, 5820, 7701, 547, 360, 31931, 1262, 83, 15515, 1990, 440, 1911, 14, 7754, 3907, 2659, 953, 2088, 275, 359, 2143, 8117, 360, 31931, 1262, 83, 15515, 297, 715, 395, 673, 3752, 8117, 8, 1501, 12, 715, 395, 673, 3752, 5201, 4517, 580, 800, 659, 673, 3752, 8117, 8, 8311, 63, 1501, 12, 715, 395, 673, 3752, 5201, 3654, 79, 659, 673, 3752, 8117, 8, 808, 63, 1501, 12, 715, 1874, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 10910, 21152, 15515, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 340, 291, 423, 22846, 14, 1162, 14, 362, 360, 3832, 297, 756, 304, 355, 291, 423, 22846, 14, 475, 63, 5410, 11894, 1757, 61, 18840, 530, 1262, 83, 15515, 1414, 1004, 26, 450, 83, 7, 450, 5218, 63, 3513, 8, 1760, 430, 953, 299, 275, 3873, 14, 7942, 8, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 288, 3839, 12, 4635, 275, 299, 14, 10664, 342, 953, 340, 299, 14, 9913, 1137, 378, 26, 355, 1499, 275, 4635, 14, 2708, 360, 1624, 13, 24, 297, 283, 1814, 1959, 1913, 342, 355, 746, 24297, 2719, 5820, 7701, 547, 8, 1328, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 327, 367, 6752, 626, 2793, 1133, 2291, 10062, 83, 334, 2930, 650, 4927, 9, 18840, 530, 1262, 83, 15515, 288, 327, 7859, 1133, 1218, 370, 314, 7937, 570, 288, 340, 330, 7, 1944, 4493, 7, 315, 3839, 26, 355, 291, 423, 22846, 14, 3070, 63, 3764, 360, 1918, 570, 1475, 3181, 3985, 84, 2291, 12452, 282, 10062, 358, 288, 587, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 355, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 267, 587, 26, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 5903, 6118, 19, 436, 333, 20, 65, 15, 311, 20, 787, 3748, 367, 10062, 12452, 367, 3063, 2659, 398, 372, 990, 2256, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tadebayo/myedge
myvenv/Lib/site-packages/PIL/ImageFile.py
14
16320
# # The Python Imaging Library. # $Id$ # # base class for image file handlers # # history: # 1995-09-09 fl Created # 1996-03-11 fl Fixed load mechanism. # 1996-04-15 fl Added pcx/xbm decoders. # 1996-04-30 fl Added encoders. # 1996-12-14 fl Added load helpers # 1997-01-11 fl Use encode_to_file where possible # 1997-08-27 fl Flush output in _save # 1998-03-05 fl Use memory mapping for some modes # 1999-02-04 fl Use memory mapping also for "I;16" and "I;16B" # 1999-05-31 fl Added image parser # 2000-10-12 fl Set readonly flag on memory-mapped images # 2002-03-20 fl Use better messages for common decoder errors # 2003-04-21 fl Fall back on mmap/map_buffer if map is not available # 2003-10-30 fl Added StubImageFile class # 2004-02-25 fl Made incremental parser more robust # # Copyright (c) 1997-2004 by Secret Labs AB # Copyright (c) 1995-2004 by Fredrik Lundh # # See the README file for information on usage and redistribution. # from PIL import Image from PIL._util import isPath import io import os import sys import struct MAXBLOCK = 65536 SAFEBLOCK = 1024*1024 LOAD_TRUNCATED_IMAGES = False ERRORS = { -1: "image buffer overrun error", -2: "decoding error", -3: "unknown error", -8: "bad configuration", -9: "out of memory error" } def raise_ioerror(error): try: message = Image.core.getcodecstatus(error) except AttributeError: message = ERRORS.get(error) if not message: message = "decoder error %d" % error raise IOError(message + " when reading image file") # # -------------------------------------------------------------------- # Helpers def _tilesort(t): # sort on offset return t[2] # # -------------------------------------------------------------------- # ImageFile base class class ImageFile(Image.Image): "Base class for image file format handlers." def __init__(self, fp=None, filename=None): Image.Image.__init__(self) self.tile = None self.readonly = 1 # until we know better self.decoderconfig = () self.decodermaxblock = MAXBLOCK if isPath(fp): # filename self.fp = open(fp, "rb") self.filename = fp else: # stream self.fp = fp self.filename = filename try: self._open() except (IndexError, # end of data TypeError, # end of data (ord) KeyError, # unsupported mode EOFError, # got header but not the first frame struct.error) as v: raise SyntaxError(v) if not self.mode or self.size[0] <= 0: raise SyntaxError("not identified by this driver") def draft(self, mode, size): "Set draft mode" pass def verify(self): "Check file integrity" # raise exception if something's wrong. must be called # directly after open, and closes file when finished. self.fp = None def load(self): "Load image data based on tile list" pixel = Image.Image.load(self) if self.tile is None: raise IOError("cannot load this image") if not self.tile: return pixel self.map = None use_mmap = self.filename and len(self.tile) == 1 # As of pypy 2.1.0, memory mapping was failing here. use_mmap = use_mmap and not hasattr(sys, 'pypy_version_info') readonly = 0 # look for read/seek overrides try: read = self.load_read # don't use mmap if there are custom read/seek functions use_mmap = False except AttributeError: read = self.fp.read try: seek = self.load_seek use_mmap = False except AttributeError: seek = self.fp.seek if use_mmap: # try memory mapping decoder_name, extents, offset, args = self.tile[0] if decoder_name == "raw" and len(args) >= 3 and args[0] == self.mode \ and args[0] in Image._MAPMODES: try: if hasattr(Image.core, "map"): # use built-in mapper WIN32 only self.map = Image.core.map(self.filename) self.map.seek(offset) self.im = self.map.readimage( self.mode, self.size, args[1], args[2] ) else: # use mmap, if possible import mmap fp = open(self.filename, "r") size = os.path.getsize(self.filename) self.map = mmap.mmap(fp.fileno(), size, access=mmap.ACCESS_READ) self.im = Image.core.map_buffer( self.map, self.size, decoder_name, extents, offset, args ) readonly = 1 # After trashing self.im, we might need to reload the palette data. if self.palette: self.palette.dirty = 1 except (AttributeError, EnvironmentError, ImportError): self.map = None self.load_prepare() if not self.map: # sort tiles in file order self.tile.sort(key=_tilesort) try: # FIXME: This is a hack to handle TIFF's JpegTables tag. prefix = self.tile_prefix except AttributeError: prefix = b"" for decoder_name, extents, offset, args in self.tile: decoder = Image._getdecoder(self.mode, decoder_name, args, self.decoderconfig) seek(offset) try: decoder.setimage(self.im, extents) except ValueError: continue if decoder.pulls_fd: decoder.setfd(self.fp) status, err_code = decoder.decode(b"") else: b = prefix while True: try: s = read(self.decodermaxblock) except (IndexError, struct.error): # truncated png/gif if LOAD_TRUNCATED_IMAGES: break else: raise IOError("image file is truncated") if not s: # truncated jpeg self.tile = [] # JpegDecode needs to clean things up here either way # If we don't destroy the decompressor, # we have a memory leak. decoder.cleanup() if LOAD_TRUNCATED_IMAGES: break else: raise IOError("image file is truncated " "(%d bytes not processed)" % len(b)) b = b + s n, err_code = decoder.decode(b) if n < 0: break b = b[n:] # Need to cleanup here to prevent leaks in PyPy decoder.cleanup() self.tile = [] self.readonly = readonly self.fp = None # might be shared if not self.map and not LOAD_TRUNCATED_IMAGES and err_code < 0: # still raised if decoder fails to return anything raise_ioerror(err_code) self.load_end() return Image.Image.load(self) def load_prepare(self): # create image memory if necessary if not self.im or\ self.im.mode != self.mode or self.im.size != self.size: self.im = Image.core.new(self.mode, self.size) # create palette (optional) if self.mode == "P": Image.Image.load(self) def load_end(self): # may be overridden pass # may be defined for contained formats # def load_seek(self, pos): # pass # may be defined for blocked formats (e.g. PNG) # def load_read(self, bytes): # pass class StubImageFile(ImageFile): """ Base class for stub image loaders. A stub loader is an image loader that can identify files of a certain format, but relies on external code to load the file. """ def _open(self): raise NotImplementedError( "StubImageFile subclass must implement _open" ) def load(self): loader = self._load() if loader is None: raise IOError("cannot find loader for this %s file" % self.format) image = loader.load(self) assert image is not None # become the other object (!) self.__class__ = image.__class__ self.__dict__ = image.__dict__ def _load(self): "(Hook) Find actual image loader." raise NotImplementedError( "StubImageFile subclass must implement _load" ) class Parser(object): """ Incremental image parser. This class implements the standard feed/close consumer interface. """ incremental = None image = None data = None decoder = None offset = 0 finished = 0 def reset(self): """ (Consumer) Reset the parser. Note that you can only call this method immediately after you've created a parser; parser instances cannot be reused. """ assert self.data is None, "cannot reuse parsers" def feed(self, data): """ (Consumer) Feed data to the parser. :param data: A string buffer. :exception IOError: If the parser failed to parse the image file. """ # collect data if self.finished: return if self.data is None: self.data = data else: self.data = self.data + data # parse what we have if self.decoder: if self.offset > 0: # skip header skip = min(len(self.data), self.offset) self.data = self.data[skip:] self.offset = self.offset - skip if self.offset > 0 or not self.data: return n, e = self.decoder.decode(self.data) if n < 0: # end of stream self.data = None self.finished = 1 if e < 0: # decoding error self.image = None raise_ioerror(e) else: # end of image return self.data = self.data[n:] elif self.image: # if we end up here with no decoder, this file cannot # be incrementally parsed. wait until we've gotten all # available data pass else: # attempt to open this file try: try: fp = io.BytesIO(self.data) im = Image.open(fp) finally: fp.close() # explicitly close the virtual file except IOError: # traceback.print_exc() pass # not enough data else: flag = hasattr(im, "load_seek") or hasattr(im, "load_read") if flag or len(im.tile) != 1: # custom load code, or multiple tiles self.decode = None else: # initialize decoder im.load_prepare() d, e, o, a = im.tile[0] im.tile = [] self.decoder = Image._getdecoder( im.mode, d, a, im.decoderconfig ) self.decoder.setimage(im.im, e) # calculate decoder offset self.offset = o if self.offset <= len(self.data): self.data = self.data[self.offset:] self.offset = 0 self.image = im def close(self): """ (Consumer) Close the stream. :returns: An image object. :exception IOError: If the parser failed to parse the image file either because it cannot be identified or cannot be decoded. """ # finish decoding if self.decoder: # get rid of what's left in the buffers self.feed(b"") self.data = self.decoder = None if not self.finished: raise IOError("image was incomplete") if not self.image: raise IOError("cannot parse this image") if self.data: # incremental parsing not possible; reopen the file # not that we have all data try: fp = io.BytesIO(self.data) self.image = Image.open(fp) finally: self.image.load() fp.close() # explicitly close the virtual file return self.image # -------------------------------------------------------------------- def _save(im, fp, tile, bufsize=0): """Helper to save image based on tile list :param im: Image object. :param fp: File object. :param tile: Tile list. :param bufsize: Optional buffer size """ im.load() if not hasattr(im, "encoderconfig"): im.encoderconfig = () tile.sort(key=_tilesort) # FIXME: make MAXBLOCK a configuration parameter # It would be great if we could have the encoder specify what it needs # But, it would need at least the image size in most cases. RawEncode is # a tricky case. bufsize = max(MAXBLOCK, bufsize, im.size[0] * 4) # see RawEncode.c if fp == sys.stdout: fp.flush() return try: fh = fp.fileno() fp.flush() except (AttributeError, io.UnsupportedOperation): # compress to Python file-compatible object for e, b, o, a in tile: e = Image._getencoder(im.mode, e, a, im.encoderconfig) if o > 0: fp.seek(o, 0) e.setimage(im.im, b) if e.pushes_fd: e.setfd(fp) l, s = e.encode_to_pyfd() else: while True: l, s, d = e.encode(bufsize) fp.write(d) if s: break if s < 0: raise IOError("encoder error %d when writing image file" % s) e.cleanup() else: # slight speedup: compress to real file object for e, b, o, a in tile: e = Image._getencoder(im.mode, e, a, im.encoderconfig) if o > 0: fp.seek(o, 0) e.setimage(im.im, b) if e.pushes_fd: e.setfd(fp) l, s = e.encode_to_pyfd() else: s = e.encode_to_file(fh, bufsize) if s < 0: raise IOError("encoder error %d when writing image file" % s) e.cleanup() if hasattr(fp, "flush"): fp.flush() def _safe_read(fp, size): """ Reads large blocks in a safe way. Unlike fp.read(n), this function doesn't trust the user. If the requested size is larger than SAFEBLOCK, the file is read block by block. :param fp: File handle. Must implement a <b>read</b> method. :param size: Number of bytes to read. :returns: A string containing up to <i>size</i> bytes of data. """ if size <= 0: return b"" if size <= SAFEBLOCK: return fp.read(size) data = [] while size > 0: block = fp.read(min(size, SAFEBLOCK)) if not block: break data.append(block) size -= len(block) return b"".join(data)
mit
[ 3, 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 1300, 1021, 367, 1834, 570, 8297, 199, 3, 199, 3, 7994, 26, 199, 3, 9013, 21, 13, 1643, 13, 1643, 2717, 257, 18208, 199, 3, 31347, 13, 1644, 13, 845, 2717, 257, 18659, 2248, 14729, 14, 199, 3, 31347, 13, 966, 13, 1046, 2717, 257, 16230, 299, 11859, 15, 1774, 77, 10334, 83, 14, 199, 3, 31347, 13, 966, 13, 1216, 2717, 257, 16230, 10295, 83, 14, 199, 3, 31347, 13, 713, 13, 1079, 2717, 257, 16230, 2248, 10897, 199, 3, 9013, 23, 13, 614, 13, 845, 2717, 257, 3645, 3752, 63, 475, 63, 493, 2382, 3962, 199, 3, 9013, 23, 13, 2036, 13, 1465, 2717, 257, 11040, 2084, 1072, 315, 485, 2117, 199, 3, 19960, 13, 1644, 13, 1717, 2717, 257, 3645, 4402, 4412, 367, 2005, 12404, 199, 3, 21300, 13, 996, 13, 966, 2717, 257, 3645, 4402, 4412, 2597, 367, 298, 41, 27, 975, 2, 436, 298, 41, 27, 975, 34, 2, 199, 3, 21300, 13, 1717, 13, 2192, 2717, 257, 16230, 1834, 1798, 199, 3, 12293, 13, 709, 13, 713, 2717, 257, 2494, 6863, 3305, 641, 4402, 13, 11663, 5935, 199, 3, 14790, 13, 1644, 13, 1165, 2717, 257, 3645, 8034, 3788, 367, 2863, 10334, 2552, 199, 3, 13004, 13, 966, 13, 2025, 2717, 257, 481, 452, 1771, 641, 21991, 15, 1130, 63, 2738, 340, 2341, 365, 440, 2808, 199, 3, 13004, 13, 709, 13, 1216, 2717, 257, 16230, 23429, 30636, 1021, 199, 3, 8353, 13, 996, 13, 821, 2717, 257, 603, 9587, 16316, 1798, 1655, 23399, 199, 3, 199, 3, 1898, 334, 67, 9, 9013, 23, 13, 15431, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 9013, 21, 13, 15431, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 504, 14937, 492, 6047, 199, 504, 14937, 423, 1974, 492, 365, 2042, 199, 646, 5890, 199, 646, 747, 199, 646, 984, 199, 646, 2702, 199, 199, 4283, 8475, 275, 25980, 199, 199, 27657, 8475, 275, 6619, 10, 7727, 199, 199, 7405, 63, 22346, 6989, 63, 1469, 5383, 275, 756, 199, 199, 21477, 275, 469, 272, 446, 17, 26, 298, 1569, 3335, 1806, 1065, 1125, 401, 272, 446, 18, 26, 298, 12796, 1125, 401, 272, 446, 19, 26, 298, 5187, 1125, 401, 272, 446, 24, 26, 298, 4087, 2897, 401, 272, 446, 25, 26, 298, 548, 402, 4402, 1125, 2, 199, 93, 421, 199, 318, 746, 63, 2308, 705, 8, 705, 304, 272, 862, 26, 267, 1245, 275, 6047, 14, 1018, 14, 362, 9276, 1205, 8, 705, 9, 272, 871, 4281, 26, 267, 1245, 275, 12539, 51, 14, 362, 8, 705, 9, 272, 340, 440, 1245, 26, 267, 1245, 275, 298, 8813, 1125, 450, 68, 2, 450, 1125, 272, 746, 5925, 8, 1188, 435, 298, 1380, 7664, 1834, 570, 531, 421, 199, 3, 199, 3, 23567, 199, 3, 11642, 83, 199, 199, 318, 485, 18819, 361, 8, 84, 304, 272, 327, 4069, 641, 3268, 272, 372, 307, 59, 18, 61, 421, 199, 3, 199, 3, 23567, 199, 3, 6047, 1173, 1300, 1021, 199, 199, 533, 6047, 1173, 8, 3491, 14, 3491, 304, 272, 298, 1563, 1021, 367, 1834, 570, 1475, 8297, 2122, 339, 347, 636, 826, 721, 277, 12, 4090, 29, 403, 12, 1788, 29, 403, 304, 267, 6047, 14, 3491, 855, 826, 721, 277, 9, 398, 291, 14, 7172, 275, 488, 267, 291, 14, 6753, 275, 413, 221, 327, 5133, 781, 5715, 8034, 398, 291, 14, 8813, 888, 275, 6248, 267, 291, 14, 8813, 988, 1457, 275, 9141, 8475, 398, 340, 365, 2042, 8, 3997, 304, 288, 327, 1788, 288, 291, 14, 3997, 275, 1551, 8, 3997, 12, 298, 4848, 531, 288, 291, 14, 1501, 275, 4090, 267, 587, 26, 288, 327, 2547, 288, 291, 14, 3997, 275, 4090, 288, 291, 14, 1501, 275, 1788, 398, 862, 26, 288, 291, 423, 1490, 342, 267, 871, 334, 12129, 12, 221, 327, 1284, 402, 666, 355, 3146, 12, 221, 327, 1284, 402, 666, 334, 2181, 9, 355, 4067, 12, 221, 327, 16313, 818, 355, 21157, 12, 221, 327, 4788, 1406, 1325, 440, 314, 1642, 2787, 355, 2702, 14, 705, 9, 465, 373, 26, 288, 746, 12053, 8, 86, 9, 398, 340, 440, 291, 14, 632, 503, 291, 14, 890, 59, 16, 61, 2695, 378, 26, 288, 746, 12053, 480, 1397, 15836, 701, 642, 5253, 531, 339, 347, 11872, 8, 277, 12, 818, 12, 1568, 304, 267, 298, 1084, 11872, 818, 2, 398, 986, 339, 347, 4911, 8, 277, 304, 267, 298, 1799, 570, 4661, 12997, 2, 398, 327, 746, 1919, 340, 6020, 1159, 6835, 14, 221, 1471, 506, 2797, 267, 327, 5370, 2410, 1551, 12, 436, 27811, 570, 1380, 9158, 14, 267, 291, 14, 3997, 275, 488, 339, 347, 2248, 8, 277, 304, 267, 298, 6200, 1834, 666, 4079, 641, 12835, 769, 2, 398, 7148, 275, 6047, 14, 3491, 14, 912, 8, 277, 9, 398, 340, 291, 14, 7172, 365, 488, 26, 288, 746, 5925, 480, 11250, 2248, 642, 1834, 531, 267, 340, 440, 291, 14, 7172, 26, 288, 372, 7148, 398, 291, 14, 1130, 275, 488, 267, 675, 63, 20671, 275, 291, 14, 1501, 436, 822, 8, 277, 14, 7172, 9, 508, 413, 267, 327, 3709, 402, 1134, 647, 499, 14, 17, 14, 16, 12, 4402, 4412, 1990, 18648, 2348, 14, 267, 675, 63, 20671, 275, 675, 63, 20671, 436, 440, 2688, 8, 1274, 12, 283, 20233, 63, 1023, 63, 815, 358, 398, 6863, 275, 378, 398, 327, 3648, 367, 1586, 15, 5507, 10580, 267, 862, 26, 288, 1586, 275, 291, 14, 912, 63, 739, 288, 327, 2793, 1133, 675, 21991, 340, 2337, 787, 3537, 1586, 15, 5507, 3423, 288, 675, 63, 20671, 275, 756, 267, 871, 4281, 26, 288, 1586, 275, 291, 14, 3997, 14, 739, 398, 862, 26, 288, 12005, 275, 291, 14, 912, 63, 5507, 288, 675, 63, 20671, 275, 756, 267, 871, 4281, 26, 288, 12005, 275, 291, 14, 3997, 14, 5507, 398, 340, 675, 63, 20671, 26, 288, 327, 862, 4402, 4412, 288, 10334, 63, 354, 12 ]
[ 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 1300, 1021, 367, 1834, 570, 8297, 199, 3, 199, 3, 7994, 26, 199, 3, 9013, 21, 13, 1643, 13, 1643, 2717, 257, 18208, 199, 3, 31347, 13, 1644, 13, 845, 2717, 257, 18659, 2248, 14729, 14, 199, 3, 31347, 13, 966, 13, 1046, 2717, 257, 16230, 299, 11859, 15, 1774, 77, 10334, 83, 14, 199, 3, 31347, 13, 966, 13, 1216, 2717, 257, 16230, 10295, 83, 14, 199, 3, 31347, 13, 713, 13, 1079, 2717, 257, 16230, 2248, 10897, 199, 3, 9013, 23, 13, 614, 13, 845, 2717, 257, 3645, 3752, 63, 475, 63, 493, 2382, 3962, 199, 3, 9013, 23, 13, 2036, 13, 1465, 2717, 257, 11040, 2084, 1072, 315, 485, 2117, 199, 3, 19960, 13, 1644, 13, 1717, 2717, 257, 3645, 4402, 4412, 367, 2005, 12404, 199, 3, 21300, 13, 996, 13, 966, 2717, 257, 3645, 4402, 4412, 2597, 367, 298, 41, 27, 975, 2, 436, 298, 41, 27, 975, 34, 2, 199, 3, 21300, 13, 1717, 13, 2192, 2717, 257, 16230, 1834, 1798, 199, 3, 12293, 13, 709, 13, 713, 2717, 257, 2494, 6863, 3305, 641, 4402, 13, 11663, 5935, 199, 3, 14790, 13, 1644, 13, 1165, 2717, 257, 3645, 8034, 3788, 367, 2863, 10334, 2552, 199, 3, 13004, 13, 966, 13, 2025, 2717, 257, 481, 452, 1771, 641, 21991, 15, 1130, 63, 2738, 340, 2341, 365, 440, 2808, 199, 3, 13004, 13, 709, 13, 1216, 2717, 257, 16230, 23429, 30636, 1021, 199, 3, 8353, 13, 996, 13, 821, 2717, 257, 603, 9587, 16316, 1798, 1655, 23399, 199, 3, 199, 3, 1898, 334, 67, 9, 9013, 23, 13, 15431, 701, 23580, 491, 2101, 14840, 199, 3, 1898, 334, 67, 9, 9013, 21, 13, 15431, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 504, 14937, 492, 6047, 199, 504, 14937, 423, 1974, 492, 365, 2042, 199, 646, 5890, 199, 646, 747, 199, 646, 984, 199, 646, 2702, 199, 199, 4283, 8475, 275, 25980, 199, 199, 27657, 8475, 275, 6619, 10, 7727, 199, 199, 7405, 63, 22346, 6989, 63, 1469, 5383, 275, 756, 199, 199, 21477, 275, 469, 272, 446, 17, 26, 298, 1569, 3335, 1806, 1065, 1125, 401, 272, 446, 18, 26, 298, 12796, 1125, 401, 272, 446, 19, 26, 298, 5187, 1125, 401, 272, 446, 24, 26, 298, 4087, 2897, 401, 272, 446, 25, 26, 298, 548, 402, 4402, 1125, 2, 199, 93, 421, 199, 318, 746, 63, 2308, 705, 8, 705, 304, 272, 862, 26, 267, 1245, 275, 6047, 14, 1018, 14, 362, 9276, 1205, 8, 705, 9, 272, 871, 4281, 26, 267, 1245, 275, 12539, 51, 14, 362, 8, 705, 9, 272, 340, 440, 1245, 26, 267, 1245, 275, 298, 8813, 1125, 450, 68, 2, 450, 1125, 272, 746, 5925, 8, 1188, 435, 298, 1380, 7664, 1834, 570, 531, 421, 199, 3, 199, 3, 23567, 199, 3, 11642, 83, 199, 199, 318, 485, 18819, 361, 8, 84, 304, 272, 327, 4069, 641, 3268, 272, 372, 307, 59, 18, 61, 421, 199, 3, 199, 3, 23567, 199, 3, 6047, 1173, 1300, 1021, 199, 199, 533, 6047, 1173, 8, 3491, 14, 3491, 304, 272, 298, 1563, 1021, 367, 1834, 570, 1475, 8297, 2122, 339, 347, 636, 826, 721, 277, 12, 4090, 29, 403, 12, 1788, 29, 403, 304, 267, 6047, 14, 3491, 855, 826, 721, 277, 9, 398, 291, 14, 7172, 275, 488, 267, 291, 14, 6753, 275, 413, 221, 327, 5133, 781, 5715, 8034, 398, 291, 14, 8813, 888, 275, 6248, 267, 291, 14, 8813, 988, 1457, 275, 9141, 8475, 398, 340, 365, 2042, 8, 3997, 304, 288, 327, 1788, 288, 291, 14, 3997, 275, 1551, 8, 3997, 12, 298, 4848, 531, 288, 291, 14, 1501, 275, 4090, 267, 587, 26, 288, 327, 2547, 288, 291, 14, 3997, 275, 4090, 288, 291, 14, 1501, 275, 1788, 398, 862, 26, 288, 291, 423, 1490, 342, 267, 871, 334, 12129, 12, 221, 327, 1284, 402, 666, 355, 3146, 12, 221, 327, 1284, 402, 666, 334, 2181, 9, 355, 4067, 12, 221, 327, 16313, 818, 355, 21157, 12, 221, 327, 4788, 1406, 1325, 440, 314, 1642, 2787, 355, 2702, 14, 705, 9, 465, 373, 26, 288, 746, 12053, 8, 86, 9, 398, 340, 440, 291, 14, 632, 503, 291, 14, 890, 59, 16, 61, 2695, 378, 26, 288, 746, 12053, 480, 1397, 15836, 701, 642, 5253, 531, 339, 347, 11872, 8, 277, 12, 818, 12, 1568, 304, 267, 298, 1084, 11872, 818, 2, 398, 986, 339, 347, 4911, 8, 277, 304, 267, 298, 1799, 570, 4661, 12997, 2, 398, 327, 746, 1919, 340, 6020, 1159, 6835, 14, 221, 1471, 506, 2797, 267, 327, 5370, 2410, 1551, 12, 436, 27811, 570, 1380, 9158, 14, 267, 291, 14, 3997, 275, 488, 339, 347, 2248, 8, 277, 304, 267, 298, 6200, 1834, 666, 4079, 641, 12835, 769, 2, 398, 7148, 275, 6047, 14, 3491, 14, 912, 8, 277, 9, 398, 340, 291, 14, 7172, 365, 488, 26, 288, 746, 5925, 480, 11250, 2248, 642, 1834, 531, 267, 340, 440, 291, 14, 7172, 26, 288, 372, 7148, 398, 291, 14, 1130, 275, 488, 267, 675, 63, 20671, 275, 291, 14, 1501, 436, 822, 8, 277, 14, 7172, 9, 508, 413, 267, 327, 3709, 402, 1134, 647, 499, 14, 17, 14, 16, 12, 4402, 4412, 1990, 18648, 2348, 14, 267, 675, 63, 20671, 275, 675, 63, 20671, 436, 440, 2688, 8, 1274, 12, 283, 20233, 63, 1023, 63, 815, 358, 398, 6863, 275, 378, 398, 327, 3648, 367, 1586, 15, 5507, 10580, 267, 862, 26, 288, 1586, 275, 291, 14, 912, 63, 739, 288, 327, 2793, 1133, 675, 21991, 340, 2337, 787, 3537, 1586, 15, 5507, 3423, 288, 675, 63, 20671, 275, 756, 267, 871, 4281, 26, 288, 1586, 275, 291, 14, 3997, 14, 739, 398, 862, 26, 288, 12005, 275, 291, 14, 912, 63, 5507, 288, 675, 63, 20671, 275, 756, 267, 871, 4281, 26, 288, 12005, 275, 291, 14, 3997, 14, 5507, 398, 340, 675, 63, 20671, 26, 288, 327, 862, 4402, 4412, 288, 10334, 63, 354, 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,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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 ]
jcpowermac/ansible
test/sanity/code-smell/no-assert.py
18
1257
#!/usr/bin/env python from __future__ import print_function import os import re import sys from collections import defaultdict PATH = 'lib/ansible' ASSERT_RE = re.compile(r'.*(?<![-:a-zA-Z#][ -])\bassert\b(?!:).*') all_matches = defaultdict(list) for dirpath, dirnames, filenames in os.walk(PATH): for filename in filenames: path = os.path.join(dirpath, filename) if not os.path.isfile(path) or not path.endswith('.py'): continue with open(path, 'r') as f: for i, line in enumerate(f.readlines()): matches = ASSERT_RE.findall(line) if matches: all_matches[path].append((i + 1, line.index('assert') + 1, matches)) if all_matches: print('Use of assert in production code is not recommended.') print('Python will remove all assert statements if run with optimizations') print('Alternatives:') print(' if not isinstance(value, dict):') print(' raise AssertionError("Expected a dict for value")') for path, matches in all_matches.items(): for line_matches in matches: for match in line_matches[2]: print('%s:%d:%d: %s' % ((path,) + line_matches[:2] + (match,))) sys.exit(1)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 504, 5055, 492, 10018, 199, 199, 3243, 275, 283, 773, 15, 4853, 7, 199, 24790, 63, 907, 275, 295, 14, 2014, 8, 82, 24898, 2229, 11230, 1988, 26, 65, 13, 6353, 13, 58, 3, 1527, 446, 27147, 66, 479, 60, 66, 26313, 26, 680, 13418, 199, 199, 452, 63, 6742, 275, 10018, 8, 513, 9, 199, 199, 509, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 3243, 304, 272, 367, 1788, 315, 6203, 26, 267, 931, 275, 747, 14, 515, 14, 904, 8, 17254, 12, 1788, 9, 267, 340, 440, 747, 14, 515, 14, 6292, 8, 515, 9, 503, 440, 931, 14, 4130, 5175, 647, 735, 288, 1980, 398, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 289, 26, 288, 367, 284, 12, 1004, 315, 3874, 8, 70, 14, 9684, 5109, 355, 4450, 275, 17567, 5397, 63, 907, 14, 6452, 8, 604, 9, 2234, 340, 4450, 26, 490, 1006, 63, 6742, 59, 515, 1055, 740, 1332, 73, 435, 413, 12, 1004, 14, 1080, 360, 479, 358, 435, 413, 12, 4450, 430, 421, 199, 692, 1006, 63, 6742, 26, 272, 870, 360, 6119, 402, 702, 315, 9920, 1233, 365, 440, 14318, 2659, 272, 870, 360, 4718, 911, 2813, 1006, 702, 9834, 340, 1255, 543, 5323, 12270, 358, 272, 870, 360, 19978, 10661, 10993, 272, 870, 360, 259, 340, 440, 1228, 8, 585, 12, 1211, 304, 358, 272, 870, 360, 263, 746, 9070, 480, 6964, 282, 1211, 367, 574, 531, 358, 339, 367, 931, 12, 4450, 315, 1006, 63, 6742, 14, 1744, 837, 267, 367, 1004, 63, 6742, 315, 4450, 26, 288, 367, 1336, 315, 1004, 63, 6742, 59, 18, 2189, 355, 870, 3508, 83, 2689, 68, 2689, 68, 26, 450, 83, 7, 450, 3666, 515, 4258, 435, 1004, 63, 6742, 1491, 18, 61, 435, 334, 1431, 20097, 272, 984, 14, 2224, 8, 17, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 504, 5055, 492, 10018, 199, 199, 3243, 275, 283, 773, 15, 4853, 7, 199, 24790, 63, 907, 275, 295, 14, 2014, 8, 82, 24898, 2229, 11230, 1988, 26, 65, 13, 6353, 13, 58, 3, 1527, 446, 27147, 66, 479, 60, 66, 26313, 26, 680, 13418, 199, 199, 452, 63, 6742, 275, 10018, 8, 513, 9, 199, 199, 509, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 3243, 304, 272, 367, 1788, 315, 6203, 26, 267, 931, 275, 747, 14, 515, 14, 904, 8, 17254, 12, 1788, 9, 267, 340, 440, 747, 14, 515, 14, 6292, 8, 515, 9, 503, 440, 931, 14, 4130, 5175, 647, 735, 288, 1980, 398, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 289, 26, 288, 367, 284, 12, 1004, 315, 3874, 8, 70, 14, 9684, 5109, 355, 4450, 275, 17567, 5397, 63, 907, 14, 6452, 8, 604, 9, 2234, 340, 4450, 26, 490, 1006, 63, 6742, 59, 515, 1055, 740, 1332, 73, 435, 413, 12, 1004, 14, 1080, 360, 479, 358, 435, 413, 12, 4450, 430, 421, 199, 692, 1006, 63, 6742, 26, 272, 870, 360, 6119, 402, 702, 315, 9920, 1233, 365, 440, 14318, 2659, 272, 870, 360, 4718, 911, 2813, 1006, 702, 9834, 340, 1255, 543, 5323, 12270, 358, 272, 870, 360, 19978, 10661, 10993, 272, 870, 360, 259, 340, 440, 1228, 8, 585, 12, 1211, 304, 358, 272, 870, 360, 263, 746, 9070, 480, 6964, 282, 1211, 367, 574, 531, 358, 339, 367, 931, 12, 4450, 315, 1006, 63, 6742, 14, 1744, 837, 267, 367, 1004, 63, 6742, 315, 4450, 26, 288, 367, 1336, 315, 1004, 63, 6742, 59, 18, 2189, 355, 870, 3508, 83, 2689, 68, 2689, 68, 26, 450, 83, 7, 450, 3666, 515, 4258, 435, 1004, 63, 6742, 1491, 18, 61, 435, 334, 1431, 20097, 272, 984, 14, 2224, 8, 17, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mcepl/youtube-dl
youtube_dl/extractor/threeqsdn.py
76
5328
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, js_to_json, mimetype2ext, ) class ThreeQSDNIE(InfoExtractor): IE_NAME = '3qsdn' IE_DESC = '3Q SDN' _VALID_URL = r'https?://playout\.3qsdn\.com/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})' _TESTS = [{ # ondemand from http://www.philharmonie.tv/veranstaltung/26/ 'url': 'http://playout.3qsdn.com/0280d6b9-1215-11e6-b427-0cc47a188158?protocol=http', 'md5': 'ab040e37bcfa2e0c079f92cb1dd7f6cd', 'info_dict': { 'id': '0280d6b9-1215-11e6-b427-0cc47a188158', 'ext': 'mp4', 'title': '0280d6b9-1215-11e6-b427-0cc47a188158', 'is_live': False, }, 'expected_warnings': ['Failed to download MPD manifest', 'Failed to parse JSON'], }, { # live video stream 'url': 'https://playout.3qsdn.com/d755d94b-4ab9-11e3-9162-0025907ad44f?js=true', 'info_dict': { 'id': 'd755d94b-4ab9-11e3-9162-0025907ad44f', 'ext': 'mp4', 'title': 're:^d755d94b-4ab9-11e3-9162-0025907ad44f [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'is_live': True, }, 'params': { 'skip_download': True, # m3u8 downloads }, 'expected_warnings': ['Failed to download MPD manifest'], }, { # live audio stream 'url': 'http://playout.3qsdn.com/9edf36e0-6bf2-11e2-a16a-9acf09e2db48', 'only_matching': True, }, { # live audio stream with some 404 URLs 'url': 'http://playout.3qsdn.com/ac5c3186-777a-11e2-9c30-9acf09e2db48', 'only_matching': True, }, { # geo restricted with 'This content is not available in your country' 'url': 'http://playout.3qsdn.com/d63a3ffe-75e8-11e2-9c30-9acf09e2db48', 'only_matching': True, }, { # geo restricted with 'playout.3qsdn.com/forbidden' 'url': 'http://playout.3qsdn.com/8e330f26-6ae2-11e2-a16a-9acf09e2db48', 'only_matching': True, }, { # live video with rtmp link 'url': 'https://playout.3qsdn.com/6092bb9e-8f72-11e4-a173-002590c750be', 'only_matching': True, }] @staticmethod def _extract_url(webpage): mobj = re.search( r'<iframe[^>]+\b(?:data-)?src=(["\'])(?P<url>%s.*?)\1' % ThreeQSDNIE._VALID_URL, webpage) if mobj: return mobj.group('url') def _real_extract(self, url): video_id = self._match_id(url) js = self._download_webpage( 'http://playout.3qsdn.com/%s' % video_id, video_id, query={'js': 'true'}) if any(p in js for p in ( '>This content is not available in your country', 'playout.3qsdn.com/forbidden')): self.raise_geo_restricted() stream_content = self._search_regex( r'streamContent\s*:\s*(["\'])(?P<content>.+?)\1', js, 'stream content', default='demand', group='content') live = stream_content == 'live' stream_type = self._search_regex( r'streamType\s*:\s*(["\'])(?P<type>audio|video)\1', js, 'stream type', default='video', group='type') formats = [] urls = set() def extract_formats(item_url, item={}): if not item_url or item_url in urls: return urls.add(item_url) ext = mimetype2ext(item.get('type')) or determine_ext(item_url, default_ext=None) if ext == 'mpd': formats.extend(self._extract_mpd_formats( item_url, video_id, mpd_id='mpd', fatal=False)) elif ext == 'm3u8': formats.extend(self._extract_m3u8_formats( item_url, video_id, 'mp4', entry_protocol='m3u8' if live else 'm3u8_native', m3u8_id='hls', fatal=False)) elif ext == 'f4m': formats.extend(self._extract_f4m_formats( item_url, video_id, f4m_id='hds', fatal=False)) else: if not self._is_valid_url(item_url, video_id): return formats.append({ 'url': item_url, 'format_id': item.get('quality'), 'ext': 'mp4' if item_url.startswith('rtsp') else ext, 'vcodec': 'none' if stream_type == 'audio' else None, }) for item_js in re.findall(r'({[^{]*?\b(?:src|source)\s*:\s*["\'].+?})', js): f = self._parse_json( item_js, video_id, transform_source=js_to_json, fatal=False) if not f: continue extract_formats(f.get('src'), f) # More relaxed version to collect additional URLs and acting # as a future-proof fallback for _, src in re.findall(r'\b(?:src|source)\s*:\s*(["\'])((?:https?|rtsp)://.+?)\1', js): extract_formats(src) self._sort_formats(formats) title = self._live_title(video_id) if live else video_id return { 'id': video_id, 'title': title, 'is_live': live, 'formats': formats, }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 8586, 63, 475, 63, 1001, 12, 272, 12200, 18, 832, 12, 199, 9, 421, 199, 533, 30467, 49, 3693, 46, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 19, 81, 3893, 78, 7, 272, 15292, 63, 15119, 275, 283, 19, 49, 428, 10872, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 2802, 548, 4537, 19, 81, 3893, 78, 4537, 957, 9448, 48, 28, 344, 24693, 983, 13, 70, 8194, 24, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 713, 29668, 272, 485, 7569, 275, 8910, 267, 327, 641, 24152, 687, 1455, 921, 1544, 14, 838, 382, 8210, 2106, 1873, 14, 6993, 15, 422, 290, 270, 4478, 10335, 15, 1479, 15, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 996, 1257, 68, 22, 66, 25, 13, 713, 1046, 13, 845, 69, 22, 13, 66, 27358, 13, 16, 2055, 2417, 65, 11501, 11240, 31, 3922, 29, 1014, 297, 267, 283, 1064, 21, 356, 283, 371, 11189, 69, 1401, 3776, 667, 18, 69, 16, 67, 19000, 70, 2942, 2894, 17, 617, 23, 70, 22, 2866, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 996, 1257, 68, 22, 66, 25, 13, 713, 1046, 13, 845, 69, 22, 13, 66, 27358, 13, 16, 2055, 2417, 65, 11501, 11240, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 996, 1257, 68, 22, 66, 25, 13, 713, 1046, 13, 845, 69, 22, 13, 66, 27358, 13, 16, 2055, 2417, 65, 11501, 11240, 297, 288, 283, 374, 63, 6442, 356, 756, 12, 267, 1660, 267, 283, 2062, 63, 5451, 356, 788, 4276, 370, 5235, 603, 11435, 7712, 297, 283, 4276, 370, 2198, 4840, 995, 272, 1660, 469, 267, 327, 12166, 3991, 2547, 267, 283, 633, 356, 283, 2859, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 68, 12315, 68, 2635, 66, 13, 20, 371, 25, 13, 845, 69, 19, 13, 25, 12438, 13, 383, 11990, 1780, 350, 1602, 70, 31, 3596, 29, 2052, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 68, 12315, 68, 2635, 66, 13, 20, 371, 25, 13, 845, 69, 19, 13, 25, 12438, 13, 383, 11990, 1780, 350, 1602, 70, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 264, 23497, 68, 12315, 68, 2635, 66, 13, 20, 371, 25, 13, 845, 69, 19, 13, 25, 12438, 13, 383, 11990, 1780, 350, 1602, 70, 359, 16, 13, 25, 8194, 20, 17063, 59, 16, 13, 25, 8194, 18, 17063, 59, 16, 13, 25, 8194, 18, 93, 359, 16, 13, 25, 8194, 18, 93, 7766, 16, 13, 25, 8194, 18, 19204, 288, 283, 374, 63, 6442, 356, 715, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 715, 12, 221, 327, 333, 19, 85, 24, 28242, 267, 1660, 267, 283, 2062, 63, 5451, 356, 788, 4276, 370, 5235, 603, 11435, 7712, 995, 272, 1660, 469, 267, 327, 12166, 10491, 2547, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 25, 27680, 1344, 69, 16, 13, 22, 4361, 18, 13, 845, 69, 18, 13, 65, 975, 65, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 12166, 10491, 2547, 543, 2005, 7901, 10867, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 645, 21, 67, 19, 11656, 13, 11956, 65, 13, 845, 69, 18, 13, 25, 67, 1216, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 8509, 15297, 543, 283, 2765, 1564, 365, 440, 2808, 315, 2195, 9023, 7, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 68, 2766, 65, 19, 2026, 13, 2194, 69, 24, 13, 845, 69, 18, 13, 25, 67, 1216, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 8509, 15297, 543, 283, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 29293, 7, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 24, 69, 14137, 70, 1479, 13, 22, 3624, 18, 13, 845, 69, 18, 13, 65, 975, 65, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 12166, 3991, 543, 519, 2791, 2142, 267, 283, 633, 356, 283, 2859, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 14520, 18, 2501, 25, 69, 13, 24, 70, 2819, 13, 845, 69, 20, 13, 65, 12478, 13, 29445, 2710, 67, 27045, 1235, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 768, 4639, 272, 347, 485, 5005, 63, 633, 8, 12022, 304, 267, 14208, 275, 295, 14, 1733, 8, 288, 519, 7601, 20052, 17478, 24621, 66, 5169, 576, 13, 5547, 2164, 30982, 3212, 1105, 2229, 48, 28, 633, 6598, 83, 6697, 2862, 17, 7, 450, 30467, 49, 3693, 46, 4332, 423, 5600, 63, 2632, 12, 9248, 9, 267, 340, 14208, 26, 288, 372, 14208, 14, 923, 360, 633, 358, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 8586, 275, 291, 423, 4249, 63, 12022, 8, 288, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 3149, 83, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 12, 288, 1827, 3713, 3596, 356, 283, 2052, 3071, 398, 340, 1263, 8, 80, 315, 8586, 367, 299, 315, 334, 355, 12696, 2765, 1564, 365, 440, 2808 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 8586, 63, 475, 63, 1001, 12, 272, 12200, 18, 832, 12, 199, 9, 421, 199, 533, 30467, 49, 3693, 46, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 19, 81, 3893, 78, 7, 272, 15292, 63, 15119, 275, 283, 19, 49, 428, 10872, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 2802, 548, 4537, 19, 81, 3893, 78, 4537, 957, 9448, 48, 28, 344, 24693, 983, 13, 70, 8194, 24, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 713, 29668, 272, 485, 7569, 275, 8910, 267, 327, 641, 24152, 687, 1455, 921, 1544, 14, 838, 382, 8210, 2106, 1873, 14, 6993, 15, 422, 290, 270, 4478, 10335, 15, 1479, 15, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 996, 1257, 68, 22, 66, 25, 13, 713, 1046, 13, 845, 69, 22, 13, 66, 27358, 13, 16, 2055, 2417, 65, 11501, 11240, 31, 3922, 29, 1014, 297, 267, 283, 1064, 21, 356, 283, 371, 11189, 69, 1401, 3776, 667, 18, 69, 16, 67, 19000, 70, 2942, 2894, 17, 617, 23, 70, 22, 2866, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 996, 1257, 68, 22, 66, 25, 13, 713, 1046, 13, 845, 69, 22, 13, 66, 27358, 13, 16, 2055, 2417, 65, 11501, 11240, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 996, 1257, 68, 22, 66, 25, 13, 713, 1046, 13, 845, 69, 22, 13, 66, 27358, 13, 16, 2055, 2417, 65, 11501, 11240, 297, 288, 283, 374, 63, 6442, 356, 756, 12, 267, 1660, 267, 283, 2062, 63, 5451, 356, 788, 4276, 370, 5235, 603, 11435, 7712, 297, 283, 4276, 370, 2198, 4840, 995, 272, 1660, 469, 267, 327, 12166, 3991, 2547, 267, 283, 633, 356, 283, 2859, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 68, 12315, 68, 2635, 66, 13, 20, 371, 25, 13, 845, 69, 19, 13, 25, 12438, 13, 383, 11990, 1780, 350, 1602, 70, 31, 3596, 29, 2052, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 68, 12315, 68, 2635, 66, 13, 20, 371, 25, 13, 845, 69, 19, 13, 25, 12438, 13, 383, 11990, 1780, 350, 1602, 70, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 264, 23497, 68, 12315, 68, 2635, 66, 13, 20, 371, 25, 13, 845, 69, 19, 13, 25, 12438, 13, 383, 11990, 1780, 350, 1602, 70, 359, 16, 13, 25, 8194, 20, 17063, 59, 16, 13, 25, 8194, 18, 17063, 59, 16, 13, 25, 8194, 18, 93, 359, 16, 13, 25, 8194, 18, 93, 7766, 16, 13, 25, 8194, 18, 19204, 288, 283, 374, 63, 6442, 356, 715, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 715, 12, 221, 327, 333, 19, 85, 24, 28242, 267, 1660, 267, 283, 2062, 63, 5451, 356, 788, 4276, 370, 5235, 603, 11435, 7712, 995, 272, 1660, 469, 267, 327, 12166, 10491, 2547, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 25, 27680, 1344, 69, 16, 13, 22, 4361, 18, 13, 845, 69, 18, 13, 65, 975, 65, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 12166, 10491, 2547, 543, 2005, 7901, 10867, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 645, 21, 67, 19, 11656, 13, 11956, 65, 13, 845, 69, 18, 13, 25, 67, 1216, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 8509, 15297, 543, 283, 2765, 1564, 365, 440, 2808, 315, 2195, 9023, 7, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 68, 2766, 65, 19, 2026, 13, 2194, 69, 24, 13, 845, 69, 18, 13, 25, 67, 1216, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 8509, 15297, 543, 283, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 29293, 7, 267, 283, 633, 356, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 24, 69, 14137, 70, 1479, 13, 22, 3624, 18, 13, 845, 69, 18, 13, 65, 975, 65, 13, 25, 29533, 1643, 69, 18, 697, 2006, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 327, 12166, 3991, 543, 519, 2791, 2142, 267, 283, 633, 356, 283, 2859, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 15, 14520, 18, 2501, 25, 69, 13, 24, 70, 2819, 13, 845, 69, 20, 13, 65, 12478, 13, 29445, 2710, 67, 27045, 1235, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 768, 4639, 272, 347, 485, 5005, 63, 633, 8, 12022, 304, 267, 14208, 275, 295, 14, 1733, 8, 288, 519, 7601, 20052, 17478, 24621, 66, 5169, 576, 13, 5547, 2164, 30982, 3212, 1105, 2229, 48, 28, 633, 6598, 83, 6697, 2862, 17, 7, 450, 30467, 49, 3693, 46, 4332, 423, 5600, 63, 2632, 12, 9248, 9, 267, 340, 14208, 26, 288, 372, 14208, 14, 923, 360, 633, 358, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 8586, 275, 291, 423, 4249, 63, 12022, 8, 288, 283, 1014, 921, 2802, 548, 14, 19, 81, 3893, 78, 14, 957, 3149, 83, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 12, 288, 1827, 3713, 3596, 356, 283, 2052, 3071, 398, 340, 1263, 8, 80, 315, 8586, 367, 299, 315, 334, 355, 12696, 2765, 1564, 365, 440, 2808, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ProfessionalIT/professionalit-webiste
sdk/google_appengine/lib/django-1.3/django/contrib/localflavor/pt/forms.py
309
1561
""" PT-specific Form helpers """ from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ import re phone_digits_re = re.compile(r'^(\d{9}|(00|\+)\d*)$') class PTZipCodeField(RegexField): default_error_messages = { 'invalid': _('Enter a zip code in the format XXXX-XXX.'), } def __init__(self, *args, **kwargs): super(PTZipCodeField, self).__init__(r'^(\d{4}-\d{3}|\d{7})$', max_length=None, min_length=None, *args, **kwargs) def clean(self,value): cleaned = super(PTZipCodeField, self).clean(value) if len(cleaned) == 7: return u'%s-%s' % (cleaned[:4],cleaned[4:]) else: return cleaned class PTPhoneNumberField(Field): """ Validate local Portuguese phone number (including international ones) It should have 9 digits (may include spaces) or start by 00 or + (international) """ default_error_messages = { 'invalid': _('Phone numbers must have 9 digits, or start by + or 00.'), } def clean(self, value): super(PTPhoneNumberField, self).clean(value) if value in EMPTY_VALUES: return u'' value = re.sub('(\.|\s)', '', smart_unicode(value)) m = phone_digits_re.search(value) if m: return u'%s' % value raise ValidationError(self.error_messages['invalid'])
lgpl-3.0
[ 624, 199, 4189, 13, 6100, 8204, 10897, 199, 624, 199, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 12939, 792, 12, 9496, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 646, 295, 199, 199, 9339, 63, 7022, 63, 264, 275, 295, 14, 2014, 8, 82, 31344, 68, 91, 25, 22441, 8, 383, 6113, 13439, 68, 13278, 9988, 421, 199, 533, 510, 52, 8674, 3034, 792, 8, 5103, 792, 304, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 3482, 1233, 315, 314, 1475, 5787, 56, 13, 13933, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 4189, 8674, 3034, 792, 12, 291, 2843, 826, 721, 82, 31344, 68, 91, 20, 93, 2696, 68, 91, 19, 93, 6113, 68, 91, 23, 1552, 4268, 288, 1390, 63, 1267, 29, 403, 12, 1748, 63, 1267, 29, 403, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 585, 304, 267, 12364, 275, 1613, 8, 4189, 8674, 3034, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 822, 8, 8275, 9, 508, 1520, 26, 1779, 372, 399, 5956, 83, 3295, 83, 7, 450, 334, 8275, 1491, 20, 467, 8275, 59, 20, 5728, 267, 587, 26, 1779, 372, 12364, 268, 199, 533, 510, 52, 25640, 792, 8, 792, 304, 272, 408, 272, 12134, 2257, 10977, 1518, 310, 261, 14617, 1329, 334, 15768, 10757, 6279, 7869, 9, 272, 2779, 1077, 1172, 1749, 7576, 334, 7551, 2387, 7883, 9, 503, 1343, 701, 8733, 503, 435, 334, 4404, 6279, 9, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 15199, 5579, 1471, 1172, 1749, 7576, 12, 503, 1343, 701, 435, 503, 8733, 8038, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 4189, 25640, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 574, 275, 295, 14, 954, 360, 2961, 14, 6113, 83, 3196, 3260, 11179, 63, 2975, 8, 585, 430, 267, 333, 275, 14617, 63, 7022, 63, 264, 14, 1733, 8, 585, 9, 267, 340, 333, 26, 288, 372, 399, 5956, 83, 7, 450, 574, 267, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 4189, 13, 6100, 8204, 10897, 199, 624, 199, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 12939, 792, 12, 9496, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 646, 295, 199, 199, 9339, 63, 7022, 63, 264, 275, 295, 14, 2014, 8, 82, 31344, 68, 91, 25, 22441, 8, 383, 6113, 13439, 68, 13278, 9988, 421, 199, 533, 510, 52, 8674, 3034, 792, 8, 5103, 792, 304, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 3482, 1233, 315, 314, 1475, 5787, 56, 13, 13933, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 4189, 8674, 3034, 792, 12, 291, 2843, 826, 721, 82, 31344, 68, 91, 20, 93, 2696, 68, 91, 19, 93, 6113, 68, 91, 23, 1552, 4268, 288, 1390, 63, 1267, 29, 403, 12, 1748, 63, 1267, 29, 403, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 585, 304, 267, 12364, 275, 1613, 8, 4189, 8674, 3034, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 822, 8, 8275, 9, 508, 1520, 26, 1779, 372, 399, 5956, 83, 3295, 83, 7, 450, 334, 8275, 1491, 20, 467, 8275, 59, 20, 5728, 267, 587, 26, 1779, 372, 12364, 268, 199, 533, 510, 52, 25640, 792, 8, 792, 304, 272, 408, 272, 12134, 2257, 10977, 1518, 310, 261, 14617, 1329, 334, 15768, 10757, 6279, 7869, 9, 272, 2779, 1077, 1172, 1749, 7576, 334, 7551, 2387, 7883, 9, 503, 1343, 701, 8733, 503, 435, 334, 4404, 6279, 9, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 15199, 5579, 1471, 1172, 1749, 7576, 12, 503, 1343, 701, 435, 503, 8733, 8038, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 4189, 25640, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 574, 275, 295, 14, 954, 360, 2961, 14, 6113, 83, 3196, 3260, 11179, 63, 2975, 8, 585, 430, 267, 333, 275, 14617, 63, 7022, 63, 264, 14, 1733, 8, 585, 9, 267, 340, 333, 26, 288, 372, 399, 5956, 83, 7, 450, 574, 267, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mani-monaj/ros_buildfarm
scripts/misc/generate_check_slaves_job.py
3
1109
#!/usr/bin/env python3 import argparse import sys from ros_buildfarm.argument import add_argument_config_url from ros_buildfarm.config import get_index from ros_buildfarm.jenkins import configure_job from ros_buildfarm.jenkins import configure_management_view from ros_buildfarm.jenkins import connect from ros_buildfarm.templates import expand_template def main(argv=sys.argv[1:]): parser = argparse.ArgumentParser( description="Generate the 'check_slaves' job on Jenkins") add_argument_config_url(parser) args = parser.parse_args(argv) config = get_index(args.config_url) job_config = get_job_config(config.notify_emails) jenkins = connect(config.jenkins_url) configure_management_view(jenkins) job_name = 'check_slaves' configure_job(jenkins, job_name, job_config) def get_job_config(notification_emails): template_name = 'misc/check_slaves_job.xml.em' job_data = { 'notification_emails': notification_emails, } job_config = expand_template(template_name, job_data) return job_config if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 646, 7534, 199, 646, 984, 199, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 2094, 492, 1050, 63, 2094, 63, 888, 63, 633, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 888, 492, 664, 63, 1080, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 25622, 492, 7908, 63, 2423, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 25622, 492, 7908, 63, 8110, 63, 1345, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 25622, 492, 4907, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 5876, 492, 6544, 63, 1160, 421, 199, 318, 2446, 8, 3020, 29, 1274, 14, 3020, 59, 17, 28847, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 628, 6864, 314, 283, 1074, 63, 32175, 7, 3906, 641, 32516, 531, 272, 1050, 63, 2094, 63, 888, 63, 633, 8, 2087, 9, 272, 1249, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 339, 1101, 275, 664, 63, 1080, 8, 589, 14, 888, 63, 633, 9, 272, 3906, 63, 888, 275, 664, 63, 2423, 63, 888, 8, 888, 14, 6814, 63, 14170, 9, 339, 29537, 275, 4907, 8, 888, 14, 25622, 63, 633, 9, 339, 7908, 63, 8110, 63, 1345, 8, 25622, 9, 339, 3906, 63, 354, 275, 283, 1074, 63, 32175, 7, 272, 7908, 63, 2423, 8, 25622, 12, 3906, 63, 354, 12, 3906, 63, 888, 9, 421, 199, 318, 664, 63, 2423, 63, 888, 8, 6761, 63, 14170, 304, 272, 1978, 63, 354, 275, 283, 9923, 15, 1074, 63, 32175, 63, 2423, 14, 1652, 14, 5633, 7, 272, 3906, 63, 576, 275, 469, 267, 283, 6761, 63, 14170, 356, 6955, 63, 14170, 12, 272, 789, 272, 3906, 63, 888, 275, 6544, 63, 1160, 8, 1160, 63, 354, 12, 3906, 63, 576, 9, 272, 372, 3906, 63, 888, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 646, 7534, 199, 646, 984, 199, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 2094, 492, 1050, 63, 2094, 63, 888, 63, 633, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 888, 492, 664, 63, 1080, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 25622, 492, 7908, 63, 2423, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 25622, 492, 7908, 63, 8110, 63, 1345, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 25622, 492, 4907, 199, 504, 882, 83, 63, 1506, 70, 5362, 14, 5876, 492, 6544, 63, 1160, 421, 199, 318, 2446, 8, 3020, 29, 1274, 14, 3020, 59, 17, 28847, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 628, 6864, 314, 283, 1074, 63, 32175, 7, 3906, 641, 32516, 531, 272, 1050, 63, 2094, 63, 888, 63, 633, 8, 2087, 9, 272, 1249, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 339, 1101, 275, 664, 63, 1080, 8, 589, 14, 888, 63, 633, 9, 272, 3906, 63, 888, 275, 664, 63, 2423, 63, 888, 8, 888, 14, 6814, 63, 14170, 9, 339, 29537, 275, 4907, 8, 888, 14, 25622, 63, 633, 9, 339, 7908, 63, 8110, 63, 1345, 8, 25622, 9, 339, 3906, 63, 354, 275, 283, 1074, 63, 32175, 7, 272, 7908, 63, 2423, 8, 25622, 12, 3906, 63, 354, 12, 3906, 63, 888, 9, 421, 199, 318, 664, 63, 2423, 63, 888, 8, 6761, 63, 14170, 304, 272, 1978, 63, 354, 275, 283, 9923, 15, 1074, 63, 32175, 63, 2423, 14, 1652, 14, 5633, 7, 272, 3906, 63, 576, 275, 469, 267, 283, 6761, 63, 14170, 356, 6955, 63, 14170, 12, 272, 789, 272, 3906, 63, 888, 275, 6544, 63, 1160, 8, 1160, 63, 354, 12, 3906, 63, 576, 9, 272, 372, 3906, 63, 888, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
hellofreedom/ansible-modules-core
cloud/openstack/os_security_group_rule.py
72
10710
#!/usr/bin/python # Copyright (c) 2015 Hewlett-Packard Development Company, L.P. # Copyright (c) 2013, Benno Joy <benno@ansible.com> # # This module 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 software 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 software. If not, see <http://www.gnu.org/licenses/>. try: import shade HAS_SHADE = True except ImportError: HAS_SHADE = False DOCUMENTATION = ''' --- module: os_security_group_rule short_description: Add/Delete rule from an existing security group extends_documentation_fragment: openstack version_added: "2.0" description: - Add or Remove rule from an existing security group options: security_group: description: - Name of the security group required: true protocol: description: - IP protocol choices: ['tcp', 'udp', 'icmp', None] default: None port_range_min: description: - Starting port required: false default: None port_range_max: description: - Ending port required: false default: None remote_ip_prefix: description: - Source IP address(es) in CIDR notation (exclusive with remote_group) required: false remote_group: description: - ID of Security group to link (exclusive with remote_ip_prefix) required: false ethertype: description: - Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules. Not all providers support IPv6. choices: ['IPv4', 'IPv6'] default: IPv4 direction: description: - The direction in which the security group rule is applied. Not all providers support egress. choices: ['egress', 'ingress'] default: ingress state: description: - Should the resource be present or absent. choices: [present, absent] default: present requirements: ["shade"] ''' EXAMPLES = ''' # Create a security group rule - os_security_group_rule: cloud: mordred security_group: foo protocol: tcp port_range_min: 80 port_range_max: 80 remote_ip_prefix: 0.0.0.0/0 # Create a security group rule for ping - os_security_group_rule: cloud: mordred security_group: foo protocol: icmp remote_ip_prefix: 0.0.0.0/0 # Another way to create the ping rule - os_security_group_rule: cloud: mordred security_group: foo protocol: icmp port_range_min: -1 port_range_max: -1 remote_ip_prefix: 0.0.0.0/0 # Create a TCP rule covering all ports - os_security_group_rule: cloud: mordred security_group: foo protocol: tcp port_range_min: 1 port_range_max: 65535 remote_ip_prefix: 0.0.0.0/0 # Another way to create the TCP rule above (defaults to all ports) - os_security_group_rule: cloud: mordred security_group: foo protocol: tcp remote_ip_prefix: 0.0.0.0/0 ''' RETURN = ''' id: description: Unique rule UUID. type: string direction: description: The direction in which the security group rule is applied. type: string sample: 'egress' ethertype: description: One of IPv4 or IPv6. type: string sample: 'IPv4' port_range_min: description: The minimum port number in the range that is matched by the security group rule. type: int sample: 8000 port_range_max: description: The maximum port number in the range that is matched by the security group rule. type: int sample: 8000 protocol: description: The protocol that is matched by the security group rule. type: string sample: 'tcp' remote_ip_prefix: description: The remote IP prefix to be associated with this security group rule. type: string sample: '0.0.0.0/0' security_group_id: description: The security group ID to associate with this security group rule. type: string ''' def _ports_match(protocol, module_min, module_max, rule_min, rule_max): """ Capture the complex port matching logic. The port values coming in for the module might be -1 (for ICMP), which will work only for Nova, but this is handled by shade. Likewise, they might be None, which works for Neutron, but not Nova. This too is handled by shade. Since shade will consistently return these port values as None, we need to convert any -1 values input to the module to None here for comparison. For TCP and UDP protocols, None values for both min and max are represented as the range 1-65535 for Nova, but remain None for Neutron. Shade returns the full range when Nova is the backend (since that is how Nova stores them), and None values for Neutron. If None values are input to the module for both values, then we need to adjust for comparison. """ # Check if the user is supplying -1 for ICMP. if protocol == 'icmp': if module_min and int(module_min) == -1: module_min = None if module_max and int(module_max) == -1: module_max = None # Check if user is supplying None values for full TCP/UDP port range. if protocol in ['tcp', 'udp'] and module_min is None and module_max is None: if (rule_min and int(rule_min) == 1 and rule_max and int(rule_max) == 65535): # (None, None) == (1, 65535) return True # Sanity check to make sure we don't have type comparison issues. if module_min: module_min = int(module_min) if module_max: module_max = int(module_max) if rule_min: rule_min = int(rule_min) if rule_max: rule_max = int(rule_max) return module_min == rule_min and module_max == rule_max def _find_matching_rule(module, secgroup): """ Find a rule in the group that matches the module parameters. :returns: The matching rule dict, or None if no matches. """ protocol = module.params['protocol'] remote_ip_prefix = module.params['remote_ip_prefix'] ethertype = module.params['ethertype'] direction = module.params['direction'] remote_group_id = module.params['remote_group'] for rule in secgroup['security_group_rules']: if (protocol == rule['protocol'] and remote_ip_prefix == rule['remote_ip_prefix'] and ethertype == rule['ethertype'] and direction == rule['direction'] and remote_group_id == rule['remote_group_id'] and _ports_match(protocol, module.params['port_range_min'], module.params['port_range_max'], rule['port_range_min'], rule['port_range_max'])): return rule return None def _system_state_change(module, secgroup): state = module.params['state'] if secgroup: rule_exists = _find_matching_rule(module, secgroup) else: return False if state == 'present' and not rule_exists: return True if state == 'absent' and rule_exists: return True return False def main(): argument_spec = openstack_full_argument_spec( security_group = dict(required=True), # NOTE(Shrews): None is an acceptable protocol value for # Neutron, but Nova will balk at this. protocol = dict(default=None, choices=[None, 'tcp', 'udp', 'icmp']), port_range_min = dict(required=False, type='int'), port_range_max = dict(required=False, type='int'), remote_ip_prefix = dict(required=False, default=None), # TODO(mordred): Make remote_group handle name and id remote_group = dict(required=False, default=None), ethertype = dict(default='IPv4', choices=['IPv4', 'IPv6']), direction = dict(default='ingress', choices=['egress', 'ingress']), state = dict(default='present', choices=['absent', 'present']), ) module_kwargs = openstack_module_kwargs( mutually_exclusive=[ ['remote_ip_prefix', 'remote_group'], ] ) module = AnsibleModule(argument_spec, supports_check_mode=True, **module_kwargs) if not HAS_SHADE: module.fail_json(msg='shade is required for this module') state = module.params['state'] security_group = module.params['security_group'] changed = False try: cloud = shade.openstack_cloud(**module.params) secgroup = cloud.get_security_group(security_group) if module.check_mode: module.exit_json(changed=_system_state_change(module, secgroup)) if state == 'present': if not secgroup: module.fail_json(msg='Could not find security group %s' % security_group) rule = _find_matching_rule(module, secgroup) if not rule: rule = cloud.create_security_group_rule( secgroup['id'], port_range_min=module.params['port_range_min'], port_range_max=module.params['port_range_max'], protocol=module.params['protocol'], remote_ip_prefix=module.params['remote_ip_prefix'], remote_group_id=module.params['remote_group'], direction=module.params['direction'], ethertype=module.params['ethertype'] ) changed = True module.exit_json(changed=changed, rule=rule, id=rule['id']) if state == 'absent' and secgroup: rule = _find_matching_rule(module, secgroup) if rule: cloud.delete_security_group_rule(rule['id']) changed = True module.exit_json(changed=changed) except shade.OpenStackCloudException as e: module.fail_json(msg=e.message) # this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import * from ansible.module_utils.openstack import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6171, 12, 26844, 889, 7135, 89, 665, 18486, 889, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 859, 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, 2032, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 893, 26, 272, 492, 32250, 272, 7509, 63, 8461, 1093, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 8461, 1093, 275, 756, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 4416, 63, 923, 63, 2200, 199, 3612, 63, 1802, 26, 2654, 15, 5392, 2332, 687, 376, 3411, 6391, 1572, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1802, 26, 2043, 446, 2654, 503, 5852, 2332, 687, 376, 3411, 6391, 1572, 199, 1419, 26, 2043, 6391, 63, 923, 26, 1362, 1369, 26, 267, 446, 2812, 402, 314, 6391, 1572, 1362, 1415, 26, 2549, 2043, 4113, 26, 489, 1369, 26, 267, 446, 3531, 4113, 489, 3415, 26, 788, 8815, 297, 283, 15036, 297, 283, 18799, 297, 488, 61, 489, 849, 26, 488, 2043, 1844, 63, 1842, 63, 827, 26, 489, 1369, 26, 267, 446, 24175, 1844, 489, 1415, 26, 3055, 489, 849, 26, 488, 2043, 1844, 63, 1842, 63, 988, 26, 489, 1369, 26, 267, 446, 9599, 316, 1844, 489, 1415, 26, 3055, 489, 849, 26, 488, 2043, 3982, 63, 711, 63, 1861, 26, 489, 1369, 26, 267, 446, 5800, 3531, 2287, 8, 397, 9, 315, 29215, 15843, 334, 12730, 543, 3982, 63, 923, 9, 489, 1415, 26, 3055, 2043, 3982, 63, 923, 26, 489, 1369, 26, 267, 446, 2870, 402, 13863, 1572, 370, 2142, 334, 12730, 543, 3982, 63, 711, 63, 1861, 9, 489, 1415, 26, 3055, 2043, 30201, 466, 26, 489, 1369, 26, 267, 446, 9498, 506, 6509, 20, 503, 6509, 22, 12, 436, 7149, 11159, 315, 29215, 1471, 881, 1336, 314, 315, 3313, 503, 325, 3313, 4713, 14, 2832, 1006, 18032, 2291, 6509, 22, 14, 489, 3415, 26, 788, 12179, 20, 297, 283, 12179, 22, 418, 489, 849, 26, 6509, 20, 2043, 7581, 26, 1362, 1369, 26, 267, 446, 710, 7581, 315, 1314, 314, 6391, 1572, 2332, 365, 6781, 14, 2832, 881, 1006, 18032, 2291, 325, 3313, 14, 1362, 3415, 26, 788, 24518, 297, 283, 24390, 418, 1362, 849, 26, 315, 3313, 2043, 1174, 26, 1362, 1369, 26, 2126, 446, 7719, 314, 2073, 506, 3451, 503, 9552, 14, 1362, 3415, 26, 359, 1881, 12, 9552, 61, 1362, 849, 26, 3451, 199, 7538, 26, 2097, 31170, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 282, 6391, 1572, 2332, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 14719, 272, 1844, 63, 1842, 63, 827, 26, 5939, 272, 1844, 63, 1842, 63, 988, 26, 5939, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 2790, 282, 6391, 1572, 2332, 367, 18249, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 20663, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 22604, 4340, 370, 1218, 314, 18249, 2332, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 20663, 272, 1844, 63, 1842, 63, 827, 26, 446, 17, 272, 1844, 63, 1842, 63, 988, 26, 446, 17, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 2790, 282, 13488, 2332, 8486, 316, 1006, 8873, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 14719, 272, 1844, 63, 1842, 63, 827, 26, 413, 272, 1844, 63, 1842, 63, 988, 26, 18247, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 22604, 4340, 370, 1218, 314, 13488, 2332, 3432, 334, 4322, 370, 1006, 8873, 9, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 14719, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 2344, 199, 199, 9677, 275, 1449, 199, 344, 26, 523, 1369, 26, 18276, 2332, 11134, 14, 523, 730, 26, 1059, 199, 6874, 26, 523, 1369, 26, 710, 7581, 315, 1314, 314, 6391, 1572, 2332, 365, 6781, 14, 523, 730, 26, 1059, 523, 2690, 26, 283, 24518, 7, 199, 27732, 466, 26, 523, 1369, 26, 7309, 402, 6509, 20, 503, 6509, 22, 14, 523, 730, 26, 1059, 523, 2690, 26, 283, 12179, 20, 7, 199, 719, 63, 1842, 63, 827, 26, 523, 1369, 26, 710, 7481, 1844, 1329, 315, 314, 1425, 626, 365, 7838, 701, 2049, 314, 6391, 1572, 2332, 14, 523, 730, 26, 1109, 523, 2690, 26, 29855, 199, 719, 63, 1842, 63, 988, 26, 523, 1369, 26, 710, 5696, 1844, 1329, 315, 314, 1425, 626, 365, 7838, 701, 2049, 314 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6171, 12, 26844, 889, 7135, 89, 665, 18486, 889, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 859, 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, 2032, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 893, 26, 272, 492, 32250, 272, 7509, 63, 8461, 1093, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 8461, 1093, 275, 756, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 4416, 63, 923, 63, 2200, 199, 3612, 63, 1802, 26, 2654, 15, 5392, 2332, 687, 376, 3411, 6391, 1572, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1802, 26, 2043, 446, 2654, 503, 5852, 2332, 687, 376, 3411, 6391, 1572, 199, 1419, 26, 2043, 6391, 63, 923, 26, 1362, 1369, 26, 267, 446, 2812, 402, 314, 6391, 1572, 1362, 1415, 26, 2549, 2043, 4113, 26, 489, 1369, 26, 267, 446, 3531, 4113, 489, 3415, 26, 788, 8815, 297, 283, 15036, 297, 283, 18799, 297, 488, 61, 489, 849, 26, 488, 2043, 1844, 63, 1842, 63, 827, 26, 489, 1369, 26, 267, 446, 24175, 1844, 489, 1415, 26, 3055, 489, 849, 26, 488, 2043, 1844, 63, 1842, 63, 988, 26, 489, 1369, 26, 267, 446, 9599, 316, 1844, 489, 1415, 26, 3055, 489, 849, 26, 488, 2043, 3982, 63, 711, 63, 1861, 26, 489, 1369, 26, 267, 446, 5800, 3531, 2287, 8, 397, 9, 315, 29215, 15843, 334, 12730, 543, 3982, 63, 923, 9, 489, 1415, 26, 3055, 2043, 3982, 63, 923, 26, 489, 1369, 26, 267, 446, 2870, 402, 13863, 1572, 370, 2142, 334, 12730, 543, 3982, 63, 711, 63, 1861, 9, 489, 1415, 26, 3055, 2043, 30201, 466, 26, 489, 1369, 26, 267, 446, 9498, 506, 6509, 20, 503, 6509, 22, 12, 436, 7149, 11159, 315, 29215, 1471, 881, 1336, 314, 315, 3313, 503, 325, 3313, 4713, 14, 2832, 1006, 18032, 2291, 6509, 22, 14, 489, 3415, 26, 788, 12179, 20, 297, 283, 12179, 22, 418, 489, 849, 26, 6509, 20, 2043, 7581, 26, 1362, 1369, 26, 267, 446, 710, 7581, 315, 1314, 314, 6391, 1572, 2332, 365, 6781, 14, 2832, 881, 1006, 18032, 2291, 325, 3313, 14, 1362, 3415, 26, 788, 24518, 297, 283, 24390, 418, 1362, 849, 26, 315, 3313, 2043, 1174, 26, 1362, 1369, 26, 2126, 446, 7719, 314, 2073, 506, 3451, 503, 9552, 14, 1362, 3415, 26, 359, 1881, 12, 9552, 61, 1362, 849, 26, 3451, 199, 7538, 26, 2097, 31170, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 282, 6391, 1572, 2332, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 14719, 272, 1844, 63, 1842, 63, 827, 26, 5939, 272, 1844, 63, 1842, 63, 988, 26, 5939, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 2790, 282, 6391, 1572, 2332, 367, 18249, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 20663, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 22604, 4340, 370, 1218, 314, 18249, 2332, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 20663, 272, 1844, 63, 1842, 63, 827, 26, 446, 17, 272, 1844, 63, 1842, 63, 988, 26, 446, 17, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 2790, 282, 13488, 2332, 8486, 316, 1006, 8873, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 14719, 272, 1844, 63, 1842, 63, 827, 26, 413, 272, 1844, 63, 1842, 63, 988, 26, 18247, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 199, 3, 22604, 4340, 370, 1218, 314, 13488, 2332, 3432, 334, 4322, 370, 1006, 8873, 9, 199, 13, 747, 63, 4416, 63, 923, 63, 2200, 26, 272, 8002, 26, 333, 2181, 581, 272, 6391, 63, 923, 26, 3925, 272, 4113, 26, 14719, 272, 3982, 63, 711, 63, 1861, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 199, 2344, 199, 199, 9677, 275, 1449, 199, 344, 26, 523, 1369, 26, 18276, 2332, 11134, 14, 523, 730, 26, 1059, 199, 6874, 26, 523, 1369, 26, 710, 7581, 315, 1314, 314, 6391, 1572, 2332, 365, 6781, 14, 523, 730, 26, 1059, 523, 2690, 26, 283, 24518, 7, 199, 27732, 466, 26, 523, 1369, 26, 7309, 402, 6509, 20, 503, 6509, 22, 14, 523, 730, 26, 1059, 523, 2690, 26, 283, 12179, 20, 7, 199, 719, 63, 1842, 63, 827, 26, 523, 1369, 26, 710, 7481, 1844, 1329, 315, 314, 1425, 626, 365, 7838, 701, 2049, 314, 6391, 1572, 2332, 14, 523, 730, 26, 1109, 523, 2690, 26, 29855, 199, 719, 63, 1842, 63, 988, 26, 523, 1369, 26, 710, 5696, 1844, 1329, 315, 314, 1425, 626, 365, 7838, 701, 2049, 314, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
little-dude/nose2
nose2/tests/functional/support/such/test_such.py
5
4675
import unittest from nose2.tools import such class SomeLayer(object): @classmethod def setUp(cls): it.somelayer = True @classmethod def tearDown(cls): del it.somelayer # # Such tests start with a declaration about the system under test # and will typically bind the test declaration to a variable with # a name that makes nice sentences, like 'this' or 'it'. # with such.A('system with complex setup') as it: # # Each layer of tests can define setup and teardown methods. # setup and teardown methods defined here run around the entire # group of tests, not each individual test. # @it.has_setup def setup(): it.things = [1] @it.has_teardown def teardown(): it.things = [] # # The 'should' decorator is used to mark tests. # @it.should('do something') def test(): assert it.things # # Tests can use all of the normal unittest TestCase assert # methods by calling them on the test declaration. # it.assertEqual(len(it.things), 1) # # The 'having' context manager is used to introduce a new layer, # one that depends on the layer(s) above it. Tests in this # new layer inherit all of the fixtures of the layer above. # with it.having('an expensive fixture'): @it.has_setup def setup(): it.things.append(2) # # Tests that take an argument will be passed the # unittest.TestCase instance that is generated to wrap # them. Tests can call any and all TestCase methods on this # instance. # @it.should('do more things') def test(case): case.assertEqual(it.things[-1], 2) # # Layers can be nested to any depth. # with it.having('another precondtion'): @it.has_setup def setup(): it.things.append(3) @it.has_teardown def teardown(): it.things.pop() @it.should('do that not this') def test(case): it.things.append(4) # # Tests can add their own cleanup functions. # case.addCleanup(it.things.pop) case.assertEqual(it.things[-1], 4, it.things) @it.should('do this not that') def test(case): case.assertEqual(it.things[-1], 3, it.things[:]) # # A layer may have any number of sub-layers. # with it.having('a different precondition'): # # A layer defined with ``having`` can make use of # layers defined elsewhere. An external layer # pulled in with ``it.uses`` becomes a parent # of the current layer (though it doesn't actually # get injected into the layer's MRO). # it.uses(SomeLayer) @it.has_setup def setup(): it.things.append(99) @it.has_teardown def teardown(): it.things.pop() # # Layers can define setup and teardown methods that wrap # each test case, as well, corresponding to TestCase.setUp # and TestCase.tearDown. # @it.has_test_setup def test_setup(case): it.is_funny = True case.is_funny = True @it.has_test_teardown def test_teardown(case): delattr(it, 'is_funny') delattr(case, 'is_funny') @it.should('do something else') def test(case): assert it.things[-1] == 99 assert it.is_funny assert case.is_funny @it.should('have another test') def test(case): assert it.is_funny assert case.is_funny @it.should('have access to an external fixture') def test(case): assert it.somelayer with it.having('a case inside the external fixture'): @it.should('still have access to that fixture') def test(case): assert it.somelayer # # To convert the layer definitions into test cases, you have to call # `createTests` and pass in the module globals, so that the test cases # and layer objects can be inserted into the module. # it.createTests(globals()) # # Such tests and normal tests can coexist in the same modules. # class NormalTest(unittest.TestCase): def test(self): pass
bsd-2-clause
[ 646, 2882, 199, 199, 504, 11354, 18, 14, 2537, 492, 4066, 421, 199, 533, 6601, 5003, 8, 785, 304, 339, 768, 3744, 272, 347, 3613, 8, 1886, 304, 267, 652, 14, 3972, 1897, 275, 715, 339, 768, 3744, 272, 347, 6766, 8, 1886, 304, 267, 2150, 652, 14, 3972, 1897, 199, 199, 3, 199, 3, 32753, 2295, 1343, 543, 282, 12560, 3595, 314, 2656, 1334, 511, 199, 3, 436, 911, 13609, 5398, 314, 511, 12560, 370, 282, 1750, 543, 199, 3, 282, 536, 626, 7704, 14213, 24256, 12, 2839, 283, 3749, 7, 503, 283, 390, 1370, 199, 3, 199, 1045, 4066, 14, 33, 360, 2253, 543, 6114, 3272, 358, 465, 652, 26, 339, 327, 272, 327, 7048, 4045, 402, 2295, 883, 5627, 3272, 436, 17558, 3102, 14, 272, 327, 3272, 436, 17558, 3102, 3247, 2348, 1255, 6818, 314, 8039, 272, 327, 1572, 402, 2295, 12, 440, 1924, 8212, 511, 14, 272, 327, 272, 768, 390, 14, 1989, 63, 2758, 272, 347, 3272, 837, 267, 652, 14, 25970, 275, 359, 17, 61, 339, 768, 390, 14, 1989, 63, 15236, 272, 347, 17558, 837, 267, 652, 14, 25970, 275, 942, 339, 327, 272, 327, 710, 283, 5626, 7, 7531, 365, 1202, 370, 2216, 2295, 14, 272, 327, 272, 768, 390, 14, 5626, 360, 1117, 6020, 358, 272, 347, 511, 837, 267, 702, 652, 14, 25970, 267, 327, 267, 327, 6496, 883, 675, 1006, 402, 314, 3293, 2882, 7640, 702, 267, 327, 3102, 701, 6358, 3062, 641, 314, 511, 12560, 14, 267, 327, 267, 652, 14, 629, 8, 552, 8, 390, 14, 25970, 395, 413, 9, 339, 327, 272, 327, 710, 283, 31569, 7, 1067, 5256, 365, 1202, 370, 13318, 3402, 282, 892, 4045, 12, 272, 327, 1373, 626, 8350, 641, 314, 4045, 8, 83, 9, 3432, 652, 14, 6496, 315, 642, 272, 327, 892, 4045, 8287, 1006, 402, 314, 15188, 402, 314, 4045, 3432, 14, 272, 327, 272, 543, 652, 14, 31569, 360, 290, 23133, 10949, 735, 267, 768, 390, 14, 1989, 63, 2758, 267, 347, 3272, 837, 288, 652, 14, 25970, 14, 740, 8, 18, 9, 398, 327, 267, 327, 6496, 626, 5452, 376, 1423, 911, 506, 3032, 314, 267, 327, 2882, 14, 1746, 1256, 626, 365, 4046, 370, 4816, 267, 327, 3062, 14, 6496, 883, 1240, 1263, 436, 1006, 7640, 3102, 641, 642, 267, 327, 1256, 14, 267, 327, 267, 768, 390, 14, 5626, 360, 1117, 1655, 7645, 358, 267, 347, 511, 8, 2546, 304, 288, 1930, 14, 629, 8, 390, 14, 25970, 1988, 17, 467, 499, 9, 398, 327, 267, 327, 9366, 1192, 883, 506, 6032, 370, 1263, 5818, 14, 267, 327, 267, 543, 652, 14, 31569, 360, 13565, 876, 2067, 296, 735, 288, 768, 390, 14, 1989, 63, 2758, 288, 347, 3272, 837, 355, 652, 14, 25970, 14, 740, 8, 19, 9, 953, 768, 390, 14, 1989, 63, 15236, 288, 347, 17558, 837, 355, 652, 14, 25970, 14, 1935, 342, 953, 768, 390, 14, 5626, 360, 1117, 626, 440, 642, 358, 288, 347, 511, 8, 2546, 304, 355, 652, 14, 25970, 14, 740, 8, 20, 9, 355, 327, 355, 327, 6496, 883, 1050, 3932, 5705, 9058, 3423, 14, 355, 327, 355, 1930, 14, 12808, 8, 390, 14, 25970, 14, 1935, 9, 355, 1930, 14, 629, 8, 390, 14, 25970, 1988, 17, 467, 841, 12, 652, 14, 25970, 9, 953, 768, 390, 14, 5626, 360, 1117, 642, 440, 626, 358, 288, 347, 511, 8, 2546, 304, 355, 1930, 14, 629, 8, 390, 14, 25970, 1988, 17, 467, 650, 12, 652, 14, 25970, 1491, 566, 398, 327, 267, 327, 437, 4045, 1443, 1172, 1263, 1329, 402, 1007, 13, 4359, 14, 267, 327, 267, 543, 652, 14, 31569, 360, 65, 3365, 876, 5394, 735, 953, 327, 288, 327, 437, 4045, 3247, 543, 1124, 31569, 1040, 883, 1852, 675, 402, 288, 327, 9393, 3247, 25320, 14, 1626, 5957, 4045, 288, 327, 25239, 1146, 315, 543, 1124, 390, 14, 5589, 1040, 15410, 282, 1676, 288, 327, 402, 314, 1453, 4045, 334, 15401, 652, 3181, 1133, 5965, 288, 327, 664, 26121, 1901, 314, 4045, 1159, 603, 1092, 680, 288, 327, 288, 652, 14, 5589, 8, 7700, 5003, 9, 953, 768, 390, 14, 1989, 63, 2758, 288, 347, 3272, 837, 355, 652, 14, 25970, 14, 740, 8, 1020, 9, 953, 768, 390, 14, 1989, 63, 15236, 288, 347, 17558, 837, 355, 652, 14, 25970, 14, 1935, 342, 953, 327, 288, 327, 9366, 1192, 883, 5627, 3272, 436, 17558, 3102, 626, 4816, 288, 327, 1924, 511, 1930, 12, 465, 5521, 12, 5226, 370, 7640, 14, 5996, 288, 327, 436, 7640, 14, 12336, 14, 288, 327, 288, 768, 390, 14, 1989, 63, 396, 63, 2758, 288, 347, 511, 63, 2758, 8, 2546, 304, 355, 652, 14, 374, 63, 7036, 9745, 275, 715, 355, 1930, 14, 374, 63, 7036, 9745, 275, 715, 953, 768, 390, 14, 1989, 63, 396, 63, 15236, 288, 347, 511, 63, 15236, 8, 2546, 304, 355, 24358, 8, 390, 12, 283, 374, 63, 7036, 9745, 358, 355, 24358, 8, 2546, 12, 283, 374, 63, 7036, 9745, 358, 953, 768, 390, 14, 5626, 360, 1117, 6020, 587, 358, 288, 347, 511, 8, 2546, 304, 355, 702, 652, 14, 25970, 1988, 17, 61, 508, 8806, 355, 702, 652, 14, 374, 63, 7036, 9745, 355, 702, 1930, 14, 374, 63, 7036, 9745, 953, 768, 390, 14, 5626, 360, 7804, 4573, 511, 358, 288, 347, 511, 8, 2546, 304, 355, 702, 652, 14, 374, 63, 7036, 9745, 355, 702, 1930, 14, 374, 63, 7036, 9745, 953, 768, 390, 14, 5626, 360, 7804, 2879, 370, 376, 5957, 10949, 358, 288, 347, 511, 8, 2546, 304, 355, 702, 652, 14, 3972, 1897, 953, 543, 652, 14, 31569, 360, 65, 1930, 6272, 314, 5957, 10949, 735, 355, 768, 390, 14, 5626, 360, 32310, 1172, 2879, 370, 626, 10949, 358, 355, 347, 511, 8, 2546, 304, 490, 702, 652, 14, 3972, 1897, 199, 199, 3, 199, 3, 4005, 3957, 314, 4045, 10269, 1901, 511, 5560, 12, 1265, 1172, 370, 1240, 199, 3, 658, 981, 2925, 64, 436, 986, 315, 314, 859, 7992, 12, 880, 626, 314, 511, 5560, 199, 3, 436, 4045, 2251, 883, 506, 11788, 1901, 314, 859, 14, 199, 3, 199, 390, 14, 981 ]
[ 2882, 199, 199, 504, 11354, 18, 14, 2537, 492, 4066, 421, 199, 533, 6601, 5003, 8, 785, 304, 339, 768, 3744, 272, 347, 3613, 8, 1886, 304, 267, 652, 14, 3972, 1897, 275, 715, 339, 768, 3744, 272, 347, 6766, 8, 1886, 304, 267, 2150, 652, 14, 3972, 1897, 199, 199, 3, 199, 3, 32753, 2295, 1343, 543, 282, 12560, 3595, 314, 2656, 1334, 511, 199, 3, 436, 911, 13609, 5398, 314, 511, 12560, 370, 282, 1750, 543, 199, 3, 282, 536, 626, 7704, 14213, 24256, 12, 2839, 283, 3749, 7, 503, 283, 390, 1370, 199, 3, 199, 1045, 4066, 14, 33, 360, 2253, 543, 6114, 3272, 358, 465, 652, 26, 339, 327, 272, 327, 7048, 4045, 402, 2295, 883, 5627, 3272, 436, 17558, 3102, 14, 272, 327, 3272, 436, 17558, 3102, 3247, 2348, 1255, 6818, 314, 8039, 272, 327, 1572, 402, 2295, 12, 440, 1924, 8212, 511, 14, 272, 327, 272, 768, 390, 14, 1989, 63, 2758, 272, 347, 3272, 837, 267, 652, 14, 25970, 275, 359, 17, 61, 339, 768, 390, 14, 1989, 63, 15236, 272, 347, 17558, 837, 267, 652, 14, 25970, 275, 942, 339, 327, 272, 327, 710, 283, 5626, 7, 7531, 365, 1202, 370, 2216, 2295, 14, 272, 327, 272, 768, 390, 14, 5626, 360, 1117, 6020, 358, 272, 347, 511, 837, 267, 702, 652, 14, 25970, 267, 327, 267, 327, 6496, 883, 675, 1006, 402, 314, 3293, 2882, 7640, 702, 267, 327, 3102, 701, 6358, 3062, 641, 314, 511, 12560, 14, 267, 327, 267, 652, 14, 629, 8, 552, 8, 390, 14, 25970, 395, 413, 9, 339, 327, 272, 327, 710, 283, 31569, 7, 1067, 5256, 365, 1202, 370, 13318, 3402, 282, 892, 4045, 12, 272, 327, 1373, 626, 8350, 641, 314, 4045, 8, 83, 9, 3432, 652, 14, 6496, 315, 642, 272, 327, 892, 4045, 8287, 1006, 402, 314, 15188, 402, 314, 4045, 3432, 14, 272, 327, 272, 543, 652, 14, 31569, 360, 290, 23133, 10949, 735, 267, 768, 390, 14, 1989, 63, 2758, 267, 347, 3272, 837, 288, 652, 14, 25970, 14, 740, 8, 18, 9, 398, 327, 267, 327, 6496, 626, 5452, 376, 1423, 911, 506, 3032, 314, 267, 327, 2882, 14, 1746, 1256, 626, 365, 4046, 370, 4816, 267, 327, 3062, 14, 6496, 883, 1240, 1263, 436, 1006, 7640, 3102, 641, 642, 267, 327, 1256, 14, 267, 327, 267, 768, 390, 14, 5626, 360, 1117, 1655, 7645, 358, 267, 347, 511, 8, 2546, 304, 288, 1930, 14, 629, 8, 390, 14, 25970, 1988, 17, 467, 499, 9, 398, 327, 267, 327, 9366, 1192, 883, 506, 6032, 370, 1263, 5818, 14, 267, 327, 267, 543, 652, 14, 31569, 360, 13565, 876, 2067, 296, 735, 288, 768, 390, 14, 1989, 63, 2758, 288, 347, 3272, 837, 355, 652, 14, 25970, 14, 740, 8, 19, 9, 953, 768, 390, 14, 1989, 63, 15236, 288, 347, 17558, 837, 355, 652, 14, 25970, 14, 1935, 342, 953, 768, 390, 14, 5626, 360, 1117, 626, 440, 642, 358, 288, 347, 511, 8, 2546, 304, 355, 652, 14, 25970, 14, 740, 8, 20, 9, 355, 327, 355, 327, 6496, 883, 1050, 3932, 5705, 9058, 3423, 14, 355, 327, 355, 1930, 14, 12808, 8, 390, 14, 25970, 14, 1935, 9, 355, 1930, 14, 629, 8, 390, 14, 25970, 1988, 17, 467, 841, 12, 652, 14, 25970, 9, 953, 768, 390, 14, 5626, 360, 1117, 642, 440, 626, 358, 288, 347, 511, 8, 2546, 304, 355, 1930, 14, 629, 8, 390, 14, 25970, 1988, 17, 467, 650, 12, 652, 14, 25970, 1491, 566, 398, 327, 267, 327, 437, 4045, 1443, 1172, 1263, 1329, 402, 1007, 13, 4359, 14, 267, 327, 267, 543, 652, 14, 31569, 360, 65, 3365, 876, 5394, 735, 953, 327, 288, 327, 437, 4045, 3247, 543, 1124, 31569, 1040, 883, 1852, 675, 402, 288, 327, 9393, 3247, 25320, 14, 1626, 5957, 4045, 288, 327, 25239, 1146, 315, 543, 1124, 390, 14, 5589, 1040, 15410, 282, 1676, 288, 327, 402, 314, 1453, 4045, 334, 15401, 652, 3181, 1133, 5965, 288, 327, 664, 26121, 1901, 314, 4045, 1159, 603, 1092, 680, 288, 327, 288, 652, 14, 5589, 8, 7700, 5003, 9, 953, 768, 390, 14, 1989, 63, 2758, 288, 347, 3272, 837, 355, 652, 14, 25970, 14, 740, 8, 1020, 9, 953, 768, 390, 14, 1989, 63, 15236, 288, 347, 17558, 837, 355, 652, 14, 25970, 14, 1935, 342, 953, 327, 288, 327, 9366, 1192, 883, 5627, 3272, 436, 17558, 3102, 626, 4816, 288, 327, 1924, 511, 1930, 12, 465, 5521, 12, 5226, 370, 7640, 14, 5996, 288, 327, 436, 7640, 14, 12336, 14, 288, 327, 288, 768, 390, 14, 1989, 63, 396, 63, 2758, 288, 347, 511, 63, 2758, 8, 2546, 304, 355, 652, 14, 374, 63, 7036, 9745, 275, 715, 355, 1930, 14, 374, 63, 7036, 9745, 275, 715, 953, 768, 390, 14, 1989, 63, 396, 63, 15236, 288, 347, 511, 63, 15236, 8, 2546, 304, 355, 24358, 8, 390, 12, 283, 374, 63, 7036, 9745, 358, 355, 24358, 8, 2546, 12, 283, 374, 63, 7036, 9745, 358, 953, 768, 390, 14, 5626, 360, 1117, 6020, 587, 358, 288, 347, 511, 8, 2546, 304, 355, 702, 652, 14, 25970, 1988, 17, 61, 508, 8806, 355, 702, 652, 14, 374, 63, 7036, 9745, 355, 702, 1930, 14, 374, 63, 7036, 9745, 953, 768, 390, 14, 5626, 360, 7804, 4573, 511, 358, 288, 347, 511, 8, 2546, 304, 355, 702, 652, 14, 374, 63, 7036, 9745, 355, 702, 1930, 14, 374, 63, 7036, 9745, 953, 768, 390, 14, 5626, 360, 7804, 2879, 370, 376, 5957, 10949, 358, 288, 347, 511, 8, 2546, 304, 355, 702, 652, 14, 3972, 1897, 953, 543, 652, 14, 31569, 360, 65, 1930, 6272, 314, 5957, 10949, 735, 355, 768, 390, 14, 5626, 360, 32310, 1172, 2879, 370, 626, 10949, 358, 355, 347, 511, 8, 2546, 304, 490, 702, 652, 14, 3972, 1897, 199, 199, 3, 199, 3, 4005, 3957, 314, 4045, 10269, 1901, 511, 5560, 12, 1265, 1172, 370, 1240, 199, 3, 658, 981, 2925, 64, 436, 986, 315, 314, 859, 7992, 12, 880, 626, 314, 511, 5560, 199, 3, 436, 4045, 2251, 883, 506, 11788, 1901, 314, 859, 14, 199, 3, 199, 390, 14, 981, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
PiaBianca/PyMaster
pymasterlib/ask.py
1
1995
# PyMaster # Copyright (C) 2014, 2015 FreedomOfRestriction <FreedomOfRestriction@openmailbox.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 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 pymasterlib as lib from pymasterlib.constants import * def load_text(ID): return lib.message.load_text("ask", ID) def what(): m = load_text("ask_what") c = [load_text("choice_rules"), load_text("choice_chore"), load_text("choice_punishments"), load_text("choice_nothing")] choice = lib.message.get_choice(m, c, len(c) - 1) if choice == 0: lib.scripts.show_rules() elif choice == 1: chore() elif choice == 2: punishments() def chore(): if lib.slave.queued_chore is not None: lib.message.show(lib.slave.queued_chore["text"]) else: lib.message.show(load_text("no_chore")) def punishments(): lib.slave.forget() punishments_ = [] for i in lib.slave.misdeeds: for misdeed in lib.slave.misdeeds[i]: if not misdeed["punished"] and misdeed["punishment"] is not None: punishments_.append(misdeed["punishment"]) if punishments_: if len(punishments_) > 1: m = load_text("punishments").format(len(punishments_)) lib.message.show(m) for punishment in punishments_: lib.message.show(punishment["text"]) else: lib.message.show(load_text("no_punishments"))
gpl-3.0
[ 3, 1611, 12288, 199, 3, 1898, 334, 35, 9, 6927, 12, 6900, 481, 3798, 676, 3466, 30290, 665, 38, 3798, 676, 3466, 30290, 32, 1490, 21869, 14, 1308, 30, 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, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 1134, 4133, 773, 465, 1973, 199, 504, 1134, 4133, 773, 14, 5559, 492, 627, 421, 199, 318, 2248, 63, 505, 8, 998, 304, 272, 372, 1973, 14, 1188, 14, 912, 63, 505, 480, 813, 401, 2870, 9, 421, 199, 318, 4052, 837, 272, 333, 275, 2248, 63, 505, 480, 813, 63, 10058, 531, 272, 286, 275, 359, 912, 63, 505, 480, 5095, 63, 4423, 1288, 2248, 63, 505, 480, 5095, 63, 335, 720, 1288, 268, 2248, 63, 505, 480, 5095, 63, 80, 324, 2453, 1470, 1288, 2248, 63, 505, 480, 5095, 63, 16323, 11323, 272, 7141, 275, 1973, 14, 1188, 14, 362, 63, 5095, 8, 77, 12, 286, 12, 822, 8, 67, 9, 446, 413, 9, 339, 340, 7141, 508, 378, 26, 267, 1973, 14, 6429, 14, 2384, 63, 4423, 342, 272, 916, 7141, 508, 413, 26, 267, 2468, 264, 342, 272, 916, 7141, 508, 499, 26, 267, 299, 324, 2453, 1470, 342, 421, 199, 318, 2468, 264, 837, 272, 340, 1973, 14, 12384, 14, 14268, 63, 335, 720, 365, 440, 488, 26, 267, 1973, 14, 1188, 14, 2384, 8, 773, 14, 12384, 14, 14268, 63, 335, 720, 905, 505, 3135, 272, 587, 26, 267, 1973, 14, 1188, 14, 2384, 8, 912, 63, 505, 480, 889, 63, 335, 720, 2237, 421, 199, 318, 299, 324, 2453, 1470, 837, 272, 1973, 14, 12384, 14, 28767, 342, 339, 299, 324, 2453, 1470, 63, 275, 942, 272, 367, 284, 315, 1973, 14, 12384, 14, 1292, 271, 5923, 26, 267, 367, 3201, 271, 379, 315, 1973, 14, 12384, 14, 1292, 271, 5923, 59, 73, 2189, 288, 340, 440, 3201, 271, 379, 905, 80, 324, 4387, 937, 436, 3201, 271, 379, 905, 80, 324, 2453, 434, 937, 365, 440, 488, 26, 355, 299, 324, 2453, 1470, 3754, 740, 8, 1292, 271, 379, 905, 80, 324, 2453, 434, 3135, 339, 340, 299, 324, 2453, 1470, 10388, 267, 340, 822, 8, 80, 324, 2453, 1470, 4602, 690, 413, 26, 288, 333, 275, 2248, 63, 505, 480, 80, 324, 2453, 1470, 3471, 908, 8, 552, 8, 80, 324, 2453, 1470, 13309, 288, 1973, 14, 1188, 14, 2384, 8, 77, 9, 398, 367, 299, 324, 2453, 434, 315, 299, 324, 2453, 1470, 10388, 288, 1973, 14, 1188, 14, 2384, 8, 80, 324, 2453, 434, 905, 505, 3135, 272, 587, 26, 267, 1973, 14, 1188, 14, 2384, 8, 912, 63, 505, 480, 889, 63, 80, 324, 2453, 1470, 2237, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1611, 12288, 199, 3, 1898, 334, 35, 9, 6927, 12, 6900, 481, 3798, 676, 3466, 30290, 665, 38, 3798, 676, 3466, 30290, 32, 1490, 21869, 14, 1308, 30, 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, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 1134, 4133, 773, 465, 1973, 199, 504, 1134, 4133, 773, 14, 5559, 492, 627, 421, 199, 318, 2248, 63, 505, 8, 998, 304, 272, 372, 1973, 14, 1188, 14, 912, 63, 505, 480, 813, 401, 2870, 9, 421, 199, 318, 4052, 837, 272, 333, 275, 2248, 63, 505, 480, 813, 63, 10058, 531, 272, 286, 275, 359, 912, 63, 505, 480, 5095, 63, 4423, 1288, 2248, 63, 505, 480, 5095, 63, 335, 720, 1288, 268, 2248, 63, 505, 480, 5095, 63, 80, 324, 2453, 1470, 1288, 2248, 63, 505, 480, 5095, 63, 16323, 11323, 272, 7141, 275, 1973, 14, 1188, 14, 362, 63, 5095, 8, 77, 12, 286, 12, 822, 8, 67, 9, 446, 413, 9, 339, 340, 7141, 508, 378, 26, 267, 1973, 14, 6429, 14, 2384, 63, 4423, 342, 272, 916, 7141, 508, 413, 26, 267, 2468, 264, 342, 272, 916, 7141, 508, 499, 26, 267, 299, 324, 2453, 1470, 342, 421, 199, 318, 2468, 264, 837, 272, 340, 1973, 14, 12384, 14, 14268, 63, 335, 720, 365, 440, 488, 26, 267, 1973, 14, 1188, 14, 2384, 8, 773, 14, 12384, 14, 14268, 63, 335, 720, 905, 505, 3135, 272, 587, 26, 267, 1973, 14, 1188, 14, 2384, 8, 912, 63, 505, 480, 889, 63, 335, 720, 2237, 421, 199, 318, 299, 324, 2453, 1470, 837, 272, 1973, 14, 12384, 14, 28767, 342, 339, 299, 324, 2453, 1470, 63, 275, 942, 272, 367, 284, 315, 1973, 14, 12384, 14, 1292, 271, 5923, 26, 267, 367, 3201, 271, 379, 315, 1973, 14, 12384, 14, 1292, 271, 5923, 59, 73, 2189, 288, 340, 440, 3201, 271, 379, 905, 80, 324, 4387, 937, 436, 3201, 271, 379, 905, 80, 324, 2453, 434, 937, 365, 440, 488, 26, 355, 299, 324, 2453, 1470, 3754, 740, 8, 1292, 271, 379, 905, 80, 324, 2453, 434, 3135, 339, 340, 299, 324, 2453, 1470, 10388, 267, 340, 822, 8, 80, 324, 2453, 1470, 4602, 690, 413, 26, 288, 333, 275, 2248, 63, 505, 480, 80, 324, 2453, 1470, 3471, 908, 8, 552, 8, 80, 324, 2453, 1470, 13309, 288, 1973, 14, 1188, 14, 2384, 8, 77, 9, 398, 367, 299, 324, 2453, 434, 315, 299, 324, 2453, 1470, 10388, 288, 1973, 14, 1188, 14, 2384, 8, 80, 324, 2453, 434, 905, 505, 3135, 272, 587, 26, 267, 1973, 14, 1188, 14, 2384, 8, 912, 63, 505, 480, 889, 63, 80, 324, 2453, 1470, 2237, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
Noirello/bonsai
docs/conf.py
1
9146
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # bonsai documentation build configuration file, created by # sphinx-quickstart on Sat Jan 18 21:30:25 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 sys.path[0:0] = [os.path.abspath('..')] # For read-the-docs: mocking the _bonsai module. from unittest.mock import MagicMock class Mock(MagicMock): @classmethod def __getattr__(cls, name): # A hack to get the objects implemented in C. if name == 'ldapconnection': return object if name == 'ldapentry': return object if name == 'ldapsearchiter': return object MOCK_MODULES = ['src.bonsai._bonsai', 'bonsai', 'bonsai._bonsai', 'bonsai.asyncio'] try: import typing except ImportError: MOCK_MODULES.append('typing') sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) import src.bonsai as bonsai #from src.bonsai import asyncio as bonsai_asyncio #from src.bonsai import ldaif as bonsai_ldif sys.modules['bonsai'] = bonsai sys.modules['bonsai.asyncio'] = bonsai.asyncio autodoc_mock_imports = ["gevent"] # 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.autodoc', 'sphinx.ext.doctest', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'bonsai' copyright = '2014-2020, noirello' # 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 = bonsai.__version__ # The full version, including alpha/beta/rc tags. release = bonsai.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. #html_theme = 'classic' #html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # 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 = 'bonsaidoc' # -- 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 = [ ('index', 'bonasi.tex', 'bonsai Documentation', 'noirello', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'bonsai', 'bonsai Documentation', ['noirello'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'bonsai', 'bonsai Documentation', 'noirello', 'bonsai', '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
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 23672, 2231, 73, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 428, 292, 17474, 6155, 7829, 26, 1216, 26, 821, 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, 1274, 14, 515, 59, 16, 26, 16, 61, 275, 359, 736, 14, 515, 14, 4832, 24893, 5440, 199, 199, 3, 2104, 1586, 13, 1589, 13, 4757, 26, 1683, 316, 314, 485, 13520, 2231, 73, 859, 14, 199, 504, 2882, 14, 1805, 492, 10079, 199, 199, 533, 4420, 8, 11988, 304, 272, 768, 3744, 272, 347, 636, 5675, 721, 1886, 12, 536, 304, 267, 327, 437, 11176, 370, 664, 314, 2251, 6366, 315, 445, 14, 267, 340, 536, 508, 283, 9642, 2105, 356, 288, 372, 909, 267, 340, 536, 508, 283, 9642, 2373, 356, 288, 372, 909, 267, 340, 536, 508, 283, 9642, 1733, 1661, 356, 288, 372, 909, 199, 199, 17749, 63, 21194, 275, 788, 2164, 14, 13520, 2231, 73, 423, 13520, 2231, 73, 297, 283, 13520, 2231, 73, 297, 283, 13520, 2231, 73, 423, 13520, 2231, 73, 297, 283, 13520, 2231, 73, 14, 19343, 418, 199, 893, 26, 272, 492, 14090, 199, 2590, 3545, 26, 272, 10362, 2504, 63, 21194, 14, 740, 360, 29747, 358, 199, 1274, 14, 3112, 14, 873, 1332, 1494, 63, 354, 12, 4420, 1012, 367, 3413, 63, 354, 315, 10362, 2504, 63, 21194, 9, 421, 199, 646, 2928, 14, 13520, 2231, 73, 465, 23672, 2231, 73, 199, 3, 504, 2928, 14, 13520, 2231, 73, 492, 16195, 465, 23672, 2231, 73, 63, 19343, 199, 3, 504, 2928, 14, 13520, 2231, 73, 492, 634, 983, 692, 465, 23672, 2231, 73, 63, 76, 7330, 199, 199, 1274, 14, 3112, 459, 13520, 2231, 73, 418, 275, 23672, 2231, 73, 199, 1274, 14, 3112, 459, 13520, 2231, 73, 14, 19343, 418, 275, 23672, 2231, 73, 14, 19343, 199, 199, 28056, 63, 1805, 63, 12775, 275, 2097, 303, 782, 937, 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, 28056, 297, 272, 283, 8008, 14, 832, 14, 11390, 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, 283, 13520, 2231, 73, 7, 199, 7307, 275, 283, 7280, 13, 13934, 12, 949, 73, 3369, 320, 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, 23672, 2231, 73, 855, 1023, 363, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 23672, 2231, 73, 855, 1023, 363, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 23672, 2231, 73, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 428, 292, 17474, 6155, 7829, 26, 1216, 26, 821, 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, 1274, 14, 515, 59, 16, 26, 16, 61, 275, 359, 736, 14, 515, 14, 4832, 24893, 5440, 199, 199, 3, 2104, 1586, 13, 1589, 13, 4757, 26, 1683, 316, 314, 485, 13520, 2231, 73, 859, 14, 199, 504, 2882, 14, 1805, 492, 10079, 199, 199, 533, 4420, 8, 11988, 304, 272, 768, 3744, 272, 347, 636, 5675, 721, 1886, 12, 536, 304, 267, 327, 437, 11176, 370, 664, 314, 2251, 6366, 315, 445, 14, 267, 340, 536, 508, 283, 9642, 2105, 356, 288, 372, 909, 267, 340, 536, 508, 283, 9642, 2373, 356, 288, 372, 909, 267, 340, 536, 508, 283, 9642, 1733, 1661, 356, 288, 372, 909, 199, 199, 17749, 63, 21194, 275, 788, 2164, 14, 13520, 2231, 73, 423, 13520, 2231, 73, 297, 283, 13520, 2231, 73, 297, 283, 13520, 2231, 73, 423, 13520, 2231, 73, 297, 283, 13520, 2231, 73, 14, 19343, 418, 199, 893, 26, 272, 492, 14090, 199, 2590, 3545, 26, 272, 10362, 2504, 63, 21194, 14, 740, 360, 29747, 358, 199, 1274, 14, 3112, 14, 873, 1332, 1494, 63, 354, 12, 4420, 1012, 367, 3413, 63, 354, 315, 10362, 2504, 63, 21194, 9, 421, 199, 646, 2928, 14, 13520, 2231, 73, 465, 23672, 2231, 73, 199, 3, 504, 2928, 14, 13520, 2231, 73, 492, 16195, 465, 23672, 2231, 73, 63, 19343, 199, 3, 504, 2928, 14, 13520, 2231, 73, 492, 634, 983, 692, 465, 23672, 2231, 73, 63, 76, 7330, 199, 199, 1274, 14, 3112, 459, 13520, 2231, 73, 418, 275, 23672, 2231, 73, 199, 1274, 14, 3112, 459, 13520, 2231, 73, 14, 19343, 418, 275, 23672, 2231, 73, 14, 19343, 199, 199, 28056, 63, 1805, 63, 12775, 275, 2097, 303, 782, 937, 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, 28056, 297, 272, 283, 8008, 14, 832, 14, 11390, 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, 283, 13520, 2231, 73, 7, 199, 7307, 275, 283, 7280, 13, 13934, 12, 949, 73, 3369, 320, 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, 23672, 2231, 73, 855, 1023, 363, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 23672, 2231, 73, 855, 1023, 363, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
osh/gnuradio
gr-blocks/python/blocks/qa_unpack_k_bits.py
57
1821
#!/usr/bin/env python # # Copyright 2006,2010,2013 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, gr_unittest, blocks import random class test_unpack(gr_unittest.TestCase): def setUp(self): self.tb = gr.top_block () def tearDown(self): self.tb = None def test_001(self): src_data = (1,0,1,1,0,1,1,0) expected_results = (1,0,1,1,0,1,1,0) src = blocks.vector_source_b(src_data,False) op = blocks.unpack_k_bits_bb(1) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data()) def test_002(self): src_data = ( 2, 3, 0, 1) expected_results = (1,0,1,1,0,0,0,1) src = blocks.vector_source_b(src_data,False) op = blocks.unpack_k_bits_bb(2) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data()) if __name__ == '__main__': gr_unittest.run(test_unpack, "test_unpack.xml")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8315, 12, 6542, 12, 6965, 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, 12, 7192, 63, 2796, 12, 5664, 199, 199, 646, 2196, 199, 199, 533, 511, 63, 5301, 8, 2587, 63, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 5842, 275, 7192, 14, 2119, 63, 1457, 6248, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 5842, 275, 488, 339, 347, 511, 63, 4587, 8, 277, 304, 267, 2928, 63, 576, 275, 260, 334, 17, 12, 16, 12, 17, 12, 17, 12, 16, 12, 17, 12, 17, 12, 16, 9, 267, 1420, 63, 2604, 275, 334, 17, 12, 16, 12, 17, 12, 17, 12, 16, 12, 17, 12, 17, 12, 16, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 12, 797, 9, 267, 1687, 275, 5664, 14, 5301, 63, 75, 63, 5609, 63, 2501, 8, 17, 9, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 66, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 2604, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 7432, 8, 277, 304, 267, 2928, 63, 576, 275, 260, 334, 221, 499, 12, 221, 650, 12, 221, 378, 12, 221, 413, 9, 267, 1420, 63, 2604, 275, 334, 17, 12, 16, 12, 17, 12, 17, 12, 16, 12, 16, 12, 16, 12, 17, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 12, 797, 9, 267, 1687, 275, 5664, 14, 5301, 63, 75, 63, 5609, 63, 2501, 8, 18, 9, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 66, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 2604, 12, 5042, 14, 576, 1012, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 2043, 7192, 63, 2796, 14, 1065, 8, 396, 63, 5301, 12, 298, 396, 63, 5301, 14, 1652, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8315, 12, 6542, 12, 6965, 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, 12, 7192, 63, 2796, 12, 5664, 199, 199, 646, 2196, 199, 199, 533, 511, 63, 5301, 8, 2587, 63, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 5842, 275, 7192, 14, 2119, 63, 1457, 6248, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 5842, 275, 488, 339, 347, 511, 63, 4587, 8, 277, 304, 267, 2928, 63, 576, 275, 260, 334, 17, 12, 16, 12, 17, 12, 17, 12, 16, 12, 17, 12, 17, 12, 16, 9, 267, 1420, 63, 2604, 275, 334, 17, 12, 16, 12, 17, 12, 17, 12, 16, 12, 17, 12, 17, 12, 16, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 12, 797, 9, 267, 1687, 275, 5664, 14, 5301, 63, 75, 63, 5609, 63, 2501, 8, 17, 9, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 66, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 2604, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 7432, 8, 277, 304, 267, 2928, 63, 576, 275, 260, 334, 221, 499, 12, 221, 650, 12, 221, 378, 12, 221, 413, 9, 267, 1420, 63, 2604, 275, 334, 17, 12, 16, 12, 17, 12, 17, 12, 16, 12, 16, 12, 16, 12, 17, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 12, 797, 9, 267, 1687, 275, 5664, 14, 5301, 63, 75, 63, 5609, 63, 2501, 8, 18, 9, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 66, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 2604, 12, 5042, 14, 576, 1012, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 2043, 7192, 63, 2796, 14, 1065, 8, 396, 63, 5301, 12, 298, 396, 63, 5301, 14, 1652, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
git-cola/git-cola
cola/widgets/dag.py
3
74824
from __future__ import division, absolute_import, unicode_literals import collections import itertools import math from functools import partial from qtpy.QtCore import Qt from qtpy.QtCore import Signal from qtpy import QtCore from qtpy import QtGui from qtpy import QtWidgets from ..compat import maxsize from ..i18n import N_ from ..models import dag from ..qtutils import get from .. import core from .. import cmds from .. import difftool from .. import gitcmds from .. import hotkeys from .. import icons from .. import observable from .. import qtcompat from .. import qtutils from .. import utils from . import archive from . import browse from . import completion from . import createbranch from . import createtag from . import defs from . import diff from . import filelist from . import standard def git_dag(context, args=None, existing_view=None, show=True): """Return a pre-populated git DAG widget.""" model = context.model branch = model.currentbranch # disambiguate between branch names and filenames by using '--' branch_doubledash = (branch + ' --') if branch else '' params = dag.DAG(branch_doubledash, 1000) params.set_arguments(args) if existing_view is None: view = GitDAG(context, params) else: view = existing_view view.set_params(params) if params.ref: view.display() if show: view.show() return view class FocusRedirectProxy(object): """Redirect actions from the main widget to child widgets""" def __init__(self, *widgets): """Provide proxied widgets; the default widget must be first""" self.widgets = widgets self.default = widgets[0] def __getattr__(self, name): return lambda *args, **kwargs: self._forward_action(name, *args, **kwargs) def _forward_action(self, name, *args, **kwargs): """Forward the captured action to the focused or default widget""" widget = QtWidgets.QApplication.focusWidget() if widget in self.widgets and hasattr(widget, name): fn = getattr(widget, name) else: fn = getattr(self.default, name) return fn(*args, **kwargs) class ViewerMixin(object): """Implementations must provide selected_items()""" def __init__(self): self.context = None # provided by implementation self.selected = None self.clicked = None self.menu_actions = None # provided by implementation def selected_item(self): """Return the currently selected item""" selected_items = self.selected_items() if not selected_items: return None return selected_items[0] def selected_oid(self): item = self.selected_item() if item is None: result = None else: result = item.commit.oid return result def selected_oids(self): return [i.commit for i in self.selected_items()] def with_oid(self, fn): oid = self.selected_oid() if oid: result = fn(oid) else: result = None return result def diff_selected_this(self): clicked_oid = self.clicked.oid selected_oid = self.selected.oid self.diff_commits.emit(selected_oid, clicked_oid) def diff_this_selected(self): clicked_oid = self.clicked.oid selected_oid = self.selected.oid self.diff_commits.emit(clicked_oid, selected_oid) def cherry_pick(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.CherryPick, context, [oid])) def revert(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.Revert, context, oid)) def copy_to_clipboard(self): self.with_oid(qtutils.set_clipboard) def create_branch(self): context = self.context create_new_branch = partial(createbranch.create_new_branch, context) self.with_oid(lambda oid: create_new_branch(revision=oid)) def create_tag(self): context = self.context self.with_oid(lambda oid: createtag.create_tag(context, ref=oid)) def create_tarball(self): context = self.context self.with_oid(lambda oid: archive.show_save_dialog(context, oid, parent=self)) def show_diff(self): context = self.context self.with_oid( lambda oid: difftool.diff_expression( context, self, oid + '^!', hide_expr=False, focus_tree=True ) ) def show_dir_diff(self): context = self.context self.with_oid( lambda oid: cmds.difftool_launch( context, left=oid, left_take_magic=True, dir_diff=True ) ) def reset_mixed(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.ResetMixed, context, ref=oid)) def reset_keep(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.ResetKeep, context, ref=oid)) def reset_merge(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.ResetMerge, context, ref=oid)) def reset_soft(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.ResetSoft, context, ref=oid)) def reset_hard(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.ResetHard, context, ref=oid)) def restore_worktree(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.RestoreWorktree, context, ref=oid)) def checkout_detached(self): context = self.context self.with_oid(lambda oid: cmds.do(cmds.Checkout, context, [oid])) def save_blob_dialog(self): context = self.context self.with_oid(lambda oid: browse.BrowseBranch.browse(context, oid)) def update_menu_actions(self, event): selected_items = self.selected_items() item = self.itemAt(event.pos()) if item is None: self.clicked = commit = None else: self.clicked = commit = item.commit has_single_selection = len(selected_items) == 1 has_selection = bool(selected_items) can_diff = bool( commit and has_single_selection and commit is not selected_items[0].commit ) if can_diff: self.selected = selected_items[0].commit else: self.selected = None self.menu_actions['diff_this_selected'].setEnabled(can_diff) self.menu_actions['diff_selected_this'].setEnabled(can_diff) self.menu_actions['diff_commit'].setEnabled(has_single_selection) self.menu_actions['diff_commit_all'].setEnabled(has_single_selection) self.menu_actions['checkout_detached'].setEnabled(has_single_selection) self.menu_actions['cherry_pick'].setEnabled(has_single_selection) self.menu_actions['copy'].setEnabled(has_single_selection) self.menu_actions['create_branch'].setEnabled(has_single_selection) self.menu_actions['create_patch'].setEnabled(has_selection) self.menu_actions['create_tag'].setEnabled(has_single_selection) self.menu_actions['create_tarball'].setEnabled(has_single_selection) self.menu_actions['reset_mixed'].setEnabled(has_single_selection) self.menu_actions['reset_keep'].setEnabled(has_single_selection) self.menu_actions['reset_merge'].setEnabled(has_single_selection) self.menu_actions['reset_soft'].setEnabled(has_single_selection) self.menu_actions['reset_hard'].setEnabled(has_single_selection) self.menu_actions['restore_worktree'].setEnabled(has_single_selection) self.menu_actions['revert'].setEnabled(has_single_selection) self.menu_actions['save_blob'].setEnabled(has_single_selection) def context_menu_event(self, event): self.update_menu_actions(event) menu = qtutils.create_menu(N_('Actions'), self) menu.addAction(self.menu_actions['diff_this_selected']) menu.addAction(self.menu_actions['diff_selected_this']) menu.addAction(self.menu_actions['diff_commit']) menu.addAction(self.menu_actions['diff_commit_all']) menu.addSeparator() menu.addAction(self.menu_actions['create_branch']) menu.addAction(self.menu_actions['create_tag']) menu.addSeparator() menu.addAction(self.menu_actions['cherry_pick']) menu.addAction(self.menu_actions['revert']) menu.addAction(self.menu_actions['create_patch']) menu.addAction(self.menu_actions['create_tarball']) menu.addSeparator() reset_menu = menu.addMenu(N_('Reset')) reset_menu.addAction(self.menu_actions['reset_soft']) reset_menu.addAction(self.menu_actions['reset_mixed']) reset_menu.addAction(self.menu_actions['restore_worktree']) reset_menu.addSeparator() reset_menu.addAction(self.menu_actions['reset_keep']) reset_menu.addAction(self.menu_actions['reset_merge']) reset_menu.addAction(self.menu_actions['reset_hard']) menu.addAction(self.menu_actions['checkout_detached']) menu.addSeparator() menu.addAction(self.menu_actions['save_blob']) menu.addAction(self.menu_actions['copy']) menu.exec_(self.mapToGlobal(event.pos())) def set_icon(icon, action): """"Set the icon for an action and return the action""" action.setIcon(icon) return action def viewer_actions(widget): return { 'diff_this_selected': set_icon( icons.compare(), qtutils.add_action( widget, N_('Diff this -> selected'), widget.proxy.diff_this_selected ), ), 'diff_selected_this': set_icon( icons.compare(), qtutils.add_action( widget, N_('Diff selected -> this'), widget.proxy.diff_selected_this ), ), 'create_branch': set_icon( icons.branch(), qtutils.add_action(widget, N_('Create Branch'), widget.proxy.create_branch), ), 'create_patch': set_icon( icons.save(), qtutils.add_action(widget, N_('Create Patch'), widget.proxy.create_patch), ), 'create_tag': set_icon( icons.tag(), qtutils.add_action(widget, N_('Create Tag'), widget.proxy.create_tag), ), 'create_tarball': set_icon( icons.file_zip(), qtutils.add_action( widget, N_('Save As Tarball/Zip...'), widget.proxy.create_tarball ), ), 'cherry_pick': set_icon( icons.style_dialog_apply(), qtutils.add_action(widget, N_('Cherry Pick'), widget.proxy.cherry_pick), ), 'revert': set_icon( icons.undo(), qtutils.add_action(widget, N_('Revert'), widget.proxy.revert) ), 'diff_commit': set_icon( icons.diff(), qtutils.add_action( widget, N_('Launch Diff Tool'), widget.proxy.show_diff, hotkeys.DIFF ), ), 'diff_commit_all': set_icon( icons.diff(), qtutils.add_action( widget, N_('Launch Directory Diff Tool'), widget.proxy.show_dir_diff, hotkeys.DIFF_SECONDARY, ), ), 'checkout_detached': qtutils.add_action( widget, N_('Checkout Detached HEAD'), widget.proxy.checkout_detached ), 'reset_soft': set_icon( icons.style_dialog_reset(), qtutils.add_action( widget, N_('Reset Branch (Soft)'), widget.proxy.reset_soft ), ), 'reset_mixed': set_icon( icons.style_dialog_reset(), qtutils.add_action( widget, N_('Reset Branch and Stage (Mixed)'), widget.proxy.reset_mixed ), ), 'reset_keep': set_icon( icons.style_dialog_reset(), qtutils.add_action( widget, N_('Restore Worktree and Reset All (Keep Unstaged Edits)'), widget.proxy.reset_keep, ), ), 'reset_merge': set_icon( icons.style_dialog_reset(), qtutils.add_action( widget, N_('Restore Worktree and Reset All (Merge)'), widget.proxy.reset_merge, ), ), 'reset_hard': set_icon( icons.style_dialog_reset(), qtutils.add_action( widget, N_('Restore Worktree and Reset All (Hard)'), widget.proxy.reset_hard, ), ), 'restore_worktree': set_icon( icons.edit(), qtutils.add_action( widget, N_('Restore Worktree'), widget.proxy.restore_worktree ), ), 'save_blob': set_icon( icons.save(), qtutils.add_action( widget, N_('Grab File...'), widget.proxy.save_blob_dialog ), ), 'copy': set_icon( icons.copy(), qtutils.add_action( widget, N_('Copy SHA-1'), widget.proxy.copy_to_clipboard, hotkeys.COPY_SHA1, ), ), } class CommitTreeWidgetItem(QtWidgets.QTreeWidgetItem): def __init__(self, commit, parent=None): QtWidgets.QTreeWidgetItem.__init__(self, parent) self.commit = commit self.setText(0, commit.summary) self.setText(1, commit.author) self.setText(2, commit.authdate) # pylint: disable=too-many-ancestors class CommitTreeWidget(standard.TreeWidget, ViewerMixin): diff_commits = Signal(object, object) zoom_to_fit = Signal() def __init__(self, context, notifier, parent): standard.TreeWidget.__init__(self, parent) ViewerMixin.__init__(self) self.setSelectionMode(self.ExtendedSelection) self.setHeaderLabels([N_('Summary'), N_('Author'), N_('Date, Time')]) self.context = context self.oidmap = {} self.menu_actions = None self.notifier = notifier self.selecting = False self.commits = [] self._adjust_columns = False self.action_up = qtutils.add_action( self, N_('Go Up'), self.go_up, hotkeys.MOVE_UP ) self.action_down = qtutils.add_action( self, N_('Go Down'), self.go_down, hotkeys.MOVE_DOWN ) self.zoom_to_fit_action = qtutils.add_action( self, N_('Zoom to Fit'), self.zoom_to_fit.emit, hotkeys.FIT ) notifier.add_observer(diff.COMMITS_SELECTED, self.commits_selected) # pylint: disable=no-member self.itemSelectionChanged.connect(self.selection_changed) def export_state(self): """Export the widget's state""" # The base class method is intentionally overridden because we only # care about the details below for this subwidget. state = {} state['column_widths'] = self.column_widths() return state def apply_state(self, state): """Apply the exported widget state""" try: column_widths = state['column_widths'] except (KeyError, ValueError): column_widths = None if column_widths: self.set_column_widths(column_widths) else: # Defer showing the columns until we are shown, and our true width # is known. Calling adjust_columns() here ends up with the wrong # answer because we have not yet been parented to the layout. # We set this flag that we process once during our initial # showEvent(). self._adjust_columns = True return True # Qt overrides def showEvent(self, event): """Override QWidget::showEvent() to size columns when we are shown""" if self._adjust_columns: self._adjust_columns = False width = self.width() two_thirds = (width * 2) // 3 one_sixth = width // 6 self.setColumnWidth(0, two_thirds) self.setColumnWidth(1, one_sixth) self.setColumnWidth(2, one_sixth) return standard.TreeWidget.showEvent(self, event) # ViewerMixin def go_up(self): self.goto(self.itemAbove) def go_down(self): self.goto(self.itemBelow) def goto(self, finder): items = self.selected_items() item = items[0] if items else None if item is None: return found = finder(item) if found: self.select([found.commit.oid]) def selected_commit_range(self): selected_items = self.selected_items() if not selected_items: return None, None return selected_items[-1].commit.oid, selected_items[0].commit.oid def set_selecting(self, selecting): self.selecting = selecting def selection_changed(self): items = self.selected_items() if not items: return self.set_selecting(True) self.notifier.notify_observers(diff.COMMITS_SELECTED, [i.commit for i in items]) self.set_selecting(False) def commits_selected(self, commits): if self.selecting: return with qtutils.BlockSignals(self): self.select([commit.oid for commit in commits]) def select(self, oids): if not oids: return self.clearSelection() for oid in oids: try: item = self.oidmap[oid] except KeyError: continue self.scrollToItem(item) item.setSelected(True) def clear(self): QtWidgets.QTreeWidget.clear(self) self.oidmap.clear() self.commits = [] def add_commits(self, commits): self.commits.extend(commits) items = [] for c in reversed(commits): item = CommitTreeWidgetItem(c) items.append(item) self.oidmap[c.oid] = item for tag in c.tags: self.oidmap[tag] = item self.insertTopLevelItems(0, items) def create_patch(self): items = self.selectedItems() if not items: return context = self.context oids = [item.commit.oid for item in reversed(items)] all_oids = [c.oid for c in self.commits] cmds.do(cmds.FormatPatch, context, oids, all_oids) # Qt overrides def contextMenuEvent(self, event): self.context_menu_event(event) def mousePressEvent(self, event): if event.button() == Qt.RightButton: event.accept() return QtWidgets.QTreeWidget.mousePressEvent(self, event) class GitDAG(standard.MainWindow): """The git-dag widget.""" updated = Signal() def __init__(self, context, params, parent=None): super(GitDAG, self).__init__(parent) self.setMinimumSize(420, 420) # change when widgets are added/removed self.widget_version = 2 self.context = context self.params = params self.model = context.model self.commits = {} self.commit_list = [] self.selection = [] self.old_refs = set() self.old_oids = None self.old_count = 0 self.force_refresh = False self.thread = None self.revtext = completion.GitLogLineEdit(context) self.maxresults = standard.SpinBox() self.zoom_out = qtutils.create_action_button( tooltip=N_('Zoom Out'), icon=icons.zoom_out() ) self.zoom_in = qtutils.create_action_button( tooltip=N_('Zoom In'), icon=icons.zoom_in() ) self.zoom_to_fit = qtutils.create_action_button( tooltip=N_('Zoom to Fit'), icon=icons.zoom_fit_best() ) self.notifier = notifier = observable.Observable() self.notifier.refs_updated = refs_updated = 'refs_updated' self.notifier.add_observer(refs_updated, self.display) self.notifier.add_observer(filelist.HISTORIES_SELECTED, self.histories_selected) self.notifier.add_observer(filelist.DIFFTOOL_SELECTED, self.difftool_selected) self.notifier.add_observer(diff.COMMITS_SELECTED, self.commits_selected) self.treewidget = CommitTreeWidget(context, notifier, self) self.diffwidget = diff.DiffWidget(context, notifier, self, is_commit=True) self.filewidget = filelist.FileWidget(context, notifier, self) self.graphview = GraphView(context, notifier, self) self.proxy = FocusRedirectProxy( self.treewidget, self.graphview, self.filewidget ) self.viewer_actions = actions = viewer_actions(self) self.treewidget.menu_actions = actions self.graphview.menu_actions = actions self.controls_layout = qtutils.hbox( defs.no_margin, defs.spacing, self.revtext, self.maxresults ) self.controls_widget = QtWidgets.QWidget() self.controls_widget.setLayout(self.controls_layout) self.log_dock = qtutils.create_dock(N_('Log'), self, stretch=False) self.log_dock.setWidget(self.treewidget) log_dock_titlebar = self.log_dock.titleBarWidget() log_dock_titlebar.add_corner_widget(self.controls_widget) self.file_dock = qtutils.create_dock(N_('Files'), self) self.file_dock.setWidget(self.filewidget) self.diff_dock = qtutils.create_dock(N_('Diff'), self) self.diff_dock.setWidget(self.diffwidget) self.graph_controls_layout = qtutils.hbox( defs.no_margin, defs.button_spacing, self.zoom_out, self.zoom_in, self.zoom_to_fit, defs.spacing, ) self.graph_controls_widget = QtWidgets.QWidget() self.graph_controls_widget.setLayout(self.graph_controls_layout) self.graphview_dock = qtutils.create_dock(N_('Graph'), self) self.graphview_dock.setWidget(self.graphview) graph_titlebar = self.graphview_dock.titleBarWidget() graph_titlebar.add_corner_widget(self.graph_controls_widget) self.lock_layout_action = qtutils.add_action_bool( self, N_('Lock Layout'), self.set_lock_layout, False ) self.refresh_action = qtutils.add_action( self, N_('Refresh'), self.refresh, hotkeys.REFRESH ) # Create the application menu self.menubar = QtWidgets.QMenuBar(self) self.setMenuBar(self.menubar) # View Menu self.view_menu = qtutils.add_menu(N_('View'), self.menubar) self.view_menu.addAction(self.refresh_action) self.view_menu.addAction(self.log_dock.toggleViewAction()) self.view_menu.addAction(self.graphview_dock.toggleViewAction()) self.view_menu.addAction(self.diff_dock.toggleViewAction()) self.view_menu.addAction(self.file_dock.toggleViewAction()) self.view_menu.addSeparator() self.view_menu.addAction(self.lock_layout_action) left = Qt.LeftDockWidgetArea right = Qt.RightDockWidgetArea self.addDockWidget(left, self.log_dock) self.addDockWidget(left, self.diff_dock) self.addDockWidget(right, self.graphview_dock) self.addDockWidget(right, self.file_dock) # Also re-loads dag.* from the saved state self.init_state(context.settings, self.resize_to_desktop) qtutils.connect_button(self.zoom_out, self.graphview.zoom_out) qtutils.connect_button(self.zoom_in, self.graphview.zoom_in) qtutils.connect_button(self.zoom_to_fit, self.graphview.zoom_to_fit) self.treewidget.zoom_to_fit.connect(self.graphview.zoom_to_fit) self.treewidget.diff_commits.connect(self.diff_commits) self.graphview.diff_commits.connect(self.diff_commits) self.filewidget.grab_file.connect(self.grab_file) # pylint: disable=no-member self.maxresults.editingFinished.connect(self.display) self.revtext.textChanged.connect(self.text_changed) self.revtext.activated.connect(self.display) self.revtext.enter.connect(self.display) self.revtext.down.connect(self.focus_tree) # The model is updated in another thread so use # signals/slots to bring control back to the main GUI thread self.model.add_observer(self.model.message_updated, self.updated.emit) self.updated.connect(self.model_updated, type=Qt.QueuedConnection) qtutils.add_action(self, 'Focus', self.focus_input, hotkeys.FOCUS) qtutils.add_close_action(self) self.set_params(params) def set_params(self, params): context = self.context self.params = params # Update fields affected by model self.revtext.setText(params.ref) self.maxresults.setValue(params.count) self.update_window_title() if self.thread is not None: self.thread.stop() self.thread = ReaderThread(context, params, self) thread = self.thread thread.begin.connect(self.thread_begin, type=Qt.QueuedConnection) thread.status.connect(self.thread_status, type=Qt.QueuedConnection) thread.add.connect(self.add_commits, type=Qt.QueuedConnection) thread.end.connect(self.thread_end, type=Qt.QueuedConnection) def focus_input(self): self.revtext.setFocus() def focus_tree(self): self.treewidget.setFocus() def text_changed(self, txt): self.params.ref = txt self.update_window_title() def update_window_title(self): project = self.model.project if self.params.ref: self.setWindowTitle( N_('%(project)s: %(ref)s - DAG') % dict(project=project, ref=self.params.ref) ) else: self.setWindowTitle(project + N_(' - DAG')) def export_state(self): state = standard.MainWindow.export_state(self) state['count'] = self.params.count state['log'] = self.treewidget.export_state() return state def apply_state(self, state): result = standard.MainWindow.apply_state(self, state) try: count = state['count'] if self.params.overridden('count'): count = self.params.count except (KeyError, TypeError, ValueError, AttributeError): count = self.params.count result = False self.params.set_count(count) self.lock_layout_action.setChecked(state.get('lock_layout', False)) try: log_state = state['log'] except (KeyError, ValueError): log_state = None if log_state: self.treewidget.apply_state(log_state) return result def model_updated(self): self.display() self.update_window_title() def refresh(self): """Unconditionally refresh the DAG""" # self.force_refresh triggers an Unconditional redraw self.force_refresh = True cmds.do(cmds.Refresh, self.context) self.force_refresh = False def display(self): """Update the view when the Git refs change""" ref = get(self.revtext) count = get(self.maxresults) context = self.context model = self.model # The DAG tries to avoid updating when the object IDs have not # changed. Without doing this the DAG constantly redraws itself # whenever inotify sends update events, which hurts usability. # # To minimize redraws we leverage `git rev-parse`. The strategy is to # use `git rev-parse` on the input line, which converts each argument # into object IDs. From there it's a simple matter of detecting when # the object IDs changed. # # In addition to object IDs, we also need to know when the set of # named references (branches, tags) changes so that an update is # triggered when new branches and tags are created. refs = set(model.local_branches + model.remote_branches + model.tags) argv = utils.shell_split(ref or 'HEAD') oids = gitcmds.parse_refs(context, argv) update = ( self.force_refresh or count != self.old_count or oids != self.old_oids or refs != self.old_refs ) if update: self.thread.stop() self.params.set_ref(ref) self.params.set_count(count) self.thread.start() self.old_oids = oids self.old_count = count self.old_refs = refs def commits_selected(self, commits): if commits: self.selection = commits def clear(self): self.commits.clear() self.commit_list = [] self.graphview.clear() self.treewidget.clear() def add_commits(self, commits): self.commit_list.extend(commits) # Keep track of commits for commit_obj in commits: self.commits[commit_obj.oid] = commit_obj for tag in commit_obj.tags: self.commits[tag] = commit_obj self.graphview.add_commits(commits) self.treewidget.add_commits(commits) def thread_begin(self): self.clear() def thread_end(self): self.restore_selection() def thread_status(self, successful): self.revtext.hint.set_error(not successful) def restore_selection(self): selection = self.selection try: commit_obj = self.commit_list[-1] except IndexError: # No commits, exist, early-out return new_commits = [self.commits.get(s.oid, None) for s in selection] new_commits = [c for c in new_commits if c is not None] if new_commits: # The old selection exists in the new state self.notifier.notify_observers(diff.COMMITS_SELECTED, new_commits) else: # The old selection is now empty. Select the top-most commit self.notifier.notify_observers(diff.COMMITS_SELECTED, [commit_obj]) self.graphview.set_initial_view() def diff_commits(self, a, b): paths = self.params.paths() if paths: cmds.difftool_launch(self.context, left=a, right=b, paths=paths) else: difftool.diff_commits(self.context, self, a, b) # Qt overrides def closeEvent(self, event): self.revtext.close_popup() self.thread.stop() standard.MainWindow.closeEvent(self, event) def histories_selected(self, histories): argv = [self.model.currentbranch, '--'] argv.extend(histories) text = core.list2cmdline(argv) self.revtext.setText(text) self.display() def difftool_selected(self, files): bottom, top = self.treewidget.selected_commit_range() if not top: return cmds.difftool_launch( self.context, left=bottom, left_take_parent=True, right=top, paths=files ) def grab_file(self, filename): """Save the selected file from the filelist widget""" oid = self.treewidget.selected_oid() model = browse.BrowseModel(oid, filename=filename) browse.save_path(self.context, filename, model) class ReaderThread(QtCore.QThread): begin = Signal() add = Signal(object) end = Signal() status = Signal(object) def __init__(self, context, params, parent): QtCore.QThread.__init__(self, parent) self.context = context self.params = params self._abort = False self._stop = False self._mutex = QtCore.QMutex() self._condition = QtCore.QWaitCondition() def run(self): context = self.context repo = dag.RepoReader(context, self.params) repo.reset() self.begin.emit() commits = [] for c in repo.get(): self._mutex.lock() if self._stop: self._condition.wait(self._mutex) self._mutex.unlock() if self._abort: repo.reset() return commits.append(c) if len(commits) >= 512: self.add.emit(commits) commits = [] self.status.emit(repo.returncode == 0) if commits: self.add.emit(commits) self.end.emit() def start(self): self._abort = False self._stop = False QtCore.QThread.start(self) def pause(self): self._mutex.lock() self._stop = True self._mutex.unlock() def resume(self): self._mutex.lock() self._stop = False self._mutex.unlock() self._condition.wakeOne() def stop(self): self._abort = True self.wait() class Cache(object): _label_font = None @classmethod def label_font(cls): font = cls._label_font if font is None: font = cls._label_font = QtWidgets.QApplication.font() font.setPointSize(6) return font class Edge(QtWidgets.QGraphicsItem): item_type = QtWidgets.QGraphicsItem.UserType + 1 def __init__(self, source, dest): QtWidgets.QGraphicsItem.__init__(self) self.setAcceptedMouseButtons(Qt.NoButton) self.source = source self.dest = dest self.commit = source.commit self.setZValue(-2) self.recompute_bound() self.path = None self.path_valid = False # Choose a new color for new branch edges if self.source.x() < self.dest.x(): color = EdgeColor.cycle() line = Qt.SolidLine elif self.source.x() != self.dest.x(): color = EdgeColor.current() line = Qt.SolidLine else: color = EdgeColor.current() line = Qt.SolidLine self.pen = QtGui.QPen(color, 4.0, line, Qt.SquareCap, Qt.RoundJoin) def recompute_bound(self): dest_pt = Commit.item_bbox.center() self.source_pt = self.mapFromItem(self.source, dest_pt) self.dest_pt = self.mapFromItem(self.dest, dest_pt) self.line = QtCore.QLineF(self.source_pt, self.dest_pt) width = self.dest_pt.x() - self.source_pt.x() height = self.dest_pt.y() - self.source_pt.y() rect = QtCore.QRectF(self.source_pt, QtCore.QSizeF(width, height)) self.bound = rect.normalized() def commits_were_invalidated(self): self.recompute_bound() self.prepareGeometryChange() # The path should not be recomputed immediately because just small part # of DAG is actually shown at same time. It will be recomputed on # demand in course of 'paint' method. self.path_valid = False # Hence, just queue redrawing. self.update() # Qt overrides def type(self): return self.item_type def boundingRect(self): return self.bound def recompute_path(self): QRectF = QtCore.QRectF QPointF = QtCore.QPointF arc_rect = 10 connector_length = 5 path = QtGui.QPainterPath() if self.source.x() == self.dest.x(): path.moveTo(self.source.x(), self.source.y()) path.lineTo(self.dest.x(), self.dest.y()) else: # Define points starting from source point1 = QPointF(self.source.x(), self.source.y()) point2 = QPointF(point1.x(), point1.y() - connector_length) point3 = QPointF(point2.x() + arc_rect, point2.y() - arc_rect) # Define points starting from dest point4 = QPointF(self.dest.x(), self.dest.y()) point5 = QPointF(point4.x(), point3.y() - arc_rect) point6 = QPointF(point5.x() - arc_rect, point5.y() + arc_rect) start_angle_arc1 = 180 span_angle_arc1 = 90 start_angle_arc2 = 90 span_angle_arc2 = -90 # If the dest is at the left of the source, then we # need to reverse some values if self.source.x() > self.dest.x(): point3 = QPointF(point2.x() - arc_rect, point3.y()) point6 = QPointF(point5.x() + arc_rect, point6.y()) span_angle_arc1 = 90 path.moveTo(point1) path.lineTo(point2) path.arcTo(QRectF(point2, point3), start_angle_arc1, span_angle_arc1) path.lineTo(point6) path.arcTo(QRectF(point6, point5), start_angle_arc2, span_angle_arc2) path.lineTo(point4) self.path = path self.path_valid = True def paint(self, painter, _option, _widget): if not self.path_valid: self.recompute_path() painter.setPen(self.pen) painter.drawPath(self.path) class EdgeColor(object): """An edge color factory""" current_color_index = 0 colors = [ QtGui.QColor(Qt.red), QtGui.QColor(Qt.green), QtGui.QColor(Qt.blue), QtGui.QColor(Qt.black), QtGui.QColor(Qt.darkRed), QtGui.QColor(Qt.darkGreen), QtGui.QColor(Qt.darkBlue), QtGui.QColor(Qt.cyan), QtGui.QColor(Qt.magenta), # Orange; Qt.yellow is too low-contrast qtutils.rgba(0xFF, 0x66, 0x00), QtGui.QColor(Qt.gray), QtGui.QColor(Qt.darkCyan), QtGui.QColor(Qt.darkMagenta), QtGui.QColor(Qt.darkYellow), QtGui.QColor(Qt.darkGray), ] @classmethod def cycle(cls): cls.current_color_index += 1 cls.current_color_index %= len(cls.colors) color = cls.colors[cls.current_color_index] color.setAlpha(128) return color @classmethod def current(cls): return cls.colors[cls.current_color_index] @classmethod def reset(cls): cls.current_color_index = 0 class Commit(QtWidgets.QGraphicsItem): item_type = QtWidgets.QGraphicsItem.UserType + 2 commit_radius = 12.0 merge_radius = 18.0 item_shape = QtGui.QPainterPath() item_shape.addRect( commit_radius / -2.0, commit_radius / -2.0, commit_radius, commit_radius ) item_bbox = item_shape.boundingRect() inner_rect = QtGui.QPainterPath() inner_rect.addRect( commit_radius / -2.0 + 2.0, commit_radius / -2.0 + 2.0, commit_radius - 4.0, commit_radius - 4.0, ) inner_rect = inner_rect.boundingRect() commit_color = QtGui.QColor(Qt.white) outline_color = commit_color.darker() merge_color = QtGui.QColor(Qt.lightGray) commit_selected_color = QtGui.QColor(Qt.green) selected_outline_color = commit_selected_color.darker() commit_pen = QtGui.QPen() commit_pen.setWidth(1) commit_pen.setColor(outline_color) def __init__( self, commit, notifier, selectable=QtWidgets.QGraphicsItem.ItemIsSelectable, cursor=Qt.PointingHandCursor, xpos=commit_radius / 2.0 + 1.0, cached_commit_color=commit_color, cached_merge_color=merge_color, ): QtWidgets.QGraphicsItem.__init__(self) self.commit = commit self.notifier = notifier self.selected = False self.setZValue(0) self.setFlag(selectable) self.setCursor(cursor) self.setToolTip(commit.oid[:12] + ': ' + commit.summary) if commit.tags: self.label = label = Label(commit) label.setParentItem(self) label.setPos(xpos + 1, -self.commit_radius / 2.0) else: self.label = None if len(commit.parents) > 1: self.brush = cached_merge_color else: self.brush = cached_commit_color self.pressed = False self.dragged = False self.edges = {} def blockSignals(self, blocked): self.notifier.notification_enabled = not blocked def itemChange(self, change, value): if change == QtWidgets.QGraphicsItem.ItemSelectedHasChanged: # Broadcast selection to other widgets selected_items = self.scene().selectedItems() commits = [item.commit for item in selected_items] self.scene().parent().set_selecting(True) self.notifier.notify_observers(diff.COMMITS_SELECTED, commits) self.scene().parent().set_selecting(False) # Cache the pen for use in paint() if value: self.brush = self.commit_selected_color color = self.selected_outline_color else: if len(self.commit.parents) > 1: self.brush = self.merge_color else: self.brush = self.commit_color color = self.outline_color commit_pen = QtGui.QPen() commit_pen.setWidth(1.0) commit_pen.setColor(color) self.commit_pen = commit_pen return QtWidgets.QGraphicsItem.itemChange(self, change, value) def type(self): return self.item_type def boundingRect(self): return self.item_bbox def shape(self): return self.item_shape def paint(self, painter, option, _widget): # Do not draw outside the exposed rect painter.setClipRect(option.exposedRect) # Draw ellipse painter.setPen(self.commit_pen) painter.setBrush(self.brush) painter.drawEllipse(self.inner_rect) def mousePressEvent(self, event): QtWidgets.QGraphicsItem.mousePressEvent(self, event) self.pressed = True self.selected = self.isSelected() def mouseMoveEvent(self, event): if self.pressed: self.dragged = True QtWidgets.QGraphicsItem.mouseMoveEvent(self, event) def mouseReleaseEvent(self, event): QtWidgets.QGraphicsItem.mouseReleaseEvent(self, event) if not self.dragged and self.selected and event.button() == Qt.LeftButton: return self.pressed = False self.dragged = False class Label(QtWidgets.QGraphicsItem): item_type = QtWidgets.QGraphicsItem.UserType + 3 head_color = QtGui.QColor(Qt.green) other_color = QtGui.QColor(Qt.white) remote_color = QtGui.QColor(Qt.yellow) head_pen = QtGui.QPen() head_pen.setColor(head_color.darker().darker()) head_pen.setWidth(1) text_pen = QtGui.QPen() text_pen.setColor(QtGui.QColor(Qt.darkGray)) text_pen.setWidth(1) alpha = 180 head_color.setAlpha(alpha) other_color.setAlpha(alpha) remote_color.setAlpha(alpha) border = 2 item_spacing = 5 text_offset = 1 def __init__(self, commit): QtWidgets.QGraphicsItem.__init__(self) self.setZValue(-1) self.commit = commit def type(self): return self.item_type def boundingRect(self, cache=Cache): QPainterPath = QtGui.QPainterPath QRectF = QtCore.QRectF width = 72 height = 18 current_width = 0 spacing = self.item_spacing border = self.border + self.text_offset # text offset=1 in paint() font = cache.label_font() item_shape = QPainterPath() base_rect = QRectF(0, 0, width, height) base_rect = base_rect.adjusted(-border, -border, border, border) item_shape.addRect(base_rect) for tag in self.commit.tags: text_shape = QPainterPath() text_shape.addText(current_width, 0, font, tag) text_rect = text_shape.boundingRect() box_rect = text_rect.adjusted(-border, -border, border, border) item_shape.addRect(box_rect) current_width = item_shape.boundingRect().width() + spacing return item_shape.boundingRect() def paint(self, painter, _option, _widget, cache=Cache): # Draw tags and branches font = cache.label_font() painter.setFont(font) current_width = 0 border = self.border offset = self.text_offset spacing = self.item_spacing QRectF = QtCore.QRectF HEAD = 'HEAD' remotes_prefix = 'remotes/' tags_prefix = 'tags/' heads_prefix = 'heads/' remotes_len = len(remotes_prefix) tags_len = len(tags_prefix) heads_len = len(heads_prefix) for tag in self.commit.tags: if tag == HEAD: painter.setPen(self.text_pen) painter.setBrush(self.remote_color) elif tag.startswith(remotes_prefix): tag = tag[remotes_len:] painter.setPen(self.text_pen) painter.setBrush(self.other_color) elif tag.startswith(tags_prefix): tag = tag[tags_len:] painter.setPen(self.text_pen) painter.setBrush(self.remote_color) elif tag.startswith(heads_prefix): tag = tag[heads_len:] painter.setPen(self.head_pen) painter.setBrush(self.head_color) else: painter.setPen(self.text_pen) painter.setBrush(self.other_color) text_rect = painter.boundingRect( QRectF(current_width, 0, 0, 0), Qt.TextSingleLine, tag ) box_rect = text_rect.adjusted(-offset, -offset, offset, offset) painter.drawRoundedRect(box_rect, border, border) painter.drawText(text_rect, Qt.TextSingleLine, tag) current_width += text_rect.width() + spacing # pylint: disable=too-many-ancestors class GraphView(QtWidgets.QGraphicsView, ViewerMixin): diff_commits = Signal(object, object) x_adjust = int(Commit.commit_radius * 4 / 3) y_adjust = int(Commit.commit_radius * 4 / 3) x_off = -18 y_off = -24 def __init__(self, context, notifier, parent): QtWidgets.QGraphicsView.__init__(self, parent) ViewerMixin.__init__(self) highlight = self.palette().color(QtGui.QPalette.Highlight) Commit.commit_selected_color = highlight Commit.selected_outline_color = highlight.darker() self.context = context self.columns = {} self.selection_list = [] self.menu_actions = None self.notifier = notifier self.commits = [] self.items = {} self.mouse_start = [0, 0] self.saved_matrix = self.transform() self.max_column = 0 self.min_column = 0 self.frontier = {} self.tagged_cells = set() self.x_start = 24 self.x_min = 24 self.x_offsets = collections.defaultdict(lambda: self.x_min) self.is_panning = False self.pressed = False self.selecting = False self.last_mouse = [0, 0] self.zoom = 2 self.setDragMode(self.RubberBandDrag) scene = QtWidgets.QGraphicsScene(self) scene.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex) self.setScene(scene) self.setRenderHint(QtGui.QPainter.Antialiasing) self.setViewportUpdateMode(self.BoundingRectViewportUpdate) self.setCacheMode(QtWidgets.QGraphicsView.CacheBackground) self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QtWidgets.QGraphicsView.NoAnchor) self.setBackgroundBrush(QtGui.QColor(Qt.white)) qtutils.add_action( self, N_('Zoom In'), self.zoom_in, hotkeys.ZOOM_IN, hotkeys.ZOOM_IN_SECONDARY, ) qtutils.add_action(self, N_('Zoom Out'), self.zoom_out, hotkeys.ZOOM_OUT) qtutils.add_action(self, N_('Zoom to Fit'), self.zoom_to_fit, hotkeys.FIT) qtutils.add_action( self, N_('Select Parent'), self._select_parent, hotkeys.MOVE_DOWN_TERTIARY ) qtutils.add_action( self, N_('Select Oldest Parent'), self._select_oldest_parent, hotkeys.MOVE_DOWN, ) qtutils.add_action( self, N_('Select Child'), self._select_child, hotkeys.MOVE_UP_TERTIARY ) qtutils.add_action( self, N_('Select Newest Child'), self._select_newest_child, hotkeys.MOVE_UP ) notifier.add_observer(diff.COMMITS_SELECTED, self.commits_selected) def clear(self): EdgeColor.reset() self.scene().clear() self.selection_list = [] self.items.clear() self.x_offsets.clear() self.x_min = 24 self.commits = [] # ViewerMixin interface def selected_items(self): """Return the currently selected items""" return self.scene().selectedItems() def zoom_in(self): self.scale_view(1.5) def zoom_out(self): self.scale_view(1.0 / 1.5) def commits_selected(self, commits): if self.selecting: return self.select([commit.oid for commit in commits]) def select(self, oids): """Select the item for the oids""" self.scene().clearSelection() for oid in oids: try: item = self.items[oid] except KeyError: continue item.blockSignals(True) item.setSelected(True) item.blockSignals(False) item_rect = item.sceneTransform().mapRect(item.boundingRect()) self.ensureVisible(item_rect) def _get_item_by_generation(self, commits, criteria_fn): """Return the item for the commit matching criteria""" if not commits: return None generation = None for commit in commits: if generation is None or criteria_fn(generation, commit.generation): oid = commit.oid generation = commit.generation try: return self.items[oid] except KeyError: return None def _oldest_item(self, commits): """Return the item for the commit with the oldest generation number""" return self._get_item_by_generation(commits, lambda a, b: a > b) def _newest_item(self, commits): """Return the item for the commit with the newest generation number""" return self._get_item_by_generation(commits, lambda a, b: a < b) def create_patch(self): items = self.selected_items() if not items: return context = self.context selected_commits = sort_by_generation([n.commit for n in items]) oids = [c.oid for c in selected_commits] all_oids = [c.oid for c in self.commits] cmds.do(cmds.FormatPatch, context, oids, all_oids) def _select_parent(self): """Select the parent with the newest generation number""" selected_item = self.selected_item() if selected_item is None: return parent_item = self._newest_item(selected_item.commit.parents) if parent_item is None: return selected_item.setSelected(False) parent_item.setSelected(True) self.ensureVisible(parent_item.mapRectToScene(parent_item.boundingRect())) def _select_oldest_parent(self): """Select the parent with the oldest generation number""" selected_item = self.selected_item() if selected_item is None: return parent_item = self._oldest_item(selected_item.commit.parents) if parent_item is None: return selected_item.setSelected(False) parent_item.setSelected(True) scene_rect = parent_item.mapRectToScene(parent_item.boundingRect()) self.ensureVisible(scene_rect) def _select_child(self): """Select the child with the oldest generation number""" selected_item = self.selected_item() if selected_item is None: return child_item = self._oldest_item(selected_item.commit.children) if child_item is None: return selected_item.setSelected(False) child_item.setSelected(True) scene_rect = child_item.mapRectToScene(child_item.boundingRect()) self.ensureVisible(scene_rect) def _select_newest_child(self): """Select the Nth child with the newest generation number (N > 1)""" selected_item = self.selected_item() if selected_item is None: return if len(selected_item.commit.children) > 1: children = selected_item.commit.children[1:] else: children = selected_item.commit.children child_item = self._newest_item(children) if child_item is None: return selected_item.setSelected(False) child_item.setSelected(True) scene_rect = child_item.mapRectToScene(child_item.boundingRect()) self.ensureVisible(scene_rect) def set_initial_view(self): items = [] selected = self.selected_items() if selected: items.extend(selected) if not selected and self.commits: commit = self.commits[-1] items.append(self.items[commit.oid]) self.setSceneRect(self.scene().itemsBoundingRect()) self.fit_view_to_items(items) def zoom_to_fit(self): """Fit selected items into the viewport""" items = self.selected_items() self.fit_view_to_items(items) def fit_view_to_items(self, items): if not items: rect = self.scene().itemsBoundingRect() else: x_min = y_min = maxsize x_max = y_max = -maxsize for item in items: pos = item.pos() x = pos.x() y = pos.y() x_min = min(x_min, x) x_max = max(x_max, x) y_min = min(y_min, y) y_max = max(y_max, y) rect = QtCore.QRectF(x_min, y_min, abs(x_max - x_min), abs(y_max - y_min)) x_adjust = abs(GraphView.x_adjust) y_adjust = abs(GraphView.y_adjust) count = max(2.0, 10.0 - len(items) / 2.0) y_offset = int(y_adjust * count) x_offset = int(x_adjust * count) rect.setX(rect.x() - x_offset // 2) rect.setY(rect.y() - y_adjust // 2) rect.setHeight(rect.height() + y_offset) rect.setWidth(rect.width() + x_offset) self.fitInView(rect, Qt.KeepAspectRatio) self.scene().invalidate() def save_selection(self, event): if event.button() != Qt.LeftButton: return elif Qt.ShiftModifier != event.modifiers(): return self.selection_list = self.selected_items() def restore_selection(self, event): if Qt.ShiftModifier != event.modifiers(): return for item in self.selection_list: item.setSelected(True) def handle_event(self, event_handler, event): self.save_selection(event) event_handler(self, event) self.restore_selection(event) self.update() def set_selecting(self, selecting): self.selecting = selecting def pan(self, event): pos = event.pos() dx = pos.x() - self.mouse_start[0] dy = pos.y() - self.mouse_start[1] if dx == 0 and dy == 0: return rect = QtCore.QRect(0, 0, abs(dx), abs(dy)) delta = self.mapToScene(rect).boundingRect() tx = delta.width() if dx < 0.0: tx = -tx ty = delta.height() if dy < 0.0: ty = -ty matrix = self.transform() matrix.reset() matrix *= self.saved_matrix matrix.translate(tx, ty) self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor) self.setTransform(matrix) def wheel_zoom(self, event): """Handle mouse wheel zooming.""" delta = qtcompat.wheel_delta(event) zoom = math.pow(2.0, delta / 512.0) factor = ( self.transform() .scale(zoom, zoom) .mapRect(QtCore.QRectF(0.0, 0.0, 1.0, 1.0)) .width() ) if factor < 0.014 or factor > 42.0: return self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.zoom = zoom self.scale(zoom, zoom) def wheel_pan(self, event): """Handle mouse wheel panning.""" unit = QtCore.QRectF(0.0, 0.0, 1.0, 1.0) factor = 1.0 / self.transform().mapRect(unit).width() tx, ty = qtcompat.wheel_translation(event) matrix = self.transform().translate(tx * factor, ty * factor) self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor) self.setTransform(matrix) def scale_view(self, scale): factor = ( self.transform() .scale(scale, scale) .mapRect(QtCore.QRectF(0, 0, 1, 1)) .width() ) if factor < 0.07 or factor > 100.0: return self.zoom = scale adjust_scrollbars = True scrollbar = self.verticalScrollBar() if scrollbar: value = get(scrollbar) min_ = scrollbar.minimum() max_ = scrollbar.maximum() range_ = max_ - min_ distance = value - min_ nonzero_range = range_ > 0.1 if nonzero_range: scrolloffset = distance / range_ else: adjust_scrollbars = False self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor) self.scale(scale, scale) scrollbar = self.verticalScrollBar() if scrollbar and adjust_scrollbars: min_ = scrollbar.minimum() max_ = scrollbar.maximum() range_ = max_ - min_ value = min_ + int(float(range_) * scrolloffset) scrollbar.setValue(value) def add_commits(self, commits): """Traverse commits and add them to the view.""" self.commits.extend(commits) scene = self.scene() for commit in commits: item = Commit(commit, self.notifier) self.items[commit.oid] = item for ref in commit.tags: self.items[ref] = item scene.addItem(item) self.layout_commits() self.link(commits) def link(self, commits): """Create edges linking commits with their parents""" scene = self.scene() for commit in commits: try: commit_item = self.items[commit.oid] except KeyError: # TODO - Handle truncated history viewing continue for parent in reversed(commit.parents): try: parent_item = self.items[parent.oid] except KeyError: # TODO - Handle truncated history viewing continue try: edge = parent_item.edges[commit.oid] except KeyError: edge = Edge(parent_item, commit_item) else: continue parent_item.edges[commit.oid] = edge commit_item.edges[parent.oid] = edge scene.addItem(edge) def layout_commits(self): positions = self.position_nodes() # Each edge is accounted in two commits. Hence, accumulate invalid # edges to prevent double edge invalidation. invalid_edges = set() for oid, (x, y) in positions.items(): item = self.items[oid] pos = item.pos() if pos != (x, y): item.setPos(x, y) for edge in item.edges.values(): invalid_edges.add(edge) for edge in invalid_edges: edge.commits_were_invalidated() # Commit node layout technique # # Nodes are aligned by a mesh. Columns and rows are distributed using # algorithms described below. # # Row assignment algorithm # # The algorithm aims consequent. # 1. A commit should be above all its parents. # 2. No commit should be at right side of a commit with a tag in same row. # This prevents overlapping of tag labels with commits and other labels. # 3. Commit density should be maximized. # # The algorithm requires that all parents of a commit were assigned column. # Nodes must be traversed in generation ascend order. This guarantees that all # parents of a commit were assigned row. So, the algorithm may operate in # course of column assignment algorithm. # # Row assignment uses frontier. A frontier is a dictionary that contains # minimum available row index for each column. It propagates during the # algorithm. Set of cells with tags is also maintained to meet second aim. # # Initialization is performed by reset_rows method. Each new column should # be declared using declare_column method. Getting row for a cell is # implemented in alloc_cell method. Frontier must be propagated for any child # of fork commit which occupies different column. This meets first aim. # # Column assignment algorithm # # The algorithm traverses nodes in generation ascend order. This guarantees # that a node will be visited after all its parents. # # The set of occupied columns are maintained during work. Initially it is # empty and no node occupied a column. Empty columns are allocated on demand. # Free index for column being allocated is searched in following way. # 1. Start from desired column and look towards graph center (0 column). # 2. Start from center and look in both directions simultaneously. # Desired column is defaulted to 0. Fork node should set desired column for # children equal to its one. This prevents branch from jumping too far from # its fork. # # Initialization is performed by reset_columns method. Column allocation is # implemented in alloc_column method. Initialization and main loop are in # recompute_grid method. The method also embeds row assignment algorithm by # implementation. # # Actions for each node are follow. # 1. If the node was not assigned a column then it is assigned empty one. # 2. Allocate row. # 3. Allocate columns for children. # If a child have a column assigned then it should no be overridden. One of # children is assigned same column as the node. If the node is a fork then the # child is chosen in generation descent order. This is a heuristic and it only # affects resulting appearance of the graph. Other children are assigned empty # columns in same order. It is the heuristic too. # 4. If no child occupies column of the node then leave it. # It is possible in consequent situations. # 4.1 The node is a leaf. # 4.2 The node is a fork and all its children are already assigned side # column. It is possible if all the children are merges. # 4.3 Single node child is a merge that is already assigned a column. # 5. Propagate frontier with respect to this node. # Each frontier entry corresponding to column occupied by any node's child # must be gather than node row index. This meets first aim of the row # assignment algorithm. # Note that frontier of child that occupies same row was propagated during # step 2. Hence, it must be propagated for children on side columns. def reset_columns(self): # Some children of displayed commits might not be accounted in # 'commits' list. It is common case during loading of big graph. # But, they are assigned a column that must be reseted. Hence, use # depth-first traversal to reset all columns assigned. for node in self.commits: if node.column is None: continue stack = [node] while stack: node = stack.pop() node.column = None for child in node.children: if child.column is not None: stack.append(child) self.columns = {} self.max_column = 0 self.min_column = 0 def reset_rows(self): self.frontier = {} self.tagged_cells = set() def declare_column(self, column): if self.frontier: # Align new column frontier by frontier of nearest column. If all # columns were left then select maximum frontier value. if not self.columns: self.frontier[column] = max(list(self.frontier.values())) return # This is heuristic that mostly affects roots. Note that the # frontier values for fork children will be overridden in course of # propagate_frontier. for offset in itertools.count(1): for c in [column + offset, column - offset]: if c not in self.columns: # Column 'c' is not occupied. continue try: frontier = self.frontier[c] except KeyError: # Column 'c' was never allocated. continue frontier -= 1 # The frontier of the column may be higher because of # tag overlapping prevention performed for previous head. try: if self.frontier[column] >= frontier: break except KeyError: pass self.frontier[column] = frontier break else: continue break else: # First commit must be assigned 0 row. self.frontier[column] = 0 def alloc_column(self, column=0): columns = self.columns # First, look for free column by moving from desired column to graph # center (column 0). for c in range(column, 0, -1 if column > 0 else 1): if c not in columns: if c > self.max_column: self.max_column = c elif c < self.min_column: self.min_column = c break else: # If no free column was found between graph center and desired # column then look for free one by moving from center along both # directions simultaneously. for c in itertools.count(0): if c not in columns: if c > self.max_column: self.max_column = c break c = -c if c not in columns: if c < self.min_column: self.min_column = c break self.declare_column(c) columns[c] = 1 return c def alloc_cell(self, column, tags): # Get empty cell from frontier. cell_row = self.frontier[column] if tags: # Prevent overlapping of tag with cells already allocated a row. if self.x_off > 0: can_overlap = list(range(column + 1, self.max_column + 1)) else: can_overlap = list(range(column - 1, self.min_column - 1, -1)) for c in can_overlap: frontier = self.frontier[c] if frontier > cell_row: cell_row = frontier # Avoid overlapping with tags of commits at cell_row. if self.x_off > 0: can_overlap = list(range(self.min_column, column)) else: can_overlap = list(range(self.max_column, column, -1)) for cell_row in itertools.count(cell_row): for c in can_overlap: if (c, cell_row) in self.tagged_cells: # Overlapping. Try next row. break else: # No overlapping was found. break # Note that all checks should be made for new cell_row value. if tags: self.tagged_cells.add((column, cell_row)) # Propagate frontier. self.frontier[column] = cell_row + 1 return cell_row def propagate_frontier(self, column, value): current = self.frontier[column] if current < value: self.frontier[column] = value def leave_column(self, column): count = self.columns[column] if count == 1: del self.columns[column] else: self.columns[column] = count - 1 def recompute_grid(self): self.reset_columns() self.reset_rows() for node in sort_by_generation(list(self.commits)): if node.column is None: # Node is either root or its parent is not in items. The last # happens when tree loading is in progress. Allocate new # columns for such nodes. node.column = self.alloc_column() node.row = self.alloc_cell(node.column, node.tags) # Allocate columns for children which are still without one. Also # propagate frontier for children. if node.is_fork(): sorted_children = sorted( node.children, key=lambda c: c.generation, reverse=True ) citer = iter(sorted_children) for child in citer: if child.column is None: # Top most child occupies column of parent. child.column = node.column # Note that frontier is propagated in course of # alloc_cell. break self.propagate_frontier(child.column, node.row + 1) else: # No child occupies same column. self.leave_column(node.column) # Note that the loop below will pass no iteration. # Rest children are allocated new column. for child in citer: if child.column is None: child.column = self.alloc_column(node.column) self.propagate_frontier(child.column, node.row + 1) elif node.children: child = node.children[0] if child.column is None: child.column = node.column # Note that frontier is propagated in course of alloc_cell. elif child.column != node.column: # Child node have other parents and occupies column of one # of them. self.leave_column(node.column) # But frontier must be propagated with respect to this # parent. self.propagate_frontier(child.column, node.row + 1) else: # This is a leaf node. self.leave_column(node.column) def position_nodes(self): self.recompute_grid() x_start = self.x_start x_min = self.x_min x_off = self.x_off y_off = self.y_off positions = {} for node in self.commits: x_pos = x_start + node.column * x_off y_pos = y_off + node.row * y_off positions[node.oid] = (x_pos, y_pos) x_min = min(x_min, x_pos) self.x_min = x_min return positions # Qt overrides def contextMenuEvent(self, event): self.context_menu_event(event) def mousePressEvent(self, event): if event.button() == Qt.MidButton: pos = event.pos() self.mouse_start = [pos.x(), pos.y()] self.saved_matrix = self.transform() self.is_panning = True return if event.button() == Qt.RightButton: event.ignore() return if event.button() == Qt.LeftButton: self.pressed = True self.handle_event(QtWidgets.QGraphicsView.mousePressEvent, event) def mouseMoveEvent(self, event): pos = self.mapToScene(event.pos()) if self.is_panning: self.pan(event) return self.last_mouse[0] = pos.x() self.last_mouse[1] = pos.y() self.handle_event(QtWidgets.QGraphicsView.mouseMoveEvent, event) if self.pressed: self.viewport().repaint() def mouseReleaseEvent(self, event): self.pressed = False if event.button() == Qt.MidButton: self.is_panning = False return self.handle_event(QtWidgets.QGraphicsView.mouseReleaseEvent, event) self.selection_list = [] self.viewport().repaint() def wheelEvent(self, event): """Handle Qt mouse wheel events.""" if event.modifiers() & Qt.ControlModifier: self.wheel_zoom(event) else: self.wheel_pan(event) def fitInView(self, rect, flags=Qt.IgnoreAspectRatio): """Override fitInView to remove unwanted margins https://bugreports.qt.io/browse/QTBUG-42331 - based on QT sources """ if self.scene() is None or rect.isNull(): return unity = self.transform().mapRect(QtCore.QRectF(0, 0, 1, 1)) self.scale(1.0 / unity.width(), 1.0 / unity.height()) view_rect = self.viewport().rect() scene_rect = self.transform().mapRect(rect) xratio = view_rect.width() / scene_rect.width() yratio = view_rect.height() / scene_rect.height() if flags == Qt.KeepAspectRatio: xratio = yratio = min(xratio, yratio) elif flags == Qt.KeepAspectRatioByExpanding: xratio = yratio = max(xratio, yratio) self.scale(xratio, yratio) self.centerOn(rect.center()) def sort_by_generation(commits): if len(commits) < 2: return commits commits.sort(key=lambda x: x.generation) return commits # Glossary # ======== # oid -- Git objects IDs (i.e. SHA-1 IDs) # ref -- Git references that resolve to a commit-ish (HEAD, branches, tags)
gpl-2.0
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 2649, 63, 5955, 199, 646, 5055, 199, 646, 7975, 199, 646, 3473, 199, 504, 9143, 492, 7417, 199, 199, 504, 19227, 647, 14, 10901, 492, 3959, 199, 504, 19227, 647, 14, 10901, 492, 18288, 199, 504, 19227, 647, 492, 10565, 199, 504, 19227, 647, 492, 5928, 199, 504, 19227, 647, 492, 17113, 199, 199, 504, 2508, 5819, 492, 19791, 199, 504, 2508, 73, 1085, 78, 492, 653, 63, 199, 504, 2508, 992, 492, 10158, 199, 504, 2508, 8440, 1208, 492, 664, 199, 504, 2508, 492, 6170, 199, 504, 2508, 492, 11465, 199, 504, 2508, 492, 3915, 3557, 199, 504, 2508, 492, 6135, 12975, 199, 504, 2508, 492, 18469, 1612, 199, 504, 2508, 492, 7016, 83, 199, 504, 2508, 492, 2607, 29454, 199, 504, 2508, 492, 19227, 5819, 199, 504, 2508, 492, 19227, 1208, 199, 504, 2508, 492, 3778, 199, 504, 1275, 492, 6359, 199, 504, 1275, 492, 19249, 199, 504, 1275, 492, 13659, 199, 504, 1275, 492, 1218, 4694, 199, 504, 1275, 492, 1218, 1450, 199, 504, 1275, 492, 22603, 199, 504, 1275, 492, 3915, 199, 504, 1275, 492, 26148, 199, 504, 1275, 492, 4465, 421, 199, 318, 6135, 63, 7406, 8, 1100, 12, 1249, 29, 403, 12, 3411, 63, 1345, 29, 403, 12, 2498, 29, 549, 304, 272, 408, 1767, 282, 876, 13, 21440, 6135, 19666, 3938, 1041, 272, 1402, 275, 1067, 14, 1238, 272, 5246, 275, 1402, 14, 1818, 4694, 272, 327, 2153, 16902, 4767, 3382, 5246, 1561, 436, 6203, 701, 1808, 2850, 7, 272, 5246, 63, 1117, 456, 1146, 1119, 275, 334, 4694, 435, 283, 1553, 358, 340, 5246, 587, 2125, 272, 1862, 275, 10158, 14, 28211, 8, 4694, 63, 1117, 456, 1146, 1119, 12, 5198, 9, 272, 1862, 14, 409, 63, 4958, 8, 589, 9, 339, 340, 3411, 63, 1345, 365, 488, 26, 267, 2455, 275, 12579, 28211, 8, 1100, 12, 1862, 9, 272, 587, 26, 267, 2455, 275, 3411, 63, 1345, 267, 2455, 14, 409, 63, 1162, 8, 1162, 9, 272, 340, 1862, 14, 1121, 26, 267, 2455, 14, 2918, 342, 272, 340, 2498, 26, 267, 2455, 14, 2384, 342, 272, 372, 2455, 421, 199, 533, 481, 10763, 7071, 4936, 8, 785, 304, 272, 408, 7071, 5445, 687, 314, 2446, 3938, 370, 1982, 11114, 624, 339, 347, 636, 826, 721, 277, 12, 627, 8583, 304, 267, 408, 25107, 10645, 5299, 11114, 27, 314, 849, 3938, 1471, 506, 1642, 624, 267, 291, 14, 8583, 275, 11114, 267, 291, 14, 885, 275, 11114, 59, 16, 61, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2400, 627, 589, 12, 1011, 958, 26, 291, 423, 6688, 63, 1287, 8, 354, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 485, 6688, 63, 1287, 8, 277, 12, 536, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 12984, 314, 17487, 1595, 370, 314, 289, 679, 2972, 503, 849, 3938, 624, 267, 3938, 275, 17113, 14, 12757, 14, 12283, 3339, 342, 267, 340, 3938, 315, 291, 14, 8583, 436, 2688, 8, 3440, 12, 536, 304, 288, 4325, 275, 2519, 8, 3440, 12, 536, 9, 267, 587, 26, 288, 4325, 275, 2519, 8, 277, 14, 885, 12, 536, 9, 398, 372, 4325, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 10935, 281, 4256, 8, 785, 304, 272, 408, 26924, 1298, 1471, 5647, 4895, 63, 1744, 32664, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1100, 275, 488, 221, 327, 2741, 701, 4514, 267, 291, 14, 5511, 275, 488, 267, 291, 14, 11276, 275, 488, 267, 291, 14, 4470, 63, 3723, 275, 488, 221, 327, 2741, 701, 4514, 339, 347, 4895, 63, 1053, 8, 277, 304, 267, 408, 1767, 314, 5544, 4895, 1242, 624, 267, 4895, 63, 1744, 275, 291, 14, 5511, 63, 1744, 342, 267, 340, 440, 4895, 63, 1744, 26, 288, 372, 488, 267, 372, 4895, 63, 1744, 59, 16, 61, 339, 347, 4895, 63, 1170, 8, 277, 304, 267, 1242, 275, 291, 14, 5511, 63, 1053, 342, 267, 340, 1242, 365, 488, 26, 288, 754, 275, 488, 267, 587, 26, 288, 754, 275, 1242, 14, 3543, 14, 1170, 267, 372, 754, 339, 347, 4895, 63, 1170, 83, 8, 277, 304, 267, 372, 359, 73, 14, 3543, 367, 284, 315, 291, 14, 5511, 63, 1744, 5106, 339, 347, 543, 63, 1170, 8, 277, 12, 4325, 304, 267, 20109, 275, 291, 14, 5511, 63, 1170, 342, 267, 340, 20109, 26, 288, 754, 275, 4325, 8, 1170, 9, 267, 587, 26, 288, 754, 275, 488, 267, 372, 754, 339, 347, 3915, 63, 5511, 63, 3749, 8, 277, 304, 267, 28614, 63, 1170, 275, 291, 14, 11276, 14, 1170, 267, 4895, 63, 1170, 275, 291, 14, 5511, 14, 1170, 267, 291, 14, 3028, 63, 18679, 14, 8159, 8, 5511, 63, 1170, 12, 28614, 63, 1170, 9, 339, 347, 3915, 63, 3749, 63, 5511, 8, 277, 304, 267, 28614, 63, 1170, 275, 291, 14, 11276, 14, 1170, 267, 4895, 63, 1170, 275, 291, 14, 5511, 14, 1170, 267, 291, 14, 3028, 63, 18679, 14, 8159, 8, 11276, 63, 1170, 12, 4895, 63, 1170, 9, 339, 347, 12907, 651, 63, 4510, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 291, 14, 1045, 63, 1170, 8, 2734, 20109, 26, 11465, 14, 1117, 8, 12975, 14, 1049, 281, 651, 8587, 12, 1067, 12, 359, 1170, 2459, 339, 347, 23347, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 291, 14, 1045, 63, 1170, 8, 2734, 20109, 26, 11465, 14, 1117, 8, 12975, 14, 497, 1884, 12, 1067, 12, 20109, 430, 339, 347, 1331, 63, 475, 63, 7548, 3576, 8, 277, 304, 267, 291, 14, 1045, 63, 1170, 8, 8440, 1208, 14, 409, 63, 7548, 3576, 9, 339, 347, 1218, 63, 4694, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 1218, 63, 1222, 63, 4694, 275, 7417, 8, 981, 4694, 14, 981, 63, 1222, 63, 4694, 12, 1067, 9, 267, 291, 14, 1045, 63, 1170, 8, 2734, 20109, 26, 1218, 63, 1222, 63, 4694, 8, 5792, 29, 1170, 430, 339, 347, 1218, 63, 1450, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 291, 14, 1045, 63, 1170, 8, 2734 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 2649, 63, 5955, 199, 646, 5055, 199, 646, 7975, 199, 646, 3473, 199, 504, 9143, 492, 7417, 199, 199, 504, 19227, 647, 14, 10901, 492, 3959, 199, 504, 19227, 647, 14, 10901, 492, 18288, 199, 504, 19227, 647, 492, 10565, 199, 504, 19227, 647, 492, 5928, 199, 504, 19227, 647, 492, 17113, 199, 199, 504, 2508, 5819, 492, 19791, 199, 504, 2508, 73, 1085, 78, 492, 653, 63, 199, 504, 2508, 992, 492, 10158, 199, 504, 2508, 8440, 1208, 492, 664, 199, 504, 2508, 492, 6170, 199, 504, 2508, 492, 11465, 199, 504, 2508, 492, 3915, 3557, 199, 504, 2508, 492, 6135, 12975, 199, 504, 2508, 492, 18469, 1612, 199, 504, 2508, 492, 7016, 83, 199, 504, 2508, 492, 2607, 29454, 199, 504, 2508, 492, 19227, 5819, 199, 504, 2508, 492, 19227, 1208, 199, 504, 2508, 492, 3778, 199, 504, 1275, 492, 6359, 199, 504, 1275, 492, 19249, 199, 504, 1275, 492, 13659, 199, 504, 1275, 492, 1218, 4694, 199, 504, 1275, 492, 1218, 1450, 199, 504, 1275, 492, 22603, 199, 504, 1275, 492, 3915, 199, 504, 1275, 492, 26148, 199, 504, 1275, 492, 4465, 421, 199, 318, 6135, 63, 7406, 8, 1100, 12, 1249, 29, 403, 12, 3411, 63, 1345, 29, 403, 12, 2498, 29, 549, 304, 272, 408, 1767, 282, 876, 13, 21440, 6135, 19666, 3938, 1041, 272, 1402, 275, 1067, 14, 1238, 272, 5246, 275, 1402, 14, 1818, 4694, 272, 327, 2153, 16902, 4767, 3382, 5246, 1561, 436, 6203, 701, 1808, 2850, 7, 272, 5246, 63, 1117, 456, 1146, 1119, 275, 334, 4694, 435, 283, 1553, 358, 340, 5246, 587, 2125, 272, 1862, 275, 10158, 14, 28211, 8, 4694, 63, 1117, 456, 1146, 1119, 12, 5198, 9, 272, 1862, 14, 409, 63, 4958, 8, 589, 9, 339, 340, 3411, 63, 1345, 365, 488, 26, 267, 2455, 275, 12579, 28211, 8, 1100, 12, 1862, 9, 272, 587, 26, 267, 2455, 275, 3411, 63, 1345, 267, 2455, 14, 409, 63, 1162, 8, 1162, 9, 272, 340, 1862, 14, 1121, 26, 267, 2455, 14, 2918, 342, 272, 340, 2498, 26, 267, 2455, 14, 2384, 342, 272, 372, 2455, 421, 199, 533, 481, 10763, 7071, 4936, 8, 785, 304, 272, 408, 7071, 5445, 687, 314, 2446, 3938, 370, 1982, 11114, 624, 339, 347, 636, 826, 721, 277, 12, 627, 8583, 304, 267, 408, 25107, 10645, 5299, 11114, 27, 314, 849, 3938, 1471, 506, 1642, 624, 267, 291, 14, 8583, 275, 11114, 267, 291, 14, 885, 275, 11114, 59, 16, 61, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2400, 627, 589, 12, 1011, 958, 26, 291, 423, 6688, 63, 1287, 8, 354, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 485, 6688, 63, 1287, 8, 277, 12, 536, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 12984, 314, 17487, 1595, 370, 314, 289, 679, 2972, 503, 849, 3938, 624, 267, 3938, 275, 17113, 14, 12757, 14, 12283, 3339, 342, 267, 340, 3938, 315, 291, 14, 8583, 436, 2688, 8, 3440, 12, 536, 304, 288, 4325, 275, 2519, 8, 3440, 12, 536, 9, 267, 587, 26, 288, 4325, 275, 2519, 8, 277, 14, 885, 12, 536, 9, 398, 372, 4325, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 10935, 281, 4256, 8, 785, 304, 272, 408, 26924, 1298, 1471, 5647, 4895, 63, 1744, 32664, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1100, 275, 488, 221, 327, 2741, 701, 4514, 267, 291, 14, 5511, 275, 488, 267, 291, 14, 11276, 275, 488, 267, 291, 14, 4470, 63, 3723, 275, 488, 221, 327, 2741, 701, 4514, 339, 347, 4895, 63, 1053, 8, 277, 304, 267, 408, 1767, 314, 5544, 4895, 1242, 624, 267, 4895, 63, 1744, 275, 291, 14, 5511, 63, 1744, 342, 267, 340, 440, 4895, 63, 1744, 26, 288, 372, 488, 267, 372, 4895, 63, 1744, 59, 16, 61, 339, 347, 4895, 63, 1170, 8, 277, 304, 267, 1242, 275, 291, 14, 5511, 63, 1053, 342, 267, 340, 1242, 365, 488, 26, 288, 754, 275, 488, 267, 587, 26, 288, 754, 275, 1242, 14, 3543, 14, 1170, 267, 372, 754, 339, 347, 4895, 63, 1170, 83, 8, 277, 304, 267, 372, 359, 73, 14, 3543, 367, 284, 315, 291, 14, 5511, 63, 1744, 5106, 339, 347, 543, 63, 1170, 8, 277, 12, 4325, 304, 267, 20109, 275, 291, 14, 5511, 63, 1170, 342, 267, 340, 20109, 26, 288, 754, 275, 4325, 8, 1170, 9, 267, 587, 26, 288, 754, 275, 488, 267, 372, 754, 339, 347, 3915, 63, 5511, 63, 3749, 8, 277, 304, 267, 28614, 63, 1170, 275, 291, 14, 11276, 14, 1170, 267, 4895, 63, 1170, 275, 291, 14, 5511, 14, 1170, 267, 291, 14, 3028, 63, 18679, 14, 8159, 8, 5511, 63, 1170, 12, 28614, 63, 1170, 9, 339, 347, 3915, 63, 3749, 63, 5511, 8, 277, 304, 267, 28614, 63, 1170, 275, 291, 14, 11276, 14, 1170, 267, 4895, 63, 1170, 275, 291, 14, 5511, 14, 1170, 267, 291, 14, 3028, 63, 18679, 14, 8159, 8, 11276, 63, 1170, 12, 4895, 63, 1170, 9, 339, 347, 12907, 651, 63, 4510, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 291, 14, 1045, 63, 1170, 8, 2734, 20109, 26, 11465, 14, 1117, 8, 12975, 14, 1049, 281, 651, 8587, 12, 1067, 12, 359, 1170, 2459, 339, 347, 23347, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 291, 14, 1045, 63, 1170, 8, 2734, 20109, 26, 11465, 14, 1117, 8, 12975, 14, 497, 1884, 12, 1067, 12, 20109, 430, 339, 347, 1331, 63, 475, 63, 7548, 3576, 8, 277, 304, 267, 291, 14, 1045, 63, 1170, 8, 8440, 1208, 14, 409, 63, 7548, 3576, 9, 339, 347, 1218, 63, 4694, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 1218, 63, 1222, 63, 4694, 275, 7417, 8, 981, 4694, 14, 981, 63, 1222, 63, 4694, 12, 1067, 9, 267, 291, 14, 1045, 63, 1170, 8, 2734, 20109, 26, 1218, 63, 1222, 63, 4694, 8, 5792, 29, 1170, 430, 339, 347, 1218, 63, 1450, 8, 277, 304, 267, 1067, 275, 291, 14, 1100, 267, 291, 14, 1045, 63, 1170, 8, 2734, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dark1729dragon/pixutils
pixutils/vplayer/PlayImgs.py
1
2169
from __future__ import nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals from .videoutils import * def default_labeller(x): try: return int(x.split('_')[1].split('.')[0]) except: try: return int(basename(x).split('_')[1].split('.')[0]) except: return 0 class Im2Video(): ''' def labeller(impath): return impath.replace('.jpg','').split('_')[1] vpath = join(dbpath, r'videoimgs/*.*') cam = Imgs2Video(vpath, labeller) video = Player(cam) cam = ThreadIt(cam) imshow = win(video) for fno, img in video.play(): imshow('show_video', img, 1) ''' def __init__(self, opaths, labeller=None): labeller = labeller or default_labeller if type(opaths) not in (list, tuple): paths = glob(opaths) else: paths = opaths if not paths: raise Exception('No file found in %s' % opaths) paths = [(int(labeller(path)), path) for path in paths] self.paths = sorted(paths, key=lambda x: x[0]) self.frameno, self.paths = list(zip(*self.paths)) self.row, self.col = cv2.imread(self.paths[0]).shape[:2] self.index = -1 def release(self): pass def read(self): self.index += 1 if len(self.paths) <= self.index: return False, None try: return True, cv2.imread(self.paths[self.index]) except: return None, None def get(self, i): if i == 3: return self.col elif i == 4: return self.row elif i == 5: return 30 elif i == 7: return len(self.paths) def set(self, i, start_frame): self.index += (start_frame - 1) def GetFeed(vpath, *a, **kw): if type(vpath) == int: return 'stream', cv2.VideoCapture(vpath) elif type(vpath) in (list,tuple) or '*' in vpath: return 'imgs', Im2Video(vpath, *a, **kw) else: assert exists(vpath), 'Video File missing: %s' % vpath return 'video', cv2.VideoCapture(vpath)
bsd-2-clause
[ 504, 636, 2443, 363, 492, 6032, 63, 14129, 12, 16952, 12, 4629, 12, 3679, 63, 646, 12, 543, 63, 6242, 12, 870, 63, 1593, 12, 2649, 63, 5955, 4388, 199, 504, 1275, 5624, 810, 3024, 492, 627, 199, 199, 318, 849, 63, 1302, 1435, 8, 88, 304, 272, 862, 26, 267, 372, 1109, 8, 88, 14, 1294, 6412, 5832, 17, 1055, 1294, 19237, 16, 566, 272, 871, 26, 267, 862, 26, 288, 372, 1109, 8, 4846, 8, 88, 680, 1294, 6412, 5832, 17, 1055, 1294, 19237, 16, 566, 267, 871, 26, 288, 372, 378, 199, 199, 533, 473, 77, 18, 9166, 837, 272, 1449, 272, 347, 1768, 1435, 8, 3236, 1619, 304, 267, 372, 1742, 1619, 14, 1814, 5175, 8476, 26516, 1294, 6412, 5832, 17, 61, 272, 373, 515, 275, 4263, 8, 697, 515, 12, 519, 7, 3722, 1017, 458, 6331, 24915, 272, 27570, 275, 473, 77, 458, 18, 9166, 8, 86, 515, 12, 1768, 1435, 9, 272, 3991, 275, 25610, 8, 15176, 9, 272, 27570, 275, 11086, 7940, 8, 15176, 9, 272, 284, 706, 1917, 275, 4747, 8, 3722, 9, 272, 367, 289, 889, 12, 6050, 315, 3991, 14, 2802, 837, 267, 284, 706, 1917, 360, 2384, 63, 3722, 297, 6050, 12, 413, 9, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 312, 3771, 12, 1768, 1435, 29, 403, 304, 267, 1768, 1435, 275, 1768, 1435, 503, 849, 63, 1302, 1435, 267, 340, 730, 8, 79, 3771, 9, 440, 315, 334, 513, 12, 2008, 304, 288, 3792, 275, 5739, 8, 79, 3771, 9, 267, 587, 26, 288, 3792, 275, 312, 3771, 267, 340, 440, 3792, 26, 288, 746, 2186, 360, 1944, 570, 1911, 315, 450, 83, 7, 450, 312, 3771, 9, 267, 3792, 275, 3842, 442, 8, 1302, 1435, 8, 515, 1826, 931, 9, 367, 931, 315, 3792, 61, 267, 291, 14, 3771, 275, 3355, 8, 3771, 12, 790, 29, 2734, 671, 26, 671, 59, 16, 566, 267, 291, 14, 1943, 889, 12, 291, 14, 3771, 275, 769, 8, 3065, 2031, 277, 14, 3771, 430, 267, 291, 14, 1143, 12, 291, 14, 761, 275, 6277, 18, 14, 1017, 739, 8, 277, 14, 3771, 59, 16, 6575, 1392, 1491, 18, 61, 267, 291, 14, 1080, 275, 446, 17, 339, 347, 4683, 8, 277, 304, 267, 986, 339, 347, 1586, 8, 277, 304, 267, 291, 14, 1080, 847, 413, 267, 340, 822, 8, 277, 14, 3771, 9, 2695, 291, 14, 1080, 26, 288, 372, 756, 12, 488, 267, 862, 26, 288, 372, 715, 12, 6277, 18, 14, 1017, 739, 8, 277, 14, 3771, 59, 277, 14, 1080, 566, 267, 871, 26, 288, 372, 488, 12, 488, 339, 347, 664, 8, 277, 12, 284, 304, 267, 340, 284, 508, 650, 26, 288, 372, 291, 14, 761, 267, 916, 284, 508, 841, 26, 288, 372, 291, 14, 1143, 267, 916, 284, 508, 959, 26, 288, 372, 4233, 267, 916, 284, 508, 1520, 26, 288, 372, 822, 8, 277, 14, 3771, 9, 339, 347, 663, 8, 277, 12, 284, 12, 1343, 63, 1943, 304, 267, 291, 14, 1080, 847, 334, 928, 63, 1943, 446, 413, 9, 4388, 199, 318, 2372, 7658, 8, 86, 515, 12, 627, 65, 12, 1011, 829, 304, 272, 340, 730, 8, 86, 515, 9, 508, 1109, 26, 267, 372, 283, 1745, 297, 6277, 18, 14, 9166, 16640, 8, 86, 515, 9, 272, 916, 730, 8, 86, 515, 9, 315, 334, 513, 12, 2960, 9, 503, 13626, 315, 373, 515, 26, 267, 372, 283, 1017, 458, 297, 473, 77, 18, 9166, 8, 86, 515, 12, 627, 65, 12, 1011, 829, 9, 272, 587, 26, 267, 702, 3495, 8, 86, 515, 395, 283, 9166, 3814, 4124, 26, 450, 83, 7, 450, 373, 515, 267, 372, 283, 3722, 297, 6277, 18, 14, 9166, 16640, 8, 86, 515, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6032, 63, 14129, 12, 16952, 12, 4629, 12, 3679, 63, 646, 12, 543, 63, 6242, 12, 870, 63, 1593, 12, 2649, 63, 5955, 4388, 199, 504, 1275, 5624, 810, 3024, 492, 627, 199, 199, 318, 849, 63, 1302, 1435, 8, 88, 304, 272, 862, 26, 267, 372, 1109, 8, 88, 14, 1294, 6412, 5832, 17, 1055, 1294, 19237, 16, 566, 272, 871, 26, 267, 862, 26, 288, 372, 1109, 8, 4846, 8, 88, 680, 1294, 6412, 5832, 17, 1055, 1294, 19237, 16, 566, 267, 871, 26, 288, 372, 378, 199, 199, 533, 473, 77, 18, 9166, 837, 272, 1449, 272, 347, 1768, 1435, 8, 3236, 1619, 304, 267, 372, 1742, 1619, 14, 1814, 5175, 8476, 26516, 1294, 6412, 5832, 17, 61, 272, 373, 515, 275, 4263, 8, 697, 515, 12, 519, 7, 3722, 1017, 458, 6331, 24915, 272, 27570, 275, 473, 77, 458, 18, 9166, 8, 86, 515, 12, 1768, 1435, 9, 272, 3991, 275, 25610, 8, 15176, 9, 272, 27570, 275, 11086, 7940, 8, 15176, 9, 272, 284, 706, 1917, 275, 4747, 8, 3722, 9, 272, 367, 289, 889, 12, 6050, 315, 3991, 14, 2802, 837, 267, 284, 706, 1917, 360, 2384, 63, 3722, 297, 6050, 12, 413, 9, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 312, 3771, 12, 1768, 1435, 29, 403, 304, 267, 1768, 1435, 275, 1768, 1435, 503, 849, 63, 1302, 1435, 267, 340, 730, 8, 79, 3771, 9, 440, 315, 334, 513, 12, 2008, 304, 288, 3792, 275, 5739, 8, 79, 3771, 9, 267, 587, 26, 288, 3792, 275, 312, 3771, 267, 340, 440, 3792, 26, 288, 746, 2186, 360, 1944, 570, 1911, 315, 450, 83, 7, 450, 312, 3771, 9, 267, 3792, 275, 3842, 442, 8, 1302, 1435, 8, 515, 1826, 931, 9, 367, 931, 315, 3792, 61, 267, 291, 14, 3771, 275, 3355, 8, 3771, 12, 790, 29, 2734, 671, 26, 671, 59, 16, 566, 267, 291, 14, 1943, 889, 12, 291, 14, 3771, 275, 769, 8, 3065, 2031, 277, 14, 3771, 430, 267, 291, 14, 1143, 12, 291, 14, 761, 275, 6277, 18, 14, 1017, 739, 8, 277, 14, 3771, 59, 16, 6575, 1392, 1491, 18, 61, 267, 291, 14, 1080, 275, 446, 17, 339, 347, 4683, 8, 277, 304, 267, 986, 339, 347, 1586, 8, 277, 304, 267, 291, 14, 1080, 847, 413, 267, 340, 822, 8, 277, 14, 3771, 9, 2695, 291, 14, 1080, 26, 288, 372, 756, 12, 488, 267, 862, 26, 288, 372, 715, 12, 6277, 18, 14, 1017, 739, 8, 277, 14, 3771, 59, 277, 14, 1080, 566, 267, 871, 26, 288, 372, 488, 12, 488, 339, 347, 664, 8, 277, 12, 284, 304, 267, 340, 284, 508, 650, 26, 288, 372, 291, 14, 761, 267, 916, 284, 508, 841, 26, 288, 372, 291, 14, 1143, 267, 916, 284, 508, 959, 26, 288, 372, 4233, 267, 916, 284, 508, 1520, 26, 288, 372, 822, 8, 277, 14, 3771, 9, 339, 347, 663, 8, 277, 12, 284, 12, 1343, 63, 1943, 304, 267, 291, 14, 1080, 847, 334, 928, 63, 1943, 446, 413, 9, 4388, 199, 318, 2372, 7658, 8, 86, 515, 12, 627, 65, 12, 1011, 829, 304, 272, 340, 730, 8, 86, 515, 9, 508, 1109, 26, 267, 372, 283, 1745, 297, 6277, 18, 14, 9166, 16640, 8, 86, 515, 9, 272, 916, 730, 8, 86, 515, 9, 315, 334, 513, 12, 2960, 9, 503, 13626, 315, 373, 515, 26, 267, 372, 283, 1017, 458, 297, 473, 77, 18, 9166, 8, 86, 515, 12, 627, 65, 12, 1011, 829, 9, 272, 587, 26, 267, 702, 3495, 8, 86, 515, 395, 283, 9166, 3814, 4124, 26, 450, 83, 7, 450, 373, 515, 267, 372, 283, 3722, 297, 6277, 18, 14, 9166, 16640, 8, 86, 515, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
fangxingli/hue
desktop/core/ext-py/django-axes-1.5.0/axes/tests.py
10
7395
import random import string import time from django.test import TestCase from django.test.utils import override_settings from django.contrib.auth.models import User from django.core.urlresolvers import NoReverseMatch from django.core.urlresolvers import reverse from axes.decorators import COOLOFF_TIME from axes.decorators import FAILURE_LIMIT from axes.models import AccessLog from axes.signals import user_locked_out from axes.utils import reset class AccessAttemptTest(TestCase): """Test case using custom settings for testing """ VALID_USERNAME = 'valid-username' VALID_PASSWORD = 'valid-password' LOCKED_MESSAGE = 'Account locked: too many login attempts.' LOGIN_FORM_KEY = '<input type="submit" value="Log in" />' def _login(self, is_valid_username=False, is_valid_password=False, user_agent='test-browser'): """Login a user. A valid credential is used when is_valid_username is True, otherwise it will use a random string to make a failed login. """ try: admin_login = reverse('admin:login') except NoReverseMatch: admin_login = reverse('admin:index') if is_valid_username: # Use a valid username username = self.VALID_USERNAME else: # Generate a wrong random username chars = string.ascii_uppercase + string.digits username = ''.join(random.choice(chars) for x in range(10)) if is_valid_password: password = self.VALID_PASSWORD else: password = 'invalid-password' response = self.client.post(admin_login, { 'username': username, 'password': password, 'this_is_the_login_form': 1, }, HTTP_USER_AGENT=user_agent) return response def setUp(self): """Create a valid user for login """ self.user = User.objects.create_superuser( username=self.VALID_USERNAME, email='test@example.com', password=self.VALID_PASSWORD, ) def test_failure_limit_once(self): """Tests the login lock trying to login one more time than failure limit """ for i in range(1, FAILURE_LIMIT): # test until one try before the limit response = self._login() # Check if we are in the same login page self.assertContains(response, self.LOGIN_FORM_KEY) # So, we shouldn't have gotten a lock-out yet. # But we should get one now response = self._login() self.assertContains(response, self.LOCKED_MESSAGE) def test_failure_limit_many(self): """Tests the login lock trying to login a lot of times more than failure limit """ for i in range(1, FAILURE_LIMIT): response = self._login() # Check if we are in the same login page self.assertContains(response, self.LOGIN_FORM_KEY) # So, we shouldn't have gotten a lock-out yet. # We should get a locked message each time we try again for i in range(0, random.randrange(1, FAILURE_LIMIT)): response = self._login() self.assertContains(response, self.LOCKED_MESSAGE) def test_valid_login(self): """Tests a valid login for a real username """ response = self._login(is_valid_username=True, is_valid_password=True) self.assertNotContains(response, self.LOGIN_FORM_KEY, status_code=302) def test_valid_logout(self): """Tests a valid logout and make sure the logout_time is updated """ response = self._login(is_valid_username=True, is_valid_password=True) self.assertEquals(AccessLog.objects.latest('id').logout_time, None) response = self.client.get(reverse('admin:logout')) self.assertNotEquals(AccessLog.objects.latest('id').logout_time, None) self.assertContains(response, 'Logged out') def test_cooling_off(self): """Tests if the cooling time allows a user to login """ self.test_failure_limit_once() # Wait for the cooling off period time.sleep(COOLOFF_TIME.total_seconds()) # It should be possible to login again, make sure it is. self.test_valid_login() def test_cooling_off_for_trusted_user(self): """Test the cooling time for a trusted user """ # Test successful login-logout, this makes the user trusted. self.test_valid_logout() # Try the cooling off time self.test_cooling_off() def test_long_user_agent_valid(self): """Tests if can handle a long user agent """ long_user_agent = 'ie6' * 1024 response = self._login(is_valid_username=True, is_valid_password=True, user_agent=long_user_agent) self.assertNotContains(response, self.LOGIN_FORM_KEY, status_code=302) def test_long_user_agent_not_valid(self): """Tests if can handle a long user agent with failure """ long_user_agent = 'ie6' * 1024 for i in range(0, FAILURE_LIMIT + 1): response = self._login(user_agent=long_user_agent) self.assertContains(response, self.LOCKED_MESSAGE) def test_reset_ip(self): """Tests if can reset an ip address """ # Make a lockout self.test_failure_limit_once() # Reset the ip so we can try again reset(ip='127.0.0.1') # Make a login attempt again self.test_valid_login() def test_reset_all(self): """Tests if can reset all attempts """ # Make a lockout self.test_failure_limit_once() # Reset all attempts so we can try again reset() # Make a login attempt again self.test_valid_login() def test_send_lockout_signal(self): """Test if the lockout signal is emitted """ class Scope(object): pass # this "hack" is needed so we don't have to use global variables or python3 features scope = Scope() scope.signal_received = 0 def signal_handler(request, username, ip_address, *args, **kwargs): scope.signal_received += 1 self.assertIsNotNone(request) # Connect signal handler user_locked_out.connect(signal_handler) # Make a lockout self.test_failure_limit_once() self.assertEquals(scope.signal_received, 1) reset() # Make another lockout self.test_failure_limit_once() self.assertEquals(scope.signal_received, 2) @override_settings(AXES_LOCK_OUT_BY_COMBINATION_USER_AND_IP=True) def test_lockout_by_combination_user_and_ip(self): """Tests the login lock with a valid username and invalid password when AXES_LOCK_OUT_BY_COMBINATION_USER_AND_IP is True """ for i in range(1, FAILURE_LIMIT): # test until one try before the limit response = self._login(is_valid_username=True, is_valid_password=False) # Check if we are in the same login page self.assertContains(response, self.LOGIN_FORM_KEY) # So, we shouldn't have gotten a lock-out yet. # But we should get one now response = self._login(is_valid_username=True, is_valid_password=False) self.assertContains(response, self.LOCKED_MESSAGE)
apache-2.0
[ 646, 2196, 199, 646, 1059, 199, 646, 900, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 16522, 492, 32036, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 7824, 14, 11582, 492, 5099, 47, 1484, 1665, 63, 4961, 199, 504, 7824, 14, 11582, 492, 10341, 3942, 63, 13387, 199, 504, 7824, 14, 992, 492, 11003, 2445, 199, 504, 7824, 14, 10458, 492, 922, 63, 9325, 63, 548, 199, 504, 7824, 14, 1208, 492, 5305, 421, 199, 533, 11003, 23272, 774, 8, 1746, 304, 272, 408, 774, 1930, 1808, 3537, 2202, 367, 5343, 272, 408, 272, 22049, 63, 11958, 275, 283, 1078, 13, 2473, 7, 272, 22049, 63, 9032, 275, 283, 1078, 13, 2060, 7, 272, 3412, 2504, 1149, 63, 8272, 275, 283, 6009, 14233, 26, 4634, 5002, 4676, 12454, 3530, 272, 5051, 568, 63, 3516, 63, 3078, 275, 2650, 1210, 730, 628, 7275, 2, 574, 628, 2445, 315, 2, 22294, 339, 347, 485, 2886, 8, 277, 12, 365, 63, 1078, 63, 2473, 29, 797, 12, 365, 63, 1078, 63, 2060, 29, 797, 12, 922, 63, 4054, 534, 396, 13, 5750, 735, 267, 408, 8880, 282, 922, 14, 437, 1686, 16338, 365, 1202, 1380, 365, 63, 1078, 63, 2473, 365, 715, 12, 267, 4257, 652, 911, 675, 282, 2196, 1059, 370, 1852, 282, 3405, 4676, 14, 267, 408, 267, 862, 26, 288, 4628, 63, 2886, 275, 3837, 360, 2113, 26, 2886, 358, 267, 871, 32036, 26, 288, 4628, 63, 2886, 275, 3837, 360, 2113, 26, 1080, 358, 398, 340, 365, 63, 1078, 63, 2473, 26, 288, 327, 3645, 282, 1686, 3434, 288, 3434, 275, 291, 14, 5600, 63, 11958, 267, 587, 26, 288, 327, 7958, 282, 6835, 2196, 3434, 288, 8365, 275, 1059, 14, 4371, 63, 26831, 435, 1059, 14, 7022, 288, 3434, 275, 6522, 904, 8, 2355, 14, 5095, 8, 6574, 9, 367, 671, 315, 1425, 8, 709, 430, 398, 340, 365, 63, 1078, 63, 2060, 26, 288, 2505, 275, 291, 14, 5600, 63, 9032, 267, 587, 26, 288, 2505, 275, 283, 3197, 13, 2060, 7, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 2113, 63, 2886, 12, 469, 288, 283, 2473, 356, 3434, 12, 288, 283, 2060, 356, 2505, 12, 288, 283, 3749, 63, 374, 63, 1589, 63, 2886, 63, 964, 356, 413, 12, 267, 1660, 3101, 63, 3791, 63, 14565, 29, 751, 63, 4054, 9, 398, 372, 1177, 339, 347, 3613, 8, 277, 304, 267, 408, 2499, 282, 1686, 922, 367, 4676, 267, 408, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 11434, 8, 288, 3434, 29, 277, 14, 5600, 63, 11958, 12, 288, 3031, 534, 396, 32, 2694, 14, 957, 297, 288, 2505, 29, 277, 14, 5600, 63, 9032, 12, 267, 776, 339, 347, 511, 63, 5328, 63, 3097, 63, 5089, 8, 277, 304, 267, 408, 2925, 314, 4676, 4650, 9936, 370, 4676, 1373, 1655, 900, 267, 2419, 5988, 2304, 267, 408, 267, 367, 284, 315, 1425, 8, 17, 12, 10341, 3942, 63, 13387, 304, 221, 327, 511, 5133, 1373, 862, 2544, 314, 2304, 288, 1177, 275, 291, 423, 2886, 342, 288, 327, 2670, 340, 781, 787, 315, 314, 2011, 4676, 2034, 288, 291, 14, 9535, 8, 1310, 12, 291, 14, 17208, 63, 3516, 63, 3078, 9, 398, 327, 2002, 12, 781, 9296, 1133, 1172, 4788, 724, 282, 4650, 13, 548, 5966, 14, 267, 327, 11017, 781, 1077, 664, 1373, 3063, 267, 1177, 275, 291, 423, 2886, 342, 267, 291, 14, 9535, 8, 1310, 12, 291, 14, 4406, 1149, 63, 8272, 9, 339, 347, 511, 63, 5328, 63, 3097, 63, 3479, 8, 277, 304, 267, 408, 2925, 314, 4676, 4650, 9936, 370, 4676, 282, 13918, 402, 5431, 1655, 267, 2419, 5988, 2304, 267, 408, 267, 367, 284, 315, 1425, 8, 17, 12, 10341, 3942, 63, 13387, 304, 288, 1177, 275, 291, 423, 2886, 342, 288, 327, 2670, 340, 781, 787, 315, 314, 2011, 4676, 2034, 288, 291, 14, 9535, 8, 1310, 12, 291, 14, 17208, 63, 3516, 63, 3078, 9, 398, 327, 2002, 12, 781, 9296, 1133, 1172, 4788, 724, 282, 4650, 13, 548, 5966, 14, 267, 327, 2136, 1077, 664, 282, 14233, 1245, 1924, 900, 781, 862, 4020, 267, 367, 284, 315, 1425, 8, 16, 12, 2196, 14, 20539, 8, 17, 12, 10341, 3942, 63, 13387, 2298, 288, 1177, 275, 291, 423, 2886, 342, 288, 291, 14, 9535, 8, 1310, 12, 291, 14, 4406, 1149, 63, 8272, 9, 339, 347, 511, 63, 1078, 63, 2886, 8, 277, 304, 267, 408, 2925, 282, 1686, 4676, 367, 282, 3363, 3434, 267, 408, 267, 1177, 275, 291, 423, 2886, 8, 374, 63, 1078, 63, 2473, 29, 549, 12, 365, 63, 1078, 63, 2060, 29, 549, 9, 267, 291, 14, 23218, 8, 1310, 12, 291, 14, 17208, 63, 3516, 63, 3078, 12, 2004, 63, 600, 29, 8551, 9, 339, 347, 511, 63, 1078, 63, 11646, 8, 277, 304, 267, 408, 2925, 282, 1686, 22079, 436, 1852, 3238, 314, 22079, 63, 521, 365, 4588, 267, 408, 267, 1177, 275, 291, 423, 2886, 8, 374, 63, 1078, 63, 2473, 29, 549, 12, 365, 63, 1078, 63, 2060, 29, 549, 9, 267, 291, 14, 2947, 8, 3946, 2445, 14, 1462, 14, 7410, 360, 344, 1959, 11646, 63, 521, 12, 488, 9, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 2113, 26, 11646, 1333, 267, 291, 14, 7418, 83, 8, 3946, 2445, 14, 1462, 14, 7410, 360, 344, 1959, 11646, 63, 521, 12, 488, 9, 267, 291, 14, 9535, 8, 1310, 12, 283, 28985, 734, 358, 339, 347, 511, 63, 18499, 316, 63, 1997, 8, 277, 304, 267, 408, 2925, 340, 314, 32268, 316, 900, 6127, 282, 922, 370, 4676, 267, 408, 267, 291, 14, 396, 63, 5328, 63, 3097, 63, 5089, 342, 398, 327, 13144, 367, 314, 32268, 316, 2331, 6247, 267, 900, 14, 4532, 8, 1439, 47, 1484, 1665, 63, 4961, 14, 2923, 63, 4515, 1012, 398, 327, 2779, 1077, 506, 3962, 370, 4676, 4020, 12, 1852, 3238, 652, 365, 14, 267, 291, 14, 396, 63, 1078, 63 ]
[ 2196, 199, 646, 1059, 199, 646, 900, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 16522, 492, 32036, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 7824, 14, 11582, 492, 5099, 47, 1484, 1665, 63, 4961, 199, 504, 7824, 14, 11582, 492, 10341, 3942, 63, 13387, 199, 504, 7824, 14, 992, 492, 11003, 2445, 199, 504, 7824, 14, 10458, 492, 922, 63, 9325, 63, 548, 199, 504, 7824, 14, 1208, 492, 5305, 421, 199, 533, 11003, 23272, 774, 8, 1746, 304, 272, 408, 774, 1930, 1808, 3537, 2202, 367, 5343, 272, 408, 272, 22049, 63, 11958, 275, 283, 1078, 13, 2473, 7, 272, 22049, 63, 9032, 275, 283, 1078, 13, 2060, 7, 272, 3412, 2504, 1149, 63, 8272, 275, 283, 6009, 14233, 26, 4634, 5002, 4676, 12454, 3530, 272, 5051, 568, 63, 3516, 63, 3078, 275, 2650, 1210, 730, 628, 7275, 2, 574, 628, 2445, 315, 2, 22294, 339, 347, 485, 2886, 8, 277, 12, 365, 63, 1078, 63, 2473, 29, 797, 12, 365, 63, 1078, 63, 2060, 29, 797, 12, 922, 63, 4054, 534, 396, 13, 5750, 735, 267, 408, 8880, 282, 922, 14, 437, 1686, 16338, 365, 1202, 1380, 365, 63, 1078, 63, 2473, 365, 715, 12, 267, 4257, 652, 911, 675, 282, 2196, 1059, 370, 1852, 282, 3405, 4676, 14, 267, 408, 267, 862, 26, 288, 4628, 63, 2886, 275, 3837, 360, 2113, 26, 2886, 358, 267, 871, 32036, 26, 288, 4628, 63, 2886, 275, 3837, 360, 2113, 26, 1080, 358, 398, 340, 365, 63, 1078, 63, 2473, 26, 288, 327, 3645, 282, 1686, 3434, 288, 3434, 275, 291, 14, 5600, 63, 11958, 267, 587, 26, 288, 327, 7958, 282, 6835, 2196, 3434, 288, 8365, 275, 1059, 14, 4371, 63, 26831, 435, 1059, 14, 7022, 288, 3434, 275, 6522, 904, 8, 2355, 14, 5095, 8, 6574, 9, 367, 671, 315, 1425, 8, 709, 430, 398, 340, 365, 63, 1078, 63, 2060, 26, 288, 2505, 275, 291, 14, 5600, 63, 9032, 267, 587, 26, 288, 2505, 275, 283, 3197, 13, 2060, 7, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 2113, 63, 2886, 12, 469, 288, 283, 2473, 356, 3434, 12, 288, 283, 2060, 356, 2505, 12, 288, 283, 3749, 63, 374, 63, 1589, 63, 2886, 63, 964, 356, 413, 12, 267, 1660, 3101, 63, 3791, 63, 14565, 29, 751, 63, 4054, 9, 398, 372, 1177, 339, 347, 3613, 8, 277, 304, 267, 408, 2499, 282, 1686, 922, 367, 4676, 267, 408, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 11434, 8, 288, 3434, 29, 277, 14, 5600, 63, 11958, 12, 288, 3031, 534, 396, 32, 2694, 14, 957, 297, 288, 2505, 29, 277, 14, 5600, 63, 9032, 12, 267, 776, 339, 347, 511, 63, 5328, 63, 3097, 63, 5089, 8, 277, 304, 267, 408, 2925, 314, 4676, 4650, 9936, 370, 4676, 1373, 1655, 900, 267, 2419, 5988, 2304, 267, 408, 267, 367, 284, 315, 1425, 8, 17, 12, 10341, 3942, 63, 13387, 304, 221, 327, 511, 5133, 1373, 862, 2544, 314, 2304, 288, 1177, 275, 291, 423, 2886, 342, 288, 327, 2670, 340, 781, 787, 315, 314, 2011, 4676, 2034, 288, 291, 14, 9535, 8, 1310, 12, 291, 14, 17208, 63, 3516, 63, 3078, 9, 398, 327, 2002, 12, 781, 9296, 1133, 1172, 4788, 724, 282, 4650, 13, 548, 5966, 14, 267, 327, 11017, 781, 1077, 664, 1373, 3063, 267, 1177, 275, 291, 423, 2886, 342, 267, 291, 14, 9535, 8, 1310, 12, 291, 14, 4406, 1149, 63, 8272, 9, 339, 347, 511, 63, 5328, 63, 3097, 63, 3479, 8, 277, 304, 267, 408, 2925, 314, 4676, 4650, 9936, 370, 4676, 282, 13918, 402, 5431, 1655, 267, 2419, 5988, 2304, 267, 408, 267, 367, 284, 315, 1425, 8, 17, 12, 10341, 3942, 63, 13387, 304, 288, 1177, 275, 291, 423, 2886, 342, 288, 327, 2670, 340, 781, 787, 315, 314, 2011, 4676, 2034, 288, 291, 14, 9535, 8, 1310, 12, 291, 14, 17208, 63, 3516, 63, 3078, 9, 398, 327, 2002, 12, 781, 9296, 1133, 1172, 4788, 724, 282, 4650, 13, 548, 5966, 14, 267, 327, 2136, 1077, 664, 282, 14233, 1245, 1924, 900, 781, 862, 4020, 267, 367, 284, 315, 1425, 8, 16, 12, 2196, 14, 20539, 8, 17, 12, 10341, 3942, 63, 13387, 2298, 288, 1177, 275, 291, 423, 2886, 342, 288, 291, 14, 9535, 8, 1310, 12, 291, 14, 4406, 1149, 63, 8272, 9, 339, 347, 511, 63, 1078, 63, 2886, 8, 277, 304, 267, 408, 2925, 282, 1686, 4676, 367, 282, 3363, 3434, 267, 408, 267, 1177, 275, 291, 423, 2886, 8, 374, 63, 1078, 63, 2473, 29, 549, 12, 365, 63, 1078, 63, 2060, 29, 549, 9, 267, 291, 14, 23218, 8, 1310, 12, 291, 14, 17208, 63, 3516, 63, 3078, 12, 2004, 63, 600, 29, 8551, 9, 339, 347, 511, 63, 1078, 63, 11646, 8, 277, 304, 267, 408, 2925, 282, 1686, 22079, 436, 1852, 3238, 314, 22079, 63, 521, 365, 4588, 267, 408, 267, 1177, 275, 291, 423, 2886, 8, 374, 63, 1078, 63, 2473, 29, 549, 12, 365, 63, 1078, 63, 2060, 29, 549, 9, 267, 291, 14, 2947, 8, 3946, 2445, 14, 1462, 14, 7410, 360, 344, 1959, 11646, 63, 521, 12, 488, 9, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 2113, 26, 11646, 1333, 267, 291, 14, 7418, 83, 8, 3946, 2445, 14, 1462, 14, 7410, 360, 344, 1959, 11646, 63, 521, 12, 488, 9, 267, 291, 14, 9535, 8, 1310, 12, 283, 28985, 734, 358, 339, 347, 511, 63, 18499, 316, 63, 1997, 8, 277, 304, 267, 408, 2925, 340, 314, 32268, 316, 900, 6127, 282, 922, 370, 4676, 267, 408, 267, 291, 14, 396, 63, 5328, 63, 3097, 63, 5089, 342, 398, 327, 13144, 367, 314, 32268, 316, 2331, 6247, 267,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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 ]
jonathf/chaospy
chaospy/distributions/baseclass/operator.py
1
2655
"""Operator transformation.""" import numpy import chaospy from ..baseclass import Distribution class OperatorDistribution(Distribution): """Operator transformation.""" def __init__(self, left, right, exclusion=None, repr_args=None): if not isinstance(left, Distribution): left = numpy.atleast_1d(left) if left.ndim > 1: raise chaospy.UnsupportedFeature( "distribution operators limited to at-most 1D arrays.") if not isinstance(right, Distribution): right = numpy.atleast_1d(right) if right.ndim > 1: raise chaospy.UnsupportedFeature( "distribution operators limited to at-most 1D arrays.") dependencies, parameters, rotation = chaospy.declare_dependencies( distribution=self, parameters=dict(left=left, right=right), is_operator=True, ) super(OperatorDistribution, self).__init__( parameters=parameters, dependencies=dependencies, exclusion=exclusion, repr_args=repr_args, ) self._cache_copy = {} self._lower_cache = {} self._upper_cache = {} def get_parameters(self, idx, cache, assert_numerical=True): parameters = super(OperatorDistribution, self).get_parameters( idx, cache, assert_numerical=assert_numerical) assert set(parameters) == {"cache", "left", "right", "idx"} if isinstance(parameters["left"], Distribution): parameters["left"] = parameters["left"]._get_cache(idx, cache=parameters["cache"], get=0) elif len(parameters["left"]) > 1 and idx is not None: parameters["left"] = parameters["left"][idx] if isinstance(parameters["right"], Distribution): parameters["right"] = parameters["right"]._get_cache(idx, cache=parameters["cache"], get=0) elif len(parameters["right"]) > 1 and idx is not None: parameters["right"] = parameters["right"][idx] if assert_numerical: assert (not isinstance(parameters["left"], Distribution) or not isinstance(parameters["right"], Distribution)) if cache is not self._cache_copy: self._cache_copy = cache self._lower_cache = {} self._upper_cache = {} if idx is None: del parameters["idx"] return parameters def _cache(self, idx, cache, get): assert get == 0 parameters = self.get_parameters(idx, cache) return self._operator(parameters["left"], parameters["right"])
mit
[ 624, 7961, 13315, 1041, 199, 646, 2680, 199, 646, 682, 31763, 647, 199, 199, 504, 2508, 1095, 533, 492, 11839, 421, 199, 533, 11013, 8580, 8, 8580, 304, 272, 408, 7961, 13315, 1041, 339, 347, 636, 826, 721, 277, 12, 3602, 12, 2451, 12, 27551, 29, 403, 12, 4700, 63, 589, 29, 403, 304, 267, 340, 440, 1228, 8, 3039, 12, 11839, 304, 288, 3602, 275, 2680, 14, 22900, 63, 17, 68, 8, 3039, 9, 288, 340, 3602, 14, 8322, 690, 413, 26, 355, 746, 682, 31763, 647, 14, 12647, 5968, 8, 490, 298, 4972, 10211, 13988, 370, 737, 13, 2786, 413, 36, 6572, 2685, 267, 340, 440, 1228, 8, 1019, 12, 11839, 304, 288, 2451, 275, 2680, 14, 22900, 63, 17, 68, 8, 1019, 9, 288, 340, 2451, 14, 8322, 690, 413, 26, 355, 746, 682, 31763, 647, 14, 12647, 5968, 8, 490, 298, 4972, 10211, 13988, 370, 737, 13, 2786, 413, 36, 6572, 2685, 267, 5124, 12, 2633, 12, 13038, 275, 682, 31763, 647, 14, 16536, 63, 5714, 8, 288, 4084, 29, 277, 12, 288, 2633, 29, 807, 8, 3039, 29, 3039, 12, 2451, 29, 1019, 395, 288, 365, 63, 3856, 29, 549, 12, 267, 776, 398, 1613, 8, 7961, 8580, 12, 291, 2843, 826, 721, 288, 2633, 29, 3214, 12, 288, 5124, 29, 5714, 12, 288, 27551, 29, 476, 10248, 12, 288, 4700, 63, 589, 29, 2722, 63, 589, 12, 267, 776, 267, 291, 423, 1637, 63, 1574, 275, 1052, 267, 291, 423, 2325, 63, 1637, 275, 1052, 267, 291, 423, 4142, 63, 1637, 275, 1052, 339, 347, 664, 63, 3214, 8, 277, 12, 4280, 12, 2581, 12, 702, 63, 10563, 8825, 29, 549, 304, 267, 2633, 275, 1613, 8, 7961, 8580, 12, 291, 680, 362, 63, 3214, 8, 288, 4280, 12, 2581, 12, 702, 63, 10563, 8825, 29, 479, 63, 10563, 8825, 9, 267, 702, 663, 8, 3214, 9, 508, 2420, 1637, 401, 298, 3039, 401, 298, 1019, 401, 298, 2996, 3570, 398, 340, 1228, 8, 3214, 905, 3039, 2255, 11839, 304, 288, 2633, 905, 3039, 937, 275, 2633, 905, 3039, 937, 423, 362, 63, 1637, 8, 2996, 12, 2581, 29, 3214, 905, 1637, 2255, 664, 29, 16, 9, 267, 916, 822, 8, 3214, 905, 3039, 3135, 690, 413, 436, 4280, 365, 440, 488, 26, 288, 2633, 905, 3039, 937, 275, 2633, 905, 3039, 9210, 2996, 61, 267, 340, 1228, 8, 3214, 905, 1019, 2255, 11839, 304, 288, 2633, 905, 1019, 937, 275, 2633, 905, 1019, 937, 423, 362, 63, 1637, 8, 2996, 12, 2581, 29, 3214, 905, 1637, 2255, 664, 29, 16, 9, 267, 916, 822, 8, 3214, 905, 1019, 3135, 690, 413, 436, 4280, 365, 440, 488, 26, 288, 2633, 905, 1019, 937, 275, 2633, 905, 1019, 9210, 2996, 61, 398, 340, 702, 63, 10563, 8825, 26, 288, 702, 334, 1397, 1228, 8, 3214, 905, 3039, 2255, 11839, 9, 503, 490, 440, 1228, 8, 3214, 905, 1019, 2255, 11839, 430, 267, 340, 2581, 365, 440, 291, 423, 1637, 63, 1574, 26, 288, 291, 423, 1637, 63, 1574, 275, 2581, 288, 291, 423, 2325, 63, 1637, 275, 1052, 288, 291, 423, 4142, 63, 1637, 275, 1052, 267, 340, 4280, 365, 488, 26, 288, 2150, 2633, 905, 2996, 937, 267, 372, 2633, 339, 347, 485, 1637, 8, 277, 12, 4280, 12, 2581, 12, 664, 304, 267, 702, 664, 508, 378, 267, 2633, 275, 291, 14, 362, 63, 3214, 8, 2996, 12, 2581, 9, 267, 372, 291, 423, 3856, 8, 3214, 905, 3039, 2255, 2633, 905, 1019, 3135, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7961, 13315, 1041, 199, 646, 2680, 199, 646, 682, 31763, 647, 199, 199, 504, 2508, 1095, 533, 492, 11839, 421, 199, 533, 11013, 8580, 8, 8580, 304, 272, 408, 7961, 13315, 1041, 339, 347, 636, 826, 721, 277, 12, 3602, 12, 2451, 12, 27551, 29, 403, 12, 4700, 63, 589, 29, 403, 304, 267, 340, 440, 1228, 8, 3039, 12, 11839, 304, 288, 3602, 275, 2680, 14, 22900, 63, 17, 68, 8, 3039, 9, 288, 340, 3602, 14, 8322, 690, 413, 26, 355, 746, 682, 31763, 647, 14, 12647, 5968, 8, 490, 298, 4972, 10211, 13988, 370, 737, 13, 2786, 413, 36, 6572, 2685, 267, 340, 440, 1228, 8, 1019, 12, 11839, 304, 288, 2451, 275, 2680, 14, 22900, 63, 17, 68, 8, 1019, 9, 288, 340, 2451, 14, 8322, 690, 413, 26, 355, 746, 682, 31763, 647, 14, 12647, 5968, 8, 490, 298, 4972, 10211, 13988, 370, 737, 13, 2786, 413, 36, 6572, 2685, 267, 5124, 12, 2633, 12, 13038, 275, 682, 31763, 647, 14, 16536, 63, 5714, 8, 288, 4084, 29, 277, 12, 288, 2633, 29, 807, 8, 3039, 29, 3039, 12, 2451, 29, 1019, 395, 288, 365, 63, 3856, 29, 549, 12, 267, 776, 398, 1613, 8, 7961, 8580, 12, 291, 2843, 826, 721, 288, 2633, 29, 3214, 12, 288, 5124, 29, 5714, 12, 288, 27551, 29, 476, 10248, 12, 288, 4700, 63, 589, 29, 2722, 63, 589, 12, 267, 776, 267, 291, 423, 1637, 63, 1574, 275, 1052, 267, 291, 423, 2325, 63, 1637, 275, 1052, 267, 291, 423, 4142, 63, 1637, 275, 1052, 339, 347, 664, 63, 3214, 8, 277, 12, 4280, 12, 2581, 12, 702, 63, 10563, 8825, 29, 549, 304, 267, 2633, 275, 1613, 8, 7961, 8580, 12, 291, 680, 362, 63, 3214, 8, 288, 4280, 12, 2581, 12, 702, 63, 10563, 8825, 29, 479, 63, 10563, 8825, 9, 267, 702, 663, 8, 3214, 9, 508, 2420, 1637, 401, 298, 3039, 401, 298, 1019, 401, 298, 2996, 3570, 398, 340, 1228, 8, 3214, 905, 3039, 2255, 11839, 304, 288, 2633, 905, 3039, 937, 275, 2633, 905, 3039, 937, 423, 362, 63, 1637, 8, 2996, 12, 2581, 29, 3214, 905, 1637, 2255, 664, 29, 16, 9, 267, 916, 822, 8, 3214, 905, 3039, 3135, 690, 413, 436, 4280, 365, 440, 488, 26, 288, 2633, 905, 3039, 937, 275, 2633, 905, 3039, 9210, 2996, 61, 267, 340, 1228, 8, 3214, 905, 1019, 2255, 11839, 304, 288, 2633, 905, 1019, 937, 275, 2633, 905, 1019, 937, 423, 362, 63, 1637, 8, 2996, 12, 2581, 29, 3214, 905, 1637, 2255, 664, 29, 16, 9, 267, 916, 822, 8, 3214, 905, 1019, 3135, 690, 413, 436, 4280, 365, 440, 488, 26, 288, 2633, 905, 1019, 937, 275, 2633, 905, 1019, 9210, 2996, 61, 398, 340, 702, 63, 10563, 8825, 26, 288, 702, 334, 1397, 1228, 8, 3214, 905, 3039, 2255, 11839, 9, 503, 490, 440, 1228, 8, 3214, 905, 1019, 2255, 11839, 430, 267, 340, 2581, 365, 440, 291, 423, 1637, 63, 1574, 26, 288, 291, 423, 1637, 63, 1574, 275, 2581, 288, 291, 423, 2325, 63, 1637, 275, 1052, 288, 291, 423, 4142, 63, 1637, 275, 1052, 267, 340, 4280, 365, 488, 26, 288, 2150, 2633, 905, 2996, 937, 267, 372, 2633, 339, 347, 485, 1637, 8, 277, 12, 4280, 12, 2581, 12, 664, 304, 267, 702, 664, 508, 378, 267, 2633, 275, 291, 14, 362, 63, 3214, 8, 2996, 12, 2581, 9, 267, 372, 291, 423, 3856, 8, 3214, 905, 3039, 2255, 2633, 905, 1019, 3135, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
tsdmgz/ansible
lib/ansible/modules/windows/win_tempfile.py
47
2164
#!/usr/bin/python # coding: utf-8 -*- # (c) 2017 Dag Wieers <dag@wieers.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 = r''' --- module: win_tempfile version_added: "2.3" author: Dag Wieers (@dagwieers) short_description: Creates temporary files and directories. description: - Creates temporary files and directories. - For non-Windows targets, please use the M(tempfile) module instead. options: state: description: - Whether to create file or directory. choices: [ file, directory ] default: file path: description: - Location where temporary file or directory should be created. - If path is not specified default system temporary directory (%TEMP%) will be used. default: '%TEMP%' prefix: description: - Prefix of file/directory name created by module. default: ansible. suffix: description: - Suffix of file/directory name created by module. default: '' notes: - For non-Windows targets, please use the M(tempfile) module instead. ''' EXAMPLES = r""" - name: Create temporary build directory win_tempfile: state: directory suffix: build - name: Create temporary file win_tempfile: state: file suffix: temp """ RETURN = r''' path: description: Path to created file or directory returned: success type: string sample: C:\Users\Administrator\AppData\Local\Temp\ansible.bMlvdk '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 26110, 644, 1873, 1192, 665, 7406, 32, 87, 1873, 1192, 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, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 17336, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 3612, 63, 1802, 26, 10560, 7937, 1584, 436, 6602, 14, 199, 1802, 26, 523, 446, 10560, 7937, 1584, 436, 6602, 14, 523, 446, 2104, 2222, 13, 8647, 4545, 12, 8749, 675, 314, 603, 8, 17336, 9, 859, 3140, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 370, 1218, 570, 503, 2082, 14, 272, 3415, 26, 359, 570, 12, 2082, 1622, 272, 849, 26, 570, 523, 931, 26, 272, 1369, 26, 489, 446, 12625, 2382, 7937, 570, 503, 2082, 1077, 506, 2737, 14, 489, 446, 982, 931, 365, 440, 2013, 849, 2656, 7937, 2082, 4366, 12510, 5, 9, 911, 506, 1202, 14, 272, 849, 26, 1543, 12510, 5, 7, 523, 2403, 26, 272, 1369, 26, 489, 446, 25110, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 849, 26, 3242, 14, 523, 4739, 26, 272, 1369, 26, 489, 446, 428, 2875, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 849, 26, 2125, 199, 5983, 26, 523, 446, 2104, 2222, 13, 8647, 4545, 12, 8749, 675, 314, 603, 8, 17336, 9, 859, 3140, 14, 199, 2344, 199, 199, 8918, 275, 519, 624, 199, 13, 536, 26, 2790, 7937, 1900, 2082, 523, 4747, 63, 17336, 26, 272, 1174, 26, 2082, 272, 4739, 26, 1900, 199, 199, 13, 536, 26, 2790, 7937, 570, 523, 4747, 63, 17336, 26, 272, 1174, 26, 570, 272, 4739, 26, 2388, 199, 624, 199, 199, 9677, 275, 519, 2344, 199, 515, 26, 523, 1369, 26, 6912, 370, 2737, 570, 503, 2082, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 445, 3427, 12117, 60, 31972, 60, 2640, 1451, 60, 5339, 60, 6530, 60, 4853, 14, 66, 45, 6371, 6341, 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, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 26110, 644, 1873, 1192, 665, 7406, 32, 87, 1873, 1192, 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, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 17336, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 3612, 63, 1802, 26, 10560, 7937, 1584, 436, 6602, 14, 199, 1802, 26, 523, 446, 10560, 7937, 1584, 436, 6602, 14, 523, 446, 2104, 2222, 13, 8647, 4545, 12, 8749, 675, 314, 603, 8, 17336, 9, 859, 3140, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 370, 1218, 570, 503, 2082, 14, 272, 3415, 26, 359, 570, 12, 2082, 1622, 272, 849, 26, 570, 523, 931, 26, 272, 1369, 26, 489, 446, 12625, 2382, 7937, 570, 503, 2082, 1077, 506, 2737, 14, 489, 446, 982, 931, 365, 440, 2013, 849, 2656, 7937, 2082, 4366, 12510, 5, 9, 911, 506, 1202, 14, 272, 849, 26, 1543, 12510, 5, 7, 523, 2403, 26, 272, 1369, 26, 489, 446, 25110, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 849, 26, 3242, 14, 523, 4739, 26, 272, 1369, 26, 489, 446, 428, 2875, 402, 570, 15, 3619, 536, 2737, 701, 859, 14, 272, 849, 26, 2125, 199, 5983, 26, 523, 446, 2104, 2222, 13, 8647, 4545, 12, 8749, 675, 314, 603, 8, 17336, 9, 859, 3140, 14, 199, 2344, 199, 199, 8918, 275, 519, 624, 199, 13, 536, 26, 2790, 7937, 1900, 2082, 523, 4747, 63, 17336, 26, 272, 1174, 26, 2082, 272, 4739, 26, 1900, 199, 199, 13, 536, 26, 2790, 7937, 570, 523, 4747, 63, 17336, 26, 272, 1174, 26, 570, 272, 4739, 26, 2388, 199, 624, 199, 199, 9677, 275, 519, 2344, 199, 515, 26, 523, 1369, 26, 6912, 370, 2737, 570, 503, 2082, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 445, 3427, 12117, 60, 31972, 60, 2640, 1451, 60, 5339, 60, 6530, 60, 4853, 14, 66, 45, 6371, 6341, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yeraydiazdiaz/nonrel-blog
django/db/backends/oracle/creation.py
29
12065
import sys import time from django.db.backends.creation import BaseDatabaseCreation TEST_DATABASE_PREFIX = 'test_' PASSWORD = 'Im_a_lumberjack' class DatabaseCreation(BaseDatabaseCreation): # This dictionary maps Field objects to their associated Oracle column # types, as strings. Column-type strings can contain format strings; they'll # be interpolated against the values of Field.__dict__ before being output. # If a column type is set to None, it won't be included in the output. # # Any format strings starting with "qn_" are quoted before being used in the # output (the "qn_" prefix is stripped before the lookup is performed. data_types = { 'AutoField': 'NUMBER(11)', 'BooleanField': 'NUMBER(1) CHECK (%(qn_column)s IN (0,1))', 'CharField': 'NVARCHAR2(%(max_length)s)', 'CommaSeparatedIntegerField': 'VARCHAR2(%(max_length)s)', 'DateField': 'DATE', 'DateTimeField': 'TIMESTAMP', 'DecimalField': 'NUMBER(%(max_digits)s, %(decimal_places)s)', 'FileField': 'NVARCHAR2(%(max_length)s)', 'FilePathField': 'NVARCHAR2(%(max_length)s)', 'FloatField': 'DOUBLE PRECISION', 'IntegerField': 'NUMBER(11)', 'BigIntegerField': 'NUMBER(19)', 'IPAddressField': 'VARCHAR2(15)', 'GenericIPAddressField': 'VARCHAR2(39)', 'NullBooleanField': 'NUMBER(1) CHECK ((%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL))', 'OneToOneField': 'NUMBER(11)', 'PositiveIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', 'PositiveSmallIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', 'SlugField': 'NVARCHAR2(%(max_length)s)', 'SmallIntegerField': 'NUMBER(11)', 'TextField': 'NCLOB', 'TimeField': 'TIMESTAMP', 'URLField': 'VARCHAR2(%(max_length)s)', } def __init__(self, connection): super(DatabaseCreation, self).__init__(connection) def _create_test_db(self, verbosity=1, autoclobber=False): TEST_NAME = self._test_database_name() TEST_USER = self._test_database_user() TEST_PASSWD = self._test_database_passwd() TEST_TBLSPACE = self._test_database_tblspace() TEST_TBLSPACE_TMP = self._test_database_tblspace_tmp() parameters = { 'dbname': TEST_NAME, 'user': TEST_USER, 'password': TEST_PASSWD, 'tblspace': TEST_TBLSPACE, 'tblspace_temp': TEST_TBLSPACE_TMP, } cursor = self.connection.cursor() if self._test_database_create(): try: self._execute_test_db_creation(cursor, parameters, verbosity) except Exception, e: sys.stderr.write("Got an error creating the test database: %s\n" % e) if not autoclobber: confirm = raw_input("It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_NAME) if autoclobber or confirm == 'yes': try: if verbosity >= 1: print "Destroying old test database '%s'..." % self.connection.alias self._execute_test_db_destruction(cursor, parameters, verbosity) self._execute_test_db_creation(cursor, parameters, verbosity) except Exception, e: sys.stderr.write("Got an error recreating the test database: %s\n" % e) sys.exit(2) else: print "Tests cancelled." sys.exit(1) if self._test_user_create(): if verbosity >= 1: print "Creating test user..." try: self._create_test_user(cursor, parameters, verbosity) except Exception, e: sys.stderr.write("Got an error creating the test user: %s\n" % e) if not autoclobber: confirm = raw_input("It appears the test user, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_USER) if autoclobber or confirm == 'yes': try: if verbosity >= 1: print "Destroying old test user..." self._destroy_test_user(cursor, parameters, verbosity) if verbosity >= 1: print "Creating test user..." self._create_test_user(cursor, parameters, verbosity) except Exception, e: sys.stderr.write("Got an error recreating the test user: %s\n" % e) sys.exit(2) else: print "Tests cancelled." sys.exit(1) self.connection.settings_dict['SAVED_USER'] = self.connection.settings_dict['USER'] self.connection.settings_dict['SAVED_PASSWORD'] = self.connection.settings_dict['PASSWORD'] self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict['USER'] = TEST_USER self.connection.settings_dict['PASSWORD'] = TEST_PASSWD return self.connection.settings_dict['NAME'] def _destroy_test_db(self, test_database_name, verbosity=1): """ Destroy a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created. """ TEST_NAME = self._test_database_name() TEST_USER = self._test_database_user() TEST_PASSWD = self._test_database_passwd() TEST_TBLSPACE = self._test_database_tblspace() TEST_TBLSPACE_TMP = self._test_database_tblspace_tmp() self.connection.settings_dict['USER'] = self.connection.settings_dict['SAVED_USER'] self.connection.settings_dict['PASSWORD'] = self.connection.settings_dict['SAVED_PASSWORD'] parameters = { 'dbname': TEST_NAME, 'user': TEST_USER, 'password': TEST_PASSWD, 'tblspace': TEST_TBLSPACE, 'tblspace_temp': TEST_TBLSPACE_TMP, } cursor = self.connection.cursor() time.sleep(1) # To avoid "database is being accessed by other users" errors. if self._test_user_create(): if verbosity >= 1: print 'Destroying test user...' self._destroy_test_user(cursor, parameters, verbosity) if self._test_database_create(): if verbosity >= 1: print 'Destroying test database tables...' self._execute_test_db_destruction(cursor, parameters, verbosity) self.connection.close() def _execute_test_db_creation(self, cursor, parameters, verbosity): if verbosity >= 2: print "_create_test_db(): dbname = %s" % parameters['dbname'] statements = [ """CREATE TABLESPACE %(tblspace)s DATAFILE '%(tblspace)s.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 200M """, """CREATE TEMPORARY TABLESPACE %(tblspace_temp)s TEMPFILE '%(tblspace_temp)s.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 100M """, ] self._execute_statements(cursor, statements, parameters, verbosity) def _create_test_user(self, cursor, parameters, verbosity): if verbosity >= 2: print "_create_test_user(): username = %s" % parameters['user'] statements = [ """CREATE USER %(user)s IDENTIFIED BY %(password)s DEFAULT TABLESPACE %(tblspace)s TEMPORARY TABLESPACE %(tblspace_temp)s QUOTA UNLIMITED ON %(tblspace)s """, """GRANT CONNECT, RESOURCE TO %(user)s""", ] self._execute_statements(cursor, statements, parameters, verbosity) def _execute_test_db_destruction(self, cursor, parameters, verbosity): if verbosity >= 2: print "_execute_test_db_destruction(): dbname=%s" % parameters['dbname'] statements = [ 'DROP TABLESPACE %(tblspace)s INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS', 'DROP TABLESPACE %(tblspace_temp)s INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS', ] self._execute_statements(cursor, statements, parameters, verbosity) def _destroy_test_user(self, cursor, parameters, verbosity): if verbosity >= 2: print "_destroy_test_user(): user=%s" % parameters['user'] print "Be patient. This can take some time..." statements = [ 'DROP USER %(user)s CASCADE', ] self._execute_statements(cursor, statements, parameters, verbosity) def _execute_statements(self, cursor, statements, parameters, verbosity): for template in statements: stmt = template % parameters if verbosity >= 2: print stmt try: cursor.execute(stmt) except Exception, err: sys.stderr.write("Failed (%s)\n" % (err)) raise def _test_database_name(self): name = TEST_DATABASE_PREFIX + self.connection.settings_dict['NAME'] try: if self.connection.settings_dict['TEST_NAME']: name = self.connection.settings_dict['TEST_NAME'] except AttributeError: pass return name def _test_database_create(self): return self.connection.settings_dict.get('TEST_CREATE', True) def _test_user_create(self): return self.connection.settings_dict.get('TEST_USER_CREATE', True) def _test_database_user(self): name = TEST_DATABASE_PREFIX + self.connection.settings_dict['USER'] try: if self.connection.settings_dict['TEST_USER']: name = self.connection.settings_dict['TEST_USER'] except KeyError: pass return name def _test_database_passwd(self): name = PASSWORD try: if self.connection.settings_dict['TEST_PASSWD']: name = self.connection.settings_dict['TEST_PASSWD'] except KeyError: pass return name def _test_database_tblspace(self): name = TEST_DATABASE_PREFIX + self.connection.settings_dict['NAME'] try: if self.connection.settings_dict['TEST_TBLSPACE']: name = self.connection.settings_dict['TEST_TBLSPACE'] except KeyError: pass return name def _test_database_tblspace_tmp(self): name = TEST_DATABASE_PREFIX + self.connection.settings_dict['NAME'] + '_temp' try: if self.connection.settings_dict['TEST_TBLSPACE_TMP']: name = self.connection.settings_dict['TEST_TBLSPACE_TMP'] except KeyError: pass return name def _get_test_db_name(self): """ We need to return the 'production' DB name to get the test DB creation machinery to work. This isn't a great deal in this case because DB names as handled by Django haven't real counterparts in Oracle. """ return self.connection.settings_dict['NAME'] def test_db_signature(self): settings_dict = self.connection.settings_dict return ( settings_dict['HOST'], settings_dict['PORT'], settings_dict['ENGINE'], settings_dict['NAME'], self._test_database_user(), ) def set_autocommit(self): self.connection.connection.autocommit = True
bsd-3-clause
[ 646, 984, 199, 646, 900, 199, 504, 1639, 14, 697, 14, 7765, 14, 8782, 492, 29103, 13921, 199, 199, 2864, 63, 17873, 63, 6351, 275, 283, 396, 8650, 199, 9032, 275, 283, 16221, 63, 65, 63, 76, 884, 19193, 7, 199, 199, 533, 8692, 13921, 8, 1563, 7243, 13921, 304, 272, 327, 961, 2600, 9033, 5024, 2251, 370, 3932, 4568, 15309, 2763, 272, 327, 2943, 12, 465, 3326, 14, 4996, 13, 466, 3326, 883, 1395, 1475, 3326, 27, 2985, 7171, 272, 327, 506, 23005, 972, 6169, 314, 1338, 402, 5024, 855, 807, 363, 2544, 3769, 1072, 14, 272, 327, 982, 282, 2763, 730, 365, 663, 370, 488, 12, 652, 7859, 1133, 506, 5120, 315, 314, 1072, 14, 272, 327, 272, 327, 6184, 1475, 3326, 6617, 543, 298, 15156, 12172, 787, 10999, 2544, 3769, 1202, 315, 314, 272, 327, 1072, 334, 1589, 298, 15156, 12172, 2403, 365, 14489, 2544, 314, 4237, 365, 10585, 14, 339, 666, 63, 1313, 275, 469, 267, 283, 4378, 356, 8540, 283, 9190, 8, 845, 3196, 267, 283, 5036, 356, 463, 283, 9190, 8, 17, 9, 17654, 17753, 15156, 63, 2301, 9, 83, 1621, 334, 16, 12, 17, 22629, 267, 283, 2183, 356, 8540, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 25732, 20727, 3901, 356, 257, 283, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 14071, 356, 8540, 283, 5390, 297, 267, 283, 4626, 356, 4483, 283, 20277, 297, 267, 283, 15975, 356, 463, 283, 9190, 12473, 988, 63, 7022, 9, 83, 12, 2818, 6355, 63, 10696, 9, 83, 3196, 267, 283, 23252, 356, 8540, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 14225, 792, 356, 4483, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 13019, 356, 7861, 283, 14989, 510, 9481, 30011, 297, 267, 283, 3901, 356, 463, 283, 9190, 8, 845, 3196, 267, 283, 25175, 356, 4519, 283, 9190, 8, 1167, 3196, 267, 283, 26969, 356, 5185, 283, 24800, 18, 8, 1046, 3196, 267, 283, 9417, 26969, 356, 263, 283, 24800, 18, 8, 1355, 3196, 267, 283, 29068, 356, 3777, 283, 9190, 8, 17, 9, 17654, 3666, 2840, 15156, 63, 2301, 9, 83, 1621, 334, 16, 12, 17, 430, 1549, 17753, 15156, 63, 2301, 9, 83, 2281, 5962, 22629, 267, 283, 14298, 356, 4483, 283, 9190, 8, 845, 3196, 267, 283, 8591, 356, 260, 283, 9190, 8, 845, 9, 17654, 17753, 15156, 63, 2301, 9, 83, 2356, 378, 3196, 267, 283, 25197, 356, 259, 283, 9190, 8, 845, 9, 17654, 17753, 15156, 63, 2301, 9, 83, 2356, 378, 3196, 267, 283, 17315, 356, 8540, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 14640, 356, 3322, 283, 9190, 8, 845, 3196, 267, 283, 6254, 356, 8540, 283, 6389, 9376, 297, 267, 283, 27115, 356, 8540, 283, 20277, 297, 267, 283, 17363, 356, 9326, 283, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1950, 304, 267, 1613, 8, 7243, 13921, 12, 291, 2843, 826, 721, 2105, 9, 339, 347, 485, 981, 63, 396, 63, 697, 8, 277, 12, 8661, 29, 17, 12, 6384, 679, 22669, 29, 797, 304, 267, 7393, 63, 2339, 275, 291, 423, 396, 63, 4659, 63, 354, 342, 267, 7393, 63, 3791, 275, 291, 423, 396, 63, 4659, 63, 751, 342, 267, 7393, 63, 6909, 16698, 275, 291, 423, 396, 63, 4659, 63, 12671, 342, 267, 7393, 63, 20098, 5296, 48, 4121, 275, 291, 423, 396, 63, 4659, 63, 5842, 478, 1142, 342, 267, 7393, 63, 20098, 5296, 48, 4121, 63, 17983, 275, 291, 423, 396, 63, 4659, 63, 5842, 478, 1142, 63, 2791, 342, 398, 2633, 275, 469, 288, 283, 13238, 356, 7393, 63, 2339, 12, 288, 283, 751, 356, 7393, 63, 3791, 12, 288, 283, 2060, 356, 7393, 63, 6909, 16698, 12, 288, 283, 5842, 478, 1142, 356, 7393, 63, 20098, 5296, 48, 4121, 12, 288, 283, 5842, 478, 1142, 63, 808, 356, 7393, 63, 20098, 5296, 48, 4121, 63, 17983, 12, 267, 789, 398, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 340, 291, 423, 396, 63, 4659, 63, 981, 837, 288, 862, 26, 355, 291, 423, 2526, 63, 396, 63, 697, 63, 8782, 8, 3937, 12, 2633, 12, 8661, 9, 288, 871, 2186, 12, 325, 26, 355, 984, 14, 3083, 14, 952, 480, 13662, 376, 1125, 6425, 314, 511, 3050, 26, 450, 83, 60, 78, 2, 450, 325, 9, 355, 340, 440, 6384, 679, 22669, 26, 490, 12679, 275, 3066, 63, 1210, 480, 7940, 11337, 314, 511, 3050, 12, 450, 83, 12, 2575, 3495, 14, 2434, 283, 5066, 7, 370, 3145, 652, 12, 503, 283, 889, 7, 370, 9311, 26, 298, 450, 7393, 63, 2339, 9, 355, 340, 6384, 679, 22669, 503, 12679, 508, 283, 5066, 356, 490, 862, 26, 717, 340, 8661, 2356, 413, 26, 1169, 870, 298, 14704, 316, 2269, 511, 3050, 1543, 83, 7, 11500, 450, 291, 14, 2105, 14, 3620, 717, 291, 423, 2526, 63, 396, 63, 697, 63, 271, 4742, 8, 3937, 12, 2633, 12, 8661, 9, 717, 291, 423, 2526, 63, 396, 63, 697, 63, 8782, 8, 3937, 12, 2633, 12, 8661, 9, 490, 871, 2186, 12, 325, 26, 717, 984, 14, 3083, 14, 952, 480, 13662, 376, 1125, 295, 20358, 314, 511, 3050, 26, 450, 83, 60, 78, 2, 450, 325, 9, 717, 984, 14, 2224, 8, 18, 9, 355, 587, 26, 490, 870, 298, 2925, 20115, 2122, 490, 984, 14, 2224, 8, 17, 9, 398, 340, 291, 423, 396, 63, 751, 63, 981, 837, 288, 340, 8661, 2356, 413, 26, 355, 870, 298, 14380, 511, 922, 11500, 288, 862, 26, 355, 291, 423, 981, 63, 396, 63, 751, 8, 3937, 12, 2633, 12, 8661, 9, 288, 871, 2186, 12, 325, 26, 355, 984, 14, 3083, 14, 952, 480, 13662, 376, 1125, 6425, 314, 511, 922, 26, 450, 83, 60, 78, 2, 450, 325, 9, 355, 340, 440, 6384, 679, 22669, 26, 490, 12679, 275, 3066, 63, 1210, 480, 7940, 11337, 314, 511, 922, 12, 450, 83, 12, 2575, 3495, 14, 2434, 283, 5066, 7, 370, 3145, 652, 12, 503, 283, 889 ]
[ 984, 199, 646, 900, 199, 504, 1639, 14, 697, 14, 7765, 14, 8782, 492, 29103, 13921, 199, 199, 2864, 63, 17873, 63, 6351, 275, 283, 396, 8650, 199, 9032, 275, 283, 16221, 63, 65, 63, 76, 884, 19193, 7, 199, 199, 533, 8692, 13921, 8, 1563, 7243, 13921, 304, 272, 327, 961, 2600, 9033, 5024, 2251, 370, 3932, 4568, 15309, 2763, 272, 327, 2943, 12, 465, 3326, 14, 4996, 13, 466, 3326, 883, 1395, 1475, 3326, 27, 2985, 7171, 272, 327, 506, 23005, 972, 6169, 314, 1338, 402, 5024, 855, 807, 363, 2544, 3769, 1072, 14, 272, 327, 982, 282, 2763, 730, 365, 663, 370, 488, 12, 652, 7859, 1133, 506, 5120, 315, 314, 1072, 14, 272, 327, 272, 327, 6184, 1475, 3326, 6617, 543, 298, 15156, 12172, 787, 10999, 2544, 3769, 1202, 315, 314, 272, 327, 1072, 334, 1589, 298, 15156, 12172, 2403, 365, 14489, 2544, 314, 4237, 365, 10585, 14, 339, 666, 63, 1313, 275, 469, 267, 283, 4378, 356, 8540, 283, 9190, 8, 845, 3196, 267, 283, 5036, 356, 463, 283, 9190, 8, 17, 9, 17654, 17753, 15156, 63, 2301, 9, 83, 1621, 334, 16, 12, 17, 22629, 267, 283, 2183, 356, 8540, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 25732, 20727, 3901, 356, 257, 283, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 14071, 356, 8540, 283, 5390, 297, 267, 283, 4626, 356, 4483, 283, 20277, 297, 267, 283, 15975, 356, 463, 283, 9190, 12473, 988, 63, 7022, 9, 83, 12, 2818, 6355, 63, 10696, 9, 83, 3196, 267, 283, 23252, 356, 8540, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 14225, 792, 356, 4483, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 13019, 356, 7861, 283, 14989, 510, 9481, 30011, 297, 267, 283, 3901, 356, 463, 283, 9190, 8, 845, 3196, 267, 283, 25175, 356, 4519, 283, 9190, 8, 1167, 3196, 267, 283, 26969, 356, 5185, 283, 24800, 18, 8, 1046, 3196, 267, 283, 9417, 26969, 356, 263, 283, 24800, 18, 8, 1355, 3196, 267, 283, 29068, 356, 3777, 283, 9190, 8, 17, 9, 17654, 3666, 2840, 15156, 63, 2301, 9, 83, 1621, 334, 16, 12, 17, 430, 1549, 17753, 15156, 63, 2301, 9, 83, 2281, 5962, 22629, 267, 283, 14298, 356, 4483, 283, 9190, 8, 845, 3196, 267, 283, 8591, 356, 260, 283, 9190, 8, 845, 9, 17654, 17753, 15156, 63, 2301, 9, 83, 2356, 378, 3196, 267, 283, 25197, 356, 259, 283, 9190, 8, 845, 9, 17654, 17753, 15156, 63, 2301, 9, 83, 2356, 378, 3196, 267, 283, 17315, 356, 8540, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 267, 283, 14640, 356, 3322, 283, 9190, 8, 845, 3196, 267, 283, 6254, 356, 8540, 283, 6389, 9376, 297, 267, 283, 27115, 356, 8540, 283, 20277, 297, 267, 283, 17363, 356, 9326, 283, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1950, 304, 267, 1613, 8, 7243, 13921, 12, 291, 2843, 826, 721, 2105, 9, 339, 347, 485, 981, 63, 396, 63, 697, 8, 277, 12, 8661, 29, 17, 12, 6384, 679, 22669, 29, 797, 304, 267, 7393, 63, 2339, 275, 291, 423, 396, 63, 4659, 63, 354, 342, 267, 7393, 63, 3791, 275, 291, 423, 396, 63, 4659, 63, 751, 342, 267, 7393, 63, 6909, 16698, 275, 291, 423, 396, 63, 4659, 63, 12671, 342, 267, 7393, 63, 20098, 5296, 48, 4121, 275, 291, 423, 396, 63, 4659, 63, 5842, 478, 1142, 342, 267, 7393, 63, 20098, 5296, 48, 4121, 63, 17983, 275, 291, 423, 396, 63, 4659, 63, 5842, 478, 1142, 63, 2791, 342, 398, 2633, 275, 469, 288, 283, 13238, 356, 7393, 63, 2339, 12, 288, 283, 751, 356, 7393, 63, 3791, 12, 288, 283, 2060, 356, 7393, 63, 6909, 16698, 12, 288, 283, 5842, 478, 1142, 356, 7393, 63, 20098, 5296, 48, 4121, 12, 288, 283, 5842, 478, 1142, 63, 808, 356, 7393, 63, 20098, 5296, 48, 4121, 63, 17983, 12, 267, 789, 398, 3920, 275, 291, 14, 2105, 14, 3937, 342, 267, 340, 291, 423, 396, 63, 4659, 63, 981, 837, 288, 862, 26, 355, 291, 423, 2526, 63, 396, 63, 697, 63, 8782, 8, 3937, 12, 2633, 12, 8661, 9, 288, 871, 2186, 12, 325, 26, 355, 984, 14, 3083, 14, 952, 480, 13662, 376, 1125, 6425, 314, 511, 3050, 26, 450, 83, 60, 78, 2, 450, 325, 9, 355, 340, 440, 6384, 679, 22669, 26, 490, 12679, 275, 3066, 63, 1210, 480, 7940, 11337, 314, 511, 3050, 12, 450, 83, 12, 2575, 3495, 14, 2434, 283, 5066, 7, 370, 3145, 652, 12, 503, 283, 889, 7, 370, 9311, 26, 298, 450, 7393, 63, 2339, 9, 355, 340, 6384, 679, 22669, 503, 12679, 508, 283, 5066, 356, 490, 862, 26, 717, 340, 8661, 2356, 413, 26, 1169, 870, 298, 14704, 316, 2269, 511, 3050, 1543, 83, 7, 11500, 450, 291, 14, 2105, 14, 3620, 717, 291, 423, 2526, 63, 396, 63, 697, 63, 271, 4742, 8, 3937, 12, 2633, 12, 8661, 9, 717, 291, 423, 2526, 63, 396, 63, 697, 63, 8782, 8, 3937, 12, 2633, 12, 8661, 9, 490, 871, 2186, 12, 325, 26, 717, 984, 14, 3083, 14, 952, 480, 13662, 376, 1125, 295, 20358, 314, 511, 3050, 26, 450, 83, 60, 78, 2, 450, 325, 9, 717, 984, 14, 2224, 8, 18, 9, 355, 587, 26, 490, 870, 298, 2925, 20115, 2122, 490, 984, 14, 2224, 8, 17, 9, 398, 340, 291, 423, 396, 63, 751, 63, 981, 837, 288, 340, 8661, 2356, 413, 26, 355, 870, 298, 14380, 511, 922, 11500, 288, 862, 26, 355, 291, 423, 981, 63, 396, 63, 751, 8, 3937, 12, 2633, 12, 8661, 9, 288, 871, 2186, 12, 325, 26, 355, 984, 14, 3083, 14, 952, 480, 13662, 376, 1125, 6425, 314, 511, 922, 26, 450, 83, 60, 78, 2, 450, 325, 9, 355, 340, 440, 6384, 679, 22669, 26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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 ]
ShinyROM/android_external_chromium_org
third_party/protobuf/descriptor_pb2.py
193
48695
# Generated by the protocol buffer compiler. DO NOT EDIT! from google.protobuf import descriptor from google.protobuf import message from google.protobuf import reflection # @@protoc_insertion_point(imports) DESCRIPTOR = descriptor.FileDescriptor( name='google/protobuf/descriptor.proto', package='google.protobuf', serialized_pb='\n google/protobuf/descriptor.proto\x12\x0fgoogle.protobuf\"G\n\x11\x46ileDescriptorSet\x12\x32\n\x04\x66ile\x18\x01 \x03(\x0b\x32$.google.protobuf.FileDescriptorProto\"\xdc\x02\n\x13\x46ileDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07package\x18\x02 \x01(\t\x12\x12\n\ndependency\x18\x03 \x03(\t\x12\x36\n\x0cmessage_type\x18\x04 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x05 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12\x38\n\x07service\x18\x06 \x03(\x0b\x32\'.google.protobuf.ServiceDescriptorProto\x12\x38\n\textension\x18\x07 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12-\n\x07options\x18\x08 \x01(\x0b\x32\x1c.google.protobuf.FileOptions\"\xa9\x03\n\x0f\x44\x65scriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x34\n\x05\x66ield\x18\x02 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x38\n\textension\x18\x06 \x03(\x0b\x32%.google.protobuf.FieldDescriptorProto\x12\x35\n\x0bnested_type\x18\x03 \x03(\x0b\x32 .google.protobuf.DescriptorProto\x12\x37\n\tenum_type\x18\x04 \x03(\x0b\x32$.google.protobuf.EnumDescriptorProto\x12H\n\x0f\x65xtension_range\x18\x05 \x03(\x0b\x32/.google.protobuf.DescriptorProto.ExtensionRange\x12\x30\n\x07options\x18\x07 \x01(\x0b\x32\x1f.google.protobuf.MessageOptions\x1a,\n\x0e\x45xtensionRange\x12\r\n\x05start\x18\x01 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x05\"\x94\x05\n\x14\x46ieldDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x03 \x01(\x05\x12:\n\x05label\x18\x04 \x01(\x0e\x32+.google.protobuf.FieldDescriptorProto.Label\x12\x38\n\x04type\x18\x05 \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x11\n\ttype_name\x18\x06 \x01(\t\x12\x10\n\x08\x65xtendee\x18\x02 \x01(\t\x12\x15\n\rdefault_value\x18\x07 \x01(\t\x12.\n\x07options\x18\x08 \x01(\x0b\x32\x1d.google.protobuf.FieldOptions\"\xb6\x02\n\x04Type\x12\x0f\n\x0bTYPE_DOUBLE\x10\x01\x12\x0e\n\nTYPE_FLOAT\x10\x02\x12\x0e\n\nTYPE_INT64\x10\x03\x12\x0f\n\x0bTYPE_UINT64\x10\x04\x12\x0e\n\nTYPE_INT32\x10\x05\x12\x10\n\x0cTYPE_FIXED64\x10\x06\x12\x10\n\x0cTYPE_FIXED32\x10\x07\x12\r\n\tTYPE_BOOL\x10\x08\x12\x0f\n\x0bTYPE_STRING\x10\t\x12\x0e\n\nTYPE_GROUP\x10\n\x12\x10\n\x0cTYPE_MESSAGE\x10\x0b\x12\x0e\n\nTYPE_BYTES\x10\x0c\x12\x0f\n\x0bTYPE_UINT32\x10\r\x12\r\n\tTYPE_ENUM\x10\x0e\x12\x11\n\rTYPE_SFIXED32\x10\x0f\x12\x11\n\rTYPE_SFIXED64\x10\x10\x12\x0f\n\x0bTYPE_SINT32\x10\x11\x12\x0f\n\x0bTYPE_SINT64\x10\x12\"C\n\x05Label\x12\x12\n\x0eLABEL_OPTIONAL\x10\x01\x12\x12\n\x0eLABEL_REQUIRED\x10\x02\x12\x12\n\x0eLABEL_REPEATED\x10\x03\"\x8c\x01\n\x13\x45numDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x03(\x0b\x32).google.protobuf.EnumValueDescriptorProto\x12-\n\x07options\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.EnumOptions\"l\n\x18\x45numValueDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06number\x18\x02 \x01(\x05\x12\x32\n\x07options\x18\x03 \x01(\x0b\x32!.google.protobuf.EnumValueOptions\"\x90\x01\n\x16ServiceDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x36\n\x06method\x18\x02 \x03(\x0b\x32&.google.protobuf.MethodDescriptorProto\x12\x30\n\x07options\x18\x03 \x01(\x0b\x32\x1f.google.protobuf.ServiceOptions\"\x7f\n\x15MethodDescriptorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\ninput_type\x18\x02 \x01(\t\x12\x13\n\x0boutput_type\x18\x03 \x01(\t\x12/\n\x07options\x18\x04 \x01(\x0b\x32\x1e.google.protobuf.MethodOptions\"\xa4\x03\n\x0b\x46ileOptions\x12\x14\n\x0cjava_package\x18\x01 \x01(\t\x12\x1c\n\x14java_outer_classname\x18\x08 \x01(\t\x12\"\n\x13java_multiple_files\x18\n \x01(\x08:\x05\x66\x61lse\x12\x46\n\x0coptimize_for\x18\t \x01(\x0e\x32).google.protobuf.FileOptions.OptimizeMode:\x05SPEED\x12!\n\x13\x63\x63_generic_services\x18\x10 \x01(\x08:\x04true\x12#\n\x15java_generic_services\x18\x11 \x01(\x08:\x04true\x12!\n\x13py_generic_services\x18\x12 \x01(\x08:\x04true\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\":\n\x0cOptimizeMode\x12\t\n\x05SPEED\x10\x01\x12\r\n\tCODE_SIZE\x10\x02\x12\x10\n\x0cLITE_RUNTIME\x10\x03*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xb8\x01\n\x0eMessageOptions\x12&\n\x17message_set_wire_format\x18\x01 \x01(\x08:\x05\x66\x61lse\x12.\n\x1fno_standard_descriptor_accessor\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x94\x02\n\x0c\x46ieldOptions\x12:\n\x05\x63type\x18\x01 \x01(\x0e\x32#.google.protobuf.FieldOptions.CType:\x06STRING\x12\x0e\n\x06packed\x18\x02 \x01(\x08\x12\x19\n\ndeprecated\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x1c\n\x14\x65xperimental_map_key\x18\t \x01(\t\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption\"/\n\x05\x43Type\x12\n\n\x06STRING\x10\x00\x12\x08\n\x04\x43ORD\x10\x01\x12\x10\n\x0cSTRING_PIECE\x10\x02*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"]\n\x0b\x45numOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"b\n\x10\x45numValueOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"`\n\x0eServiceOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"_\n\rMethodOptions\x12\x43\n\x14uninterpreted_option\x18\xe7\x07 \x03(\x0b\x32$.google.protobuf.UninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x85\x02\n\x13UninterpretedOption\x12;\n\x04name\x18\x02 \x03(\x0b\x32-.google.protobuf.UninterpretedOption.NamePart\x12\x18\n\x10identifier_value\x18\x03 \x01(\t\x12\x1a\n\x12positive_int_value\x18\x04 \x01(\x04\x12\x1a\n\x12negative_int_value\x18\x05 \x01(\x03\x12\x14\n\x0c\x64ouble_value\x18\x06 \x01(\x01\x12\x14\n\x0cstring_value\x18\x07 \x01(\x0c\x1a\x33\n\x08NamePart\x12\x11\n\tname_part\x18\x01 \x02(\t\x12\x14\n\x0cis_extension\x18\x02 \x02(\x08\x42)\n\x13\x63om.google.protobufB\x10\x44\x65scriptorProtosH\x01') _FIELDDESCRIPTORPROTO_TYPE = descriptor.EnumDescriptor( name='Type', full_name='google.protobuf.FieldDescriptorProto.Type', filename=None, file=DESCRIPTOR, values=[ descriptor.EnumValueDescriptor( name='TYPE_DOUBLE', index=0, number=1, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_FLOAT', index=1, number=2, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_INT64', index=2, number=3, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_UINT64', index=3, number=4, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_INT32', index=4, number=5, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_FIXED64', index=5, number=6, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_FIXED32', index=6, number=7, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_BOOL', index=7, number=8, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_STRING', index=8, number=9, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_GROUP', index=9, number=10, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_MESSAGE', index=10, number=11, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_BYTES', index=11, number=12, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_UINT32', index=12, number=13, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_ENUM', index=13, number=14, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_SFIXED32', index=14, number=15, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_SFIXED64', index=15, number=16, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_SINT32', index=16, number=17, options=None, type=None), descriptor.EnumValueDescriptor( name='TYPE_SINT64', index=17, number=18, options=None, type=None), ], containing_type=None, options=None, serialized_start=1187, serialized_end=1497, ) _FIELDDESCRIPTORPROTO_LABEL = descriptor.EnumDescriptor( name='Label', full_name='google.protobuf.FieldDescriptorProto.Label', filename=None, file=DESCRIPTOR, values=[ descriptor.EnumValueDescriptor( name='LABEL_OPTIONAL', index=0, number=1, options=None, type=None), descriptor.EnumValueDescriptor( name='LABEL_REQUIRED', index=1, number=2, options=None, type=None), descriptor.EnumValueDescriptor( name='LABEL_REPEATED', index=2, number=3, options=None, type=None), ], containing_type=None, options=None, serialized_start=1499, serialized_end=1566, ) _FILEOPTIONS_OPTIMIZEMODE = descriptor.EnumDescriptor( name='OptimizeMode', full_name='google.protobuf.FileOptions.OptimizeMode', filename=None, file=DESCRIPTOR, values=[ descriptor.EnumValueDescriptor( name='SPEED', index=0, number=1, options=None, type=None), descriptor.EnumValueDescriptor( name='CODE_SIZE', index=1, number=2, options=None, type=None), descriptor.EnumValueDescriptor( name='LITE_RUNTIME', index=2, number=3, options=None, type=None), ], containing_type=None, options=None, serialized_start=2449, serialized_end=2507, ) _FIELDOPTIONS_CTYPE = descriptor.EnumDescriptor( name='CType', full_name='google.protobuf.FieldOptions.CType', filename=None, file=DESCRIPTOR, values=[ descriptor.EnumValueDescriptor( name='STRING', index=0, number=0, options=None, type=None), descriptor.EnumValueDescriptor( name='CORD', index=1, number=1, options=None, type=None), descriptor.EnumValueDescriptor( name='STRING_PIECE', index=2, number=2, options=None, type=None), ], containing_type=None, options=None, serialized_start=2926, serialized_end=2973, ) _FILEDESCRIPTORSET = descriptor.Descriptor( name='FileDescriptorSet', full_name='google.protobuf.FileDescriptorSet', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='file', full_name='google.protobuf.FileDescriptorSet.file', index=0, number=1, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=53, serialized_end=124, ) _FILEDESCRIPTORPROTO = descriptor.Descriptor( name='FileDescriptorProto', full_name='google.protobuf.FileDescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.FileDescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='package', full_name='google.protobuf.FileDescriptorProto.package', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='dependency', full_name='google.protobuf.FileDescriptorProto.dependency', index=2, number=3, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='message_type', full_name='google.protobuf.FileDescriptorProto.message_type', index=3, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='enum_type', full_name='google.protobuf.FileDescriptorProto.enum_type', index=4, number=5, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='service', full_name='google.protobuf.FileDescriptorProto.service', index=5, number=6, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='extension', full_name='google.protobuf.FileDescriptorProto.extension', index=6, number=7, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.FileDescriptorProto.options', index=7, number=8, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=127, serialized_end=475, ) _DESCRIPTORPROTO_EXTENSIONRANGE = descriptor.Descriptor( name='ExtensionRange', full_name='google.protobuf.DescriptorProto.ExtensionRange', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='start', full_name='google.protobuf.DescriptorProto.ExtensionRange.start', index=0, number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='end', full_name='google.protobuf.DescriptorProto.ExtensionRange.end', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=859, serialized_end=903, ) _DESCRIPTORPROTO = descriptor.Descriptor( name='DescriptorProto', full_name='google.protobuf.DescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.DescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='field', full_name='google.protobuf.DescriptorProto.field', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='extension', full_name='google.protobuf.DescriptorProto.extension', index=2, number=6, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='nested_type', full_name='google.protobuf.DescriptorProto.nested_type', index=3, number=3, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='enum_type', full_name='google.protobuf.DescriptorProto.enum_type', index=4, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='extension_range', full_name='google.protobuf.DescriptorProto.extension_range', index=5, number=5, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.DescriptorProto.options', index=6, number=7, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[_DESCRIPTORPROTO_EXTENSIONRANGE, ], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=478, serialized_end=903, ) _FIELDDESCRIPTORPROTO = descriptor.Descriptor( name='FieldDescriptorProto', full_name='google.protobuf.FieldDescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.FieldDescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='number', full_name='google.protobuf.FieldDescriptorProto.number', index=1, number=3, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='label', full_name='google.protobuf.FieldDescriptorProto.label', index=2, number=4, type=14, cpp_type=8, label=1, has_default_value=False, default_value=1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='type', full_name='google.protobuf.FieldDescriptorProto.type', index=3, number=5, type=14, cpp_type=8, label=1, has_default_value=False, default_value=1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='type_name', full_name='google.protobuf.FieldDescriptorProto.type_name', index=4, number=6, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='extendee', full_name='google.protobuf.FieldDescriptorProto.extendee', index=5, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='default_value', full_name='google.protobuf.FieldDescriptorProto.default_value', index=6, number=7, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.FieldDescriptorProto.options', index=7, number=8, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ _FIELDDESCRIPTORPROTO_TYPE, _FIELDDESCRIPTORPROTO_LABEL, ], options=None, is_extendable=False, extension_ranges=[], serialized_start=906, serialized_end=1566, ) _ENUMDESCRIPTORPROTO = descriptor.Descriptor( name='EnumDescriptorProto', full_name='google.protobuf.EnumDescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.EnumDescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='value', full_name='google.protobuf.EnumDescriptorProto.value', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.EnumDescriptorProto.options', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=1569, serialized_end=1709, ) _ENUMVALUEDESCRIPTORPROTO = descriptor.Descriptor( name='EnumValueDescriptorProto', full_name='google.protobuf.EnumValueDescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.EnumValueDescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='number', full_name='google.protobuf.EnumValueDescriptorProto.number', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.EnumValueDescriptorProto.options', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=1711, serialized_end=1819, ) _SERVICEDESCRIPTORPROTO = descriptor.Descriptor( name='ServiceDescriptorProto', full_name='google.protobuf.ServiceDescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.ServiceDescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='method', full_name='google.protobuf.ServiceDescriptorProto.method', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.ServiceDescriptorProto.options', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=1822, serialized_end=1966, ) _METHODDESCRIPTORPROTO = descriptor.Descriptor( name='MethodDescriptorProto', full_name='google.protobuf.MethodDescriptorProto', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.MethodDescriptorProto.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='input_type', full_name='google.protobuf.MethodDescriptorProto.input_type', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='output_type', full_name='google.protobuf.MethodDescriptorProto.output_type', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='options', full_name='google.protobuf.MethodDescriptorProto.options', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=1968, serialized_end=2095, ) _FILEOPTIONS = descriptor.Descriptor( name='FileOptions', full_name='google.protobuf.FileOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='java_package', full_name='google.protobuf.FileOptions.java_package', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='java_outer_classname', full_name='google.protobuf.FileOptions.java_outer_classname', index=1, number=8, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='java_multiple_files', full_name='google.protobuf.FileOptions.java_multiple_files', index=2, number=10, type=8, cpp_type=7, label=1, has_default_value=True, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='optimize_for', full_name='google.protobuf.FileOptions.optimize_for', index=3, number=9, type=14, cpp_type=8, label=1, has_default_value=True, default_value=1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='cc_generic_services', full_name='google.protobuf.FileOptions.cc_generic_services', index=4, number=16, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='java_generic_services', full_name='google.protobuf.FileOptions.java_generic_services', index=5, number=17, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='py_generic_services', full_name='google.protobuf.FileOptions.py_generic_services', index=6, number=18, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.FileOptions.uninterpreted_option', index=7, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ _FILEOPTIONS_OPTIMIZEMODE, ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=2098, serialized_end=2518, ) _MESSAGEOPTIONS = descriptor.Descriptor( name='MessageOptions', full_name='google.protobuf.MessageOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='message_set_wire_format', full_name='google.protobuf.MessageOptions.message_set_wire_format', index=0, number=1, type=8, cpp_type=7, label=1, has_default_value=True, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='no_standard_descriptor_accessor', full_name='google.protobuf.MessageOptions.no_standard_descriptor_accessor', index=1, number=2, type=8, cpp_type=7, label=1, has_default_value=True, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.MessageOptions.uninterpreted_option', index=2, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=2521, serialized_end=2705, ) _FIELDOPTIONS = descriptor.Descriptor( name='FieldOptions', full_name='google.protobuf.FieldOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='ctype', full_name='google.protobuf.FieldOptions.ctype', index=0, number=1, type=14, cpp_type=8, label=1, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='packed', full_name='google.protobuf.FieldOptions.packed', index=1, number=2, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='deprecated', full_name='google.protobuf.FieldOptions.deprecated', index=2, number=3, type=8, cpp_type=7, label=1, has_default_value=True, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='experimental_map_key', full_name='google.protobuf.FieldOptions.experimental_map_key', index=3, number=9, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.FieldOptions.uninterpreted_option', index=4, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ _FIELDOPTIONS_CTYPE, ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=2708, serialized_end=2984, ) _ENUMOPTIONS = descriptor.Descriptor( name='EnumOptions', full_name='google.protobuf.EnumOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.EnumOptions.uninterpreted_option', index=0, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=2986, serialized_end=3079, ) _ENUMVALUEOPTIONS = descriptor.Descriptor( name='EnumValueOptions', full_name='google.protobuf.EnumValueOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.EnumValueOptions.uninterpreted_option', index=0, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=3081, serialized_end=3179, ) _SERVICEOPTIONS = descriptor.Descriptor( name='ServiceOptions', full_name='google.protobuf.ServiceOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.ServiceOptions.uninterpreted_option', index=0, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=3181, serialized_end=3277, ) _METHODOPTIONS = descriptor.Descriptor( name='MethodOptions', full_name='google.protobuf.MethodOptions', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='uninterpreted_option', full_name='google.protobuf.MethodOptions.uninterpreted_option', index=0, number=999, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=True, extension_ranges=[(1000, 536870912), ], serialized_start=3279, serialized_end=3374, ) _UNINTERPRETEDOPTION_NAMEPART = descriptor.Descriptor( name='NamePart', full_name='google.protobuf.UninterpretedOption.NamePart', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name_part', full_name='google.protobuf.UninterpretedOption.NamePart.name_part', index=0, number=1, type=9, cpp_type=9, label=2, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='is_extension', full_name='google.protobuf.UninterpretedOption.NamePart.is_extension', index=1, number=2, type=8, cpp_type=7, label=2, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=3587, serialized_end=3638, ) _UNINTERPRETEDOPTION = descriptor.Descriptor( name='UninterpretedOption', full_name='google.protobuf.UninterpretedOption', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ descriptor.FieldDescriptor( name='name', full_name='google.protobuf.UninterpretedOption.name', index=0, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='identifier_value', full_name='google.protobuf.UninterpretedOption.identifier_value', index=1, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='positive_int_value', full_name='google.protobuf.UninterpretedOption.positive_int_value', index=2, number=4, type=4, cpp_type=4, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='negative_int_value', full_name='google.protobuf.UninterpretedOption.negative_int_value', index=3, number=5, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='double_value', full_name='google.protobuf.UninterpretedOption.double_value', index=4, number=6, type=1, cpp_type=5, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), descriptor.FieldDescriptor( name='string_value', full_name='google.protobuf.UninterpretedOption.string_value', index=5, number=7, type=12, cpp_type=9, label=1, has_default_value=False, default_value="", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[_UNINTERPRETEDOPTION_NAMEPART, ], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=3377, serialized_end=3638, ) _FILEDESCRIPTORSET.fields_by_name['file'].message_type = _FILEDESCRIPTORPROTO _FILEDESCRIPTORPROTO.fields_by_name['message_type'].message_type = _DESCRIPTORPROTO _FILEDESCRIPTORPROTO.fields_by_name['enum_type'].message_type = _ENUMDESCRIPTORPROTO _FILEDESCRIPTORPROTO.fields_by_name['service'].message_type = _SERVICEDESCRIPTORPROTO _FILEDESCRIPTORPROTO.fields_by_name['extension'].message_type = _FIELDDESCRIPTORPROTO _FILEDESCRIPTORPROTO.fields_by_name['options'].message_type = _FILEOPTIONS _DESCRIPTORPROTO_EXTENSIONRANGE.containing_type = _DESCRIPTORPROTO; _DESCRIPTORPROTO.fields_by_name['field'].message_type = _FIELDDESCRIPTORPROTO _DESCRIPTORPROTO.fields_by_name['extension'].message_type = _FIELDDESCRIPTORPROTO _DESCRIPTORPROTO.fields_by_name['nested_type'].message_type = _DESCRIPTORPROTO _DESCRIPTORPROTO.fields_by_name['enum_type'].message_type = _ENUMDESCRIPTORPROTO _DESCRIPTORPROTO.fields_by_name['extension_range'].message_type = _DESCRIPTORPROTO_EXTENSIONRANGE _DESCRIPTORPROTO.fields_by_name['options'].message_type = _MESSAGEOPTIONS _FIELDDESCRIPTORPROTO.fields_by_name['label'].enum_type = _FIELDDESCRIPTORPROTO_LABEL _FIELDDESCRIPTORPROTO.fields_by_name['type'].enum_type = _FIELDDESCRIPTORPROTO_TYPE _FIELDDESCRIPTORPROTO.fields_by_name['options'].message_type = _FIELDOPTIONS _FIELDDESCRIPTORPROTO_TYPE.containing_type = _FIELDDESCRIPTORPROTO; _FIELDDESCRIPTORPROTO_LABEL.containing_type = _FIELDDESCRIPTORPROTO; _ENUMDESCRIPTORPROTO.fields_by_name['value'].message_type = _ENUMVALUEDESCRIPTORPROTO _ENUMDESCRIPTORPROTO.fields_by_name['options'].message_type = _ENUMOPTIONS _ENUMVALUEDESCRIPTORPROTO.fields_by_name['options'].message_type = _ENUMVALUEOPTIONS _SERVICEDESCRIPTORPROTO.fields_by_name['method'].message_type = _METHODDESCRIPTORPROTO _SERVICEDESCRIPTORPROTO.fields_by_name['options'].message_type = _SERVICEOPTIONS _METHODDESCRIPTORPROTO.fields_by_name['options'].message_type = _METHODOPTIONS _FILEOPTIONS.fields_by_name['optimize_for'].enum_type = _FILEOPTIONS_OPTIMIZEMODE _FILEOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _FILEOPTIONS_OPTIMIZEMODE.containing_type = _FILEOPTIONS; _MESSAGEOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _FIELDOPTIONS.fields_by_name['ctype'].enum_type = _FIELDOPTIONS_CTYPE _FIELDOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _FIELDOPTIONS_CTYPE.containing_type = _FIELDOPTIONS; _ENUMOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _ENUMVALUEOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _SERVICEOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _METHODOPTIONS.fields_by_name['uninterpreted_option'].message_type = _UNINTERPRETEDOPTION _UNINTERPRETEDOPTION_NAMEPART.containing_type = _UNINTERPRETEDOPTION; _UNINTERPRETEDOPTION.fields_by_name['name'].message_type = _UNINTERPRETEDOPTION_NAMEPART class FileDescriptorSet(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _FILEDESCRIPTORSET # @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorSet) class FileDescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _FILEDESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto) class DescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType class ExtensionRange(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _DESCRIPTORPROTO_EXTENSIONRANGE # @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange) DESCRIPTOR = _DESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto) class FieldDescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _FIELDDESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto) class EnumDescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _ENUMDESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto) class EnumValueDescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _ENUMVALUEDESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto) class ServiceDescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _SERVICEDESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto) class MethodDescriptorProto(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _METHODDESCRIPTORPROTO # @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto) class FileOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _FILEOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) class MessageOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _MESSAGEOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) class FieldOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _FIELDOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) class EnumOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _ENUMOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) class EnumValueOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _ENUMVALUEOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) class ServiceOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _SERVICEOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) class MethodOptions(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _METHODOPTIONS # @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) class UninterpretedOption(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType class NamePart(message.Message): __metaclass__ = reflection.GeneratedProtocolMessageType DESCRIPTOR = _UNINTERPRETEDOPTION_NAMEPART # @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart) DESCRIPTOR = _UNINTERPRETEDOPTION # @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption) # @@protoc_insertion_point(module_scope)
bsd-3-clause
[ 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 199, 504, 6233, 14, 7204, 492, 5872, 199, 504, 6233, 14, 7204, 492, 1245, 199, 504, 6233, 14, 7204, 492, 25572, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 421, 199, 7580, 275, 5872, 14, 23859, 8, 523, 536, 534, 3098, 15, 7204, 15, 4120, 14, 2625, 297, 523, 2559, 534, 3098, 14, 7204, 297, 523, 6380, 63, 3317, 17115, 78, 6233, 15, 7204, 15, 4120, 14, 2625, 60, 88, 713, 60, 88, 16, 70, 3098, 14, 7204, 4451, 39, 60, 78, 60, 88, 845, 60, 88, 2466, 441, 4311, 1084, 60, 88, 713, 60, 88, 708, 60, 78, 60, 88, 966, 60, 88, 1272, 441, 60, 88, 1085, 60, 88, 614, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 4, 14, 3098, 14, 7204, 14, 23859, 8548, 13356, 10550, 60, 88, 996, 60, 78, 60, 88, 969, 60, 88, 2466, 441, 4311, 8548, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 354, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 16, 70, 60, 78, 60, 88, 1780, 2491, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 713, 60, 78, 60, 78, 8575, 60, 88, 1085, 60, 88, 1644, 971, 88, 1644, 2961, 84, 60, 88, 713, 60, 88, 1344, 60, 78, 60, 88, 16, 67, 1188, 63, 466, 60, 88, 1085, 60, 88, 966, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 1275, 3098, 14, 7204, 14, 4311, 8548, 60, 88, 713, 60, 88, 1401, 60, 78, 60, 724, 453, 63, 466, 60, 88, 1085, 60, 88, 1717, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 4, 14, 3098, 14, 7204, 14, 5081, 4311, 8548, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 1780, 1364, 60, 88, 1085, 60, 88, 1690, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 60, 1370, 3098, 14, 7204, 14, 3167, 4311, 8548, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 3858, 724, 438, 60, 88, 1085, 60, 88, 1780, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 17229, 3098, 14, 7204, 14, 8510, 8548, 60, 88, 713, 2696, 78, 60, 88, 1780, 1419, 60, 88, 1085, 60, 88, 2036, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 67, 14, 3098, 14, 7204, 14, 1173, 4558, 13356, 1800, 25, 60, 88, 1644, 60, 78, 60, 88, 16, 70, 60, 88, 1602, 60, 88, 2182, 3116, 8548, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 354, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1082, 60, 78, 60, 88, 1717, 60, 88, 1272, 553, 60, 88, 1085, 60, 88, 996, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 17229, 3098, 14, 7204, 14, 8510, 8548, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 3858, 724, 438, 60, 88, 1085, 60, 88, 1690, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 17229, 3098, 14, 7204, 14, 8510, 8548, 60, 88, 713, 60, 88, 1276, 60, 78, 60, 88, 16, 66, 6376, 63, 466, 60, 88, 1085, 60, 88, 1644, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 1275, 3098, 14, 7204, 14, 4311, 8548, 60, 88, 713, 60, 88, 1401, 60, 78, 60, 724, 453, 63, 466, 60, 88, 1085, 60, 88, 966, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 4, 14, 3098, 14, 7204, 14, 5081, 4311, 8548, 60, 88, 713, 40, 60, 78, 60, 88, 16, 70, 60, 88, 2182, 88, 724, 438, 63, 1842, 60, 88, 1085, 60, 88, 1717, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 8083, 3098, 14, 7204, 14, 4311, 8548, 14, 6382, 4709, 60, 88, 713, 60, 88, 1216, 60, 78, 60, 88, 1780, 1419, 60, 88, 1085, 60, 88, 1780, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 70, 14, 3098, 14, 7204, 14, 2209, 4558, 60, 88, 17, 65, 4202, 78, 60, 88, 16, 69, 60, 88, 2322, 88, 724, 438, 4709, 60, 88, 713, 60, 82, 60, 78, 60, 88, 1717, 928, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1717, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1644, 60, 88, 2182, 977, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 1717, 13356, 88, 2635, 60, 88, 1717, 60, 78, 60, 88, 1079, 60, 88, 2466, 553, 4311, 8548, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 354, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 16, 69, 60, 78, 60, 88, 1690, 1955, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 1717, 60, 88, 713, 3427, 78, 60, 88, 1717, 1302, 60, 88, 1085, 60, 88, 966, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 26240, 3098, 14, 7204, 14, 8510, 8548, 14, 4314, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 966, 466, 60, 88, 1085, 60, 88, 1717, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 4856, 3098, 14, 7204, 14, 8510, 8548, 14, 804, 60, 88, 713, 60, 88, 845, 60, 78, 60, 21002, 63, 354, 60, 88, 1085, 60, 88, 1690, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 709, 60, 78, 60, 88, 2036, 60, 88, 2182, 88, 724, 11192, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1046, 60, 78, 60, 82, 885, 63, 585, 60, 88, 1085, 60, 88, 1780, 971, 88, 614, 2961, 84, 60, 88, 713, 3134, 78, 60, 88, 1780, 1419, 60, 88, 1085, 60, 88, 2036, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 68, 14, 3098, 14, 7204, 14, 792, 4558, 13356, 1774, 22, 60, 88, 996, 60, 78, 60, 88, 966, 804, 60, 88, 713 ]
[ 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 199, 504, 6233, 14, 7204, 492, 5872, 199, 504, 6233, 14, 7204, 492, 1245, 199, 504, 6233, 14, 7204, 492, 25572, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 421, 199, 7580, 275, 5872, 14, 23859, 8, 523, 536, 534, 3098, 15, 7204, 15, 4120, 14, 2625, 297, 523, 2559, 534, 3098, 14, 7204, 297, 523, 6380, 63, 3317, 17115, 78, 6233, 15, 7204, 15, 4120, 14, 2625, 60, 88, 713, 60, 88, 16, 70, 3098, 14, 7204, 4451, 39, 60, 78, 60, 88, 845, 60, 88, 2466, 441, 4311, 1084, 60, 88, 713, 60, 88, 708, 60, 78, 60, 88, 966, 60, 88, 1272, 441, 60, 88, 1085, 60, 88, 614, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 4, 14, 3098, 14, 7204, 14, 23859, 8548, 13356, 10550, 60, 88, 996, 60, 78, 60, 88, 969, 60, 88, 2466, 441, 4311, 8548, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 354, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 16, 70, 60, 78, 60, 88, 1780, 2491, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 713, 60, 78, 60, 78, 8575, 60, 88, 1085, 60, 88, 1644, 971, 88, 1644, 2961, 84, 60, 88, 713, 60, 88, 1344, 60, 78, 60, 88, 16, 67, 1188, 63, 466, 60, 88, 1085, 60, 88, 966, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 1275, 3098, 14, 7204, 14, 4311, 8548, 60, 88, 713, 60, 88, 1401, 60, 78, 60, 724, 453, 63, 466, 60, 88, 1085, 60, 88, 1717, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 4, 14, 3098, 14, 7204, 14, 5081, 4311, 8548, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 1780, 1364, 60, 88, 1085, 60, 88, 1690, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 60, 1370, 3098, 14, 7204, 14, 3167, 4311, 8548, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 3858, 724, 438, 60, 88, 1085, 60, 88, 1780, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 17229, 3098, 14, 7204, 14, 8510, 8548, 60, 88, 713, 2696, 78, 60, 88, 1780, 1419, 60, 88, 1085, 60, 88, 2036, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 67, 14, 3098, 14, 7204, 14, 1173, 4558, 13356, 1800, 25, 60, 88, 1644, 60, 78, 60, 88, 16, 70, 60, 88, 1602, 60, 88, 2182, 3116, 8548, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 354, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1082, 60, 78, 60, 88, 1717, 60, 88, 1272, 553, 60, 88, 1085, 60, 88, 996, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 17229, 3098, 14, 7204, 14, 8510, 8548, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 3858, 724, 438, 60, 88, 1085, 60, 88, 1690, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 17229, 3098, 14, 7204, 14, 8510, 8548, 60, 88, 713, 60, 88, 1276, 60, 78, 60, 88, 16, 66, 6376, 63, 466, 60, 88, 1085, 60, 88, 1644, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 1275, 3098, 14, 7204, 14, 4311, 8548, 60, 88, 713, 60, 88, 1401, 60, 78, 60, 724, 453, 63, 466, 60, 88, 1085, 60, 88, 966, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 4, 14, 3098, 14, 7204, 14, 5081, 4311, 8548, 60, 88, 713, 40, 60, 78, 60, 88, 16, 70, 60, 88, 2182, 88, 724, 438, 63, 1842, 60, 88, 1085, 60, 88, 1717, 971, 88, 1644, 2961, 88, 16, 66, 60, 88, 708, 8083, 3098, 14, 7204, 14, 4311, 8548, 14, 6382, 4709, 60, 88, 713, 60, 88, 1216, 60, 78, 60, 88, 1780, 1419, 60, 88, 1085, 60, 88, 1780, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 70, 14, 3098, 14, 7204, 14, 2209, 4558, 60, 88, 17, 65, 4202, 78, 60, 88, 16, 69, 60, 88, 2322, 88, 724, 438, 4709, 60, 88, 713, 60, 82, 60, 78, 60, 88, 1717, 928, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1717, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1644, 60, 88, 2182, 977, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 1717, 13356, 88, 2635, 60, 88, 1717, 60, 78, 60, 88, 1079, 60, 88, 2466, 553, 4311, 8548, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 354, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 16, 69, 60, 78, 60, 88, 1690, 1955, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 1717, 60, 88, 713, 3427, 78, 60, 88, 1717, 1302, 60, 88, 1085, 60, 88, 966, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 26240, 3098, 14, 7204, 14, 8510, 8548, 14, 4314, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 966, 466, 60, 88, 1085, 60, 88, 1717, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 4856, 3098, 14, 7204, 14, 8510, 8548, 14, 804, 60, 88, 713, 60, 88, 845, 60, 78, 60, 21002, 63, 354, 60, 88, 1085, 60, 88, 1690, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 709, 60, 78, 60, 88, 2036, 60, 88, 2182, 88, 724, 11192, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1046, 60, 78, 60, 82, 885, 63, 585, 60, 88, 1085, 60, 88, 1780, 971, 88, 614, 2961, 84, 60, 88, 713, 3134, 78, 60, 88, 1780, 1419, 60, 88, 1085, 60, 88, 2036, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 68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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 ]
davidsminor/cortex
test/IECoreGL/ShaderLoaderTest.py
5
5102
########################################################################## # # Copyright (c) 2007-2012, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # * Neither the name of Image Engine Design nor the names of any # other contributors to this software may be used to endorse or # promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ########################################################################## import unittest import os.path import IECore import IECoreGL IECoreGL.init( False ) class ShaderLoaderTest( unittest.TestCase ) : def test( self ) : sp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders", ":" ) l = IECoreGL.ShaderLoader( sp ) s = l.load( "3dLabs/Toon" ) self.assert_( s.typeName()=="IECoreGL::Shader" ) ss = l.load( "3dLabs/Toon" ) self.assert_( s.isSame( ss ) ) # shader is too complicated for my graphics card s = l.load( "3dLabs/Mandel" ) self.assert_( s.typeName()=="IECoreGL::Shader" ) self.assert_( IECoreGL.ShaderLoader.defaultShaderLoader().isSame( IECoreGL.ShaderLoader.defaultShaderLoader() ) ) def testPreprocessing( self ) : sp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders", ":" ) psp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders/include", ":" ) # this should work l = IECoreGL.ShaderLoader( sp, psp ) s = l.load( "failWithoutPreprocessing" ) # but turning off preprocessing should cause a throw l = IECoreGL.ShaderLoader( sp ) self.assertRaises( RuntimeError, l.load, "failWithoutPreprocessing" ) def testPreprocessingAllowsVersionAndExtension( self ) : sp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders", ":" ) psp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders/include", ":" ) l = IECoreGL.ShaderLoader( sp, psp ) l.load( "versionAndExtension" ) def testPreprocessingThrowsOnBadDirective( self ) : sp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders", ":" ) psp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders/include", ":" ) l = IECoreGL.ShaderLoader( sp, psp ) self.assertRaises( RuntimeError, l.load, "badPreprocessingDirective" ) def testLoadSourceMessagesAndCaching( self ) : sp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders", ":" ) psp = IECore.SearchPath( os.path.dirname( __file__ ) + "/shaders/include", ":" ) l = IECoreGL.ShaderLoader( sp, psp ) with IECore.CapturingMessageHandler() as mh : source = l.loadSource( "thisShaderDoesntExist" ) self.assertEqual( source, ( "", "", "" ) ) source = l.loadSource( "thisShaderDoesntExist" ) self.assertEqual( source, ( "", "", "" ) ) # we don't want messages over and over for repeated failures to # load. self.assertEqual( len( mh.messages ), 1 ) # but we do want a nice sensible message the first time. self.failUnless( "thisShaderDoesntExist" in mh.messages[0].message ) def testClear( self ) : sp = IECore.SearchPath( "/tmp", ":" ) l = IECoreGL.ShaderLoader( sp ) f = open('/tmp/testShader.frag','w') f.write( """void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }""" ) f.close() s = l.load( "testShader" ) f = open('/tmp/testShader.frag','w') f.write( """void main() { gl_FragColor = vec4( 0.0, 1.0, 0.0, 1.0 ); }""" ) f.close() # Source is updated, but we will still reuse the cache s2 = l.load( "testShader" ) self.assert_( s.isSame( s2 ) ) l.clear() # After clearing, the shader is now updated. ( Ideally we would test the modified functionality of the shader here, but that seems hard. ) s3 = l.load( "testShader" ) self.assert_( not s.isSame( s3 ) ) if __name__ == "__main__": unittest.main()
bsd-3-clause
[ 26863, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 10219, 13, 7409, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 258, 627, 11443, 314, 536, 402, 6047, 12580, 29410, 6590, 314, 1561, 402, 1263, 199, 3, 755, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 755, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 755, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 2882, 199, 646, 747, 14, 515, 199, 199, 646, 14707, 199, 646, 14707, 2226, 199, 199, 41, 13682, 2226, 14, 826, 8, 756, 776, 199, 199, 533, 5244, 669, 5455, 774, 8, 2882, 14, 1746, 776, 520, 421, 198, 318, 511, 8, 291, 776, 520, 2742, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 776, 2742, 198, 83, 275, 634, 14, 912, 8, 298, 19, 68, 44, 2101, 15, 32435, 2, 776, 507, 198, 277, 14, 479, 2531, 308, 14, 466, 985, 342, 11800, 41, 13682, 2226, 447, 21511, 2, 776, 2742, 198, 385, 275, 634, 14, 912, 8, 298, 19, 68, 44, 2101, 15, 32435, 2, 776, 507, 198, 277, 14, 479, 2531, 308, 14, 374, 8479, 8, 10110, 776, 776, 2742, 198, 3, 25958, 365, 4634, 23515, 367, 3002, 24348, 12564, 507, 198, 83, 275, 634, 14, 912, 8, 298, 19, 68, 44, 2101, 15, 2395, 2264, 2, 776, 507, 198, 277, 14, 479, 2531, 308, 14, 466, 985, 342, 11800, 41, 13682, 2226, 447, 21511, 2, 776, 2742, 198, 277, 14, 479, 2531, 14707, 2226, 14, 21511, 5455, 14, 885, 21511, 5455, 1252, 374, 8479, 8, 14707, 2226, 14, 21511, 5455, 14, 885, 21511, 5455, 342, 776, 776, 421, 198, 318, 511, 2398, 6338, 8, 291, 776, 520, 2742, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 2742, 198, 3, 642, 1077, 1736, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 507, 198, 83, 275, 634, 14, 912, 8, 298, 1633, 12450, 2398, 6338, 2, 776, 2742, 198, 3, 1325, 7485, 316, 2331, 26471, 1077, 7675, 282, 7978, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 776, 507, 198, 277, 14, 1855, 8, 6064, 12, 634, 14, 912, 12, 298, 1633, 12450, 2398, 6338, 2, 776, 421, 198, 318, 511, 2398, 6338, 19780, 3353, 3325, 6382, 8, 291, 776, 520, 28550, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 2742, 198, 76, 14, 912, 8, 298, 1023, 3325, 6382, 2, 776, 18118, 198, 318, 511, 2398, 6338, 2719, 3838, 3314, 5725, 29489, 8, 291, 776, 520, 28550, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 2742, 198, 277, 14, 1855, 8, 6064, 12, 634, 14, 912, 12, 298, 4087, 2398, 6338, 29489, 2, 776, 198, 8299, 198, 318, 511, 6200, 2980, 14508, 3325, 35, 23302, 8, 291, 776, 520, 28550, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 9068 ]
[ 199, 3, 199, 3, 221, 1898, 334, 67, 9, 10219, 13, 7409, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 258, 627, 11443, 314, 536, 402, 6047, 12580, 29410, 6590, 314, 1561, 402, 1263, 199, 3, 755, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 755, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 755, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 2882, 199, 646, 747, 14, 515, 199, 199, 646, 14707, 199, 646, 14707, 2226, 199, 199, 41, 13682, 2226, 14, 826, 8, 756, 776, 199, 199, 533, 5244, 669, 5455, 774, 8, 2882, 14, 1746, 776, 520, 421, 198, 318, 511, 8, 291, 776, 520, 2742, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 776, 2742, 198, 83, 275, 634, 14, 912, 8, 298, 19, 68, 44, 2101, 15, 32435, 2, 776, 507, 198, 277, 14, 479, 2531, 308, 14, 466, 985, 342, 11800, 41, 13682, 2226, 447, 21511, 2, 776, 2742, 198, 385, 275, 634, 14, 912, 8, 298, 19, 68, 44, 2101, 15, 32435, 2, 776, 507, 198, 277, 14, 479, 2531, 308, 14, 374, 8479, 8, 10110, 776, 776, 2742, 198, 3, 25958, 365, 4634, 23515, 367, 3002, 24348, 12564, 507, 198, 83, 275, 634, 14, 912, 8, 298, 19, 68, 44, 2101, 15, 2395, 2264, 2, 776, 507, 198, 277, 14, 479, 2531, 308, 14, 466, 985, 342, 11800, 41, 13682, 2226, 447, 21511, 2, 776, 2742, 198, 277, 14, 479, 2531, 14707, 2226, 14, 21511, 5455, 14, 885, 21511, 5455, 1252, 374, 8479, 8, 14707, 2226, 14, 21511, 5455, 14, 885, 21511, 5455, 342, 776, 776, 421, 198, 318, 511, 2398, 6338, 8, 291, 776, 520, 2742, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 2742, 198, 3, 642, 1077, 1736, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 507, 198, 83, 275, 634, 14, 912, 8, 298, 1633, 12450, 2398, 6338, 2, 776, 2742, 198, 3, 1325, 7485, 316, 2331, 26471, 1077, 7675, 282, 7978, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 776, 507, 198, 277, 14, 1855, 8, 6064, 12, 634, 14, 912, 12, 298, 1633, 12450, 2398, 6338, 2, 776, 421, 198, 318, 511, 2398, 6338, 19780, 3353, 3325, 6382, 8, 291, 776, 520, 28550, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 2742, 198, 76, 14, 912, 8, 298, 1023, 3325, 6382, 2, 776, 18118, 198, 318, 511, 2398, 6338, 2719, 3838, 3314, 5725, 29489, 8, 291, 776, 520, 28550, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 401, 14725, 776, 507, 198, 80, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435, 3286, 18116, 83, 15, 2613, 401, 14725, 776, 507, 198, 76, 275, 14707, 2226, 14, 21511, 5455, 8, 2249, 12, 299, 681, 776, 2742, 198, 277, 14, 1855, 8, 6064, 12, 634, 14, 912, 12, 298, 4087, 2398, 6338, 29489, 2, 776, 198, 8299, 198, 318, 511, 6200, 2980, 14508, 3325, 35, 23302, 8, 291, 776, 520, 28550, 198, 681, 275, 14707, 14, 5278, 2042, 8, 747, 14, 515, 14, 3475, 8, 636, 493, 363, 776, 435,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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 ]
seaotterman/tensorflow
tensorflow/python/util/lazy_loader.py
20
2006
# 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. # ============================================================================== """A LazyLoader class.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import importlib import types class LazyLoader(types.ModuleType): """Lazily import a module, mainly to avoid pulling in large dependancies. `contrib`, and `ffmpeg` are examples of modules that are large and not always needed, and this allows them to only be loaded when they are used. """ # The lint error here is incorrect. def __init__(self, local_name, parent_module_globals, name): # pylint: disable=super-on-old-class self._local_name = local_name self._parent_module_globals = parent_module_globals super(LazyLoader, self).__init__(name) def _load(self): # Import the target module and insert it into the parent's namespace module = importlib.import_module(self.__name__) self._parent_module_globals[self._local_name] = module # Update this object's dict so that if someone keeps a reference to the # LazyLoader, lookups are efficient (__getattr__ is only called on lookups # that fail). self.__dict__.update(module.__dict__) return module def __getattr__(self, item): module = self._load() return getattr(module, item) def __dir__(self): module = self._load() return dir(module)
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, 199, 624, 33, 22373, 5455, 1021, 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, 14802, 199, 646, 2943, 421, 199, 533, 22373, 5455, 8, 1313, 14, 21820, 304, 523, 408, 44, 4651, 3444, 492, 282, 859, 12, 27580, 370, 5126, 10299, 316, 315, 7031, 11687, 290, 2578, 14, 819, 658, 2828, 3559, 436, 658, 27648, 64, 787, 7251, 402, 4621, 626, 787, 7031, 436, 440, 3544, 523, 4346, 12, 436, 642, 6127, 3062, 370, 1454, 506, 6511, 1380, 2985, 787, 1202, 14, 523, 408, 819, 327, 710, 24620, 1125, 2348, 365, 8927, 14, 523, 347, 636, 826, 721, 277, 12, 2257, 63, 354, 12, 1676, 63, 578, 63, 8473, 12, 536, 304, 221, 327, 4287, 26, 3507, 29, 4792, 13, 265, 13, 1753, 13, 533, 272, 291, 423, 1832, 63, 354, 275, 2257, 63, 354, 272, 291, 423, 1708, 63, 578, 63, 8473, 275, 1676, 63, 578, 63, 8473, 339, 1613, 8, 14269, 5455, 12, 291, 2843, 826, 721, 354, 9, 819, 347, 485, 912, 8, 277, 304, 272, 327, 3161, 314, 1347, 859, 436, 5518, 652, 1901, 314, 1676, 1159, 3231, 272, 859, 275, 14802, 14, 646, 63, 578, 8, 277, 855, 354, 3368, 272, 291, 423, 1708, 63, 578, 63, 8473, 59, 277, 423, 1832, 63, 354, 61, 275, 859, 339, 327, 6162, 642, 909, 1159, 1211, 880, 626, 340, 17122, 18578, 282, 3659, 370, 314, 272, 327, 257, 22373, 5455, 12, 16807, 787, 13402, 25373, 5675, 363, 365, 1454, 2797, 641, 16807, 272, 327, 257, 626, 2449, 680, 272, 291, 855, 807, 4343, 873, 8, 578, 855, 807, 3368, 339, 372, 859, 819, 347, 636, 5675, 721, 277, 12, 1242, 304, 272, 859, 275, 291, 423, 912, 342, 272, 372, 2519, 8, 578, 12, 1242, 9, 819, 347, 636, 694, 721, 277, 304, 272, 859, 275, 291, 423, 912, 342, 272, 372, 2935, 8, 578, 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 ]
[ 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, 33, 22373, 5455, 1021, 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, 14802, 199, 646, 2943, 421, 199, 533, 22373, 5455, 8, 1313, 14, 21820, 304, 523, 408, 44, 4651, 3444, 492, 282, 859, 12, 27580, 370, 5126, 10299, 316, 315, 7031, 11687, 290, 2578, 14, 819, 658, 2828, 3559, 436, 658, 27648, 64, 787, 7251, 402, 4621, 626, 787, 7031, 436, 440, 3544, 523, 4346, 12, 436, 642, 6127, 3062, 370, 1454, 506, 6511, 1380, 2985, 787, 1202, 14, 523, 408, 819, 327, 710, 24620, 1125, 2348, 365, 8927, 14, 523, 347, 636, 826, 721, 277, 12, 2257, 63, 354, 12, 1676, 63, 578, 63, 8473, 12, 536, 304, 221, 327, 4287, 26, 3507, 29, 4792, 13, 265, 13, 1753, 13, 533, 272, 291, 423, 1832, 63, 354, 275, 2257, 63, 354, 272, 291, 423, 1708, 63, 578, 63, 8473, 275, 1676, 63, 578, 63, 8473, 339, 1613, 8, 14269, 5455, 12, 291, 2843, 826, 721, 354, 9, 819, 347, 485, 912, 8, 277, 304, 272, 327, 3161, 314, 1347, 859, 436, 5518, 652, 1901, 314, 1676, 1159, 3231, 272, 859, 275, 14802, 14, 646, 63, 578, 8, 277, 855, 354, 3368, 272, 291, 423, 1708, 63, 578, 63, 8473, 59, 277, 423, 1832, 63, 354, 61, 275, 859, 339, 327, 6162, 642, 909, 1159, 1211, 880, 626, 340, 17122, 18578, 282, 3659, 370, 314, 272, 327, 257, 22373, 5455, 12, 16807, 787, 13402, 25373, 5675, 363, 365, 1454, 2797, 641, 16807, 272, 327, 257, 626, 2449, 680, 272, 291, 855, 807, 4343, 873, 8, 578, 855, 807, 3368, 339, 372, 859, 819, 347, 636, 5675, 721, 277, 12, 1242, 304, 272, 859, 275, 291, 423, 912, 342, 272, 372, 2519, 8, 578, 12, 1242, 9, 819, 347, 636, 694, 721, 277, 304, 272, 859, 275, 291, 423, 912, 342, 272, 372, 2935, 8, 578, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
slipperyhank/pyphi
benchmarks/benchmarks/compute.py
2
3384
import timeit import copy from pyphi import cache as _cache, compute, config, constants, examples, Subsystem from .subsystem import clear_subsystem_caches def _clear_joblib_cache(): constants.joblib_memory.clear() class BenchmarkConstellation: params = [ ['parallel', 'sequential'], ['basic', 'rule154', 'fig16'] ] param_names = ['mode', 'network'] number = 1 repeat = 1 def setup(self, mode, network): if network == 'basic': self.subsys = examples.basic_subsystem() elif network == 'rule154': network = examples.rule154_network() state = (1,) * 5 self.subsys = Subsystem(network, state, network.node_indices) elif network == 'fig16': network = examples.fig16() state = (0,) * 7 self.subsys = Subsystem(network, state, network.node_indices) else: raise ValueError(network) if mode == 'parallel': config.PARALLEL_CONCEPT_EVALUATION = True elif mode == 'sequential': config.PARALLEL_CONCEPT_EVALUATION = False else: raise ValueError(mode) def time_constellation(self, mode, network): clear_subsystem_caches(self.subsys) # network purview caches are left intact compute.constellation(self.subsys) class BenchmarkMainComplex(): params = [ ['parallel', 'sequential'], ['basic', 'rule154', 'fig16'], ['local', 'redis'] ] param_names = ['mode', 'network', 'cache'] # Use `default_timer` (clock time) instead of process time because # parallel execution spawns separate processes which are not counted # in process time. # Additionally, we don't need to clear any network caches because we # only run 1 iteration. # TODO: do we need to clear global caches? timer = timeit.default_timer number = 1 repeat = 1 timeout = 10000 def setup(self, mode, network, cache): if network == 'basic': self.network = examples.basic_network() self.state = (0, 1, 1) elif network == 'rule154': self.network = examples.rule154_network() self.state = (0, 1, 0, 1, 1) elif network == 'fig16': self.network = examples.fig16() self.state = (1, 0, 0, 1, 1, 1, 0) else: raise ValueError(network) # Save config self.default_config = copy.copy(config.__dict__) # Execution mode if mode == 'parallel': config.PARALLEL_CUT_EVALUATION = True elif mode == 'sequential': config.PARALLEL_CUT_EVALUATION = False else: raise ValueError(mode) # Cache mode if cache == 'local': config.REDIS_CACHE = False elif cache == 'redis': config.REDIS_CACHE = True if _cache.RedisConn().ping() is False: # No server running raise NotImplementedError else: raise ValueError(cache) config.CACHE_BIGMIPS = False def teardown(self, mode, network, cache): # Revert config config.__dict__.update(self.default_config) def time_main_complex(self, mode, network, cache): # Do it! compute.main_complex(self.network, self.state)
gpl-3.0
[ 199, 646, 900, 390, 199, 646, 1331, 199, 199, 504, 1134, 10909, 492, 2581, 465, 485, 1637, 12, 4526, 12, 1101, 12, 5262, 12, 7251, 12, 4804, 2253, 199, 504, 1275, 954, 2253, 492, 5436, 63, 954, 2253, 63, 17595, 421, 199, 318, 485, 3584, 63, 2423, 773, 63, 1637, 837, 272, 5262, 14, 2423, 773, 63, 4844, 14, 3584, 342, 421, 199, 533, 27067, 714, 30721, 2212, 26, 339, 1862, 275, 359, 267, 788, 11887, 297, 283, 16211, 995, 267, 788, 4316, 297, 283, 2200, 10478, 297, 283, 592, 975, 418, 272, 1622, 272, 1215, 63, 1247, 275, 788, 632, 297, 283, 1200, 418, 272, 1329, 275, 413, 272, 11982, 275, 413, 339, 347, 3272, 8, 277, 12, 818, 12, 2784, 304, 267, 340, 2784, 508, 283, 4316, 356, 288, 291, 14, 954, 1274, 275, 7251, 14, 4316, 63, 954, 2253, 342, 267, 916, 2784, 508, 283, 2200, 10478, 356, 288, 2784, 275, 7251, 14, 2200, 10478, 63, 1200, 342, 288, 1174, 275, 334, 17, 4258, 627, 959, 288, 291, 14, 954, 1274, 275, 4804, 2253, 8, 1200, 12, 1174, 12, 2784, 14, 932, 63, 4108, 9, 267, 916, 2784, 508, 283, 592, 975, 356, 288, 2784, 275, 7251, 14, 592, 975, 342, 288, 1174, 275, 334, 16, 4258, 627, 1520, 288, 291, 14, 954, 1274, 275, 4804, 2253, 8, 1200, 12, 1174, 12, 2784, 14, 932, 63, 4108, 9, 267, 587, 26, 288, 746, 1722, 8, 1200, 9, 398, 340, 818, 508, 283, 11887, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 1864, 7177, 63, 28805, 53, 2594, 275, 715, 267, 916, 818, 508, 283, 16211, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 1864, 7177, 63, 28805, 53, 2594, 275, 756, 267, 587, 26, 288, 746, 1722, 8, 632, 9, 339, 347, 900, 63, 388, 30721, 2212, 8, 277, 12, 818, 12, 2784, 304, 267, 5436, 63, 954, 2253, 63, 17595, 8, 277, 14, 954, 1274, 9, 267, 327, 2784, 5861, 1345, 18014, 787, 3602, 315, 4552, 267, 4526, 14, 388, 30721, 2212, 8, 277, 14, 954, 1274, 9, 421, 199, 533, 27067, 6756, 14500, 837, 339, 1862, 275, 359, 267, 788, 11887, 297, 283, 16211, 995, 267, 788, 4316, 297, 283, 2200, 10478, 297, 283, 592, 975, 995, 267, 788, 1832, 297, 283, 15369, 418, 272, 1622, 272, 1215, 63, 1247, 275, 788, 632, 297, 283, 1200, 297, 283, 1637, 418, 339, 327, 3645, 658, 885, 63, 7414, 64, 334, 9597, 900, 9, 3140, 402, 2112, 900, 2952, 272, 327, 9861, 6451, 5844, 87, 561, 7396, 10358, 1314, 787, 440, 31662, 272, 327, 315, 2112, 900, 14, 272, 327, 25448, 12, 781, 2793, 1133, 1929, 370, 5436, 1263, 2784, 18014, 2952, 781, 272, 327, 1454, 1255, 413, 8494, 14, 272, 327, 3254, 26, 886, 781, 1929, 370, 5436, 2288, 18014, 31, 272, 9715, 275, 900, 390, 14, 885, 63, 7414, 272, 1329, 275, 413, 272, 11982, 275, 413, 272, 2653, 275, 11630, 339, 347, 3272, 8, 277, 12, 818, 12, 2784, 12, 2581, 304, 398, 340, 2784, 508, 283, 4316, 356, 288, 291, 14, 1200, 275, 7251, 14, 4316, 63, 1200, 342, 288, 291, 14, 929, 275, 334, 16, 12, 413, 12, 413, 9, 267, 916, 2784, 508, 283, 2200, 10478, 356, 288, 291, 14, 1200, 275, 7251, 14, 2200, 10478, 63, 1200, 342, 288, 291, 14, 929, 275, 334, 16, 12, 413, 12, 378, 12, 413, 12, 413, 9, 267, 916, 2784, 508, 283, 592, 975, 356, 288, 291, 14, 1200, 275, 7251, 14, 592, 975, 342, 288, 291, 14, 929, 275, 334, 17, 12, 378, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 9, 267, 587, 26, 288, 746, 1722, 8, 1200, 9, 398, 327, 11063, 1101, 267, 291, 14, 885, 63, 888, 275, 1331, 14, 1574, 8, 888, 855, 807, 3368, 398, 327, 28573, 818, 267, 340, 818, 508, 283, 11887, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 24678, 63, 28805, 53, 2594, 275, 715, 267, 916, 818, 508, 283, 16211, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 24678, 63, 28805, 53, 2594, 275, 756, 267, 587, 26, 288, 746, 1722, 8, 632, 9, 398, 327, 11977, 818, 267, 340, 2581, 508, 283, 1832, 356, 288, 1101, 14, 907, 6178, 63, 8677, 275, 756, 267, 916, 2581, 508, 283, 15369, 356, 288, 1101, 14, 907, 6178, 63, 8677, 275, 715, 288, 340, 485, 1637, 14, 29605, 6805, 1252, 4073, 342, 365, 756, 26, 355, 327, 3091, 1654, 3879, 355, 746, 4279, 267, 587, 26, 288, 746, 1722, 8, 1637, 9, 398, 1101, 14, 8677, 63, 18643, 45, 12346, 275, 756, 339, 347, 17558, 8, 277, 12, 818, 12, 2784, 12, 2581, 304, 267, 327, 799, 1884, 1101, 267, 1101, 855, 807, 4343, 873, 8, 277, 14, 885, 63, 888, 9, 339, 347, 900, 63, 973, 63, 5254, 8, 277, 12, 818, 12, 2784, 12, 2581, 304, 267, 327, 4226, 652, 1, 267, 4526, 14, 973, 63, 5254, 8, 277, 14, 1200, 12, 291, 14, 929, 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 ]
[ 646, 900, 390, 199, 646, 1331, 199, 199, 504, 1134, 10909, 492, 2581, 465, 485, 1637, 12, 4526, 12, 1101, 12, 5262, 12, 7251, 12, 4804, 2253, 199, 504, 1275, 954, 2253, 492, 5436, 63, 954, 2253, 63, 17595, 421, 199, 318, 485, 3584, 63, 2423, 773, 63, 1637, 837, 272, 5262, 14, 2423, 773, 63, 4844, 14, 3584, 342, 421, 199, 533, 27067, 714, 30721, 2212, 26, 339, 1862, 275, 359, 267, 788, 11887, 297, 283, 16211, 995, 267, 788, 4316, 297, 283, 2200, 10478, 297, 283, 592, 975, 418, 272, 1622, 272, 1215, 63, 1247, 275, 788, 632, 297, 283, 1200, 418, 272, 1329, 275, 413, 272, 11982, 275, 413, 339, 347, 3272, 8, 277, 12, 818, 12, 2784, 304, 267, 340, 2784, 508, 283, 4316, 356, 288, 291, 14, 954, 1274, 275, 7251, 14, 4316, 63, 954, 2253, 342, 267, 916, 2784, 508, 283, 2200, 10478, 356, 288, 2784, 275, 7251, 14, 2200, 10478, 63, 1200, 342, 288, 1174, 275, 334, 17, 4258, 627, 959, 288, 291, 14, 954, 1274, 275, 4804, 2253, 8, 1200, 12, 1174, 12, 2784, 14, 932, 63, 4108, 9, 267, 916, 2784, 508, 283, 592, 975, 356, 288, 2784, 275, 7251, 14, 592, 975, 342, 288, 1174, 275, 334, 16, 4258, 627, 1520, 288, 291, 14, 954, 1274, 275, 4804, 2253, 8, 1200, 12, 1174, 12, 2784, 14, 932, 63, 4108, 9, 267, 587, 26, 288, 746, 1722, 8, 1200, 9, 398, 340, 818, 508, 283, 11887, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 1864, 7177, 63, 28805, 53, 2594, 275, 715, 267, 916, 818, 508, 283, 16211, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 1864, 7177, 63, 28805, 53, 2594, 275, 756, 267, 587, 26, 288, 746, 1722, 8, 632, 9, 339, 347, 900, 63, 388, 30721, 2212, 8, 277, 12, 818, 12, 2784, 304, 267, 5436, 63, 954, 2253, 63, 17595, 8, 277, 14, 954, 1274, 9, 267, 327, 2784, 5861, 1345, 18014, 787, 3602, 315, 4552, 267, 4526, 14, 388, 30721, 2212, 8, 277, 14, 954, 1274, 9, 421, 199, 533, 27067, 6756, 14500, 837, 339, 1862, 275, 359, 267, 788, 11887, 297, 283, 16211, 995, 267, 788, 4316, 297, 283, 2200, 10478, 297, 283, 592, 975, 995, 267, 788, 1832, 297, 283, 15369, 418, 272, 1622, 272, 1215, 63, 1247, 275, 788, 632, 297, 283, 1200, 297, 283, 1637, 418, 339, 327, 3645, 658, 885, 63, 7414, 64, 334, 9597, 900, 9, 3140, 402, 2112, 900, 2952, 272, 327, 9861, 6451, 5844, 87, 561, 7396, 10358, 1314, 787, 440, 31662, 272, 327, 315, 2112, 900, 14, 272, 327, 25448, 12, 781, 2793, 1133, 1929, 370, 5436, 1263, 2784, 18014, 2952, 781, 272, 327, 1454, 1255, 413, 8494, 14, 272, 327, 3254, 26, 886, 781, 1929, 370, 5436, 2288, 18014, 31, 272, 9715, 275, 900, 390, 14, 885, 63, 7414, 272, 1329, 275, 413, 272, 11982, 275, 413, 272, 2653, 275, 11630, 339, 347, 3272, 8, 277, 12, 818, 12, 2784, 12, 2581, 304, 398, 340, 2784, 508, 283, 4316, 356, 288, 291, 14, 1200, 275, 7251, 14, 4316, 63, 1200, 342, 288, 291, 14, 929, 275, 334, 16, 12, 413, 12, 413, 9, 267, 916, 2784, 508, 283, 2200, 10478, 356, 288, 291, 14, 1200, 275, 7251, 14, 2200, 10478, 63, 1200, 342, 288, 291, 14, 929, 275, 334, 16, 12, 413, 12, 378, 12, 413, 12, 413, 9, 267, 916, 2784, 508, 283, 592, 975, 356, 288, 291, 14, 1200, 275, 7251, 14, 592, 975, 342, 288, 291, 14, 929, 275, 334, 17, 12, 378, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 9, 267, 587, 26, 288, 746, 1722, 8, 1200, 9, 398, 327, 11063, 1101, 267, 291, 14, 885, 63, 888, 275, 1331, 14, 1574, 8, 888, 855, 807, 3368, 398, 327, 28573, 818, 267, 340, 818, 508, 283, 11887, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 24678, 63, 28805, 53, 2594, 275, 715, 267, 916, 818, 508, 283, 16211, 356, 288, 1101, 14, 4014, 748, 906, 44, 63, 24678, 63, 28805, 53, 2594, 275, 756, 267, 587, 26, 288, 746, 1722, 8, 632, 9, 398, 327, 11977, 818, 267, 340, 2581, 508, 283, 1832, 356, 288, 1101, 14, 907, 6178, 63, 8677, 275, 756, 267, 916, 2581, 508, 283, 15369, 356, 288, 1101, 14, 907, 6178, 63, 8677, 275, 715, 288, 340, 485, 1637, 14, 29605, 6805, 1252, 4073, 342, 365, 756, 26, 355, 327, 3091, 1654, 3879, 355, 746, 4279, 267, 587, 26, 288, 746, 1722, 8, 1637, 9, 398, 1101, 14, 8677, 63, 18643, 45, 12346, 275, 756, 339, 347, 17558, 8, 277, 12, 818, 12, 2784, 12, 2581, 304, 267, 327, 799, 1884, 1101, 267, 1101, 855, 807, 4343, 873, 8, 277, 14, 885, 63, 888, 9, 339, 347, 900, 63, 973, 63, 5254, 8, 277, 12, 818, 12, 2784, 12, 2581, 304, 267, 327, 4226, 652, 1, 267, 4526, 14, 973, 63, 5254, 8, 277, 14, 1200, 12, 291, 14, 929, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
RobbieBowman/Robot-Game-AI
rg.py
3
1416
# users will import rg to be able to use robot game functions import math import operator settings = None # constants CENTER_POINT = None def after_settings(): global CENTER_POINT global settings CENTER_POINT = (int(settings.board_size / 2), int(settings.board_size / 2)) def set_settings(s): global settings settings = s after_settings() ############################## dist = lambda p1, p2: math.sqrt((p2[0]-p1[0])**2 + (p2[1]-p1[1])**2) wdist = lambda p1, p2: abs(p2[0]-p1[0]) + abs(p2[1]-p1[1]) def loc_types(loc): for i in range(2): if not (0 <= loc[i] < settings.board_size): return ['invalid'] types = ['normal'] if loc in settings.spawn_coords: types.append('spawn') if loc in settings.obstacles: types.append('obstacle') return types def locs_around(loc, filter_out=None): filter_out = filter_out or [] offsets = ((0, 1), (1, 0), (0, -1), (-1, 0)) locs = [] for o in offsets: new_loc = tuple(map(operator.add, loc, o)) if len(set(filter_out) & set(loc_types(new_loc))) == 0: locs.append(new_loc) return locs def toward(curr, dest): if curr == dest: return curr x0, y0 = curr x, y = dest x_diff, y_diff = x - x0, y - y0 if abs(x_diff) < abs(y_diff): return (x0, y0 + y_diff / abs(y_diff)) return (x0 + x_diff / abs(x_diff), y0)
unlicense
[ 3, 4390, 911, 492, 23136, 370, 506, 7688, 370, 675, 14544, 9219, 3423, 199, 646, 3473, 199, 646, 4182, 199, 199, 1751, 275, 488, 199, 199, 3, 5262, 199, 199, 17611, 63, 7217, 275, 488, 199, 199, 318, 2410, 63, 1751, 837, 272, 2288, 445, 12533, 63, 7217, 272, 2288, 2202, 272, 445, 12533, 63, 7217, 275, 334, 442, 8, 1751, 14, 3576, 63, 890, 1182, 499, 395, 1109, 8, 1751, 14, 3576, 63, 890, 1182, 499, 430, 199, 199, 318, 663, 63, 1751, 8, 83, 304, 272, 2288, 2202, 272, 2202, 275, 308, 272, 2410, 63, 1751, 342, 199, 199, 6565, 3726, 199, 199, 2686, 275, 2400, 299, 17, 12, 299, 18, 26, 3473, 14, 5079, 1332, 80, 18, 59, 16, 11285, 80, 17, 59, 16, 566, 538, 18, 435, 334, 80, 18, 59, 17, 11285, 80, 17, 59, 17, 566, 538, 18, 9, 199, 87, 2686, 275, 2400, 299, 17, 12, 299, 18, 26, 2853, 8, 80, 18, 59, 16, 11285, 80, 17, 59, 16, 566, 435, 2853, 8, 80, 18, 59, 17, 11285, 80, 17, 59, 17, 566, 199, 199, 318, 4355, 63, 1313, 8, 2102, 304, 272, 367, 284, 315, 1425, 8, 18, 304, 267, 340, 440, 334, 16, 2695, 4355, 59, 73, 61, 665, 2202, 14, 3576, 63, 890, 304, 288, 372, 788, 3197, 418, 272, 2943, 275, 788, 3302, 418, 272, 340, 4355, 315, 2202, 14, 10212, 63, 8032, 26, 267, 2943, 14, 740, 360, 10212, 358, 272, 340, 4355, 315, 2202, 14, 2873, 270, 645, 2978, 26, 267, 2943, 14, 740, 360, 2873, 270, 12550, 358, 272, 372, 2943, 199, 199, 318, 29502, 63, 11659, 8, 2102, 12, 2457, 63, 548, 29, 403, 304, 272, 2457, 63, 548, 275, 2457, 63, 548, 503, 942, 272, 15340, 275, 3666, 16, 12, 413, 395, 334, 17, 12, 378, 395, 334, 16, 12, 446, 17, 395, 5868, 17, 12, 378, 430, 272, 29502, 275, 942, 339, 367, 312, 315, 15340, 26, 267, 892, 63, 2102, 275, 2008, 8, 1130, 8, 3856, 14, 525, 12, 4355, 12, 312, 430, 267, 340, 822, 8, 409, 8, 1541, 63, 548, 9, 1253, 663, 8, 2102, 63, 1313, 8, 1222, 63, 2102, 1724, 508, 378, 26, 288, 29502, 14, 740, 8, 1222, 63, 2102, 9, 272, 372, 29502, 199, 199, 318, 370, 3079, 8, 9808, 12, 2053, 304, 272, 340, 8230, 508, 2053, 26, 267, 372, 8230, 339, 671, 16, 12, 612, 16, 275, 8230, 272, 671, 12, 612, 275, 2053, 272, 671, 63, 3028, 12, 612, 63, 3028, 275, 671, 446, 671, 16, 12, 612, 446, 612, 16, 339, 340, 2853, 8, 88, 63, 3028, 9, 665, 2853, 8, 89, 63, 3028, 304, 267, 372, 334, 88, 16, 12, 612, 16, 435, 612, 63, 3028, 1182, 2853, 8, 89, 63, 3028, 430, 272, 372, 334, 88, 16, 435, 671, 63, 3028, 1182, 2853, 8, 88, 63, 3028, 395, 612, 16, 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 ]
[ 4390, 911, 492, 23136, 370, 506, 7688, 370, 675, 14544, 9219, 3423, 199, 646, 3473, 199, 646, 4182, 199, 199, 1751, 275, 488, 199, 199, 3, 5262, 199, 199, 17611, 63, 7217, 275, 488, 199, 199, 318, 2410, 63, 1751, 837, 272, 2288, 445, 12533, 63, 7217, 272, 2288, 2202, 272, 445, 12533, 63, 7217, 275, 334, 442, 8, 1751, 14, 3576, 63, 890, 1182, 499, 395, 1109, 8, 1751, 14, 3576, 63, 890, 1182, 499, 430, 199, 199, 318, 663, 63, 1751, 8, 83, 304, 272, 2288, 2202, 272, 2202, 275, 308, 272, 2410, 63, 1751, 342, 199, 199, 6565, 3726, 199, 199, 2686, 275, 2400, 299, 17, 12, 299, 18, 26, 3473, 14, 5079, 1332, 80, 18, 59, 16, 11285, 80, 17, 59, 16, 566, 538, 18, 435, 334, 80, 18, 59, 17, 11285, 80, 17, 59, 17, 566, 538, 18, 9, 199, 87, 2686, 275, 2400, 299, 17, 12, 299, 18, 26, 2853, 8, 80, 18, 59, 16, 11285, 80, 17, 59, 16, 566, 435, 2853, 8, 80, 18, 59, 17, 11285, 80, 17, 59, 17, 566, 199, 199, 318, 4355, 63, 1313, 8, 2102, 304, 272, 367, 284, 315, 1425, 8, 18, 304, 267, 340, 440, 334, 16, 2695, 4355, 59, 73, 61, 665, 2202, 14, 3576, 63, 890, 304, 288, 372, 788, 3197, 418, 272, 2943, 275, 788, 3302, 418, 272, 340, 4355, 315, 2202, 14, 10212, 63, 8032, 26, 267, 2943, 14, 740, 360, 10212, 358, 272, 340, 4355, 315, 2202, 14, 2873, 270, 645, 2978, 26, 267, 2943, 14, 740, 360, 2873, 270, 12550, 358, 272, 372, 2943, 199, 199, 318, 29502, 63, 11659, 8, 2102, 12, 2457, 63, 548, 29, 403, 304, 272, 2457, 63, 548, 275, 2457, 63, 548, 503, 942, 272, 15340, 275, 3666, 16, 12, 413, 395, 334, 17, 12, 378, 395, 334, 16, 12, 446, 17, 395, 5868, 17, 12, 378, 430, 272, 29502, 275, 942, 339, 367, 312, 315, 15340, 26, 267, 892, 63, 2102, 275, 2008, 8, 1130, 8, 3856, 14, 525, 12, 4355, 12, 312, 430, 267, 340, 822, 8, 409, 8, 1541, 63, 548, 9, 1253, 663, 8, 2102, 63, 1313, 8, 1222, 63, 2102, 1724, 508, 378, 26, 288, 29502, 14, 740, 8, 1222, 63, 2102, 9, 272, 372, 29502, 199, 199, 318, 370, 3079, 8, 9808, 12, 2053, 304, 272, 340, 8230, 508, 2053, 26, 267, 372, 8230, 339, 671, 16, 12, 612, 16, 275, 8230, 272, 671, 12, 612, 275, 2053, 272, 671, 63, 3028, 12, 612, 63, 3028, 275, 671, 446, 671, 16, 12, 612, 446, 612, 16, 339, 340, 2853, 8, 88, 63, 3028, 9, 665, 2853, 8, 89, 63, 3028, 304, 267, 372, 334, 88, 16, 12, 612, 16, 435, 612, 63, 3028, 1182, 2853, 8, 89, 63, 3028, 430, 272, 372, 334, 88, 16, 435, 671, 63, 3028, 1182, 2853, 8, 88, 63, 3028, 395, 612, 16, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
narasimhan-v/avocado-misc-tests-1
io/disk/fiotest.py
4
10168
#!/usr/bin/env python # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # See LICENSE for more details. # # Copyright: 2016 Red Hat, Inc. # Author: Amador Pahim <apahim@redhat.com> # # Based on code by Randy Dunlap <rdunlap@xenotime.net> # copyright 2006 Randy Dunlap <rdunlap@xenotime.net> # https://github.com/autotest/autotest-client-tests/tree/master/fio """ FIO Test """ import os import avocado from avocado import Test from avocado.utils import archive from avocado.utils import build from avocado.utils import pmem from avocado.utils import disk from avocado.utils import lv_utils from avocado.utils import process, distro from avocado.utils import softwareraid from avocado.utils.partition import Partition from avocado.utils.software_manager import SoftwareManager from avocado.utils.partition import PartitionError class FioTest(Test): """ fio is an I/O tool meant to be used both for benchmark and stress/hardware verification. :see: http://freecode.com/projects/fio :param fio_tarbal: name of the tarbal of fio suite located in deps path :param fio_job: config defining set of executed tests located in deps path """ def setUp(self): """ Build 'fio'. """ default_url = "https://brick.kernel.dk/snaps/fio-git-latest.tar.gz" url = self.params.get('fio_tool_url', default=default_url) self.disk = self.params.get('disk', default=None) self.disk_type = self.params.get('disk_type', default='') fs_args = self.params.get('fs_args', default='') mnt_args = self.params.get('mnt_args', default='') self.fio_file = 'fiotest-image' self.fs_create = False self.lv_create = False self.raid_create = False self.devdax_file = None fstype = self.params.get('fs', default='') if fstype == 'btrfs': ver = int(distro.detect().version) rel = int(distro.detect().release) if distro.detect().name == 'rhel': if (ver == 7 and rel >= 4) or ver > 7: self.cancel("btrfs is not supported with \ RHEL 7.4 onwards") lv_needed = self.params.get('lv', default=False) raid_needed = self.params.get('raid', default=False) if distro.detect().name in ['Ubuntu', 'debian']: pkg_list = ['libaio-dev'] if fstype == 'btrfs': pkg_list.append('btrfs-progs') else: pkg_list = ['libaio', 'libaio-devel'] if self.disk_type == 'nvdimm': pkg_list.extend(['autoconf', 'pkg-config']) if distro.detect().name == 'SuSE': pkg_list.extend(['ndctl', 'libnuma-devel', 'libndctl-devel']) else: pkg_list.extend(['ndctl', 'daxctl', 'numactl-devel', 'ndctl-devel', 'daxctl-devel']) if raid_needed: pkg_list.append('mdadm') smm = SoftwareManager() for pkg in pkg_list: if pkg and not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Package %s is missing and could not be installed" % pkg) tarball = self.fetch_asset(url) archive.extract(tarball, self.teststmpdir) self.sourcedir = os.path.join(self.teststmpdir, "fio") fio_flags = "" self.ld_path = "" if self.disk_type == 'nvdimm': self.setup_pmem_disk(mnt_args) self.log.info("Building PMDK for NVDIMM fio engines") pmdk_url = self.params.get('pmdk_url', default='') tar = self.fetch_asset(pmdk_url, expire='7d') archive.extract(tar, self.teststmpdir) version = os.path.basename(tar.split('.tar.')[0]) pmdk_src = os.path.join(self.teststmpdir, version) build.make(pmdk_src) build.make(pmdk_src, extra_args='install prefix=%s' % self.teststmpdir) os.chdir(self.sourcedir) ext_flags = '`PKG_CONFIG_PATH=%s/lib/pkgconfig pkg-config --cflags\ --libs libpmem libpmemblk`' % self.teststmpdir self.ld_path = "LD_LIBRARY_PATH=%s/lib" % self.teststmpdir out = process.system_output('./configure --extra-cflags=' '"%s"' % ext_flags, shell=True) fio_flags = "LDFLAGS='%s'" % ext_flags for eng in ['PMDK libpmem', 'PMDK dev-dax', 'libnuma']: for line in out.decode().splitlines(): if line.startswith(eng) and 'no' in line: self.cancel("PMEM engines not built with fio") if not self.disk: self.disk = self.workdir self.dirs = self.disk if self.disk in disk.get_disks(): if raid_needed: raid_name = '/dev/md/mdsraid' self.create_raid(self.disk, raid_name) self.raid_create = True self.disk = raid_name if lv_needed: self.disk = self.create_lv(self.disk) self.lv_create = True self.dirs = self.disk if fstype: self.dirs = self.workdir self.create_fs(self.disk, self.dirs, fstype, fs_args, mnt_args) self.fs_create = True build.make(self.sourcedir, extra_args=fio_flags) @avocado.fail_on(pmem.PMemException) def setup_pmem_disk(self, mnt_args): if not self.disk: self.plib = pmem.PMem() regions = sorted(self.plib.run_ndctl_list( '-R'), key=lambda i: i['size'], reverse=True) if not regions: self.plib.enable_region() regions = sorted(self.plib.run_ndctl_list( '-R'), key=lambda i: i['size'], reverse=True) region = self.plib.run_ndctl_list_val(regions[0], 'dev') if self.plib.run_ndctl_list("-N -r %s" % region): self.plib.destroy_namespace(region=region, force=True) if 'dax' in mnt_args: self.plib.create_namespace(region=region) self.disk = "/dev/%s" % self.plib.run_ndctl_list_val( self.plib.run_ndctl_list('-N -r %s' % region)[0], 'blockdev') else: self.plib.create_namespace( region=region, mode='devdax') self.devdax_file = "/dev/%s" % self.plib.run_ndctl_list_val( self.plib.run_ndctl_list('-N -r %s' % region)[0], 'chardev') def create_raid(self, l_disk, l_raid_name): self.sraid = softwareraid.SoftwareRaid(l_raid_name, '0', l_disk.split(), '1.2') self.sraid.create() def delete_raid(self): self.sraid.stop() self.sraid.clear_superblock() def create_lv(self, l_disk): vgname = 'avocado_vg' lvname = 'avocado_lv' lv_size = lv_utils.get_device_total_space(l_disk) / 2330168 lv_utils.vg_create(vgname, l_disk) lv_utils.lv_create(vgname, lvname, lv_size) return '/dev/%s/%s' % (vgname, lvname) def delete_lv(self): vgname = 'avocado_vg' lvname = 'avocado_lv' lv_utils.lv_remove(vgname, lvname) lv_utils.vg_remove(vgname) def create_fs(self, l_disk, mountpoint, fstype, fs_args='', mnt_args=''): self.part_obj = Partition(l_disk, mountpoint=mountpoint) self.part_obj.unmount() self.part_obj.mkfs(fstype, args=fs_args) try: self.part_obj.mount(args=mnt_args) except PartitionError: self.fail("Mounting disk %s on directory %s failed" % (l_disk, mountpoint)) def delete_fs(self, l_disk): self.part_obj.unmount() delete_fs = "dd if=/dev/zero bs=512 count=512 of=%s" % l_disk if process.system(delete_fs, shell=True, ignore_status=True): self.fail("Failed to delete filesystem on %s" % l_disk) def test(self): """ Execute 'fio' with appropriate parameters. """ self.log.info("Test will run on %s", self.dirs) fio_job = self.params.get('fio_job', default='fio-simple.job') # if fs is present create a file on that fs, if no fs # self.dirs = path to disk, thus a filename is not needed if self.fs_create: filename = "%s/%s" % (self.dirs, self.fio_file) elif self.devdax_file: filename = self.devdax_file else: filename = self.dirs cmd = '%s %s/fio %s --filename=%s' % (self.ld_path, self.sourcedir, self.get_data(fio_job), filename) status = process.system(cmd, ignore_status=True, shell=True) if status: # status of 3 is a common warning with iscsi disks but fio # process completes successfully so throw a warning not # a fail. For other nonzero statuses we should fail. if status == 3: self.log.warning("Warnings during fio run") else: self.fail("fio run failed") def tearDown(self): ''' Cleanup of disk used to perform this test ''' if os.path.exists(self.fio_file): os.remove(self.fio_file) if self.fs_create: self.delete_fs(self.disk) if self.lv_create: self.delete_lv() if self.raid_create: self.delete_raid()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 199, 3, 1666, 5113, 367, 1655, 2436, 14, 199, 3, 199, 3, 1898, 26, 7800, 9572, 13002, 12, 3277, 14, 199, 3, 6529, 26, 437, 77, 25453, 10164, 72, 1017, 665, 65, 387, 72, 1017, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 21311, 641, 1233, 701, 820, 460, 89, 577, 324, 4762, 665, 6883, 324, 4762, 32, 13615, 79, 521, 14, 846, 30, 199, 3, 257, 4248, 8315, 820, 460, 89, 577, 324, 4762, 665, 6883, 324, 4762, 32, 13615, 79, 521, 14, 846, 30, 199, 3, 257, 4178, 921, 5031, 14, 957, 15, 2495, 396, 15, 2495, 396, 13, 1258, 13, 2219, 15, 2350, 15, 4133, 15, 329, 79, 199, 199, 624, 199, 1976, 47, 1379, 199, 624, 199, 199, 646, 747, 199, 646, 2289, 679, 5129, 199, 199, 504, 2289, 679, 5129, 492, 1379, 199, 504, 2289, 679, 5129, 14, 1208, 492, 6359, 199, 504, 2289, 679, 5129, 14, 1208, 492, 1900, 199, 504, 2289, 679, 5129, 14, 1208, 492, 299, 5286, 199, 504, 2289, 679, 5129, 14, 1208, 492, 4543, 199, 504, 2289, 679, 5129, 14, 1208, 492, 20604, 63, 1208, 199, 504, 2289, 679, 5129, 14, 1208, 492, 2112, 12, 20499, 199, 504, 2289, 679, 5129, 14, 1208, 492, 2032, 24204, 199, 504, 2289, 679, 5129, 14, 1208, 14, 5312, 492, 27353, 199, 504, 2289, 679, 5129, 14, 1208, 14, 15619, 63, 2609, 492, 2290, 2988, 199, 504, 2289, 679, 5129, 14, 1208, 14, 5312, 492, 27353, 547, 421, 199, 533, 481, 2308, 774, 8, 774, 304, 339, 408, 272, 289, 2308, 365, 376, 473, 15, 47, 4744, 18329, 370, 506, 1202, 3865, 367, 12338, 436, 272, 31692, 15, 16529, 14786, 14, 339, 520, 3239, 26, 1455, 921, 4624, 600, 14, 957, 15, 6776, 15, 329, 79, 339, 520, 635, 289, 2308, 63, 5369, 4982, 26, 536, 402, 314, 5330, 4982, 402, 289, 2308, 5241, 16180, 315, 10140, 931, 272, 520, 635, 289, 2308, 63, 2423, 26, 1101, 12669, 663, 402, 7934, 2295, 16180, 315, 10140, 931, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 6516, 283, 329, 79, 1370, 267, 408, 267, 849, 63, 633, 275, 298, 2859, 921, 29541, 14, 4989, 14, 6341, 15, 10002, 83, 15, 329, 79, 13, 3187, 13, 7410, 14, 5369, 14, 6838, 2, 267, 1166, 275, 291, 14, 1162, 14, 362, 360, 329, 79, 63, 3557, 63, 633, 297, 849, 29, 885, 63, 633, 9, 267, 291, 14, 4032, 275, 291, 14, 1162, 14, 362, 360, 4032, 297, 849, 29, 403, 9, 267, 291, 14, 4032, 63, 466, 275, 291, 14, 1162, 14, 362, 360, 4032, 63, 466, 297, 849, 13275, 267, 7449, 63, 589, 275, 291, 14, 1162, 14, 362, 360, 2319, 63, 589, 297, 849, 13275, 267, 333, 343, 63, 589, 275, 291, 14, 1162, 14, 362, 360, 20481, 63, 589, 297, 849, 13275, 267, 291, 14, 329, 79, 63, 493, 275, 283, 329, 79, 396, 13, 1569, 7, 398, 291, 14, 2319, 63, 981, 275, 756, 267, 291, 14, 6371, 63, 981, 275, 756, 267, 291, 14, 24204, 63, 981, 275, 756, 267, 291, 14, 2374, 983, 88, 63, 493, 275, 488, 398, 289, 20615, 275, 291, 14, 1162, 14, 362, 360, 2319, 297, 849, 13275, 267, 340, 289, 20615, 508, 283, 66, 454, 2319, 356, 288, 809, 275, 1109, 8, 18371, 14, 13552, 1252, 1023, 9, 288, 4668, 275, 1109, 8, 18371, 14, 13552, 1252, 3221, 9, 288, 340, 20499, 14, 13552, 1252, 354, 508, 283, 17157, 352, 356, 355, 340, 334, 422, 508, 1520, 436, 4668, 2356, 841, 9, 503, 809, 690, 1520, 26, 490, 291, 14, 6406, 480, 66, 454, 2319, 365, 440, 3748, 543, 971, 1816, 820, 24771, 1520, 14, 20, 641, 4751, 531, 398, 20604, 63, 11368, 275, 291, 14, 1162, 14, 362, 360, 6371, 297, 849, 29, 797, 9, 267, 660, 344, 63, 11368, 275, 291, 14, 1162, 14, 362, 360, 24204, 297, 849, 29, 797, 9, 398, 340, 20499, 14, 13552, 1252, 354, 315, 788, 53, 19313, 297, 283, 23204, 2565, 288, 5496, 63, 513, 275, 788, 773, 65, 2308, 13, 2374, 418, 288, 340, 289, 20615, 508, 283, 66, 454, 2319, 356, 355, 5496, 63, 513, 14, 740, 360, 66, 454, 2319, 13, 496, 458, 358, 267, 587, 26, 288, 5496, 63, 513, 275, 788, 773, 65, 2308, 297, 283, 773, 65, 2308, 13, 27870, 418, 288, 340, 291, 14, 4032, 63, 466, 508, 283, 15969, 328, 596, 356, 355, 5496, 63, 513, 14, 2880, 2941, 2495, 2190, 297, 283, 4600, 13, 888, 1105, 355, 340, 20499, 14, 13552, 1252, 354, 508, 283, 27032, 899, 356, 490, 5496, 63, 513, 14, 2880, 2941, 977, 8077, 297, 283, 773, 19498, 13, 27870, 297, 3660, 283, 773, 977, 8077, 13, 27870, 1105, 355, 587, 26, 490, 5496, 63, 513, 14, 2880, 2941, 977, 8077, 297, 283, 983, 88, 8077, 297, 283, 19498, 8077, 13, 27870, 297, 3660, 283, 977, 8077, 13, 27870, 297, 283, 983, 88, 8077, 13, 27870, 1105, 267, 340, 660, 344, 63, 11368, 26, 288, 5496, 63, 513, 14, 740, 360, 1064, 14464, 358, 398, 308, 596, 275, 2290, 2988, 342, 267, 367, 5496, 315, 5496, 63, 513, 26, 288, 340, 5496, 436, 440, 308, 596, 14, 1074, 63, 7657, 8, 4600, 9, 436, 440, 308, 596, 14, 3174, 8, 4600, 304, 355, 291, 14, 6406, 480, 8599, 450, 83, 365, 4124, 436, 4293, 440, 506, 4903, 2, 1169, 450, 5496, 9, 398, 17641, 275, 291, 14, 3535, 63, 6562, 8, 633, 9, 267, 6359, 14, 5005, 8, 18829 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 199, 3, 1666, 5113, 367, 1655, 2436, 14, 199, 3, 199, 3, 1898, 26, 7800, 9572, 13002, 12, 3277, 14, 199, 3, 6529, 26, 437, 77, 25453, 10164, 72, 1017, 665, 65, 387, 72, 1017, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 21311, 641, 1233, 701, 820, 460, 89, 577, 324, 4762, 665, 6883, 324, 4762, 32, 13615, 79, 521, 14, 846, 30, 199, 3, 257, 4248, 8315, 820, 460, 89, 577, 324, 4762, 665, 6883, 324, 4762, 32, 13615, 79, 521, 14, 846, 30, 199, 3, 257, 4178, 921, 5031, 14, 957, 15, 2495, 396, 15, 2495, 396, 13, 1258, 13, 2219, 15, 2350, 15, 4133, 15, 329, 79, 199, 199, 624, 199, 1976, 47, 1379, 199, 624, 199, 199, 646, 747, 199, 646, 2289, 679, 5129, 199, 199, 504, 2289, 679, 5129, 492, 1379, 199, 504, 2289, 679, 5129, 14, 1208, 492, 6359, 199, 504, 2289, 679, 5129, 14, 1208, 492, 1900, 199, 504, 2289, 679, 5129, 14, 1208, 492, 299, 5286, 199, 504, 2289, 679, 5129, 14, 1208, 492, 4543, 199, 504, 2289, 679, 5129, 14, 1208, 492, 20604, 63, 1208, 199, 504, 2289, 679, 5129, 14, 1208, 492, 2112, 12, 20499, 199, 504, 2289, 679, 5129, 14, 1208, 492, 2032, 24204, 199, 504, 2289, 679, 5129, 14, 1208, 14, 5312, 492, 27353, 199, 504, 2289, 679, 5129, 14, 1208, 14, 15619, 63, 2609, 492, 2290, 2988, 199, 504, 2289, 679, 5129, 14, 1208, 14, 5312, 492, 27353, 547, 421, 199, 533, 481, 2308, 774, 8, 774, 304, 339, 408, 272, 289, 2308, 365, 376, 473, 15, 47, 4744, 18329, 370, 506, 1202, 3865, 367, 12338, 436, 272, 31692, 15, 16529, 14786, 14, 339, 520, 3239, 26, 1455, 921, 4624, 600, 14, 957, 15, 6776, 15, 329, 79, 339, 520, 635, 289, 2308, 63, 5369, 4982, 26, 536, 402, 314, 5330, 4982, 402, 289, 2308, 5241, 16180, 315, 10140, 931, 272, 520, 635, 289, 2308, 63, 2423, 26, 1101, 12669, 663, 402, 7934, 2295, 16180, 315, 10140, 931, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 6516, 283, 329, 79, 1370, 267, 408, 267, 849, 63, 633, 275, 298, 2859, 921, 29541, 14, 4989, 14, 6341, 15, 10002, 83, 15, 329, 79, 13, 3187, 13, 7410, 14, 5369, 14, 6838, 2, 267, 1166, 275, 291, 14, 1162, 14, 362, 360, 329, 79, 63, 3557, 63, 633, 297, 849, 29, 885, 63, 633, 9, 267, 291, 14, 4032, 275, 291, 14, 1162, 14, 362, 360, 4032, 297, 849, 29, 403, 9, 267, 291, 14, 4032, 63, 466, 275, 291, 14, 1162, 14, 362, 360, 4032, 63, 466, 297, 849, 13275, 267, 7449, 63, 589, 275, 291, 14, 1162, 14, 362, 360, 2319, 63, 589, 297, 849, 13275, 267, 333, 343, 63, 589, 275, 291, 14, 1162, 14, 362, 360, 20481, 63, 589, 297, 849, 13275, 267, 291, 14, 329, 79, 63, 493, 275, 283, 329, 79, 396, 13, 1569, 7, 398, 291, 14, 2319, 63, 981, 275, 756, 267, 291, 14, 6371, 63, 981, 275, 756, 267, 291, 14, 24204, 63, 981, 275, 756, 267, 291, 14, 2374, 983, 88, 63, 493, 275, 488, 398, 289, 20615, 275, 291, 14, 1162, 14, 362, 360, 2319, 297, 849, 13275, 267, 340, 289, 20615, 508, 283, 66, 454, 2319, 356, 288, 809, 275, 1109, 8, 18371, 14, 13552, 1252, 1023, 9, 288, 4668, 275, 1109, 8, 18371, 14, 13552, 1252, 3221, 9, 288, 340, 20499, 14, 13552, 1252, 354, 508, 283, 17157, 352, 356, 355, 340, 334, 422, 508, 1520, 436, 4668, 2356, 841, 9, 503, 809, 690, 1520, 26, 490, 291, 14, 6406, 480, 66, 454, 2319, 365, 440, 3748, 543, 971, 1816, 820, 24771, 1520, 14, 20, 641, 4751, 531, 398, 20604, 63, 11368, 275, 291, 14, 1162, 14, 362, 360, 6371, 297, 849, 29, 797, 9, 267, 660, 344, 63, 11368, 275, 291, 14, 1162, 14, 362, 360, 24204, 297, 849, 29, 797, 9, 398, 340, 20499, 14, 13552, 1252, 354, 315, 788, 53, 19313, 297, 283, 23204, 2565, 288, 5496, 63, 513, 275, 788, 773, 65, 2308, 13, 2374, 418, 288, 340, 289, 20615, 508, 283, 66, 454, 2319, 356, 355, 5496, 63, 513, 14, 740, 360, 66, 454, 2319, 13, 496, 458, 358, 267, 587, 26, 288, 5496, 63, 513, 275, 788, 773, 65, 2308, 297, 283, 773, 65, 2308, 13, 27870, 418, 288, 340, 291, 14, 4032, 63, 466, 508, 283, 15969, 328, 596, 356, 355, 5496, 63, 513, 14, 2880, 2941, 2495, 2190, 297, 283, 4600, 13, 888, 1105, 355, 340, 20499, 14, 13552, 1252, 354, 508, 283, 27032, 899, 356, 490, 5496, 63, 513, 14, 2880, 2941, 977, 8077, 297, 283, 773, 19498, 13, 27870, 297, 3660, 283, 773, 977, 8077, 13, 27870, 1105, 355, 587, 26, 490, 5496, 63, 513, 14, 2880, 2941, 977, 8077, 297, 283, 983, 88, 8077, 297, 283, 19498, 8077, 13, 27870, 297, 3660, 283, 977, 8077, 13, 27870, 297, 283, 983, 88, 8077, 13, 27870, 1105, 267, 340, 660, 344, 63, 11368, 26, 288, 5496, 63, 513, 14, 740, 360, 1064, 14464, 358, 398, 308, 596, 275, 2290, 2988, 342, 267, 367, 5496, 315, 5496, 63, 513, 26, 288, 340, 5496, 436, 440, 308, 596, 14, 1074, 63, 7657, 8, 4600, 9, 436, 440, 308, 596, 14, 3174, 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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 ]
pierreg/tensorflow
tensorflow/contrib/specs/python/specs.py
63
4927
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Builder for TensorFlow models specified using specs_ops. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import inspect from six import exec_ from tensorflow.contrib.specs.python import params_ops from tensorflow.contrib.specs.python import specs_lib from tensorflow.contrib.specs.python import specs_ops def eval_params(params, environment=None): """Evaluates a parameter specification and returns the environment. Args: params: parameter assignments as a string environment: a dictionary of input bindings Returns: Environment with additional bindings created by executing `params` Raises: Exception: other exceptions raised during execution of `params` """ specs_lib.check_keywords(params) bindings = {} if environment: bindings.update(environment) exec_(params, vars(params_ops), bindings) # pylint: disable=exec-used return bindings def eval_spec(spec, environment=None): """Evaluates a spec and returns the environment. This function allows you to use a spec to obtain multiple bindings in an environment. That is useful if you use the spec language to specify multiple components of a larger network, for example: "left = Cr(64, [5,5]); right = Fc(64)" Usually, you will want to use `create_net` or `create_net_fun` below. Args: spec: specification as a string environment: a dictionary of input bindings Returns: Environment with additional bindings created by spec. Raises: Exception: other exceptions raised during execution of `spec` """ specs_lib.check_keywords(spec) bindings = {} if environment: bindings.update(environment) exec_(spec, vars(specs_ops), bindings) # pylint: disable=exec-used return bindings def create_net_fun(spec, environment=None): """Evaluates a spec and returns the binding of `net`. Specs are written in a DSL based on function composition. A spec like `net = Cr(64, [3, 3])` assigns an object that represents a single argument function capable of creating a network to the variable `net`. Args: spec: specification as a string, ending with a `net = ...` statement environment: a dictionary of input bindings Returns: A callable that instantiates the `net` binding. Raises: ValueError: spec failed to create a `net` Exception: other exceptions raised during execution of `spec` """ bindings = eval_spec(spec, environment) net = bindings.get("net", None) if net is None: raise ValueError("spec failed to create 'net': %s" % (spec,)) return net.funcall def create_net(spec, inputs, environment=None): """Evaluates a spec and creates a network instance given the inputs. Args: spec: specification as a string, ending with a `net = ...` statement inputs: input that `net` is applied to environment: a dictionary of input bindings Returns: A callable that instantiates the `net` binding. Raises: ValueError: spec failed to create a `net` Exception: other exceptions raised during execution of `spec` """ return create_net_fun(spec, environment)(inputs) class LocalImport(object): """A class that allows us to temporarily import something. Attributes: frame: the frame in which the context manager was invocked names: a dictionary containing the new bindings old: variable bindings that have been shadowed by the import """ def __init__(self, names): """Create a context manager that binds the names in values. Args: names: A dictionary or module containing the bindings. """ if not isinstance(names, dict): names = vars(names) self.names = names def __enter__(self): self.frame = inspect.currentframe() bindings = self.frame.f_back.f_globals self.old = {k: bindings.get(k, None) for k in self.names.keys()} bindings.update(self.names) def __exit__(self, some_type, value, traceback): del some_type, value, traceback bindings = self.frame.f_back.f_globals bindings.update(self.old) for k, v in self.old.items(): if v is None: del bindings[k] del self.frame ops = LocalImport(specs_ops)
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 6437, 367, 9134, 1709, 2013, 1808, 15941, 63, 1483, 14, 199, 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, 421, 199, 646, 6485, 199, 199, 504, 3816, 492, 2146, 63, 199, 504, 3228, 14, 2828, 14, 7273, 14, 1548, 492, 1862, 63, 1483, 199, 504, 3228, 14, 2828, 14, 7273, 14, 1548, 492, 15941, 63, 773, 199, 504, 3228, 14, 2828, 14, 7273, 14, 1548, 492, 15941, 63, 1483, 421, 199, 318, 3468, 63, 1162, 8, 1162, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 2725, 8929, 436, 2529, 314, 3734, 14, 819, 3033, 26, 489, 1862, 26, 2725, 18121, 465, 282, 1059, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 9711, 543, 4722, 17792, 2737, 701, 489, 14043, 658, 1162, 64, 819, 6218, 26, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1162, 64, 523, 408, 523, 15941, 63, 773, 14, 1074, 63, 7511, 8, 1162, 9, 523, 17792, 275, 1052, 523, 340, 3734, 26, 17792, 14, 873, 8, 5418, 9, 523, 2146, 2531, 1162, 12, 6802, 8, 1162, 63, 1483, 395, 17792, 9, 221, 327, 4287, 26, 3507, 29, 1628, 13, 2972, 523, 372, 17792, 421, 199, 318, 3468, 63, 1650, 8, 1650, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 3158, 436, 2529, 314, 3734, 14, 819, 961, 805, 6127, 1265, 370, 675, 282, 3158, 370, 3332, 3663, 17792, 523, 315, 376, 3734, 14, 10314, 365, 2997, 340, 1265, 675, 314, 3158, 2637, 370, 523, 4165, 3663, 7323, 402, 282, 12142, 2784, 12, 367, 2893, 26, 298, 3039, 523, 275, 30277, 8, 772, 12, 359, 21, 12, 21, 21153, 2451, 275, 481, 67, 8, 772, 2924, 24612, 12, 1265, 911, 2934, 370, 675, 523, 658, 981, 63, 846, 64, 503, 658, 981, 63, 846, 63, 7036, 64, 5084, 14, 819, 3033, 26, 489, 3158, 26, 8929, 465, 282, 1059, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 9711, 543, 4722, 17792, 2737, 701, 3158, 14, 819, 6218, 26, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1650, 64, 819, 408, 523, 15941, 63, 773, 14, 1074, 63, 7511, 8, 1650, 9, 523, 17792, 275, 1052, 523, 340, 3734, 26, 17792, 14, 873, 8, 5418, 9, 523, 2146, 2531, 1650, 12, 6802, 8, 7273, 63, 1483, 395, 17792, 9, 221, 327, 4287, 26, 3507, 29, 1628, 13, 2972, 523, 372, 17792, 421, 199, 318, 1218, 63, 846, 63, 7036, 8, 1650, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 3158, 436, 2529, 314, 11696, 402, 658, 846, 2313, 819, 31511, 83, 787, 5313, 315, 282, 577, 4929, 4079, 641, 805, 31586, 14, 221, 437, 3158, 523, 2839, 658, 846, 275, 30277, 8, 772, 12, 359, 19, 12, 650, 566, 64, 465, 20440, 376, 909, 626, 8469, 282, 523, 2849, 1423, 805, 4021, 461, 402, 6425, 282, 2784, 370, 523, 314, 1750, 658, 846, 2313, 819, 3033, 26, 489, 3158, 26, 8929, 465, 282, 1059, 12, 13401, 543, 282, 658, 846, 275, 2263, 64, 5164, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 437, 4550, 626, 9034, 2335, 314, 658, 846, 64, 11696, 14, 819, 6218, 26, 489, 1722, 26, 3158, 3405, 370, 1218, 282, 658, 846, 64, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1650, 64, 819, 408, 523, 17792, 275, 3468, 63, 1650, 8, 1650, 12, 3734, 9, 523, 1851, 275, 17792, 14, 362, 480, 846, 401, 488, 9, 523, 340, 1851, 365, 488, 26, 272, 746, 1722, 480, 1650, 3405, 370, 1218, 283, 846, 356, 450, 83, 2, 450, 334, 1650, 4641, 523, 372, 1851, 14, 1532, 452, 421, 199, 318, 1218, 63, 846, 8, 1650, 12, 4153, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 3158, 436, 8491, 282, 2784, 1256, 1627, 314, 4153, 14, 819, 3033, 26, 489, 3158, 26, 8929, 465, 282, 1059, 12, 13401, 543, 282, 658, 846, 275, 2263, 64, 5164, 489, 4153, 26, 1324, 626, 658, 846, 64, 365, 6781, 370, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 437, 4550, 626, 9034, 2335, 314, 658, 846, 64, 11696, 14, 819, 6218, 26, 489, 1722, 26, 3158, 3405, 370, 1218, 282, 658, 846, 64, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1650, 64, 523, 408, 523, 372, 1218, 63, 846, 63, 7036, 8, 1650, 12, 3734, 5130, 3711, 9, 421, 199, 533, 10111, 6295, 8, 785, 304, 523, 408, 33, 1021, 626, 6127, 2739, 370, 22256, 492, 6020, 14, 819, 9382, 26, 489, 2787, 26, 314, 2787, 315, 1314, 314, 1067, 5256, 1990, 4572, 766, 379, 489, 1561, 26, 282, 2600, 3035, 314, 892, 17792, 489, 2269, 26, 1750, 17792, 626, 1172, 2757, 15084, 379, 701, 314, 492, 523, 408, 819, 347, 636, 826, 721, 277, 12, 1561, 304, 272, 408, 2499, 282, 1067, 5256, 626, 5398, 83, 314, 1561, 315, 1338, 14, 339, 3033, 26, 267, 1561, 26, 437, 2600, 503, 859, 3035, 314, 17792, 14, 272, 408, 272, 340, 440, 1228, 8, 1247, 12, 1211, 304, 489, 1561, 275, 6802, 8, 1247, 9, 272, 291, 14, 1247, 275, 1561 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 6437, 367, 9134, 1709, 2013, 1808, 15941, 63, 1483, 14, 199, 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, 421, 199, 646, 6485, 199, 199, 504, 3816, 492, 2146, 63, 199, 504, 3228, 14, 2828, 14, 7273, 14, 1548, 492, 1862, 63, 1483, 199, 504, 3228, 14, 2828, 14, 7273, 14, 1548, 492, 15941, 63, 773, 199, 504, 3228, 14, 2828, 14, 7273, 14, 1548, 492, 15941, 63, 1483, 421, 199, 318, 3468, 63, 1162, 8, 1162, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 2725, 8929, 436, 2529, 314, 3734, 14, 819, 3033, 26, 489, 1862, 26, 2725, 18121, 465, 282, 1059, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 9711, 543, 4722, 17792, 2737, 701, 489, 14043, 658, 1162, 64, 819, 6218, 26, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1162, 64, 523, 408, 523, 15941, 63, 773, 14, 1074, 63, 7511, 8, 1162, 9, 523, 17792, 275, 1052, 523, 340, 3734, 26, 17792, 14, 873, 8, 5418, 9, 523, 2146, 2531, 1162, 12, 6802, 8, 1162, 63, 1483, 395, 17792, 9, 221, 327, 4287, 26, 3507, 29, 1628, 13, 2972, 523, 372, 17792, 421, 199, 318, 3468, 63, 1650, 8, 1650, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 3158, 436, 2529, 314, 3734, 14, 819, 961, 805, 6127, 1265, 370, 675, 282, 3158, 370, 3332, 3663, 17792, 523, 315, 376, 3734, 14, 10314, 365, 2997, 340, 1265, 675, 314, 3158, 2637, 370, 523, 4165, 3663, 7323, 402, 282, 12142, 2784, 12, 367, 2893, 26, 298, 3039, 523, 275, 30277, 8, 772, 12, 359, 21, 12, 21, 21153, 2451, 275, 481, 67, 8, 772, 2924, 24612, 12, 1265, 911, 2934, 370, 675, 523, 658, 981, 63, 846, 64, 503, 658, 981, 63, 846, 63, 7036, 64, 5084, 14, 819, 3033, 26, 489, 3158, 26, 8929, 465, 282, 1059, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 9711, 543, 4722, 17792, 2737, 701, 3158, 14, 819, 6218, 26, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1650, 64, 819, 408, 523, 15941, 63, 773, 14, 1074, 63, 7511, 8, 1650, 9, 523, 17792, 275, 1052, 523, 340, 3734, 26, 17792, 14, 873, 8, 5418, 9, 523, 2146, 2531, 1650, 12, 6802, 8, 7273, 63, 1483, 395, 17792, 9, 221, 327, 4287, 26, 3507, 29, 1628, 13, 2972, 523, 372, 17792, 421, 199, 318, 1218, 63, 846, 63, 7036, 8, 1650, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 3158, 436, 2529, 314, 11696, 402, 658, 846, 2313, 819, 31511, 83, 787, 5313, 315, 282, 577, 4929, 4079, 641, 805, 31586, 14, 221, 437, 3158, 523, 2839, 658, 846, 275, 30277, 8, 772, 12, 359, 19, 12, 650, 566, 64, 465, 20440, 376, 909, 626, 8469, 282, 523, 2849, 1423, 805, 4021, 461, 402, 6425, 282, 2784, 370, 523, 314, 1750, 658, 846, 2313, 819, 3033, 26, 489, 3158, 26, 8929, 465, 282, 1059, 12, 13401, 543, 282, 658, 846, 275, 2263, 64, 5164, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 437, 4550, 626, 9034, 2335, 314, 658, 846, 64, 11696, 14, 819, 6218, 26, 489, 1722, 26, 3158, 3405, 370, 1218, 282, 658, 846, 64, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1650, 64, 819, 408, 523, 17792, 275, 3468, 63, 1650, 8, 1650, 12, 3734, 9, 523, 1851, 275, 17792, 14, 362, 480, 846, 401, 488, 9, 523, 340, 1851, 365, 488, 26, 272, 746, 1722, 480, 1650, 3405, 370, 1218, 283, 846, 356, 450, 83, 2, 450, 334, 1650, 4641, 523, 372, 1851, 14, 1532, 452, 421, 199, 318, 1218, 63, 846, 8, 1650, 12, 4153, 12, 3734, 29, 403, 304, 523, 408, 10006, 85, 2335, 282, 3158, 436, 8491, 282, 2784, 1256, 1627, 314, 4153, 14, 819, 3033, 26, 489, 3158, 26, 8929, 465, 282, 1059, 12, 13401, 543, 282, 658, 846, 275, 2263, 64, 5164, 489, 4153, 26, 1324, 626, 658, 846, 64, 365, 6781, 370, 489, 3734, 26, 282, 2600, 402, 1324, 17792, 819, 1803, 26, 489, 437, 4550, 626, 9034, 2335, 314, 658, 846, 64, 11696, 14, 819, 6218, 26, 489, 1722, 26, 3158, 3405, 370, 1218, 282, 658, 846, 64, 489, 2186, 26, 1163, 4967, 4915, 5309, 6451, 402, 658, 1650, 64, 523, 408, 523, 372, 1218, 63, 846, 63, 7036, 8, 1650, 12, 3734, 5130, 3711, 9, 421, 199, 533, 10111, 6295, 8, 785, 304, 523, 408, 33, 1021, 626, 6127, 2739, 370, 22256, 492, 6020, 14, 819, 9382, 26, 489, 2787, 26, 314, 2787, 315, 1314, 314, 1067, 5256, 1990, 4572, 766, 379, 489, 1561, 26, 282, 2600, 3035, 314, 892, 17792, 489, 2269, 26, 1750, 17792, 626, 1172, 2757, 15084, 379, 701, 314, 492, 523, 408, 819, 347, 636, 826, 721, 277, 12, 1561, 304, 272, 408, 2499, 282, 1067, 5256, 626, 5398, 83, 314, 1561, 315, 1338, 14, 339, 3033, 26, 267, 1561, 26, 437, 2600, 503, 859, 3035, 314, 17792, 14, 272, 408, 272, 340, 440, 1228, 8, 1247, 12, 1211, 304, 489, 1561, 275, 6802, 8, 1247, 9, 272, 291, 14, 1247, 275, 1561, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thnee/ansible
test/units/modules/network/nxos/test_nxos_bgp_neighbor_af.py
68
4912
# (c) 2016 Red Hat Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from units.compat.mock import patch from ansible.modules.network.nxos import nxos_bgp_neighbor_af from .nxos_module import TestNxosModule, load_fixture, set_module_args class TestNxosBgpNeighborAfModule(TestNxosModule): module = nxos_bgp_neighbor_af def setUp(self): super(TestNxosBgpNeighborAfModule, self).setUp() self.mock_load_config = patch('ansible.modules.network.nxos.nxos_bgp_neighbor_af.load_config') self.load_config = self.mock_load_config.start() self.mock_get_config = patch('ansible.modules.network.nxos.nxos_bgp_neighbor_af.get_config') self.get_config = self.mock_get_config.start() def tearDown(self): super(TestNxosBgpNeighborAfModule, self).tearDown() self.mock_load_config.stop() self.mock_get_config.stop() def load_fixtures(self, commands=None, device=''): self.get_config.return_value = load_fixture('nxos_bgp', 'config.cfg') self.load_config.return_value = [] def test_nxos_bgp_neighbor_af(self): set_module_args(dict(asn=65535, neighbor='192.0.2.3', afi='ipv4', safi='unicast', route_reflector_client=True)) result = self.execute_module(changed=True) self.assertEqual(result['commands'], [ 'router bgp 65535', 'neighbor 192.0.2.3', 'address-family ipv4 unicast', 'route-reflector-client' ]) def test_nxos_bgp_neighbor_af_exists(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast')) self.execute_module(changed=False, commands=[]) def test_nxos_bgp_neighbor_af_absent(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', state='absent')) self.execute_module( changed=True, sort=False, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'no address-family ipv4 unicast'] ) def test_nxos_bgp_neighbor_af_advertise_map(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', advertise_map_exist=['my_advertise_map', 'my_exist_map'])) self.execute_module( changed=True, sort=False, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'address-family ipv4 unicast', 'advertise-map my_advertise_map exist-map my_exist_map'] ) def test_nxos_bgp_neighbor_af_advertise_map_non_exist(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', advertise_map_non_exist=['my_advertise_map', 'my_non_exist_map'])) self.execute_module( changed=True, sort=False, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'address-family ipv4 unicast', 'advertise-map my_advertise_map non-exist-map my_non_exist_map'] ) def test_nxos_bgp_neighbor_af_max_prefix_limit_default(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', max_prefix_limit='default')) self.execute_module( changed=True, sort=False, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'address-family ipv4 unicast', 'no maximum-prefix'] ) def test_nxos_bgp_neighbor_af_max_prefix(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', max_prefix_threshold=20, max_prefix_limit=20)) self.execute_module( changed=True, sort=False, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'address-family ipv4 unicast', 'maximum-prefix 20 20'] ) def test_nxos_bgp_neighbor_af_disable_peer_as_check(self): set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', disable_peer_as_check=True)) self.execute_module( changed=True, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'address-family ipv4 unicast', 'disable-peer-as-check'] )
gpl-3.0
[ 3, 334, 67, 9, 7800, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 17982, 492, 22072, 63, 10132, 63, 13881, 63, 2756, 199, 504, 1275, 17982, 63, 578, 492, 1379, 46, 22101, 2377, 12, 2248, 63, 5997, 12, 663, 63, 578, 63, 589, 421, 199, 533, 1379, 46, 22101, 34, 4927, 13779, 14799, 2377, 8, 774, 46, 22101, 2377, 304, 339, 859, 275, 22072, 63, 10132, 63, 13881, 63, 2756, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 34, 4927, 13779, 14799, 2377, 12, 291, 680, 5996, 342, 398, 291, 14, 1805, 63, 912, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 10132, 63, 13881, 63, 2756, 14, 912, 63, 888, 358, 267, 291, 14, 912, 63, 888, 275, 291, 14, 1805, 63, 912, 63, 888, 14, 928, 342, 398, 291, 14, 1805, 63, 362, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 10132, 63, 13881, 63, 2756, 14, 362, 63, 888, 358, 267, 291, 14, 362, 63, 888, 275, 291, 14, 1805, 63, 362, 63, 888, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 34, 4927, 13779, 14799, 2377, 12, 291, 680, 12336, 342, 267, 291, 14, 1805, 63, 912, 63, 888, 14, 2379, 342, 267, 291, 14, 1805, 63, 362, 63, 888, 14, 2379, 342, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 2243, 9280, 267, 291, 14, 362, 63, 888, 14, 1107, 63, 585, 275, 2248, 63, 5997, 360, 17982, 63, 10132, 297, 283, 888, 14, 4128, 358, 267, 291, 14, 912, 63, 888, 14, 1107, 63, 585, 275, 942, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 5756, 14, 16, 14, 18, 14, 19, 297, 282, 329, 534, 4774, 20, 297, 2490, 2937, 329, 534, 5209, 1810, 297, 7475, 63, 1121, 3283, 63, 1258, 29, 549, 430, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 359, 288, 283, 4995, 16884, 18247, 297, 283, 13881, 13567, 14, 16, 14, 18, 14, 19, 297, 283, 1562, 13, 6606, 3278, 20, 625, 530, 1810, 297, 288, 283, 4449, 13, 1121, 3283, 13, 1258, 7, 267, 4794, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 2444, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 12, 3718, 14285, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 5575, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 297, 1174, 534, 5575, 1333, 267, 291, 14, 2526, 63, 578, 8, 288, 2896, 29, 549, 12, 4069, 29, 797, 12, 288, 3718, 2968, 4995, 16884, 18247, 297, 283, 13881, 650, 14, 19, 14, 19, 14, 21, 297, 283, 889, 2287, 13, 6606, 3278, 20, 625, 530, 1810, 418, 267, 776, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 24576, 261, 63, 1130, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 297, 2490, 19613, 261, 63, 1130, 63, 4494, 2968, 1662, 63, 24576, 261, 63, 1130, 297, 283, 1662, 63, 4494, 63, 1130, 5156, 267, 291, 14, 2526, 63, 578, 8, 288, 2896, 29, 549, 12, 4069, 29, 797, 12, 288, 3718, 2968, 4995, 16884, 18247, 297, 283, 13881, 650, 14, 19, 14, 19, 14, 21, 297, 283, 1562, 13, 6606, 3278, 20, 625, 530, 1810, 297, 283, 24576, 261, 13, 1130, 3002, 63, 24576, 261, 63, 1130, 2187, 13, 1130, 3002, 63, 4494, 63, 1130, 418, 267, 776, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 24576, 261, 63, 1130, 63, 2865, 63, 4494, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 297, 2490, 19613, 261, 63, 1130, 63, 2865, 63, 4494, 2968, 1662, 63, 24576, 261, 63, 1130, 297, 283, 1662, 63, 2865, 63, 4494, 63, 1130, 5156, 267, 291, 14, 2526, 63, 578, 8, 288, 2896, 29, 549, 12, 4069, 29, 797, 12, 288, 3718, 2968, 4995, 16884, 18247, 297, 283, 13881, 650, 14, 19 ]
[ 334, 67, 9, 7800, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 17982, 492, 22072, 63, 10132, 63, 13881, 63, 2756, 199, 504, 1275, 17982, 63, 578, 492, 1379, 46, 22101, 2377, 12, 2248, 63, 5997, 12, 663, 63, 578, 63, 589, 421, 199, 533, 1379, 46, 22101, 34, 4927, 13779, 14799, 2377, 8, 774, 46, 22101, 2377, 304, 339, 859, 275, 22072, 63, 10132, 63, 13881, 63, 2756, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 34, 4927, 13779, 14799, 2377, 12, 291, 680, 5996, 342, 398, 291, 14, 1805, 63, 912, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 10132, 63, 13881, 63, 2756, 14, 912, 63, 888, 358, 267, 291, 14, 912, 63, 888, 275, 291, 14, 1805, 63, 912, 63, 888, 14, 928, 342, 398, 291, 14, 1805, 63, 362, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 10132, 63, 13881, 63, 2756, 14, 362, 63, 888, 358, 267, 291, 14, 362, 63, 888, 275, 291, 14, 1805, 63, 362, 63, 888, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 34, 4927, 13779, 14799, 2377, 12, 291, 680, 12336, 342, 267, 291, 14, 1805, 63, 912, 63, 888, 14, 2379, 342, 267, 291, 14, 1805, 63, 362, 63, 888, 14, 2379, 342, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 2243, 9280, 267, 291, 14, 362, 63, 888, 14, 1107, 63, 585, 275, 2248, 63, 5997, 360, 17982, 63, 10132, 297, 283, 888, 14, 4128, 358, 267, 291, 14, 912, 63, 888, 14, 1107, 63, 585, 275, 942, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 5756, 14, 16, 14, 18, 14, 19, 297, 282, 329, 534, 4774, 20, 297, 2490, 2937, 329, 534, 5209, 1810, 297, 7475, 63, 1121, 3283, 63, 1258, 29, 549, 430, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 359, 288, 283, 4995, 16884, 18247, 297, 283, 13881, 13567, 14, 16, 14, 18, 14, 19, 297, 283, 1562, 13, 6606, 3278, 20, 625, 530, 1810, 297, 288, 283, 4449, 13, 1121, 3283, 13, 1258, 7, 267, 4794, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 2444, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 12, 3718, 14285, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 5575, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 297, 1174, 534, 5575, 1333, 267, 291, 14, 2526, 63, 578, 8, 288, 2896, 29, 549, 12, 4069, 29, 797, 12, 288, 3718, 2968, 4995, 16884, 18247, 297, 283, 13881, 650, 14, 19, 14, 19, 14, 21, 297, 283, 889, 2287, 13, 6606, 3278, 20, 625, 530, 1810, 418, 267, 776, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 24576, 261, 63, 1130, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 297, 2490, 19613, 261, 63, 1130, 63, 4494, 2968, 1662, 63, 24576, 261, 63, 1130, 297, 283, 1662, 63, 4494, 63, 1130, 5156, 267, 291, 14, 2526, 63, 578, 8, 288, 2896, 29, 549, 12, 4069, 29, 797, 12, 288, 3718, 2968, 4995, 16884, 18247, 297, 283, 13881, 650, 14, 19, 14, 19, 14, 21, 297, 283, 1562, 13, 6606, 3278, 20, 625, 530, 1810, 297, 283, 24576, 261, 13, 1130, 3002, 63, 24576, 261, 63, 1130, 2187, 13, 1130, 3002, 63, 4494, 63, 1130, 418, 267, 776, 339, 347, 511, 63, 17982, 63, 10132, 63, 13881, 63, 2756, 63, 24576, 261, 63, 1130, 63, 2865, 63, 4494, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 6228, 29, 26439, 12, 15503, 534, 19, 14, 19, 14, 19, 14, 21, 297, 282, 329, 534, 4774, 20, 297, 2937, 329, 534, 5209, 1810, 297, 2490, 19613, 261, 63, 1130, 63, 2865, 63, 4494, 2968, 1662, 63, 24576, 261, 63, 1130, 297, 283, 1662, 63, 2865, 63, 4494, 63, 1130, 5156, 267, 291, 14, 2526, 63, 578, 8, 288, 2896, 29, 549, 12, 4069, 29, 797, 12, 288, 3718, 2968, 4995, 16884, 18247, 297,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 1, 1, 1, 1, 1, 1, 1, 1 ]
FeatherCoin/Feathercoin
contrib/devtools/security-check.py
22
8242
#!/usr/bin/env python3 # Copyright (c) 2015-2018 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' Perform basic ELF security checks on a series of executables. Exit status will be 0 if successful, and the program will be silent. Otherwise the exit status will be 1 and it will log which executables failed which checks. Needs `readelf` (for ELF) and `objdump` (for PE). ''' import subprocess import sys import os READELF_CMD = os.getenv('READELF', '/usr/bin/readelf') OBJDUMP_CMD = os.getenv('OBJDUMP', '/usr/bin/objdump') NONFATAL = {} # checks which are non-fatal for now but only generate a warning def check_ELF_PIE(executable): ''' Check for position independent executable (PIE), allowing for address space randomization. ''' p = subprocess.Popen([READELF_CMD, '-h', '-W', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode: raise IOError('Error opening file') ok = False for line in stdout.splitlines(): line = line.split() if len(line)>=2 and line[0] == 'Type:' and line[1] == 'DYN': ok = True return ok def get_ELF_program_headers(executable): '''Return type and flags for ELF program headers''' p = subprocess.Popen([READELF_CMD, '-l', '-W', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode: raise IOError('Error opening file') in_headers = False count = 0 headers = [] for line in stdout.splitlines(): if line.startswith('Program Headers:'): in_headers = True if line == '': in_headers = False if in_headers: if count == 1: # header line ofs_typ = line.find('Type') ofs_offset = line.find('Offset') ofs_flags = line.find('Flg') ofs_align = line.find('Align') if ofs_typ == -1 or ofs_offset == -1 or ofs_flags == -1 or ofs_align == -1: raise ValueError('Cannot parse elfread -lW output') elif count > 1: typ = line[ofs_typ:ofs_offset].rstrip() flags = line[ofs_flags:ofs_align].rstrip() headers.append((typ, flags)) count += 1 return headers def check_ELF_NX(executable): ''' Check that no sections are writable and executable (including the stack) ''' have_wx = False have_gnu_stack = False for (typ, flags) in get_ELF_program_headers(executable): if typ == 'GNU_STACK': have_gnu_stack = True if 'W' in flags and 'E' in flags: # section is both writable and executable have_wx = True return have_gnu_stack and not have_wx def check_ELF_RELRO(executable): ''' Check for read-only relocations. GNU_RELRO program header must exist Dynamic section must have BIND_NOW flag ''' have_gnu_relro = False for (typ, flags) in get_ELF_program_headers(executable): # Note: not checking flags == 'R': here as linkers set the permission differently # This does not affect security: the permission flags of the GNU_RELRO program header are ignored, the PT_LOAD header determines the effective permissions. # However, the dynamic linker need to write to this area so these are RW. # Glibc itself takes care of mprotecting this area R after relocations are finished. # See also https://marc.info/?l=binutils&m=1498883354122353 if typ == 'GNU_RELRO': have_gnu_relro = True have_bindnow = False p = subprocess.Popen([READELF_CMD, '-d', '-W', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode: raise IOError('Error opening file') for line in stdout.splitlines(): tokens = line.split() if len(tokens)>1 and tokens[1] == '(BIND_NOW)' or (len(tokens)>2 and tokens[1] == '(FLAGS)' and 'BIND_NOW' in tokens[2:]): have_bindnow = True return have_gnu_relro and have_bindnow def check_ELF_Canary(executable): ''' Check for use of stack canary ''' p = subprocess.Popen([READELF_CMD, '--dyn-syms', '-W', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode: raise IOError('Error opening file') ok = False for line in stdout.splitlines(): if '__stack_chk_fail' in line: ok = True return ok def get_PE_dll_characteristics(executable): ''' Get PE DllCharacteristics bits. Returns a tuple (arch,bits) where arch is 'i386:x86-64' or 'i386' and bits is the DllCharacteristics value. ''' p = subprocess.Popen([OBJDUMP_CMD, '-x', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode: raise IOError('Error opening file') arch = '' bits = 0 for line in stdout.splitlines(): tokens = line.split() if len(tokens)>=2 and tokens[0] == 'architecture:': arch = tokens[1].rstrip(',') if len(tokens)>=2 and tokens[0] == 'DllCharacteristics': bits = int(tokens[1],16) return (arch,bits) IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020 IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040 IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100 def check_PE_DYNAMIC_BASE(executable): '''PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR)''' (arch,bits) = get_PE_dll_characteristics(executable) reqbits = IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE return (bits & reqbits) == reqbits # On 64 bit, must support high-entropy 64-bit address space layout randomization in addition to DYNAMIC_BASE # to have secure ASLR. def check_PE_HIGH_ENTROPY_VA(executable): '''PIE: DllCharacteristics bit 0x20 signifies high-entropy ASLR''' (arch,bits) = get_PE_dll_characteristics(executable) if arch == 'i386:x86-64': reqbits = IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA else: # Unnecessary on 32-bit assert(arch == 'i386') reqbits = 0 return (bits & reqbits) == reqbits def check_PE_NX(executable): '''NX: DllCharacteristics bit 0x100 signifies nxcompat (DEP)''' (arch,bits) = get_PE_dll_characteristics(executable) return (bits & IMAGE_DLL_CHARACTERISTICS_NX_COMPAT) == IMAGE_DLL_CHARACTERISTICS_NX_COMPAT CHECKS = { 'ELF': [ ('PIE', check_ELF_PIE), ('NX', check_ELF_NX), ('RELRO', check_ELF_RELRO), ('Canary', check_ELF_Canary) ], 'PE': [ ('DYNAMIC_BASE', check_PE_DYNAMIC_BASE), ('HIGH_ENTROPY_VA', check_PE_HIGH_ENTROPY_VA), ('NX', check_PE_NX) ] } def identify_executable(executable): with open(filename, 'rb') as f: magic = f.read(4) if magic.startswith(b'MZ'): return 'PE' elif magic.startswith(b'\x7fELF'): return 'ELF' return None if __name__ == '__main__': retval = 0 for filename in sys.argv[1:]: try: etype = identify_executable(filename) if etype is None: print('%s: unknown format' % filename) retval = 1 continue failed = [] warning = [] for (name, func) in CHECKS[etype]: if not func(filename): if name in NONFATAL: warning.append(name) else: failed.append(name) if failed: print('%s: failed %s' % (filename, ' '.join(failed))) retval = 1 if warning: print('%s: warning %s' % (filename, ' '.join(warning))) except IOError: print('%s: cannot open' % filename) retval = 1 sys.exit(retval)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 6900, 13, 12682, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 2344, 199, 20906, 5678, 662, 15965, 6391, 5920, 641, 282, 6779, 402, 31172, 14, 199, 6699, 2004, 911, 506, 378, 340, 9512, 12, 436, 314, 2240, 911, 506, 10866, 14, 199, 8632, 2605, 314, 4458, 2004, 911, 506, 413, 436, 652, 911, 943, 1314, 31172, 3405, 1314, 5920, 14, 199, 28390, 658, 8273, 271, 276, 64, 334, 509, 662, 15965, 9, 436, 658, 1113, 2724, 64, 334, 509, 19599, 680, 199, 2344, 199, 646, 3873, 199, 646, 984, 199, 646, 747, 199, 199, 24345, 4424, 38, 63, 9744, 275, 747, 14, 12959, 360, 24345, 4424, 38, 297, 1994, 2647, 15, 1393, 15, 8273, 271, 276, 358, 199, 15862, 26406, 63, 9744, 275, 747, 14, 12959, 360, 15862, 26406, 297, 1994, 2647, 15, 1393, 15, 1113, 2724, 358, 199, 13887, 29086, 275, 1052, 327, 5920, 1314, 787, 2222, 13, 16208, 367, 3063, 1325, 1454, 3550, 282, 5721, 199, 199, 318, 1104, 63, 2901, 38, 63, 2252, 37, 8, 5904, 304, 272, 1449, 272, 2670, 367, 3421, 12717, 7286, 334, 2252, 37, 395, 17266, 367, 2287, 4601, 2196, 2072, 14, 272, 1449, 272, 299, 275, 3873, 14, 7942, 779, 24345, 4424, 38, 63, 9744, 12, 2475, 72, 297, 2475, 55, 297, 7286, 467, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 9009, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 272, 334, 2703, 12, 4635, 9, 275, 299, 14, 10664, 342, 272, 340, 299, 14, 9913, 26, 267, 746, 5925, 360, 547, 13618, 570, 358, 339, 4112, 275, 756, 272, 367, 1004, 315, 3839, 14, 7644, 837, 267, 1004, 275, 1004, 14, 1294, 342, 267, 340, 822, 8, 604, 9, 8119, 18, 436, 1004, 59, 16, 61, 508, 283, 804, 4881, 436, 1004, 59, 17, 61, 508, 283, 11446, 46, 356, 288, 4112, 275, 715, 272, 372, 4112, 199, 199, 318, 664, 63, 2901, 38, 63, 6815, 63, 2139, 8, 5904, 304, 272, 1449, 1767, 730, 436, 3285, 367, 662, 15965, 2240, 2323, 2344, 272, 299, 275, 3873, 14, 7942, 779, 24345, 4424, 38, 63, 9744, 12, 2475, 76, 297, 2475, 55, 297, 7286, 467, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 9009, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 272, 334, 2703, 12, 4635, 9, 275, 299, 14, 10664, 342, 272, 340, 299, 14, 9913, 26, 267, 746, 5925, 360, 547, 13618, 570, 358, 272, 315, 63, 2139, 275, 756, 272, 2338, 275, 378, 272, 2323, 275, 942, 272, 367, 1004, 315, 3839, 14, 7644, 837, 267, 340, 1004, 14, 2460, 360, 9184, 21391, 23117, 288, 315, 63, 2139, 275, 715, 267, 340, 1004, 508, 8061, 288, 315, 63, 2139, 275, 756, 267, 340, 315, 63, 2139, 26, 288, 340, 2338, 508, 413, 26, 327, 1406, 1004, 355, 402, 83, 63, 9749, 275, 1004, 14, 1623, 360, 804, 358, 355, 402, 83, 63, 2743, 275, 1004, 14, 1623, 360, 6397, 358, 355, 402, 83, 63, 2469, 275, 1004, 14, 1623, 360, 7579, 71, 358, 355, 402, 83, 63, 5743, 275, 1004, 14, 1623, 360, 9497, 358, 355, 340, 402, 83, 63, 9749, 508, 446, 17, 503, 402, 83, 63, 2743, 508, 446, 17, 503, 402, 83, 63, 2469, 508, 446, 17, 503, 402, 83, 63, 5743, 221, 508, 446, 17, 26, 490, 746, 1722, 360, 6612, 2198, 325, 276, 739, 446, 76, 55, 1072, 358, 288, 916, 2338, 690, 413, 26, 355, 6211, 275, 1004, 59, 14105, 63, 9749, 26, 14105, 63, 2743, 1055, 6735, 342, 355, 3285, 275, 1004, 59, 14105, 63, 2469, 26, 14105, 63, 5743, 1055, 6735, 342, 355, 2323, 14, 740, 1332, 9749, 12, 3285, 430, 288, 2338, 847, 413, 272, 372, 2323, 199, 199, 318, 1104, 63, 2901, 38, 63, 16764, 8, 5904, 304, 272, 1449, 272, 2670, 626, 949, 10189, 787, 17267, 436, 7286, 334, 15768, 314, 3464, 9, 272, 1449, 272, 1172, 63, 6323, 275, 756, 272, 1172, 63, 3689, 63, 2340, 275, 756, 272, 367, 334, 9749, 12, 3285, 9, 315, 664, 63, 2901, 38, 63, 6815, 63, 2139, 8, 5904, 304, 267, 340, 6211, 508, 283, 17732, 63, 17014, 356, 288, 1172, 63, 3689, 63, 2340, 275, 715, 267, 340, 283, 55, 7, 315, 3285, 436, 283, 37, 7, 315, 3285, 26, 327, 3420, 365, 3865, 17267, 436, 7286, 288, 1172, 63, 6323, 275, 715, 272, 372, 1172, 63, 3689, 63, 2340, 436, 440, 1172, 63, 6323, 199, 199, 318, 1104, 63, 2901, 38, 63, 13604, 1092, 8, 5904, 304, 272, 1449, 272, 2670, 367, 1586, 13, 2118, 295, 8022, 14, 272, 1664, 63, 13604, 1092, 2240, 1406, 1471, 2187, 272, 21907, 3420, 1471, 1172, 699, 3192, 63, 14283, 3305, 272, 1449, 272, 1172, 63, 3689, 63, 3369, 293, 275, 756, 272, 367, 334, 9749, 12, 3285, 9, 315, 664, 63, 2901, 38, 63, 6815, 63, 2139, 8, 5904, 304, 267, 327, 3390, 26, 440, 7907, 3285, 508, 283, 50, 356, 2348, 465, 2142, 1192, 663, 314, 4983, 23142, 267, 327, 961, 1630, 440, 12787, 6391, 26, 314, 4983, 3285, 402, 314, 1664, 63, 13604, 1092, 2240, 1406, 787, 5525, 12, 314, 510, 52, 63, 7405, 1406, 16756, 314, 15826, 3443, 14, 267, 327, 9738, 12, 314, 8336, 17261, 1929, 370, 2218, 370, 642, 9150, 880, 3520, 787, 820, 55, 14, 267, 327, 598, 20217, 6337, 6181, 10296, 402, 6118, 293, 5302, 316, 642, 9150, 820, 2410, 295, 8022, 787, 9158, 14, 267, 327, 1666, 2597, 4178, 921, 30342, 14, 815, 10197, 76, 29, 1393, 1208, 6, 77, 29, 10721, 13997, 1153, 1477, 7507, 15355, 267, 340, 6211, 508, 283, 17732, 63, 13604, 1092, 356, 288, 1172, 63, 3689, 63, 3369, 293, 275, 715, 339, 1172, 63, 3409, 2131, 275, 756, 272, 299, 275, 3873, 14, 7942, 779, 24345, 4424, 38, 63, 9744, 12, 2475, 68, 297, 2475, 55, 297, 7286, 467, 3839, 29, 5781 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 6900, 13, 12682, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 2344, 199, 20906, 5678, 662, 15965, 6391, 5920, 641, 282, 6779, 402, 31172, 14, 199, 6699, 2004, 911, 506, 378, 340, 9512, 12, 436, 314, 2240, 911, 506, 10866, 14, 199, 8632, 2605, 314, 4458, 2004, 911, 506, 413, 436, 652, 911, 943, 1314, 31172, 3405, 1314, 5920, 14, 199, 28390, 658, 8273, 271, 276, 64, 334, 509, 662, 15965, 9, 436, 658, 1113, 2724, 64, 334, 509, 19599, 680, 199, 2344, 199, 646, 3873, 199, 646, 984, 199, 646, 747, 199, 199, 24345, 4424, 38, 63, 9744, 275, 747, 14, 12959, 360, 24345, 4424, 38, 297, 1994, 2647, 15, 1393, 15, 8273, 271, 276, 358, 199, 15862, 26406, 63, 9744, 275, 747, 14, 12959, 360, 15862, 26406, 297, 1994, 2647, 15, 1393, 15, 1113, 2724, 358, 199, 13887, 29086, 275, 1052, 327, 5920, 1314, 787, 2222, 13, 16208, 367, 3063, 1325, 1454, 3550, 282, 5721, 199, 199, 318, 1104, 63, 2901, 38, 63, 2252, 37, 8, 5904, 304, 272, 1449, 272, 2670, 367, 3421, 12717, 7286, 334, 2252, 37, 395, 17266, 367, 2287, 4601, 2196, 2072, 14, 272, 1449, 272, 299, 275, 3873, 14, 7942, 779, 24345, 4424, 38, 63, 9744, 12, 2475, 72, 297, 2475, 55, 297, 7286, 467, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 9009, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 272, 334, 2703, 12, 4635, 9, 275, 299, 14, 10664, 342, 272, 340, 299, 14, 9913, 26, 267, 746, 5925, 360, 547, 13618, 570, 358, 339, 4112, 275, 756, 272, 367, 1004, 315, 3839, 14, 7644, 837, 267, 1004, 275, 1004, 14, 1294, 342, 267, 340, 822, 8, 604, 9, 8119, 18, 436, 1004, 59, 16, 61, 508, 283, 804, 4881, 436, 1004, 59, 17, 61, 508, 283, 11446, 46, 356, 288, 4112, 275, 715, 272, 372, 4112, 199, 199, 318, 664, 63, 2901, 38, 63, 6815, 63, 2139, 8, 5904, 304, 272, 1449, 1767, 730, 436, 3285, 367, 662, 15965, 2240, 2323, 2344, 272, 299, 275, 3873, 14, 7942, 779, 24345, 4424, 38, 63, 9744, 12, 2475, 76, 297, 2475, 55, 297, 7286, 467, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 9009, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 272, 334, 2703, 12, 4635, 9, 275, 299, 14, 10664, 342, 272, 340, 299, 14, 9913, 26, 267, 746, 5925, 360, 547, 13618, 570, 358, 272, 315, 63, 2139, 275, 756, 272, 2338, 275, 378, 272, 2323, 275, 942, 272, 367, 1004, 315, 3839, 14, 7644, 837, 267, 340, 1004, 14, 2460, 360, 9184, 21391, 23117, 288, 315, 63, 2139, 275, 715, 267, 340, 1004, 508, 8061, 288, 315, 63, 2139, 275, 756, 267, 340, 315, 63, 2139, 26, 288, 340, 2338, 508, 413, 26, 327, 1406, 1004, 355, 402, 83, 63, 9749, 275, 1004, 14, 1623, 360, 804, 358, 355, 402, 83, 63, 2743, 275, 1004, 14, 1623, 360, 6397, 358, 355, 402, 83, 63, 2469, 275, 1004, 14, 1623, 360, 7579, 71, 358, 355, 402, 83, 63, 5743, 275, 1004, 14, 1623, 360, 9497, 358, 355, 340, 402, 83, 63, 9749, 508, 446, 17, 503, 402, 83, 63, 2743, 508, 446, 17, 503, 402, 83, 63, 2469, 508, 446, 17, 503, 402, 83, 63, 5743, 221, 508, 446, 17, 26, 490, 746, 1722, 360, 6612, 2198, 325, 276, 739, 446, 76, 55, 1072, 358, 288, 916, 2338, 690, 413, 26, 355, 6211, 275, 1004, 59, 14105, 63, 9749, 26, 14105, 63, 2743, 1055, 6735, 342, 355, 3285, 275, 1004, 59, 14105, 63, 2469, 26, 14105, 63, 5743, 1055, 6735, 342, 355, 2323, 14, 740, 1332, 9749, 12, 3285, 430, 288, 2338, 847, 413, 272, 372, 2323, 199, 199, 318, 1104, 63, 2901, 38, 63, 16764, 8, 5904, 304, 272, 1449, 272, 2670, 626, 949, 10189, 787, 17267, 436, 7286, 334, 15768, 314, 3464, 9, 272, 1449, 272, 1172, 63, 6323, 275, 756, 272, 1172, 63, 3689, 63, 2340, 275, 756, 272, 367, 334, 9749, 12, 3285, 9, 315, 664, 63, 2901, 38, 63, 6815, 63, 2139, 8, 5904, 304, 267, 340, 6211, 508, 283, 17732, 63, 17014, 356, 288, 1172, 63, 3689, 63, 2340, 275, 715, 267, 340, 283, 55, 7, 315, 3285, 436, 283, 37, 7, 315, 3285, 26, 327, 3420, 365, 3865, 17267, 436, 7286, 288, 1172, 63, 6323, 275, 715, 272, 372, 1172, 63, 3689, 63, 2340, 436, 440, 1172, 63, 6323, 199, 199, 318, 1104, 63, 2901, 38, 63, 13604, 1092, 8, 5904, 304, 272, 1449, 272, 2670, 367, 1586, 13, 2118, 295, 8022, 14, 272, 1664, 63, 13604, 1092, 2240, 1406, 1471, 2187, 272, 21907, 3420, 1471, 1172, 699, 3192, 63, 14283, 3305, 272, 1449, 272, 1172, 63, 3689, 63, 3369, 293, 275, 756, 272, 367, 334, 9749, 12, 3285, 9, 315, 664, 63, 2901, 38, 63, 6815, 63, 2139, 8, 5904, 304, 267, 327, 3390, 26, 440, 7907, 3285, 508, 283, 50, 356, 2348, 465, 2142, 1192, 663, 314, 4983, 23142, 267, 327, 961, 1630, 440, 12787, 6391, 26, 314, 4983, 3285, 402, 314, 1664, 63, 13604, 1092, 2240, 1406, 787, 5525, 12, 314, 510, 52, 63, 7405, 1406, 16756, 314, 15826, 3443, 14, 267, 327, 9738, 12, 314, 8336, 17261, 1929, 370, 2218, 370, 642, 9150, 880, 3520, 787, 820, 55, 14, 267, 327, 598, 20217, 6337, 6181, 10296, 402, 6118, 293, 5302, 316, 642, 9150, 820, 2410, 295, 8022, 787, 9158, 14, 267, 327, 1666, 2597, 4178, 921, 30342, 14, 815, 10197, 76, 29, 1393, 1208, 6, 77, 29, 10721, 13997, 1153, 1477, 7507, 15355, 267, 340, 6211, 508, 283, 17732, 63, 13604, 1092, 356, 288, 1172, 63, 3689, 63, 3369, 293, 275, 715, 339, 1172, 63, 3409, 2131, 275, 756, 272, 299, 275, 3873, 14, 7942, 779, 24345, 4424, 38, 63, 9744, 12, 2475, 68, 297, 2475, 55, 297, 7286, 467, 3839, 29, 5781, 0 ]
[ 1, 1, 1, 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pyramid_authsanity
src/pyramid_authsanity/policy.py
1
6144
import base64 import os from pyramid.authorization import Authenticated, Everyone from pyramid.interfaces import IAuthenticationPolicy, IDebugLogger from zope.interface import implementer from .util import _find_services, _session_registered, add_vary_callback def _clean_principal(princid): """Utility function that cleans up the passed in principal This can easily also be extended for example to make sure that certain usernames are automatically off-limits. """ if princid in (Authenticated, Everyone): princid = None return princid _marker = object() @implementer(IAuthenticationPolicy) class AuthServicePolicy(object): def _log(self, msg, methodname, request): logger = request.registry.queryUtility(IDebugLogger) if logger: cls = self.__class__ classname = cls.__module__ + "." + cls.__name__ methodname = classname + "." + methodname logger.debug(methodname + ": " + msg) _find_services = staticmethod(_find_services) # Testing _session_registered = staticmethod(_session_registered) # Testing _have_session = _marker def __init__(self, debug=False): self.debug = debug def unauthenticated_userid(self, request): """ We do not allow the unauthenticated userid to be used. """ def authenticated_userid(self, request): """ Returns the authenticated userid for this request. """ debug = self.debug (sourcesvc, authsvc) = self._find_services(request) request.add_response_callback(add_vary_callback(sourcesvc.vary)) try: userid = authsvc.userid() except Exception: debug and self._log( "authentication has not yet been completed", "authenticated_userid", request, ) (principal, ticket) = sourcesvc.get_value() debug and self._log( "source service provided information: (principal: %r, ticket: %r)" % (principal, ticket), "authenticated_userid", request, ) # Verify the principal and the ticket, even if None authsvc.verify_ticket(principal, ticket) try: # This should now return None or the userid userid = authsvc.userid() except Exception: userid = None debug and self._log( "authenticated_userid returning: %r" % (userid,), "authenticated_userid", request, ) return userid def effective_principals(self, request): """ A list of effective principals derived from request. """ debug = self.debug effective_principals = [Everyone] userid = self.authenticated_userid(request) (_, authsvc) = self._find_services(request) if userid is None: debug and self._log( "authenticated_userid returned %r; returning %r" % (userid, effective_principals), "effective_principals", request, ) return effective_principals if _clean_principal(userid) is None: debug and self._log( ( "authenticated_userid returned disallowed %r; returning %r " "as if it was None" % (userid, effective_principals) ), "effective_principals", request, ) return effective_principals effective_principals.append(Authenticated) effective_principals.append(userid) effective_principals.extend(authsvc.groups()) debug and self._log( "returning effective principals: %r" % (effective_principals,), "effective_principals", request, ) return effective_principals def remember(self, request, principal, **kw): """ Returns a list of headers that are to be set from the source service. """ debug = self.debug if self._have_session is _marker: self._have_session = self._session_registered(request) prev_userid = self.authenticated_userid(request) (sourcesvc, authsvc) = self._find_services(request) request.add_response_callback(add_vary_callback(sourcesvc.vary)) value = {} value["principal"] = principal value["ticket"] = ticket = ( base64.urlsafe_b64encode(os.urandom(32)).rstrip(b"=").decode("ascii") ) debug and self._log( "Remember principal: %r, ticket: %r" % (principal, ticket), "remember", request, ) authsvc.add_ticket(principal, ticket) # Clear the previous session if self._have_session: if prev_userid != principal: request.session.invalidate() else: # We are logging in the same user that is already logged in, we # still want to generate a new session, but we can keep the # existing data data = dict(request.session.items()) request.session.invalidate() request.session.update(data) request.session.new_csrf_token() return sourcesvc.headers_remember([principal, ticket]) def forget(self, request): """ A list of headers which will delete appropriate cookies.""" debug = self.debug if self._have_session is _marker: self._have_session = self._session_registered(request) (sourcesvc, authsvc) = self._find_services(request) request.add_response_callback(add_vary_callback(sourcesvc.vary)) (_, ticket) = sourcesvc.get_value() debug and self._log("Forgetting ticket: %r" % (ticket,), "forget", request) authsvc.remove_ticket(ticket) # Clear the session by invalidating it if self._have_session: request.session.invalidate() return sourcesvc.headers_forget()
isc
[ 646, 1300, 772, 199, 646, 747, 199, 199, 504, 30704, 14, 15846, 492, 3590, 8080, 12, 18414, 368, 199, 504, 30704, 14, 7436, 492, 473, 10348, 4845, 12, 473, 7084, 4455, 199, 504, 20110, 14, 3266, 492, 2456, 28826, 199, 199, 504, 1275, 1974, 492, 485, 1623, 63, 5950, 12, 485, 1730, 63, 11616, 12, 1050, 63, 21989, 63, 3058, 421, 199, 318, 485, 3118, 63, 19200, 8, 2700, 6559, 344, 304, 272, 408, 17505, 805, 626, 15158, 796, 1536, 314, 3032, 315, 21646, 272, 961, 883, 16174, 2597, 506, 9243, 367, 2893, 370, 1852, 3238, 626, 9842, 272, 922, 1247, 787, 5847, 2331, 13, 9368, 14, 272, 408, 272, 340, 5448, 6559, 344, 315, 334, 30871, 12, 18414, 368, 304, 267, 5448, 6559, 344, 275, 488, 272, 372, 5448, 6559, 344, 421, 199, 63, 4211, 275, 909, 342, 421, 199, 32, 1729, 28826, 8, 41, 10348, 4845, 9, 199, 533, 3590, 3167, 4845, 8, 785, 304, 272, 347, 485, 793, 8, 277, 12, 1499, 12, 28009, 12, 1056, 304, 267, 2512, 275, 1056, 14, 5189, 14, 1131, 17505, 8, 41, 7084, 4455, 9, 267, 340, 2512, 26, 288, 843, 275, 291, 855, 533, 363, 288, 15876, 275, 843, 855, 578, 363, 435, 14530, 435, 843, 855, 354, 363, 288, 28009, 275, 15876, 435, 14530, 435, 28009, 288, 2512, 14, 1757, 8, 765, 354, 435, 7244, 298, 435, 1499, 9, 339, 485, 1623, 63, 5950, 275, 12822, 1547, 1623, 63, 5950, 9, 221, 327, 11940, 272, 485, 1730, 63, 11616, 275, 12822, 1547, 1730, 63, 11616, 9, 221, 327, 11940, 272, 485, 7804, 63, 1730, 275, 485, 4211, 339, 347, 636, 826, 721, 277, 12, 3105, 29, 797, 304, 267, 291, 14, 1757, 275, 3105, 339, 347, 625, 12177, 63, 19737, 8, 277, 12, 1056, 304, 267, 408, 2136, 886, 440, 2040, 314, 625, 12177, 25580, 370, 506, 1202, 14, 408, 339, 347, 15082, 63, 19737, 8, 277, 12, 1056, 304, 267, 408, 1803, 314, 15082, 25580, 367, 642, 1056, 14, 408, 267, 3105, 275, 291, 14, 1757, 398, 334, 1365, 10599, 12, 1790, 10599, 9, 275, 291, 423, 1623, 63, 5950, 8, 1069, 9, 267, 1056, 14, 525, 63, 1310, 63, 3058, 8, 525, 63, 21989, 63, 3058, 8, 1365, 10599, 14, 21989, 430, 398, 862, 26, 288, 25580, 275, 1790, 10599, 14, 19737, 342, 267, 871, 2186, 26, 288, 3105, 436, 291, 423, 793, 8, 355, 298, 11725, 965, 440, 5966, 2757, 9709, 401, 355, 298, 12177, 63, 19737, 401, 355, 1056, 12, 288, 776, 288, 334, 19200, 12, 12052, 9, 275, 1350, 10599, 14, 362, 63, 585, 342, 953, 3105, 436, 291, 423, 793, 8, 355, 298, 1365, 2435, 2741, 2556, 26, 334, 19200, 26, 450, 82, 12, 12052, 26, 450, 82, 2924, 355, 450, 334, 19200, 12, 12052, 395, 355, 298, 12177, 63, 19737, 401, 355, 1056, 12, 288, 776, 953, 327, 7635, 314, 21646, 436, 314, 12052, 12, 2755, 340, 488, 288, 1790, 10599, 14, 4712, 63, 9201, 8, 19200, 12, 12052, 9, 953, 862, 26, 355, 327, 961, 1077, 3063, 372, 488, 503, 314, 25580, 355, 25580, 275, 1790, 10599, 14, 19737, 342, 288, 871, 2186, 26, 355, 25580, 275, 488, 398, 3105, 436, 291, 423, 793, 8, 288, 298, 12177, 63, 19737, 8152, 26, 450, 82, 2, 450, 334, 19737, 4706, 288, 298, 12177, 63, 19737, 401, 288, 1056, 12, 267, 776, 398, 372, 25580, 339, 347, 15826, 63, 2700, 10352, 2551, 8, 277, 12, 1056, 304, 267, 408, 437, 769, 402, 15826, 5448, 10352, 2551, 7131, 687, 1056, 14, 408, 267, 3105, 275, 291, 14, 1757, 267, 15826, 63, 2700, 10352, 2551, 275, 359, 24527, 368, 61, 398, 25580, 275, 291, 14, 12177, 63, 19737, 8, 1069, 9, 267, 27017, 1790, 10599, 9, 275, 291, 423, 1623, 63, 5950, 8, 1069, 9, 398, 340, 25580, 365, 488, 26, 288, 3105, 436, 291, 423, 793, 8, 355, 298, 12177, 63, 19737, 2138, 450, 82, 27, 8152, 450, 82, 2, 355, 450, 334, 19737, 12, 15826, 63, 2700, 10352, 2551, 395, 355, 298, 20427, 63, 2700, 10352, 2551, 401, 355, 1056, 12, 288, 776, 288, 372, 15826, 63, 2700, 10352, 2551, 398, 340, 485, 3118, 63, 19200, 8, 19737, 9, 365, 488, 26, 288, 3105, 436, 291, 423, 793, 8, 355, 334, 490, 298, 12177, 63, 19737, 2138, 30994, 450, 82, 27, 8152, 450, 82, 298, 490, 298, 305, 340, 652, 1990, 488, 2, 450, 334, 19737, 12, 15826, 63, 2700, 10352, 2551, 9, 355, 2318, 355, 298, 20427, 63, 2700, 10352, 2551, 401, 355, 1056, 12, 288, 776, 288, 372, 15826, 63, 2700, 10352, 2551, 398, 15826, 63, 2700, 10352, 2551, 14, 740, 8, 30871, 9, 267, 15826, 63, 2700, 10352, 2551, 14, 740, 8, 19737, 9, 267, 15826, 63, 2700, 10352, 2551, 14, 2880, 8, 1178, 10599, 14, 2634, 1012, 398, 3105, 436, 291, 423, 793, 8, 288, 298, 24112, 15826, 5448, 10352, 2551, 26, 450, 82, 2, 450, 334, 20427, 63, 2700, 10352, 2551, 4706, 288, 298, 20427, 63, 2700, 10352, 2551, 401, 288, 1056, 12, 267, 776, 267, 372, 15826, 63, 2700, 10352, 2551, 339, 347, 21027, 8, 277, 12, 1056, 12, 21646, 12, 1011, 829, 304, 267, 408, 1803, 282, 769, 402, 2323, 626, 787, 370, 506, 663, 687, 314, 1350, 2435, 14, 408, 267, 3105, 275, 291, 14, 1757, 398, 340, 291, 423, 7804, 63, 1730, 365, 485, 4211, 26, 288, 291, 423, 7804, 63, 1730, 275, 291, 423, 1730, 63, 11616, 8, 1069, 9, 398, 5071, 63, 19737, 275, 291, 14, 12177, 63, 19737, 8, 1069, 9, 398, 334, 1365, 10599, 12, 1790, 10599, 9, 275, 291, 423, 1623, 63, 5950, 8, 1069, 9, 398, 1056, 14, 525, 63, 1310, 63, 3058, 8, 525, 63, 21989, 63, 3058, 8, 1365, 10599, 14, 21989, 430, 398, 574, 275, 1052, 267, 574, 905, 19200, 937, 275, 21646, 267, 574, 905, 9201, 937, 275, 12052, 275, 334, 288, 1300, 772, 14, 28201, 63, 66, 772, 2143, 8, 736, 14, 22776, 8, 708, 4992, 6735, 8, 66, 2, 29, 3471, 2708, 480, 4371, 531, 267, 776, 398, 3105, 436, 291, 423, 793, 8, 288, 298, 497, 1114, 21646, 26, 450, 82, 12, 12052, 26, 450 ]
[ 1300, 772, 199, 646, 747, 199, 199, 504, 30704, 14, 15846, 492, 3590, 8080, 12, 18414, 368, 199, 504, 30704, 14, 7436, 492, 473, 10348, 4845, 12, 473, 7084, 4455, 199, 504, 20110, 14, 3266, 492, 2456, 28826, 199, 199, 504, 1275, 1974, 492, 485, 1623, 63, 5950, 12, 485, 1730, 63, 11616, 12, 1050, 63, 21989, 63, 3058, 421, 199, 318, 485, 3118, 63, 19200, 8, 2700, 6559, 344, 304, 272, 408, 17505, 805, 626, 15158, 796, 1536, 314, 3032, 315, 21646, 272, 961, 883, 16174, 2597, 506, 9243, 367, 2893, 370, 1852, 3238, 626, 9842, 272, 922, 1247, 787, 5847, 2331, 13, 9368, 14, 272, 408, 272, 340, 5448, 6559, 344, 315, 334, 30871, 12, 18414, 368, 304, 267, 5448, 6559, 344, 275, 488, 272, 372, 5448, 6559, 344, 421, 199, 63, 4211, 275, 909, 342, 421, 199, 32, 1729, 28826, 8, 41, 10348, 4845, 9, 199, 533, 3590, 3167, 4845, 8, 785, 304, 272, 347, 485, 793, 8, 277, 12, 1499, 12, 28009, 12, 1056, 304, 267, 2512, 275, 1056, 14, 5189, 14, 1131, 17505, 8, 41, 7084, 4455, 9, 267, 340, 2512, 26, 288, 843, 275, 291, 855, 533, 363, 288, 15876, 275, 843, 855, 578, 363, 435, 14530, 435, 843, 855, 354, 363, 288, 28009, 275, 15876, 435, 14530, 435, 28009, 288, 2512, 14, 1757, 8, 765, 354, 435, 7244, 298, 435, 1499, 9, 339, 485, 1623, 63, 5950, 275, 12822, 1547, 1623, 63, 5950, 9, 221, 327, 11940, 272, 485, 1730, 63, 11616, 275, 12822, 1547, 1730, 63, 11616, 9, 221, 327, 11940, 272, 485, 7804, 63, 1730, 275, 485, 4211, 339, 347, 636, 826, 721, 277, 12, 3105, 29, 797, 304, 267, 291, 14, 1757, 275, 3105, 339, 347, 625, 12177, 63, 19737, 8, 277, 12, 1056, 304, 267, 408, 2136, 886, 440, 2040, 314, 625, 12177, 25580, 370, 506, 1202, 14, 408, 339, 347, 15082, 63, 19737, 8, 277, 12, 1056, 304, 267, 408, 1803, 314, 15082, 25580, 367, 642, 1056, 14, 408, 267, 3105, 275, 291, 14, 1757, 398, 334, 1365, 10599, 12, 1790, 10599, 9, 275, 291, 423, 1623, 63, 5950, 8, 1069, 9, 267, 1056, 14, 525, 63, 1310, 63, 3058, 8, 525, 63, 21989, 63, 3058, 8, 1365, 10599, 14, 21989, 430, 398, 862, 26, 288, 25580, 275, 1790, 10599, 14, 19737, 342, 267, 871, 2186, 26, 288, 3105, 436, 291, 423, 793, 8, 355, 298, 11725, 965, 440, 5966, 2757, 9709, 401, 355, 298, 12177, 63, 19737, 401, 355, 1056, 12, 288, 776, 288, 334, 19200, 12, 12052, 9, 275, 1350, 10599, 14, 362, 63, 585, 342, 953, 3105, 436, 291, 423, 793, 8, 355, 298, 1365, 2435, 2741, 2556, 26, 334, 19200, 26, 450, 82, 12, 12052, 26, 450, 82, 2924, 355, 450, 334, 19200, 12, 12052, 395, 355, 298, 12177, 63, 19737, 401, 355, 1056, 12, 288, 776, 953, 327, 7635, 314, 21646, 436, 314, 12052, 12, 2755, 340, 488, 288, 1790, 10599, 14, 4712, 63, 9201, 8, 19200, 12, 12052, 9, 953, 862, 26, 355, 327, 961, 1077, 3063, 372, 488, 503, 314, 25580, 355, 25580, 275, 1790, 10599, 14, 19737, 342, 288, 871, 2186, 26, 355, 25580, 275, 488, 398, 3105, 436, 291, 423, 793, 8, 288, 298, 12177, 63, 19737, 8152, 26, 450, 82, 2, 450, 334, 19737, 4706, 288, 298, 12177, 63, 19737, 401, 288, 1056, 12, 267, 776, 398, 372, 25580, 339, 347, 15826, 63, 2700, 10352, 2551, 8, 277, 12, 1056, 304, 267, 408, 437, 769, 402, 15826, 5448, 10352, 2551, 7131, 687, 1056, 14, 408, 267, 3105, 275, 291, 14, 1757, 267, 15826, 63, 2700, 10352, 2551, 275, 359, 24527, 368, 61, 398, 25580, 275, 291, 14, 12177, 63, 19737, 8, 1069, 9, 267, 27017, 1790, 10599, 9, 275, 291, 423, 1623, 63, 5950, 8, 1069, 9, 398, 340, 25580, 365, 488, 26, 288, 3105, 436, 291, 423, 793, 8, 355, 298, 12177, 63, 19737, 2138, 450, 82, 27, 8152, 450, 82, 2, 355, 450, 334, 19737, 12, 15826, 63, 2700, 10352, 2551, 395, 355, 298, 20427, 63, 2700, 10352, 2551, 401, 355, 1056, 12, 288, 776, 288, 372, 15826, 63, 2700, 10352, 2551, 398, 340, 485, 3118, 63, 19200, 8, 19737, 9, 365, 488, 26, 288, 3105, 436, 291, 423, 793, 8, 355, 334, 490, 298, 12177, 63, 19737, 2138, 30994, 450, 82, 27, 8152, 450, 82, 298, 490, 298, 305, 340, 652, 1990, 488, 2, 450, 334, 19737, 12, 15826, 63, 2700, 10352, 2551, 9, 355, 2318, 355, 298, 20427, 63, 2700, 10352, 2551, 401, 355, 1056, 12, 288, 776, 288, 372, 15826, 63, 2700, 10352, 2551, 398, 15826, 63, 2700, 10352, 2551, 14, 740, 8, 30871, 9, 267, 15826, 63, 2700, 10352, 2551, 14, 740, 8, 19737, 9, 267, 15826, 63, 2700, 10352, 2551, 14, 2880, 8, 1178, 10599, 14, 2634, 1012, 398, 3105, 436, 291, 423, 793, 8, 288, 298, 24112, 15826, 5448, 10352, 2551, 26, 450, 82, 2, 450, 334, 20427, 63, 2700, 10352, 2551, 4706, 288, 298, 20427, 63, 2700, 10352, 2551, 401, 288, 1056, 12, 267, 776, 267, 372, 15826, 63, 2700, 10352, 2551, 339, 347, 21027, 8, 277, 12, 1056, 12, 21646, 12, 1011, 829, 304, 267, 408, 1803, 282, 769, 402, 2323, 626, 787, 370, 506, 663, 687, 314, 1350, 2435, 14, 408, 267, 3105, 275, 291, 14, 1757, 398, 340, 291, 423, 7804, 63, 1730, 365, 485, 4211, 26, 288, 291, 423, 7804, 63, 1730, 275, 291, 423, 1730, 63, 11616, 8, 1069, 9, 398, 5071, 63, 19737, 275, 291, 14, 12177, 63, 19737, 8, 1069, 9, 398, 334, 1365, 10599, 12, 1790, 10599, 9, 275, 291, 423, 1623, 63, 5950, 8, 1069, 9, 398, 1056, 14, 525, 63, 1310, 63, 3058, 8, 525, 63, 21989, 63, 3058, 8, 1365, 10599, 14, 21989, 430, 398, 574, 275, 1052, 267, 574, 905, 19200, 937, 275, 21646, 267, 574, 905, 9201, 937, 275, 12052, 275, 334, 288, 1300, 772, 14, 28201, 63, 66, 772, 2143, 8, 736, 14, 22776, 8, 708, 4992, 6735, 8, 66, 2, 29, 3471, 2708, 480, 4371, 531, 267, 776, 398, 3105, 436, 291, 423, 793, 8, 288, 298, 497, 1114, 21646, 26, 450, 82, 12, 12052, 26, 450, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
maxalbert/ansible
lib/ansible/galaxy/role.py
40
11943
######################################################################## # # (C) 2015, Brian Coca <bcoca@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # ######################################################################## import datetime import os import subprocess import tarfile import tempfile import yaml from shutil import rmtree from urllib2 import urlopen from ansible import constants as C from ansible.errors import AnsibleError class GalaxyRole(object): SUPPORTED_SCMS = set(['git', 'hg']) META_MAIN = os.path.join('meta', 'main.yml') META_INSTALL = os.path.join('meta', '.galaxy_install_info') ROLE_DIRS = ('defaults','files','handlers','meta','tasks','templates','vars') def __init__(self, galaxy, name, src=None, version=None, scm=None): self._metadata = None self._install_info = None self.options = galaxy.options self.display = galaxy.display self.name = name self.version = version self.src = src or name self.scm = scm self.path = (os.path.join(galaxy.roles_path, self.name)) def fetch_from_scm_archive(self): # this can be configured to prevent unwanted SCMS but cannot add new ones unless the code is also updated if scm not in self.scms: self.display.display("The %s scm is not currently supported" % scm) return False tempdir = tempfile.mkdtemp() clone_cmd = [scm, 'clone', role_url, self.name] with open('/dev/null', 'w') as devnull: try: self.display.display("- executing: %s" % " ".join(clone_cmd)) popen = subprocess.Popen(clone_cmd, cwd=tempdir, stdout=devnull, stderr=devnull) except: raise AnsibleError("error executing: %s" % " ".join(clone_cmd)) rc = popen.wait() if rc != 0: self.display.display("- command %s failed" % ' '.join(clone_cmd)) self.display.display(" in directory %s" % tempdir) return False temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar') if scm == 'hg': archive_cmd = ['hg', 'archive', '--prefix', "%s/" % self.name] if role_version: archive_cmd.extend(['-r', role_version]) archive_cmd.append(temp_file.name) if scm == 'git': archive_cmd = ['git', 'archive', '--prefix=%s/' % self.name, '--output=%s' % temp_file.name] if role_version: archive_cmd.append(role_version) else: archive_cmd.append('HEAD') with open('/dev/null', 'w') as devnull: self.display.display("- executing: %s" % " ".join(archive_cmd)) popen = subprocess.Popen(archive_cmd, cwd=os.path.join(tempdir, self.name), stderr=devnull, stdout=devnull) rc = popen.wait() if rc != 0: self.display.display("- command %s failed" % ' '.join(archive_cmd)) self.display.display(" in directory %s" % tempdir) return False rmtree(tempdir, ignore_errors=True) return temp_file.name @property def metadata(self): """ Returns role metadata """ if self._metadata is None: meta_path = os.path.join(self.path, self.META_MAIN) if os.path.isfile(meta_path): try: f = open(meta_path, 'r') self._metadata = yaml.safe_load(f) except: self.display.vvvvv("Unable to load metadata for %s" % self.name) return False finally: f.close() return self._metadata @property def install_info(self): """ Returns role install info """ if self._install_info is None: info_path = os.path.join(self.path, self.META_INSTALL) if os.path.isfile(info_path): try: f = open(info_path, 'r') self._install_info = yaml.safe_load(f) except: self.display.vvvvv("Unable to load Galaxy install info for %s" % self.name) return False finally: f.close() return self._install_info def _write_galaxy_install_info(self): """ Writes a YAML-formatted file to the role's meta/ directory (named .galaxy_install_info) which contains some information we can use later for commands like 'list' and 'info'. """ info = dict( version=self.version, install_date=datetime.datetime.utcnow().strftime("%c"), ) info_path = os.path.join(self.path, self.META_INSTALL) try: f = open(info_path, 'w+') self._install_info = yaml.safe_dump(info, f) except: return False finally: f.close() return True def remove(self): """ Removes the specified role from the roles path. There is a sanity check to make sure there's a meta/main.yml file at this path so the user doesn't blow away random directories """ if self.metadata: try: rmtree(self.path) return True except: pass return False def fetch(self, role_data): """ Downloads the archived role from github to a temp location """ if role_data: # first grab the file and save it to a temp location if "github_user" in role_data and "github_repo" in role_data: archive_url = 'https://github.com/%s/%s/archive/%s.tar.gz' % (role_data["github_user"], role_data["github_repo"], self.version) else: archive_url = self.src self.display.display("- downloading role from %s" % archive_url) try: url_file = urlopen(archive_url) temp_file = tempfile.NamedTemporaryFile(delete=False) data = url_file.read() while data: temp_file.write(data) data = url_file.read() temp_file.close() return temp_file.name except: # TODO: better urllib2 error handling for error # messages that are more exact self.display.error("failed to download the file.") return False def install(self, role_filename): # the file is a tar, so open it that way and extract it # to the specified (or default) roles directory if not tarfile.is_tarfile(role_filename): self.display.error("the file downloaded was not a tar.gz") return False else: if role_filename.endswith('.gz'): role_tar_file = tarfile.open(role_filename, "r:gz") else: role_tar_file = tarfile.open(role_filename, "r") # verify the role's meta file meta_file = None members = role_tar_file.getmembers() # next find the metadata file for member in members: if self.META_MAIN in member.name: meta_file = member break if not meta_file: self.display.error("this role does not appear to have a meta/main.yml file.") return False else: try: self._metadata = yaml.safe_load(role_tar_file.extractfile(meta_file)) except: self.display.error("this role does not appear to have a valid meta/main.yml file.") return False # we strip off the top-level directory for all of the files contained within # the tar file here, since the default is 'github_repo-target', and change it # to the specified role's name self.display.display("- extracting %s to %s" % (self.name, self.path)) try: if os.path.exists(self.path): if not os.path.isdir(self.path): self.display.error("the specified roles path exists and is not a directory.") return False elif not getattr(self.options, "force", False): self.display.error("the specified role %s appears to already exist. Use --force to replace it." % self.name) return False else: # using --force, remove the old path if not self.remove(): self.display.error("%s doesn't appear to contain a role." % self.path) self.display.error(" please remove this directory manually if you really want to put the role here.") return False else: os.makedirs(self.path) # now we do the actual extraction to the path for member in members: # we only extract files, and remove any relative path # bits that might be in the file for security purposes # and drop the leading directory, as mentioned above if member.isreg() or member.issym(): parts = member.name.split(os.sep)[1:] final_parts = [] for part in parts: if part != '..' and '~' not in part and '$' not in part: final_parts.append(part) member.name = os.path.join(*final_parts) role_tar_file.extract(member, self.path) # write out the install info file for later use self._write_galaxy_install_info() except OSError as e: self.display.error("Could not update files in %s: %s" % (self.path, str(e))) return False # return the parsed yaml metadata self.display.display("- %s was installed successfully" % self.name) return True @property def spec(self): """ Returns role spec info { 'scm': 'git', 'src': 'http://git.example.com/repos/repo.git', 'version': 'v1.0', 'name': 'repo' } """ return dict(scm=self.scm, src=self.src, version=self.version, name=self.name) @staticmethod def url_to_spec(roleurl): # gets the role name out of a repo like # http://git.example.com/repos/repo.git" => "repo" if '://' not in roleurl and '@' not in roleurl: return roleurl trailing_path = roleurl.split('/')[-1] if trailing_path.endswith('.git'): trailing_path = trailing_path[:-4] if trailing_path.endswith('.tar.gz'): trailing_path = trailing_path[:-7] if ',' in trailing_path: trailing_path = trailing_path.split(',')[0] return trailing_path
gpl-3.0
[ 3949, 199, 3, 199, 3, 334, 35, 9, 6900, 12, 699, 18429, 445, 679, 65, 665, 66, 331, 696, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3949, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 3873, 199, 646, 13608, 199, 646, 5549, 199, 646, 8864, 199, 504, 5145, 492, 20978, 199, 504, 4011, 18, 492, 18279, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2550, 492, 13358, 199, 199, 533, 598, 15914, 7422, 8, 785, 304, 339, 32501, 63, 5153, 3053, 275, 663, 2941, 3187, 297, 283, 9208, 1105, 272, 603, 15808, 63, 5848, 275, 747, 14, 515, 14, 904, 360, 2024, 297, 283, 973, 14, 11714, 358, 272, 603, 15808, 63, 16811, 275, 747, 14, 515, 14, 904, 360, 2024, 297, 1987, 24806, 63, 3174, 63, 815, 358, 272, 9769, 906, 63, 14455, 275, 661, 4322, 1673, 1725, 1673, 5586, 1673, 2024, 1673, 5054, 1673, 5876, 1673, 2936, 358, 2378, 347, 636, 826, 721, 277, 12, 486, 15914, 12, 536, 12, 2928, 29, 403, 12, 1015, 29, 403, 12, 25811, 29, 403, 304, 398, 291, 423, 2343, 275, 488, 267, 291, 423, 3174, 63, 815, 275, 488, 398, 291, 14, 1419, 275, 486, 15914, 14, 1419, 267, 291, 14, 2918, 275, 486, 15914, 14, 2918, 398, 291, 14, 354, 275, 536, 267, 291, 14, 1023, 275, 1015, 267, 291, 14, 2164, 275, 2928, 503, 536, 267, 291, 14, 17143, 275, 25811, 398, 291, 14, 515, 275, 334, 736, 14, 515, 14, 904, 8, 24806, 14, 8050, 63, 515, 12, 291, 14, 354, 430, 339, 347, 5267, 63, 504, 63, 17143, 63, 6404, 8, 277, 304, 398, 327, 642, 883, 506, 7526, 370, 7981, 625, 19361, 12075, 3053, 1325, 3913, 1050, 892, 7869, 7444, 314, 1233, 365, 2597, 4588, 267, 340, 25811, 440, 315, 291, 14, 551, 706, 26, 288, 291, 14, 2918, 14, 2918, 480, 1918, 450, 83, 25811, 365, 440, 5544, 3748, 2, 450, 25811, 9, 288, 372, 756, 398, 21628, 275, 5549, 14, 11983, 342, 267, 7289, 63, 1760, 275, 359, 17143, 12, 283, 6311, 297, 4719, 63, 633, 12, 291, 14, 354, 61, 267, 543, 1551, 2336, 2374, 15, 2307, 297, 283, 87, 358, 465, 4866, 2307, 26, 288, 862, 26, 355, 291, 14, 2918, 14, 2918, 6096, 14043, 26, 450, 83, 2, 450, 298, 3680, 904, 8, 6311, 63, 1760, 430, 355, 17758, 275, 3873, 14, 7942, 8, 6311, 63, 1760, 12, 8288, 29, 11567, 12, 3839, 29, 19778, 12, 4635, 29, 19778, 9, 288, 871, 26, 355, 746, 13358, 480, 705, 14043, 26, 450, 83, 2, 450, 298, 3680, 904, 8, 6311, 63, 1760, 430, 288, 4819, 275, 17758, 14, 2573, 342, 267, 340, 4819, 1137, 378, 26, 288, 291, 14, 2918, 14, 2918, 6096, 1414, 450, 83, 3405, 2, 450, 283, 1987, 904, 8, 6311, 63, 1760, 430, 288, 291, 14, 2918, 14, 2918, 480, 221, 315, 2082, 450, 83, 2, 450, 21628, 9, 288, 372, 756, 398, 2388, 63, 493, 275, 5549, 14, 19320, 8, 1807, 29, 797, 12, 4739, 15637, 5369, 358, 267, 340, 25811, 508, 283, 9208, 356, 288, 6359, 63, 1760, 275, 788, 9208, 297, 283, 6404, 297, 2850, 1861, 297, 2071, 83, 6687, 450, 291, 14, 354, 61, 288, 340, 4719, 63, 1023, 26, 355, 6359, 63, 1760, 14, 2880, 24829, 82, 297, 4719, 63, 1023, 566, 288, 6359, 63, 1760, 14, 740, 8, 808, 63, 493, 14, 354, 9, 267, 340, 25811, 508, 283, 3187, 356, 288, 6359, 63, 1760, 275, 788, 3187, 297, 283, 6404, 297, 2850, 1861, 2458, 83, 4805, 450, 291, 14, 354, 12, 2850, 1199, 2458, 83, 7, 450, 2388, 63, 493, 14, 354, 61, 288, 340, 4719, 63, 1023, 26, 355, 6359, 63, 1760, 14, 740, 8, 3756, 63, 1023, 9, 288, 587, 26, 355, 6359, 63, 1760, 14, 740, 360, 5211, 358, 398, 543, 1551, 2336, 2374, 15, 2307, 297, 283, 87, 358, 465, 4866, 2307, 26, 288, 291, 14, 2918, 14, 2918, 6096, 14043, 26, 450, 83, 2, 450, 298, 3680, 904, 8, 6404, 63, 1760, 430, 288, 17758, 275, 3873, 14, 7942, 8, 6404, 63, 1760, 12, 8288, 29, 736, 14, 515, 14, 904, 8, 11567, 12, 291, 14, 354, 395, 3660, 4635, 29, 19778, 12, 3839, 29, 19778, 9, 288, 4819, 275, 17758, 14, 2573, 342, 267, 340, 4819, 1137, 378, 26, 288, 291, 14, 2918, 14, 2918, 6096, 1414, 450, 83, 3405, 2, 450, 283, 1987, 904, 8, 6404, 63, 1760, 430, 288, 291, 14, 2918, 14, 2918, 480, 221, 315, 2082, 450, 83, 2, 450, 21628, 9, 288, 372, 756, 398, 20978, 8, 11567, 12, 3686, 63, 2550, 29, 549, 9, 398, 372, 2388, 63, 493, 14, 354, 339, 768, 1829, 272, 347, 3341, 8, 277, 304, 267, 408, 267, 1803, 4719, 3341, 267, 408, 267, 340, 291, 423, 2343, 365, 488, 26, 288, 3404, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 515, 12, 291, 14, 10614, 63, 5848, 9, 288, 340, 747, 14, 515, 14, 6292, 8, 2024, 63, 515, 304, 355, 862, 26, 490, 289, 275, 1551, 8, 2024, 63, 515, 12, 283, 82, 358, 490, 291, 423, 2343, 275, 8864, 14, 3489, 63, 912, 8, 70, 9, 355, 871 ]
[ 199, 3, 199, 3, 334, 35, 9, 6900, 12, 699, 18429, 445, 679, 65, 665, 66, 331, 696, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3949, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 3873, 199, 646, 13608, 199, 646, 5549, 199, 646, 8864, 199, 504, 5145, 492, 20978, 199, 504, 4011, 18, 492, 18279, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2550, 492, 13358, 199, 199, 533, 598, 15914, 7422, 8, 785, 304, 339, 32501, 63, 5153, 3053, 275, 663, 2941, 3187, 297, 283, 9208, 1105, 272, 603, 15808, 63, 5848, 275, 747, 14, 515, 14, 904, 360, 2024, 297, 283, 973, 14, 11714, 358, 272, 603, 15808, 63, 16811, 275, 747, 14, 515, 14, 904, 360, 2024, 297, 1987, 24806, 63, 3174, 63, 815, 358, 272, 9769, 906, 63, 14455, 275, 661, 4322, 1673, 1725, 1673, 5586, 1673, 2024, 1673, 5054, 1673, 5876, 1673, 2936, 358, 2378, 347, 636, 826, 721, 277, 12, 486, 15914, 12, 536, 12, 2928, 29, 403, 12, 1015, 29, 403, 12, 25811, 29, 403, 304, 398, 291, 423, 2343, 275, 488, 267, 291, 423, 3174, 63, 815, 275, 488, 398, 291, 14, 1419, 275, 486, 15914, 14, 1419, 267, 291, 14, 2918, 275, 486, 15914, 14, 2918, 398, 291, 14, 354, 275, 536, 267, 291, 14, 1023, 275, 1015, 267, 291, 14, 2164, 275, 2928, 503, 536, 267, 291, 14, 17143, 275, 25811, 398, 291, 14, 515, 275, 334, 736, 14, 515, 14, 904, 8, 24806, 14, 8050, 63, 515, 12, 291, 14, 354, 430, 339, 347, 5267, 63, 504, 63, 17143, 63, 6404, 8, 277, 304, 398, 327, 642, 883, 506, 7526, 370, 7981, 625, 19361, 12075, 3053, 1325, 3913, 1050, 892, 7869, 7444, 314, 1233, 365, 2597, 4588, 267, 340, 25811, 440, 315, 291, 14, 551, 706, 26, 288, 291, 14, 2918, 14, 2918, 480, 1918, 450, 83, 25811, 365, 440, 5544, 3748, 2, 450, 25811, 9, 288, 372, 756, 398, 21628, 275, 5549, 14, 11983, 342, 267, 7289, 63, 1760, 275, 359, 17143, 12, 283, 6311, 297, 4719, 63, 633, 12, 291, 14, 354, 61, 267, 543, 1551, 2336, 2374, 15, 2307, 297, 283, 87, 358, 465, 4866, 2307, 26, 288, 862, 26, 355, 291, 14, 2918, 14, 2918, 6096, 14043, 26, 450, 83, 2, 450, 298, 3680, 904, 8, 6311, 63, 1760, 430, 355, 17758, 275, 3873, 14, 7942, 8, 6311, 63, 1760, 12, 8288, 29, 11567, 12, 3839, 29, 19778, 12, 4635, 29, 19778, 9, 288, 871, 26, 355, 746, 13358, 480, 705, 14043, 26, 450, 83, 2, 450, 298, 3680, 904, 8, 6311, 63, 1760, 430, 288, 4819, 275, 17758, 14, 2573, 342, 267, 340, 4819, 1137, 378, 26, 288, 291, 14, 2918, 14, 2918, 6096, 1414, 450, 83, 3405, 2, 450, 283, 1987, 904, 8, 6311, 63, 1760, 430, 288, 291, 14, 2918, 14, 2918, 480, 221, 315, 2082, 450, 83, 2, 450, 21628, 9, 288, 372, 756, 398, 2388, 63, 493, 275, 5549, 14, 19320, 8, 1807, 29, 797, 12, 4739, 15637, 5369, 358, 267, 340, 25811, 508, 283, 9208, 356, 288, 6359, 63, 1760, 275, 788, 9208, 297, 283, 6404, 297, 2850, 1861, 297, 2071, 83, 6687, 450, 291, 14, 354, 61, 288, 340, 4719, 63, 1023, 26, 355, 6359, 63, 1760, 14, 2880, 24829, 82, 297, 4719, 63, 1023, 566, 288, 6359, 63, 1760, 14, 740, 8, 808, 63, 493, 14, 354, 9, 267, 340, 25811, 508, 283, 3187, 356, 288, 6359, 63, 1760, 275, 788, 3187, 297, 283, 6404, 297, 2850, 1861, 2458, 83, 4805, 450, 291, 14, 354, 12, 2850, 1199, 2458, 83, 7, 450, 2388, 63, 493, 14, 354, 61, 288, 340, 4719, 63, 1023, 26, 355, 6359, 63, 1760, 14, 740, 8, 3756, 63, 1023, 9, 288, 587, 26, 355, 6359, 63, 1760, 14, 740, 360, 5211, 358, 398, 543, 1551, 2336, 2374, 15, 2307, 297, 283, 87, 358, 465, 4866, 2307, 26, 288, 291, 14, 2918, 14, 2918, 6096, 14043, 26, 450, 83, 2, 450, 298, 3680, 904, 8, 6404, 63, 1760, 430, 288, 17758, 275, 3873, 14, 7942, 8, 6404, 63, 1760, 12, 8288, 29, 736, 14, 515, 14, 904, 8, 11567, 12, 291, 14, 354, 395, 3660, 4635, 29, 19778, 12, 3839, 29, 19778, 9, 288, 4819, 275, 17758, 14, 2573, 342, 267, 340, 4819, 1137, 378, 26, 288, 291, 14, 2918, 14, 2918, 6096, 1414, 450, 83, 3405, 2, 450, 283, 1987, 904, 8, 6404, 63, 1760, 430, 288, 291, 14, 2918, 14, 2918, 480, 221, 315, 2082, 450, 83, 2, 450, 21628, 9, 288, 372, 756, 398, 20978, 8, 11567, 12, 3686, 63, 2550, 29, 549, 9, 398, 372, 2388, 63, 493, 14, 354, 339, 768, 1829, 272, 347, 3341, 8, 277, 304, 267, 408, 267, 1803, 4719, 3341, 267, 408, 267, 340, 291, 423, 2343, 365, 488, 26, 288, 3404, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 515, 12, 291, 14, 10614, 63, 5848, 9, 288, 340, 747, 14, 515, 14, 6292, 8, 2024, 63, 515, 304, 355, 862, 26, 490, 289, 275, 1551, 8, 2024, 63, 515, 12, 283, 82, 358, 490, 291, 423, 2343, 275, 8864, 14, 3489, 63, 912, 8, 70, 9, 355, 871, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
willhardy/django
django/urls/resolvers.py
18
16937
""" This module converts requested URLs to callback view functions. RegexURLResolver is the main class here. Its resolve() method takes a URL (as a string) and returns a ResolverMatch object which provides access to all attributes of the resolved URL match. """ from __future__ import unicode_literals import functools import re from importlib import import_module from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils import lru_cache, six from django.utils.datastructures import MultiValueDict from django.utils.encoding import force_str, force_text from django.utils.functional import cached_property from django.utils.http import RFC3986_SUBDELIMS, urlquote from django.utils.regex_helper import normalize from django.utils.translation import get_language from .exceptions import NoReverseMatch, Resolver404 from .utils import get_callable class ResolverMatch(object): def __init__(self, func, args, kwargs, url_name=None, app_names=None, namespaces=None): self.func = func self.args = args self.kwargs = kwargs self.url_name = url_name # If a URLRegexResolver doesn't have a namespace or app_name, it passes # in an empty value. self.app_names = [x for x in app_names if x] if app_names else [] self.app_name = ':'.join(self.app_names) self.namespaces = [x for x in namespaces if x] if namespaces else [] self.namespace = ':'.join(self.namespaces) if not hasattr(func, '__name__'): # A class-based view self._func_path = '.'.join([func.__class__.__module__, func.__class__.__name__]) else: # A function-based view self._func_path = '.'.join([func.__module__, func.__name__]) view_path = url_name or self._func_path self.view_name = ':'.join(self.namespaces + [view_path]) def __getitem__(self, index): return (self.func, self.args, self.kwargs)[index] def __repr__(self): return "ResolverMatch(func=%s, args=%s, kwargs=%s, url_name=%s, app_names=%s, namespaces=%s)" % ( self._func_path, self.args, self.kwargs, self.url_name, self.app_names, self.namespaces, ) @lru_cache.lru_cache(maxsize=None) def get_resolver(urlconf=None): if urlconf is None: from django.conf import settings urlconf = settings.ROOT_URLCONF return RegexURLResolver(r'^/', urlconf) @lru_cache.lru_cache(maxsize=None) def get_ns_resolver(ns_pattern, resolver): # Build a namespaced resolver for the given parent URLconf pattern. # This makes it possible to have captured parameters in the parent # URLconf pattern. ns_resolver = RegexURLResolver(ns_pattern, resolver.url_patterns) return RegexURLResolver(r'^/', [ns_resolver]) class LocaleRegexProvider(object): """ A mixin to provide a default regex property which can vary by active language. """ def __init__(self, regex): # regex is either a string representing a regular expression, or a # translatable string (using ugettext_lazy) representing a regular # expression. self._regex = regex self._regex_dict = {} @property def regex(self): """ Return a compiled regular expression based on the activate language. """ language_code = get_language() if language_code not in self._regex_dict: regex = self._regex if isinstance(self._regex, six.string_types) else force_text(self._regex) try: compiled_regex = re.compile(regex, re.UNICODE) except re.error as e: raise ImproperlyConfigured( '"%s" is not a valid regular expression: %s' % (regex, six.text_type(e)) ) self._regex_dict[language_code] = compiled_regex return self._regex_dict[language_code] class RegexURLPattern(LocaleRegexProvider): def __init__(self, regex, callback, default_args=None, name=None): LocaleRegexProvider.__init__(self, regex) self.callback = callback # the view self.default_args = default_args or {} self.name = name def __repr__(self): return force_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern)) def resolve(self, path): match = self.regex.search(path) if match: # If there are any named groups, use those as kwargs, ignoring # non-named groups. Otherwise, pass all non-named arguments as # positional arguments. kwargs = match.groupdict() args = () if kwargs else match.groups() # In both cases, pass any extra_kwargs as **kwargs. kwargs.update(self.default_args) return ResolverMatch(self.callback, args, kwargs, self.name) @cached_property def lookup_str(self): """ A string that identifies the view (e.g. 'path.to.view_function' or 'path.to.ClassBasedView'). """ callback = self.callback # Python 3.5 collapses nested partials, so can change "while" to "if" # when it's the minimum supported version. while isinstance(callback, functools.partial): callback = callback.func if not hasattr(callback, '__name__'): return callback.__module__ + "." + callback.__class__.__name__ else: return callback.__module__ + "." + callback.__name__ class RegexURLResolver(LocaleRegexProvider): def __init__(self, regex, urlconf_name, default_kwargs=None, app_name=None, namespace=None): LocaleRegexProvider.__init__(self, regex) # urlconf_name is the dotted Python path to the module defining # urlpatterns. It may also be an object with an urlpatterns attribute # or urlpatterns itself. self.urlconf_name = urlconf_name self.callback = None self.default_kwargs = default_kwargs or {} self.namespace = namespace self.app_name = app_name self._reverse_dict = {} self._namespace_dict = {} self._app_dict = {} # set of dotted paths to all functions and classes that are used in # urlpatterns self._callback_strs = set() self._populated = False def __repr__(self): if isinstance(self.urlconf_name, list) and len(self.urlconf_name): # Don't bother to output the whole list, it can be huge urlconf_repr = '<%s list>' % self.urlconf_name[0].__class__.__name__ else: urlconf_repr = repr(self.urlconf_name) return str('<%s %s (%s:%s) %s>') % ( self.__class__.__name__, urlconf_repr, self.app_name, self.namespace, self.regex.pattern, ) def _populate(self): lookups = MultiValueDict() namespaces = {} apps = {} language_code = get_language() for pattern in reversed(self.url_patterns): if isinstance(pattern, RegexURLPattern): self._callback_strs.add(pattern.lookup_str) p_pattern = pattern.regex.pattern if p_pattern.startswith('^'): p_pattern = p_pattern[1:] if isinstance(pattern, RegexURLResolver): if pattern.namespace: namespaces[pattern.namespace] = (p_pattern, pattern) if pattern.app_name: apps.setdefault(pattern.app_name, []).append(pattern.namespace) else: parent_pat = pattern.regex.pattern for name in pattern.reverse_dict: for matches, pat, defaults in pattern.reverse_dict.getlist(name): new_matches = normalize(parent_pat + pat) lookups.appendlist( name, ( new_matches, p_pattern + pat, dict(defaults, **pattern.default_kwargs), ) ) for namespace, (prefix, sub_pattern) in pattern.namespace_dict.items(): namespaces[namespace] = (p_pattern + prefix, sub_pattern) for app_name, namespace_list in pattern.app_dict.items(): apps.setdefault(app_name, []).extend(namespace_list) self._callback_strs.update(pattern._callback_strs) else: bits = normalize(p_pattern) lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args)) if pattern.name is not None: lookups.appendlist(pattern.name, (bits, p_pattern, pattern.default_args)) self._reverse_dict[language_code] = lookups self._namespace_dict[language_code] = namespaces self._app_dict[language_code] = apps self._populated = True @property def reverse_dict(self): language_code = get_language() if language_code not in self._reverse_dict: self._populate() return self._reverse_dict[language_code] @property def namespace_dict(self): language_code = get_language() if language_code not in self._namespace_dict: self._populate() return self._namespace_dict[language_code] @property def app_dict(self): language_code = get_language() if language_code not in self._app_dict: self._populate() return self._app_dict[language_code] def _is_callback(self, name): if not self._populated: self._populate() return name in self._callback_strs def resolve(self, path): path = force_text(path) # path may be a reverse_lazy object tried = [] match = self.regex.search(path) if match: new_path = path[match.end():] for pattern in self.url_patterns: try: sub_match = pattern.resolve(new_path) except Resolver404 as e: sub_tried = e.args[0].get('tried') if sub_tried is not None: tried.extend([pattern] + t for t in sub_tried) else: tried.append([pattern]) else: if sub_match: # Merge captured arguments in match with submatch sub_match_dict = dict(match.groupdict(), **self.default_kwargs) sub_match_dict.update(sub_match.kwargs) # If there are *any* named groups, ignore all non-named groups. # Otherwise, pass all non-named arguments as positional arguments. sub_match_args = sub_match.args if not sub_match_dict: sub_match_args = match.groups() + sub_match.args return ResolverMatch( sub_match.func, sub_match_args, sub_match_dict, sub_match.url_name, [self.app_name] + sub_match.app_names, [self.namespace] + sub_match.namespaces, ) tried.append([pattern]) raise Resolver404({'tried': tried, 'path': new_path}) raise Resolver404({'path': path}) @cached_property def urlconf_module(self): if isinstance(self.urlconf_name, six.string_types): return import_module(self.urlconf_name) else: return self.urlconf_name @cached_property def url_patterns(self): # urlconf_module might be a valid set of patterns, so we default to it patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) try: iter(patterns) except TypeError: msg = ( "The included URLconf '{name}' does not appear to have any " "patterns in it. If you see valid patterns in the file then " "the issue is probably caused by a circular import." ) raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) return patterns def resolve_error_handler(self, view_type): callback = getattr(self.urlconf_module, 'handler%s' % view_type, None) if not callback: # No handler specified in file; use lazy import, since # django.conf.urls imports this file. from django.conf import urls callback = getattr(urls, 'handler%s' % view_type) return get_callable(callback), {} def _reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs): if args and kwargs: raise ValueError("Don't mix *args and **kwargs in call to reverse()!") text_args = [force_text(v) for v in args] text_kwargs = {k: force_text(v) for (k, v) in kwargs.items()} if not self._populated: self._populate() possibilities = self.reverse_dict.getlist(lookup_view) for possibility, pattern, defaults in possibilities: for result, params in possibility: if args: if len(args) != len(params): continue candidate_subs = dict(zip(params, text_args)) else: if (set(kwargs.keys()) | set(defaults.keys()) != set(params) | set(defaults.keys())): continue matches = True for k, v in defaults.items(): if kwargs.get(k, v) != v: matches = False break if not matches: continue candidate_subs = text_kwargs # WSGI provides decoded URLs, without %xx escapes, and the URL # resolver operates on such URLs. First substitute arguments # without quoting to build a decoded URL and look for a match. # Then, if we have a match, redo the substitution with quoted # arguments in order to return a properly encoded URL. candidate_pat = _prefix.replace('%', '%%') + result if re.search('^%s%s' % (re.escape(_prefix), pattern), candidate_pat % candidate_subs, re.UNICODE): # safe characters from `pchar` definition of RFC 3986 url = urlquote(candidate_pat % candidate_subs, safe=RFC3986_SUBDELIMS + str('/~:@')) # Don't allow construction of scheme relative urls. if url.startswith('//'): url = '/%%2F%s' % url[2:] return url # lookup_view can be URL name or callable, but callables are not # friendly in error messages. m = getattr(lookup_view, '__module__', None) n = getattr(lookup_view, '__name__', None) if m is not None and n is not None: lookup_view_s = "%s.%s" % (m, n) else: lookup_view_s = lookup_view patterns = [pattern for (possibility, pattern, defaults) in possibilities] raise NoReverseMatch( "Reverse for '%s' with arguments '%s' and keyword " "arguments '%s' not found. %d pattern(s) tried: %s" % (lookup_view_s, args, kwargs, len(patterns), patterns) ) class LocaleRegexURLResolver(RegexURLResolver): """ A URL resolver that always matches the active language code as URL prefix. Rather than taking a regex argument, we just override the ``regex`` function to always return the active language-code as regex. """ def __init__( self, urlconf_name, default_kwargs=None, app_name=None, namespace=None, prefix_default_language=True, ): super(LocaleRegexURLResolver, self).__init__( None, urlconf_name, default_kwargs, app_name, namespace, ) self.prefix_default_language = prefix_default_language @property def regex(self): language_code = get_language() or settings.LANGUAGE_CODE if language_code not in self._regex_dict: if language_code == settings.LANGUAGE_CODE and not self.prefix_default_language: regex_string = '' else: regex_string = '^%s/' % language_code self._regex_dict[language_code] = re.compile(regex_string, re.UNICODE) return self._regex_dict[language_code]
bsd-3-clause
[ 624, 199, 2765, 859, 15373, 5839, 10867, 370, 3233, 2455, 3423, 14, 199, 199, 5103, 2632, 12407, 365, 314, 2446, 1021, 2348, 14, 22940, 7512, 342, 1083, 6181, 282, 2851, 334, 305, 199, 65, 1059, 9, 436, 2529, 282, 26046, 4486, 909, 1314, 6571, 2879, 370, 1006, 199, 2987, 402, 314, 12152, 2851, 1336, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 9143, 199, 646, 295, 199, 504, 14802, 492, 492, 63, 578, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 492, 634, 6558, 63, 1637, 12, 3816, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 495, 12, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 1014, 492, 7329, 29451, 63, 6348, 4424, 1469, 51, 12, 1166, 3513, 199, 504, 1639, 14, 1208, 14, 3821, 63, 3676, 492, 7666, 199, 504, 1639, 14, 1208, 14, 6893, 492, 664, 63, 3671, 199, 199, 504, 1275, 3924, 492, 32036, 12, 26046, 5188, 199, 504, 1275, 1208, 492, 664, 63, 8296, 421, 199, 533, 26046, 4486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 2562, 12, 1249, 12, 2074, 12, 1166, 63, 354, 29, 403, 12, 1145, 63, 1247, 29, 403, 12, 10747, 29, 403, 304, 267, 291, 14, 1532, 275, 2562, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 958, 275, 2074, 267, 291, 14, 633, 63, 354, 275, 1166, 63, 354, 398, 327, 982, 282, 2851, 5103, 12407, 3181, 1133, 1172, 282, 3231, 503, 1145, 63, 354, 12, 652, 14933, 267, 327, 315, 376, 2701, 574, 14, 267, 291, 14, 571, 63, 1247, 275, 359, 88, 367, 671, 315, 1145, 63, 1247, 340, 671, 61, 340, 1145, 63, 1247, 587, 942, 267, 291, 14, 571, 63, 354, 275, 29010, 904, 8, 277, 14, 571, 63, 1247, 9, 267, 291, 14, 9247, 275, 359, 88, 367, 671, 315, 10747, 340, 671, 61, 340, 10747, 587, 942, 267, 291, 14, 3251, 275, 29010, 904, 8, 277, 14, 9247, 9, 398, 340, 440, 2688, 8, 1532, 12, 2560, 354, 12168, 288, 327, 437, 1021, 13, 6788, 2455, 288, 291, 423, 1532, 63, 515, 275, 15671, 904, 779, 1532, 855, 533, 4914, 578, 3108, 2562, 855, 533, 4914, 354, 363, 566, 267, 587, 26, 288, 327, 437, 805, 13, 6788, 2455, 288, 291, 423, 1532, 63, 515, 275, 15671, 904, 779, 1532, 855, 578, 3108, 2562, 855, 354, 363, 566, 398, 2455, 63, 515, 275, 1166, 63, 354, 503, 291, 423, 1532, 63, 515, 267, 291, 14, 1345, 63, 354, 275, 29010, 904, 8, 277, 14, 9247, 435, 359, 1345, 63, 515, 566, 339, 347, 636, 6095, 721, 277, 12, 1478, 304, 267, 372, 334, 277, 14, 1532, 12, 291, 14, 589, 12, 291, 14, 958, 2788, 1080, 61, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 12407, 4486, 8, 1532, 2458, 83, 12, 1249, 2458, 83, 12, 2074, 2458, 83, 12, 1166, 63, 354, 2458, 83, 12, 1145, 63, 1247, 2458, 83, 12, 10747, 2458, 83, 2924, 450, 334, 288, 291, 423, 1532, 63, 515, 12, 291, 14, 589, 12, 291, 14, 958, 12, 291, 14, 633, 63, 354, 12, 288, 291, 14, 571, 63, 1247, 12, 291, 14, 9247, 12, 267, 776, 421, 199, 32, 25003, 63, 1637, 14, 25003, 63, 1637, 8, 13634, 29, 403, 9, 199, 318, 664, 63, 7717, 8, 21801, 29, 403, 304, 272, 340, 30009, 365, 488, 26, 267, 687, 1639, 14, 2190, 492, 2202, 267, 30009, 275, 2202, 14, 5441, 63, 18125, 272, 372, 12939, 2632, 12407, 8, 82, 4289, 3678, 30009, 9, 421, 199, 32, 25003, 63, 1637, 14, 25003, 63, 1637, 8, 13634, 29, 403, 9, 199, 318, 664, 63, 561, 63, 7717, 8, 561, 63, 3401, 12, 15611, 304, 272, 327, 6516, 282, 3231, 68, 15611, 367, 314, 1627, 1676, 2851, 2190, 3851, 14, 272, 327, 961, 7704, 652, 3962, 370, 1172, 17487, 2633, 315, 314, 1676, 272, 327, 2851, 2190, 3851, 14, 272, 700, 63, 7717, 275, 12939, 2632, 12407, 8, 561, 63, 3401, 12, 15611, 14, 633, 63, 7435, 9, 272, 372, 12939, 2632, 12407, 8, 82, 4289, 3678, 359, 561, 63, 7717, 566, 421, 199, 533, 28298, 5103, 6663, 8, 785, 304, 272, 408, 272, 437, 20048, 370, 5647, 282, 849, 5163, 3324, 1314, 883, 17083, 701, 4702, 272, 2637, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5163, 304, 267, 327, 5163, 365, 1902, 282, 1059, 6144, 282, 5578, 3965, 12, 503, 282, 267, 327, 1752, 25099, 1059, 334, 4941, 10366, 63, 6395, 9, 6144, 282, 5578, 267, 327, 3965, 14, 267, 291, 423, 3821, 275, 5163, 267, 291, 423, 3821, 63, 807, 275, 1052, 339, 768, 1829, 272, 347, 5163, 8, 277, 304, 267, 408, 267, 1432, 282, 10311, 5578, 3965, 4079, 641, 314, 15422, 2637, 14, 267, 408, 267, 2637, 63, 600, 275, 664, 63, 3671, 342, 267, 340, 2637, 63, 600, 440, 315, 291, 423, 3821, 63, 807, 26, 288, 5163, 275, 291, 423, 3821, 340, 1228, 8, 277, 423, 3821, 12, 3816, 14, 875, 63, 1313, 9, 587, 3542, 63, 505, 8, 277, 423, 3821, 9, 288, 862, 26, 355, 10311, 63, 3821, 275, 295, 14, 2014, 8, 3821, 12, 295, 14, 12819, 9, 288, 871, 295, 14, 705, 465, 325, 26, 355, 746, 11897, 8, 490, 18253, 83, 2, 365, 440, 282, 1686, 5578, 3965, 26, 450, 83, 7, 450, 490, 334, 3821, 12, 3816, 14, 505, 63, 466, 8, 69, 430, 355, 776, 288, 291, 423, 3821, 63, 807, 59, 3671, 63, 600, 61, 275, 10311, 63, 3821, 267, 372, 291, 423, 3821, 63, 807, 59, 3671, 63, 600, 61, 421, 199, 533, 12939, 2632, 9959, 8, 20342, 5103, 6663, 304, 272, 347, 636, 826, 721, 277, 12, 5163, 12, 3233, 12, 849, 63, 589, 29, 403, 12, 536, 29, 403, 304, 267, 28298, 5103, 6663, 855, 826, 721, 277, 12, 5163, 9, 267, 291, 14, 3058, 275, 3233, 221, 327, 314, 2455, 267, 291, 14 ]
[ 199, 2765, 859, 15373, 5839, 10867, 370, 3233, 2455, 3423, 14, 199, 199, 5103, 2632, 12407, 365, 314, 2446, 1021, 2348, 14, 22940, 7512, 342, 1083, 6181, 282, 2851, 334, 305, 199, 65, 1059, 9, 436, 2529, 282, 26046, 4486, 909, 1314, 6571, 2879, 370, 1006, 199, 2987, 402, 314, 12152, 2851, 1336, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 9143, 199, 646, 295, 199, 504, 14802, 492, 492, 63, 578, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 492, 634, 6558, 63, 1637, 12, 3816, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 495, 12, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 1014, 492, 7329, 29451, 63, 6348, 4424, 1469, 51, 12, 1166, 3513, 199, 504, 1639, 14, 1208, 14, 3821, 63, 3676, 492, 7666, 199, 504, 1639, 14, 1208, 14, 6893, 492, 664, 63, 3671, 199, 199, 504, 1275, 3924, 492, 32036, 12, 26046, 5188, 199, 504, 1275, 1208, 492, 664, 63, 8296, 421, 199, 533, 26046, 4486, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 2562, 12, 1249, 12, 2074, 12, 1166, 63, 354, 29, 403, 12, 1145, 63, 1247, 29, 403, 12, 10747, 29, 403, 304, 267, 291, 14, 1532, 275, 2562, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 958, 275, 2074, 267, 291, 14, 633, 63, 354, 275, 1166, 63, 354, 398, 327, 982, 282, 2851, 5103, 12407, 3181, 1133, 1172, 282, 3231, 503, 1145, 63, 354, 12, 652, 14933, 267, 327, 315, 376, 2701, 574, 14, 267, 291, 14, 571, 63, 1247, 275, 359, 88, 367, 671, 315, 1145, 63, 1247, 340, 671, 61, 340, 1145, 63, 1247, 587, 942, 267, 291, 14, 571, 63, 354, 275, 29010, 904, 8, 277, 14, 571, 63, 1247, 9, 267, 291, 14, 9247, 275, 359, 88, 367, 671, 315, 10747, 340, 671, 61, 340, 10747, 587, 942, 267, 291, 14, 3251, 275, 29010, 904, 8, 277, 14, 9247, 9, 398, 340, 440, 2688, 8, 1532, 12, 2560, 354, 12168, 288, 327, 437, 1021, 13, 6788, 2455, 288, 291, 423, 1532, 63, 515, 275, 15671, 904, 779, 1532, 855, 533, 4914, 578, 3108, 2562, 855, 533, 4914, 354, 363, 566, 267, 587, 26, 288, 327, 437, 805, 13, 6788, 2455, 288, 291, 423, 1532, 63, 515, 275, 15671, 904, 779, 1532, 855, 578, 3108, 2562, 855, 354, 363, 566, 398, 2455, 63, 515, 275, 1166, 63, 354, 503, 291, 423, 1532, 63, 515, 267, 291, 14, 1345, 63, 354, 275, 29010, 904, 8, 277, 14, 9247, 435, 359, 1345, 63, 515, 566, 339, 347, 636, 6095, 721, 277, 12, 1478, 304, 267, 372, 334, 277, 14, 1532, 12, 291, 14, 589, 12, 291, 14, 958, 2788, 1080, 61, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 12407, 4486, 8, 1532, 2458, 83, 12, 1249, 2458, 83, 12, 2074, 2458, 83, 12, 1166, 63, 354, 2458, 83, 12, 1145, 63, 1247, 2458, 83, 12, 10747, 2458, 83, 2924, 450, 334, 288, 291, 423, 1532, 63, 515, 12, 291, 14, 589, 12, 291, 14, 958, 12, 291, 14, 633, 63, 354, 12, 288, 291, 14, 571, 63, 1247, 12, 291, 14, 9247, 12, 267, 776, 421, 199, 32, 25003, 63, 1637, 14, 25003, 63, 1637, 8, 13634, 29, 403, 9, 199, 318, 664, 63, 7717, 8, 21801, 29, 403, 304, 272, 340, 30009, 365, 488, 26, 267, 687, 1639, 14, 2190, 492, 2202, 267, 30009, 275, 2202, 14, 5441, 63, 18125, 272, 372, 12939, 2632, 12407, 8, 82, 4289, 3678, 30009, 9, 421, 199, 32, 25003, 63, 1637, 14, 25003, 63, 1637, 8, 13634, 29, 403, 9, 199, 318, 664, 63, 561, 63, 7717, 8, 561, 63, 3401, 12, 15611, 304, 272, 327, 6516, 282, 3231, 68, 15611, 367, 314, 1627, 1676, 2851, 2190, 3851, 14, 272, 327, 961, 7704, 652, 3962, 370, 1172, 17487, 2633, 315, 314, 1676, 272, 327, 2851, 2190, 3851, 14, 272, 700, 63, 7717, 275, 12939, 2632, 12407, 8, 561, 63, 3401, 12, 15611, 14, 633, 63, 7435, 9, 272, 372, 12939, 2632, 12407, 8, 82, 4289, 3678, 359, 561, 63, 7717, 566, 421, 199, 533, 28298, 5103, 6663, 8, 785, 304, 272, 408, 272, 437, 20048, 370, 5647, 282, 849, 5163, 3324, 1314, 883, 17083, 701, 4702, 272, 2637, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5163, 304, 267, 327, 5163, 365, 1902, 282, 1059, 6144, 282, 5578, 3965, 12, 503, 282, 267, 327, 1752, 25099, 1059, 334, 4941, 10366, 63, 6395, 9, 6144, 282, 5578, 267, 327, 3965, 14, 267, 291, 423, 3821, 275, 5163, 267, 291, 423, 3821, 63, 807, 275, 1052, 339, 768, 1829, 272, 347, 5163, 8, 277, 304, 267, 408, 267, 1432, 282, 10311, 5578, 3965, 4079, 641, 314, 15422, 2637, 14, 267, 408, 267, 2637, 63, 600, 275, 664, 63, 3671, 342, 267, 340, 2637, 63, 600, 440, 315, 291, 423, 3821, 63, 807, 26, 288, 5163, 275, 291, 423, 3821, 340, 1228, 8, 277, 423, 3821, 12, 3816, 14, 875, 63, 1313, 9, 587, 3542, 63, 505, 8, 277, 423, 3821, 9, 288, 862, 26, 355, 10311, 63, 3821, 275, 295, 14, 2014, 8, 3821, 12, 295, 14, 12819, 9, 288, 871, 295, 14, 705, 465, 325, 26, 355, 746, 11897, 8, 490, 18253, 83, 2, 365, 440, 282, 1686, 5578, 3965, 26, 450, 83, 7, 450, 490, 334, 3821, 12, 3816, 14, 505, 63, 466, 8, 69, 430, 355, 776, 288, 291, 423, 3821, 63, 807, 59, 3671, 63, 600, 61, 275, 10311, 63, 3821, 267, 372, 291, 423, 3821, 63, 807, 59, 3671, 63, 600, 61, 421, 199, 533, 12939, 2632, 9959, 8, 20342, 5103, 6663, 304, 272, 347, 636, 826, 721, 277, 12, 5163, 12, 3233, 12, 849, 63, 589, 29, 403, 12, 536, 29, 403, 304, 267, 28298, 5103, 6663, 855, 826, 721, 277, 12, 5163, 9, 267, 291, 14, 3058, 275, 3233, 221, 327, 314, 2455, 267, 291, 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, 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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 ]
PrincetonUniversity/seisflows
seisflows/workflow/test_postprocess.py
2
1036
# # This is Seisflows # # See LICENCE file # ############################################################################### # Import system modules import sys # Import Numpy import numpy as np # Local imports from seisflows.tools import unix from seisflows.tools.tools import exists from seisflows.config import custom_import, ParameterError from seisflows.workflow.base import base PAR = sys.modules['seisflows_parameters'] PATH = sys.modules['seisflows_paths'] solver = sys.modules['seisflows_solver'] postprocess = sys.modules['seisflows_postprocess'] migration = custom_import('workflow', 'migration')() class test_postprocess(base): """ Postprocessing class """ def check(self): """ Checks parameters and paths """ migration.check() if 'INPUT' not in PATH: setattr(PATH, 'INPUT', None) def main(self): """ Writes gradient of objective function """ if not PATH.INPUT: migration.main() postprocess.process_kernels()
bsd-2-clause
[ 3, 199, 3, 961, 365, 3240, 374, 22777, 199, 3, 199, 3, 1666, 5059, 6013, 570, 199, 3, 199, 11490, 199, 199, 3, 3161, 2656, 4621, 199, 646, 984, 199, 199, 3, 3161, 20535, 199, 646, 2680, 465, 980, 199, 199, 3, 10111, 8925, 199, 504, 542, 374, 22777, 14, 2537, 492, 16572, 199, 504, 542, 374, 22777, 14, 2537, 14, 2537, 492, 3495, 199, 504, 542, 374, 22777, 14, 888, 492, 3537, 63, 646, 12, 12009, 547, 199, 504, 542, 374, 22777, 14, 8856, 14, 1095, 492, 1300, 199, 199, 4014, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 3214, 418, 199, 3243, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 3771, 418, 199, 199, 11263, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 11263, 418, 199, 32238, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 32238, 418, 199, 199, 8998, 275, 3537, 63, 646, 360, 8856, 297, 283, 8998, 358, 342, 421, 199, 533, 511, 63, 32238, 8, 1095, 304, 272, 408, 7711, 6338, 1021, 272, 408, 339, 347, 1104, 8, 277, 304, 267, 408, 13813, 2633, 436, 3792, 267, 408, 267, 8367, 14, 1074, 342, 398, 340, 283, 7321, 7, 440, 315, 15097, 26, 288, 5371, 8, 3243, 12, 283, 7321, 297, 488, 9, 339, 347, 2446, 8, 277, 304, 267, 408, 30753, 6709, 402, 20632, 805, 267, 408, 267, 340, 440, 15097, 14, 7321, 26, 288, 8367, 14, 973, 342, 398, 2963, 1412, 14, 1412, 63, 29824, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 961, 365, 3240, 374, 22777, 199, 3, 199, 3, 1666, 5059, 6013, 570, 199, 3, 199, 11490, 199, 199, 3, 3161, 2656, 4621, 199, 646, 984, 199, 199, 3, 3161, 20535, 199, 646, 2680, 465, 980, 199, 199, 3, 10111, 8925, 199, 504, 542, 374, 22777, 14, 2537, 492, 16572, 199, 504, 542, 374, 22777, 14, 2537, 14, 2537, 492, 3495, 199, 504, 542, 374, 22777, 14, 888, 492, 3537, 63, 646, 12, 12009, 547, 199, 504, 542, 374, 22777, 14, 8856, 14, 1095, 492, 1300, 199, 199, 4014, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 3214, 418, 199, 3243, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 3771, 418, 199, 199, 11263, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 11263, 418, 199, 32238, 275, 984, 14, 3112, 459, 261, 374, 22777, 63, 32238, 418, 199, 199, 8998, 275, 3537, 63, 646, 360, 8856, 297, 283, 8998, 358, 342, 421, 199, 533, 511, 63, 32238, 8, 1095, 304, 272, 408, 7711, 6338, 1021, 272, 408, 339, 347, 1104, 8, 277, 304, 267, 408, 13813, 2633, 436, 3792, 267, 408, 267, 8367, 14, 1074, 342, 398, 340, 283, 7321, 7, 440, 315, 15097, 26, 288, 5371, 8, 3243, 12, 283, 7321, 297, 488, 9, 339, 347, 2446, 8, 277, 304, 267, 408, 30753, 6709, 402, 20632, 805, 267, 408, 267, 340, 440, 15097, 14, 7321, 26, 288, 8367, 14, 973, 342, 398, 2963, 1412, 14, 1412, 63, 29824, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
danielberndt/Feature_Langpop
librarian/plugins/__init__.py
2
5147
""" plugins: code related to plugins and plugin loaders Copyright 2014-2015, Outernet Inc. Some rights reserved. This software is free software licensed under the terms of GPLv3. See COPYING file that comes with the source code, or http://www.gnu.org/licenses/gpl.txt. """ import os import logging import bottle from bottle import static_file from .exceptions import NotSupportedError PLUGINS_PATH = os.path.dirname(__file__) INSTALLED = {} DASHBOARD = [] def is_pkg(path): init = os.path.join(path, '__init__.py') return os.path.isdir(path) and os.path.isfile(init) def list_plugins(): plugins = [] for p in os.listdir(PLUGINS_PATH): pkgdir = os.path.join(PLUGINS_PATH, p) if not is_pkg(pkgdir): continue plugins.append(p) return plugins def route_plugin(app, mod): """ Return a function for routing plugin routes The route information must be in the following format:: (name, callback, method, path, route_configuration) The path is always prefixed with ``/p/module_name/``. For instance, if your route has a path of ``/bar``, and is called ``foo``, it will be remapped to ``/p/foo/bar``. Similarily to paths, names are also modified. The ``plugins:`` prefix. For a plugin module ``foo`` and route name of ``bar``, we therefore get a full route name that spells ``plugins:foo:bar``. :param app: app for which to create the routing function :param mod: name of the plugin module :returns: routing function """ def _route_plugin(*routes): for route in routes: name, callback, method, path, kw = route name = 'plugins:%s:%s' % (mod, name) path = ('/p/%s/' % mod) + path.lstrip('/') app.route(path, method, callback, name=name, **kw) return _route_plugin def install_views(mod): """ Add view lookup path if plugin has views directory :param mod: module name """ view_path = os.path.join(PLUGINS_PATH, mod, 'views') if not os.path.isdir(view_path): return bottle.TEMPLATE_PATH.insert(1, view_path) def install_static(app, mod): """ Add routes for plugin static if plugin contains a static directory All routes are mapped to urls that start with ``/s/`` prefix followed by module name. So, for a plugin called ``foo``, we get ``js/main.js`` asset by using the following path: ``/s/foo/js/main.js``. Each route is also given a name with ``plugins:`` prefix and ``:static`` suffix added to the module name. Fof a module called ``foo``, the route name is ``plugins:foo:static``. :param app: application object :param mod: module name """ static_path = os.path.join(PLUGINS_PATH, mod, 'static') if not os.path.isdir(static_path): return def _route_plugin_static(path): return static_file(path, static_path) _route_plugin_static.__name__ = '_route_%s_static' % mod app.route('/s/%s/<path:path>' % mod, 'GET', _route_plugin_static, name='plugins:%s:static' % mod, no_i18n=True, skip=app.config['librarian.skip_plugins']) def install_plugins(app): plugins = list_plugins() conf = app.config to_install = [p for p in plugins if conf.get('plugins.%s' % p, False)] dashboard = conf['dashboard.plugins'] # Import each plugin module and initialize it for mod in to_install: try: plugin = __import__('librarian.plugins.%s.plugin' % mod, fromlist=['plugin']) logging.debug("Plugin '%s' loaded", mod) except ImportError as err: logging.error("Plugin '%s' could not be loaded, skipping (reason: " "%s)", mod, err) continue except NotSupportedError as err: logging.error( "Plugin '%s' not supported, skipping (reason: %s)", mod, err.reason) continue try: plugin.install(app, route_plugin(app, mod)) except NotSupportedError as err: logging.error( "Plugin '%s' not supported, skipping (reason: %s)", mod, err.reason) continue except AttributeError: logging.error("Plugin '%s' not correctly implemented, skipping", mod) continue install_views(mod) install_static(app, mod) INSTALLED[mod] = plugin logging.info('Installed plugin %s', mod) # Install dashboard plugins for plugins that have them logging.debug("Installing dashboard plugins: %s", ', '.join(dashboard)) for p in dashboard: if p not in INSTALLED: logging.debug("Plugin '%s' is not installed, ignoring", p) continue plugin = INSTALLED[p] try: DASHBOARD.append(plugin.Dashboard()) logging.info('Installed dashboard plugin %s', p) except AttributeError: logging.debug("No dashboard plugin for '%s'", p) continue
gpl-3.0
[ 624, 199, 5265, 26, 1233, 4048, 370, 8963, 436, 3589, 25520, 199, 199, 7384, 6927, 13, 7806, 12, 593, 2699, 846, 3277, 14, 199, 7700, 4481, 4644, 14, 199, 199, 2765, 2032, 365, 2867, 2032, 18233, 1334, 314, 2895, 402, 14629, 86, 19, 14, 1666, 9685, 199, 493, 626, 12477, 543, 314, 1350, 1233, 12, 503, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 2424, 14, 199, 624, 199, 199, 646, 747, 199, 646, 2050, 199, 199, 646, 5888, 1118, 199, 504, 5888, 1118, 492, 2955, 63, 493, 199, 199, 504, 1275, 3924, 492, 2832, 10682, 547, 199, 199, 16483, 10789, 63, 3243, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 15942, 275, 1052, 199, 29019, 23368, 275, 942, 421, 199, 318, 365, 63, 4600, 8, 515, 304, 272, 4205, 275, 747, 14, 515, 14, 904, 8, 515, 12, 2560, 826, 4343, 647, 358, 272, 372, 747, 14, 515, 14, 6027, 8, 515, 9, 436, 747, 14, 515, 14, 6292, 8, 826, 9, 421, 199, 318, 769, 63, 5265, 837, 272, 8963, 275, 942, 272, 367, 299, 315, 747, 14, 7374, 8, 16483, 10789, 63, 3243, 304, 267, 5496, 694, 275, 747, 14, 515, 14, 904, 8, 16483, 10789, 63, 3243, 12, 299, 9, 267, 340, 440, 365, 63, 4600, 8, 4600, 694, 304, 288, 1980, 267, 8963, 14, 740, 8, 80, 9, 272, 372, 8963, 421, 199, 318, 7475, 63, 2718, 8, 571, 12, 3413, 304, 272, 408, 1432, 282, 805, 367, 14870, 3589, 15777, 339, 710, 7475, 2556, 1471, 506, 315, 314, 2569, 1475, 447, 398, 334, 354, 12, 3233, 12, 268, 1083, 12, 931, 12, 7475, 63, 4758, 9, 339, 710, 931, 365, 3544, 18239, 543, 1124, 15, 80, 15, 578, 63, 354, 15, 4345, 2104, 1256, 12, 340, 2195, 272, 7475, 965, 282, 931, 402, 1124, 15, 1700, 4542, 436, 365, 2797, 1124, 1421, 4542, 652, 911, 506, 295, 11663, 370, 272, 1124, 15, 80, 15, 1421, 15, 1700, 4345, 339, 20046, 3444, 370, 3792, 12, 1561, 787, 2597, 6042, 14, 710, 1124, 5265, 5409, 2403, 14, 2104, 272, 282, 3589, 859, 1124, 1421, 1040, 436, 7475, 536, 402, 1124, 1700, 4542, 781, 16119, 664, 282, 2615, 272, 7475, 536, 626, 14475, 76, 478, 1124, 5265, 26, 1421, 26, 1700, 4345, 339, 520, 635, 1145, 26, 258, 1145, 367, 1314, 370, 1218, 314, 14870, 805, 272, 520, 635, 3413, 26, 258, 536, 402, 314, 3589, 859, 272, 520, 5808, 26, 755, 14870, 805, 272, 408, 272, 347, 485, 4449, 63, 2718, 2031, 13243, 304, 267, 367, 7475, 315, 15777, 26, 288, 536, 12, 3233, 12, 1083, 12, 931, 12, 4775, 275, 7475, 288, 536, 275, 283, 5265, 2689, 83, 2689, 83, 7, 450, 334, 1494, 12, 536, 9, 288, 931, 275, 14606, 80, 3149, 83, 4805, 450, 3413, 9, 435, 931, 14, 10124, 7825, 288, 1145, 14, 4449, 8, 515, 12, 1083, 12, 3233, 12, 536, 29, 354, 12, 1011, 829, 9, 272, 372, 485, 4449, 63, 2718, 421, 199, 318, 3907, 63, 4196, 8, 1494, 304, 272, 408, 2654, 2455, 4237, 931, 340, 3589, 965, 6858, 2082, 339, 520, 635, 3413, 26, 221, 859, 536, 272, 408, 272, 2455, 63, 515, 275, 747, 14, 515, 14, 904, 8, 16483, 10789, 63, 3243, 12, 3413, 12, 283, 4196, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 1345, 63, 515, 304, 267, 372, 272, 5888, 1118, 14, 7433, 63, 3243, 14, 3176, 8, 17, 12, 2455, 63, 515, 9, 421, 199, 318, 3907, 63, 1986, 8, 571, 12, 3413, 304, 272, 408, 2654, 15777, 367, 3589, 2955, 340, 3589, 3509, 282, 2955, 2082, 339, 2900, 15777, 787, 9994, 370, 8187, 626, 1343, 543, 1124, 15, 83, 15, 1040, 2403, 9437, 701, 272, 859, 536, 14, 2002, 12, 367, 282, 3589, 2797, 1124, 1421, 4542, 781, 664, 1124, 3596, 15, 973, 14, 3596, 1040, 8977, 272, 701, 1808, 314, 2569, 931, 26, 1124, 15, 83, 15, 1421, 15, 3596, 15, 973, 14, 3596, 4345, 339, 7048, 7475, 365, 2597, 1627, 282, 536, 543, 1124, 5265, 5409, 2403, 436, 1124, 26, 1986, 1040, 272, 4739, 3483, 370, 314, 859, 536, 14, 481, 1618, 282, 859, 2797, 1124, 1421, 4542, 314, 7475, 272, 536, 365, 1124, 5265, 26, 1421, 26, 1986, 4345, 339, 520, 635, 1145, 26, 221, 4223, 909, 272, 520, 635, 3413, 26, 221, 859, 536, 272, 408, 272, 2955, 63, 515, 275, 747, 14, 515, 14, 904, 8, 16483, 10789, 63, 3243, 12, 3413, 12, 283, 1986, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 1986, 63, 515, 304, 267, 372, 339, 347, 485, 4449, 63, 2718, 63, 1986, 8, 515, 304, 267, 372, 2955, 63, 493, 8, 515, 12, 2955, 63, 515, 9, 272, 485, 4449, 63, 2718, 63, 1986, 855, 354, 363, 275, 2513, 4449, 4970, 83, 63, 1986, 7, 450, 3413, 339, 1145, 14, 4449, 2336, 83, 3149, 83, 8316, 515, 26, 515, 3524, 450, 3413, 12, 283, 2970, 297, 1598, 485, 4449, 63, 2718, 63, 1986, 12, 1598, 536, 534, 5265, 2689, 83, 26, 1986, 7, 450, 3413, 12, 1598, 949, 63, 73, 1085, 78, 29, 549, 12, 1598, 3372, 29, 571, 14, 888, 459, 773, 82, 15289, 14, 2759, 63, 5265, 1105, 421, 199, 318, 3907, 63, 5265, 8, 571, 304, 272, 8963, 275, 769, 63, 5265, 342, 272, 3743, 275, 1145, 14, 888, 272, 370, 63, 3174, 275, 359, 80, 367, 299, 315, 8963, 340, 3743, 14, 362, 360, 5265, 4111, 83, 7, 450, 299, 12, 756, 1874, 272, 17216, 275, 3743, 459, 9743, 14, 5265, 418, 339, 327, 3161, 1924, 3589, 859, 436, 8265, 652, 272, 367, 3413, 315, 370, 63, 3174, 26, 267, 862, 26, 288, 3589, 275, 636, 646, 19734, 773, 82, 15289, 14, 5265, 4111, 83, 14, 2718, 7, 450, 3413, 12, 1816, 25321, 2968, 2718, 1105, 288, 2050, 14, 1757, 480, 5061, 1543, 83, 7, 6511, 401, 3413, 9, 267, 871, 3545, 465, 2329, 26, 288, 2050, 14, 705, 480, 5061, 1543, 83, 7, 4293, 440, 506, 6511, 12, 16068, 334, 5764, 26, 298, 2079, 2071, 83, 4186, 3413, 12, 2329, 9, 288, 1980, 267, 871, 2832, 10682, 547, 465 ]
[ 199, 5265, 26, 1233, 4048, 370, 8963, 436, 3589, 25520, 199, 199, 7384, 6927, 13, 7806, 12, 593, 2699, 846, 3277, 14, 199, 7700, 4481, 4644, 14, 199, 199, 2765, 2032, 365, 2867, 2032, 18233, 1334, 314, 2895, 402, 14629, 86, 19, 14, 1666, 9685, 199, 493, 626, 12477, 543, 314, 1350, 1233, 12, 503, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 2424, 14, 199, 624, 199, 199, 646, 747, 199, 646, 2050, 199, 199, 646, 5888, 1118, 199, 504, 5888, 1118, 492, 2955, 63, 493, 199, 199, 504, 1275, 3924, 492, 2832, 10682, 547, 199, 199, 16483, 10789, 63, 3243, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 15942, 275, 1052, 199, 29019, 23368, 275, 942, 421, 199, 318, 365, 63, 4600, 8, 515, 304, 272, 4205, 275, 747, 14, 515, 14, 904, 8, 515, 12, 2560, 826, 4343, 647, 358, 272, 372, 747, 14, 515, 14, 6027, 8, 515, 9, 436, 747, 14, 515, 14, 6292, 8, 826, 9, 421, 199, 318, 769, 63, 5265, 837, 272, 8963, 275, 942, 272, 367, 299, 315, 747, 14, 7374, 8, 16483, 10789, 63, 3243, 304, 267, 5496, 694, 275, 747, 14, 515, 14, 904, 8, 16483, 10789, 63, 3243, 12, 299, 9, 267, 340, 440, 365, 63, 4600, 8, 4600, 694, 304, 288, 1980, 267, 8963, 14, 740, 8, 80, 9, 272, 372, 8963, 421, 199, 318, 7475, 63, 2718, 8, 571, 12, 3413, 304, 272, 408, 1432, 282, 805, 367, 14870, 3589, 15777, 339, 710, 7475, 2556, 1471, 506, 315, 314, 2569, 1475, 447, 398, 334, 354, 12, 3233, 12, 268, 1083, 12, 931, 12, 7475, 63, 4758, 9, 339, 710, 931, 365, 3544, 18239, 543, 1124, 15, 80, 15, 578, 63, 354, 15, 4345, 2104, 1256, 12, 340, 2195, 272, 7475, 965, 282, 931, 402, 1124, 15, 1700, 4542, 436, 365, 2797, 1124, 1421, 4542, 652, 911, 506, 295, 11663, 370, 272, 1124, 15, 80, 15, 1421, 15, 1700, 4345, 339, 20046, 3444, 370, 3792, 12, 1561, 787, 2597, 6042, 14, 710, 1124, 5265, 5409, 2403, 14, 2104, 272, 282, 3589, 859, 1124, 1421, 1040, 436, 7475, 536, 402, 1124, 1700, 4542, 781, 16119, 664, 282, 2615, 272, 7475, 536, 626, 14475, 76, 478, 1124, 5265, 26, 1421, 26, 1700, 4345, 339, 520, 635, 1145, 26, 258, 1145, 367, 1314, 370, 1218, 314, 14870, 805, 272, 520, 635, 3413, 26, 258, 536, 402, 314, 3589, 859, 272, 520, 5808, 26, 755, 14870, 805, 272, 408, 272, 347, 485, 4449, 63, 2718, 2031, 13243, 304, 267, 367, 7475, 315, 15777, 26, 288, 536, 12, 3233, 12, 1083, 12, 931, 12, 4775, 275, 7475, 288, 536, 275, 283, 5265, 2689, 83, 2689, 83, 7, 450, 334, 1494, 12, 536, 9, 288, 931, 275, 14606, 80, 3149, 83, 4805, 450, 3413, 9, 435, 931, 14, 10124, 7825, 288, 1145, 14, 4449, 8, 515, 12, 1083, 12, 3233, 12, 536, 29, 354, 12, 1011, 829, 9, 272, 372, 485, 4449, 63, 2718, 421, 199, 318, 3907, 63, 4196, 8, 1494, 304, 272, 408, 2654, 2455, 4237, 931, 340, 3589, 965, 6858, 2082, 339, 520, 635, 3413, 26, 221, 859, 536, 272, 408, 272, 2455, 63, 515, 275, 747, 14, 515, 14, 904, 8, 16483, 10789, 63, 3243, 12, 3413, 12, 283, 4196, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 1345, 63, 515, 304, 267, 372, 272, 5888, 1118, 14, 7433, 63, 3243, 14, 3176, 8, 17, 12, 2455, 63, 515, 9, 421, 199, 318, 3907, 63, 1986, 8, 571, 12, 3413, 304, 272, 408, 2654, 15777, 367, 3589, 2955, 340, 3589, 3509, 282, 2955, 2082, 339, 2900, 15777, 787, 9994, 370, 8187, 626, 1343, 543, 1124, 15, 83, 15, 1040, 2403, 9437, 701, 272, 859, 536, 14, 2002, 12, 367, 282, 3589, 2797, 1124, 1421, 4542, 781, 664, 1124, 3596, 15, 973, 14, 3596, 1040, 8977, 272, 701, 1808, 314, 2569, 931, 26, 1124, 15, 83, 15, 1421, 15, 3596, 15, 973, 14, 3596, 4345, 339, 7048, 7475, 365, 2597, 1627, 282, 536, 543, 1124, 5265, 5409, 2403, 436, 1124, 26, 1986, 1040, 272, 4739, 3483, 370, 314, 859, 536, 14, 481, 1618, 282, 859, 2797, 1124, 1421, 4542, 314, 7475, 272, 536, 365, 1124, 5265, 26, 1421, 26, 1986, 4345, 339, 520, 635, 1145, 26, 221, 4223, 909, 272, 520, 635, 3413, 26, 221, 859, 536, 272, 408, 272, 2955, 63, 515, 275, 747, 14, 515, 14, 904, 8, 16483, 10789, 63, 3243, 12, 3413, 12, 283, 1986, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 1986, 63, 515, 304, 267, 372, 339, 347, 485, 4449, 63, 2718, 63, 1986, 8, 515, 304, 267, 372, 2955, 63, 493, 8, 515, 12, 2955, 63, 515, 9, 272, 485, 4449, 63, 2718, 63, 1986, 855, 354, 363, 275, 2513, 4449, 4970, 83, 63, 1986, 7, 450, 3413, 339, 1145, 14, 4449, 2336, 83, 3149, 83, 8316, 515, 26, 515, 3524, 450, 3413, 12, 283, 2970, 297, 1598, 485, 4449, 63, 2718, 63, 1986, 12, 1598, 536, 534, 5265, 2689, 83, 26, 1986, 7, 450, 3413, 12, 1598, 949, 63, 73, 1085, 78, 29, 549, 12, 1598, 3372, 29, 571, 14, 888, 459, 773, 82, 15289, 14, 2759, 63, 5265, 1105, 421, 199, 318, 3907, 63, 5265, 8, 571, 304, 272, 8963, 275, 769, 63, 5265, 342, 272, 3743, 275, 1145, 14, 888, 272, 370, 63, 3174, 275, 359, 80, 367, 299, 315, 8963, 340, 3743, 14, 362, 360, 5265, 4111, 83, 7, 450, 299, 12, 756, 1874, 272, 17216, 275, 3743, 459, 9743, 14, 5265, 418, 339, 327, 3161, 1924, 3589, 859, 436, 8265, 652, 272, 367, 3413, 315, 370, 63, 3174, 26, 267, 862, 26, 288, 3589, 275, 636, 646, 19734, 773, 82, 15289, 14, 5265, 4111, 83, 14, 2718, 7, 450, 3413, 12, 1816, 25321, 2968, 2718, 1105, 288, 2050, 14, 1757, 480, 5061, 1543, 83, 7, 6511, 401, 3413, 9, 267, 871, 3545, 465, 2329, 26, 288, 2050, 14, 705, 480, 5061, 1543, 83, 7, 4293, 440, 506, 6511, 12, 16068, 334, 5764, 26, 298, 2079, 2071, 83, 4186, 3413, 12, 2329, 9, 288, 1980, 267, 871, 2832, 10682, 547, 465, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
h3biomed/ansible
lib/ansible/modules/messaging/rabbitmq/rabbitmq_vhost.py
63
3952
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2013, Chatham Financial <oss@chathamfinancial.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: rabbitmq_vhost short_description: Manage the state of a virtual host in RabbitMQ description: - Manage the state of a virtual host in RabbitMQ version_added: "1.1" author: Chris Hoffman (@chrishoffman) options: name: description: - The name of the vhost to manage required: true aliases: [vhost] node: description: - erlang node name of the rabbit we wish to configure default: rabbit version_added: "1.2" tracing: description: - Enable/disable tracing for a vhost type: bool default: 'no' aliases: [trace] state: description: - The state of vhost default: present choices: [present, absent] ''' EXAMPLES = ''' # Ensure that the vhost /test exists. - rabbitmq_vhost: name: /test state: present ''' from ansible.module_utils.basic import AnsibleModule class RabbitMqVhost(object): def __init__(self, module, name, tracing, node): self.module = module self.name = name self.tracing = tracing self.node = node self._tracing = False self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True) def _exec(self, args, run_in_check_mode=False): if not self.module.check_mode or (self.module.check_mode and run_in_check_mode): cmd = [self._rabbitmqctl, '-q', '-n', self.node] rc, out, err = self.module.run_command(cmd + args, check_rc=True) return out.splitlines() return list() def get(self): vhosts = self._exec(['list_vhosts', 'name', 'tracing'], True) for vhost in vhosts: if '\t' not in vhost: continue name, tracing = vhost.split('\t') if name == self.name: self._tracing = self.module.boolean(tracing) return True return False def add(self): return self._exec(['add_vhost', self.name]) def delete(self): return self._exec(['delete_vhost', self.name]) def set_tracing(self): if self.tracing != self._tracing: if self.tracing: self._enable_tracing() else: self._disable_tracing() return True return False def _enable_tracing(self): return self._exec(['trace_on', '-p', self.name]) def _disable_tracing(self): return self._exec(['trace_off', '-p', self.name]) def main(): arg_spec = dict( name=dict(required=True, aliases=['vhost']), tracing=dict(default='off', aliases=['trace'], type='bool'), state=dict(default='present', choices=['present', 'absent']), node=dict(default='rabbit'), ) module = AnsibleModule( argument_spec=arg_spec, supports_check_mode=True ) name = module.params['name'] tracing = module.params['tracing'] state = module.params['state'] node = module.params['node'] result = dict(changed=False, name=name, state=state) rabbitmq_vhost = RabbitMqVhost(module, name, tracing, node) if rabbitmq_vhost.get(): if state == 'absent': rabbitmq_vhost.delete() result['changed'] = True else: if rabbitmq_vhost.set_tracing(): result['changed'] = True elif state == 'present': rabbitmq_vhost.add() rabbitmq_vhost.set_tracing() result['changed'] = True module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6171, 12, 2799, 1619, 455, 11711, 24409, 665, 26890, 32, 335, 1619, 455, 2408, 24409, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 29773, 29490, 63, 32071, 199, 3612, 63, 1802, 26, 14944, 314, 1174, 402, 282, 5791, 1591, 315, 820, 371, 2075, 14449, 199, 1802, 26, 523, 446, 14944, 314, 1174, 402, 282, 5791, 1591, 315, 820, 371, 2075, 14449, 199, 1023, 63, 3270, 26, 298, 17, 14, 17, 2, 199, 2502, 26, 2799, 5719, 869, 1997, 1237, 8593, 335, 5719, 526, 556, 1237, 9, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 373, 1102, 370, 9635, 272, 1415, 26, 2549, 272, 5481, 26, 359, 32071, 61, 523, 1031, 26, 272, 1369, 26, 489, 446, 9266, 4159, 1031, 536, 402, 314, 29773, 2075, 781, 13809, 370, 7908, 272, 849, 26, 29773, 2075, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 523, 23465, 26, 272, 1369, 26, 489, 446, 12030, 15, 5993, 23465, 367, 282, 373, 1102, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 272, 5481, 26, 359, 3446, 61, 523, 1174, 26, 272, 1369, 26, 489, 446, 710, 1174, 402, 373, 1102, 272, 849, 26, 3451, 272, 3415, 26, 359, 1881, 12, 9552, 61, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 7523, 626, 314, 373, 1102, 1182, 396, 3495, 14, 199, 13, 29773, 29490, 63, 32071, 26, 272, 536, 26, 1182, 396, 272, 1174, 26, 3451, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 533, 820, 371, 2075, 45, 81, 54, 1102, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 536, 12, 23465, 12, 1031, 304, 267, 291, 14, 578, 275, 859, 267, 291, 14, 354, 275, 536, 267, 291, 14, 21635, 275, 23465, 267, 291, 14, 932, 275, 1031, 398, 291, 423, 21635, 275, 756, 267, 291, 423, 14411, 29490, 8077, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 14411, 29490, 8077, 297, 715, 9, 339, 347, 485, 1628, 8, 277, 12, 1249, 12, 1255, 63, 262, 63, 1074, 63, 632, 29, 797, 304, 267, 340, 440, 291, 14, 578, 14, 1074, 63, 632, 503, 334, 277, 14, 578, 14, 1074, 63, 632, 436, 1255, 63, 262, 63, 1074, 63, 632, 304, 288, 2088, 275, 359, 277, 423, 14411, 29490, 8077, 12, 2475, 81, 297, 2475, 78, 297, 291, 14, 932, 61, 288, 4819, 12, 734, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 8, 1760, 435, 1249, 12, 1104, 63, 1195, 29, 549, 9, 288, 372, 734, 14, 7644, 342, 267, 372, 769, 342, 339, 347, 664, 8, 277, 304, 267, 373, 5146, 275, 291, 423, 1628, 2941, 513, 63, 86, 5146, 297, 283, 354, 297, 283, 21635, 995, 715, 9, 398, 367, 373, 1102, 315, 373, 5146, 26, 288, 340, 1557, 84, 7, 440, 315, 373, 1102, 26, 355, 1980, 953, 536, 12, 23465, 275, 373, 1102, 14, 1294, 2258, 84, 358, 288, 340, 536, 508, 291, 14, 354, 26, 355, 291, 423, 21635, 275, 291, 14, 578, 14, 4871, 8, 21635, 9, 355, 372, 715, 267, 372, 756, 339, 347, 1050, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 525, 63, 32071, 297, 291, 14, 354, 566, 339, 347, 3145, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 1807, 63, 32071, 297, 291, 14, 354, 566, 339, 347, 663, 63, 21635, 8, 277, 304, 267, 340, 291, 14, 21635, 1137, 291, 423, 21635, 26, 288, 340, 291, 14, 21635, 26, 355, 291, 423, 4296, 63, 21635, 342, 288, 587, 26, 355, 291, 423, 5993, 63, 21635, 342, 288, 372, 715, 267, 372, 756, 339, 347, 485, 4296, 63, 21635, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 3446, 63, 265, 297, 2475, 80, 297, 291, 14, 354, 566, 339, 347, 485, 5993, 63, 21635, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 3446, 63, 1997, 297, 2475, 80, 297, 291, 14, 354, 566, 421, 199, 318, 2446, 837, 272, 1680, 63, 1650, 275, 1211, 8, 267, 536, 29, 807, 8, 2427, 29, 549, 12, 5481, 2968, 32071, 3815, 267, 23465, 29, 807, 8, 885, 534, 1997, 297, 5481, 2968, 3446, 995, 730, 534, 2245, 659, 267, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 3815, 267, 1031, 29, 807, 8, 885, 534, 14411, 2075, 659, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 1273, 63, 1650, 12, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 339, 536, 275, 859, 14, 1162, 459, 354, 418, 272, 23465, 275, 859, 14, 1162, 459, 21635, 418, 272, 1174, 275, 859, 14, 1162, 459, 929, 418, 272, 1031, 275, 859, 14, 1162, 459, 932, 418, 272, 754, 275, 1211, 8, 2489, 29, 797, 12, 536, 29, 354, 12, 1174, 29, 929, 9, 272, 29773, 29490, 63, 32071, 275, 820, 371, 2075, 45, 81, 54, 1102, 8, 578, 12, 536, 12, 23465, 12, 1031, 9, 339, 340, 29773, 29490, 63, 32071, 14, 362, 837, 267, 340, 1174, 508, 283, 5575, 356, 288, 29773, 29490, 63, 32071, 14, 1807, 342, 288, 754, 459, 2489, 418, 275, 715, 267, 587, 26, 288, 340, 29773, 29490, 63, 32071, 14, 409, 63, 21635, 837, 355, 754, 459, 2489, 418, 275, 715, 272, 916, 1174, 508, 283, 1881, 356, 267, 29773, 29490, 63, 32071, 14, 525, 342, 267, 29773, 29490, 63, 32071, 14, 409, 63, 21635, 342, 267, 754 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6171, 12, 2799, 1619, 455, 11711, 24409, 665, 26890, 32, 335, 1619, 455, 2408, 24409, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 29773, 29490, 63, 32071, 199, 3612, 63, 1802, 26, 14944, 314, 1174, 402, 282, 5791, 1591, 315, 820, 371, 2075, 14449, 199, 1802, 26, 523, 446, 14944, 314, 1174, 402, 282, 5791, 1591, 315, 820, 371, 2075, 14449, 199, 1023, 63, 3270, 26, 298, 17, 14, 17, 2, 199, 2502, 26, 2799, 5719, 869, 1997, 1237, 8593, 335, 5719, 526, 556, 1237, 9, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 373, 1102, 370, 9635, 272, 1415, 26, 2549, 272, 5481, 26, 359, 32071, 61, 523, 1031, 26, 272, 1369, 26, 489, 446, 9266, 4159, 1031, 536, 402, 314, 29773, 2075, 781, 13809, 370, 7908, 272, 849, 26, 29773, 2075, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 523, 23465, 26, 272, 1369, 26, 489, 446, 12030, 15, 5993, 23465, 367, 282, 373, 1102, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 272, 5481, 26, 359, 3446, 61, 523, 1174, 26, 272, 1369, 26, 489, 446, 710, 1174, 402, 373, 1102, 272, 849, 26, 3451, 272, 3415, 26, 359, 1881, 12, 9552, 61, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 7523, 626, 314, 373, 1102, 1182, 396, 3495, 14, 199, 13, 29773, 29490, 63, 32071, 26, 272, 536, 26, 1182, 396, 272, 1174, 26, 3451, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 533, 820, 371, 2075, 45, 81, 54, 1102, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 536, 12, 23465, 12, 1031, 304, 267, 291, 14, 578, 275, 859, 267, 291, 14, 354, 275, 536, 267, 291, 14, 21635, 275, 23465, 267, 291, 14, 932, 275, 1031, 398, 291, 423, 21635, 275, 756, 267, 291, 423, 14411, 29490, 8077, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 14411, 29490, 8077, 297, 715, 9, 339, 347, 485, 1628, 8, 277, 12, 1249, 12, 1255, 63, 262, 63, 1074, 63, 632, 29, 797, 304, 267, 340, 440, 291, 14, 578, 14, 1074, 63, 632, 503, 334, 277, 14, 578, 14, 1074, 63, 632, 436, 1255, 63, 262, 63, 1074, 63, 632, 304, 288, 2088, 275, 359, 277, 423, 14411, 29490, 8077, 12, 2475, 81, 297, 2475, 78, 297, 291, 14, 932, 61, 288, 4819, 12, 734, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 8, 1760, 435, 1249, 12, 1104, 63, 1195, 29, 549, 9, 288, 372, 734, 14, 7644, 342, 267, 372, 769, 342, 339, 347, 664, 8, 277, 304, 267, 373, 5146, 275, 291, 423, 1628, 2941, 513, 63, 86, 5146, 297, 283, 354, 297, 283, 21635, 995, 715, 9, 398, 367, 373, 1102, 315, 373, 5146, 26, 288, 340, 1557, 84, 7, 440, 315, 373, 1102, 26, 355, 1980, 953, 536, 12, 23465, 275, 373, 1102, 14, 1294, 2258, 84, 358, 288, 340, 536, 508, 291, 14, 354, 26, 355, 291, 423, 21635, 275, 291, 14, 578, 14, 4871, 8, 21635, 9, 355, 372, 715, 267, 372, 756, 339, 347, 1050, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 525, 63, 32071, 297, 291, 14, 354, 566, 339, 347, 3145, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 1807, 63, 32071, 297, 291, 14, 354, 566, 339, 347, 663, 63, 21635, 8, 277, 304, 267, 340, 291, 14, 21635, 1137, 291, 423, 21635, 26, 288, 340, 291, 14, 21635, 26, 355, 291, 423, 4296, 63, 21635, 342, 288, 587, 26, 355, 291, 423, 5993, 63, 21635, 342, 288, 372, 715, 267, 372, 756, 339, 347, 485, 4296, 63, 21635, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 3446, 63, 265, 297, 2475, 80, 297, 291, 14, 354, 566, 339, 347, 485, 5993, 63, 21635, 8, 277, 304, 267, 372, 291, 423, 1628, 2941, 3446, 63, 1997, 297, 2475, 80, 297, 291, 14, 354, 566, 421, 199, 318, 2446, 837, 272, 1680, 63, 1650, 275, 1211, 8, 267, 536, 29, 807, 8, 2427, 29, 549, 12, 5481, 2968, 32071, 3815, 267, 23465, 29, 807, 8, 885, 534, 1997, 297, 5481, 2968, 3446, 995, 730, 534, 2245, 659, 267, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 3815, 267, 1031, 29, 807, 8, 885, 534, 14411, 2075, 659, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 1273, 63, 1650, 12, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 339, 536, 275, 859, 14, 1162, 459, 354, 418, 272, 23465, 275, 859, 14, 1162, 459, 21635, 418, 272, 1174, 275, 859, 14, 1162, 459, 929, 418, 272, 1031, 275, 859, 14, 1162, 459, 932, 418, 272, 754, 275, 1211, 8, 2489, 29, 797, 12, 536, 29, 354, 12, 1174, 29, 929, 9, 272, 29773, 29490, 63, 32071, 275, 820, 371, 2075, 45, 81, 54, 1102, 8, 578, 12, 536, 12, 23465, 12, 1031, 9, 339, 340, 29773, 29490, 63, 32071, 14, 362, 837, 267, 340, 1174, 508, 283, 5575, 356, 288, 29773, 29490, 63, 32071, 14, 1807, 342, 288, 754, 459, 2489, 418, 275, 715, 267, 587, 26, 288, 340, 29773, 29490, 63, 32071, 14, 409, 63, 21635, 837, 355, 754, 459, 2489, 418, 275, 715, 272, 916, 1174, 508, 283, 1881, 356, 267, 29773, 29490, 63, 32071, 14, 525, 342, 267, 29773, 29490, 63, 32071, 14, 409, 63, 21635, 342, 267, 754, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mobilecoind/mobilecoin
contrib/testgen/base58.py
2139
2818
''' Bitcoin base58 encoding and decoding. Based on https://bitcointalk.org/index.php?topic=1026.0 (public domain) ''' import hashlib # for compatibility with following code... class SHA256: new = hashlib.sha256 if str != bytes: # Python 3.x def ord(c): return c def chr(n): return bytes( (n,) ) __b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' __b58base = len(__b58chars) b58chars = __b58chars def b58encode(v): """ encode v, which is a string of bytes, to base58. """ long_value = 0 for (i, c) in enumerate(v[::-1]): long_value += (256**i) * ord(c) result = '' while long_value >= __b58base: div, mod = divmod(long_value, __b58base) result = __b58chars[mod] + result long_value = div result = __b58chars[long_value] + result # Bitcoin does a little leading-zero-compression: # leading 0-bytes in the input become leading-1s nPad = 0 for c in v: if c == '\0': nPad += 1 else: break return (__b58chars[0]*nPad) + result def b58decode(v, length = None): """ decode v into a string of len bytes """ long_value = 0 for (i, c) in enumerate(v[::-1]): long_value += __b58chars.find(c) * (__b58base**i) result = bytes() while long_value >= 256: div, mod = divmod(long_value, 256) result = chr(mod) + result long_value = div result = chr(long_value) + result nPad = 0 for c in v: if c == __b58chars[0]: nPad += 1 else: break result = chr(0)*nPad + result if length is not None and len(result) != length: return None return result def checksum(v): """Return 32-bit checksum based on SHA256""" return SHA256.new(SHA256.new(v).digest()).digest()[0:4] def b58encode_chk(v): """b58encode a string, with 32-bit checksum""" return b58encode(v + checksum(v)) def b58decode_chk(v): """decode a base58 string, check and remove checksum""" result = b58decode(v) if result is None: return None h3 = checksum(result[:-4]) if result[-4:] == checksum(result[:-4]): return result[:-4] else: return None def get_bcaddress_version(strAddress): """ Returns None if strAddress is invalid. Otherwise returns integer version of address. """ addr = b58decode_chk(strAddress) if addr is None or len(addr)!=21: return None version = addr[0] return ord(version) if __name__ == '__main__': # Test case (from http://gitorious.org/bitcoin/python-base58.git) assert get_bcaddress_version('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC') is 0 _ohai = 'o hai'.encode('ascii') _tmp = b58encode(_ohai) assert _tmp == 'DYB3oMS' assert b58decode(_tmp, 5) == _ohai print("Tests passed")
mit
[ 2344, 199, 4734, 9061, 1300, 2010, 2644, 436, 15952, 14, 199, 199, 20409, 641, 4178, 921, 2075, 331, 442, 4878, 14, 1308, 15, 1080, 14, 8624, 31, 5746, 29, 32351, 14, 16, 334, 3455, 2881, 9, 199, 2344, 199, 646, 8337, 199, 199, 3, 367, 7163, 543, 2569, 1233, 1396, 199, 533, 12002, 3912, 26, 272, 892, 275, 8337, 14, 4835, 3912, 199, 199, 692, 620, 1137, 2783, 26, 272, 327, 2018, 650, 14, 88, 272, 347, 6206, 8, 67, 304, 267, 372, 286, 272, 347, 8678, 8, 78, 304, 267, 372, 2783, 8, 334, 78, 4258, 776, 199, 199, 363, 66, 2010, 6574, 275, 283, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 363, 66, 2010, 1095, 275, 822, 3460, 66, 2010, 6574, 9, 199, 66, 2010, 6574, 275, 636, 66, 2010, 6574, 199, 199, 318, 330, 2010, 2143, 8, 86, 304, 272, 408, 3752, 373, 12, 1314, 365, 282, 1059, 402, 2783, 12, 370, 1300, 2010, 14, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 334, 3912, 538, 73, 9, 627, 6206, 8, 67, 9, 339, 754, 275, 2125, 272, 1830, 1846, 63, 585, 2356, 636, 66, 2010, 1095, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 636, 66, 2010, 1095, 9, 267, 754, 275, 636, 66, 2010, 6574, 59, 1494, 61, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 636, 66, 2010, 6574, 59, 2809, 63, 585, 61, 435, 754, 339, 327, 21158, 1630, 282, 12050, 9186, 13, 4262, 13, 12849, 26, 272, 327, 9186, 378, 13, 2394, 315, 314, 1324, 8649, 9186, 13, 17, 83, 272, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 1557, 16, 356, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 372, 25373, 66, 2010, 6574, 59, 16, 3672, 78, 18584, 9, 435, 754, 199, 199, 318, 330, 2010, 2708, 8, 86, 12, 2582, 275, 488, 304, 272, 408, 4849, 373, 1901, 282, 1059, 402, 822, 2783, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 636, 66, 2010, 6574, 14, 1623, 8, 67, 9, 627, 25373, 66, 2010, 1095, 538, 73, 9, 339, 754, 275, 2783, 342, 272, 1830, 1846, 63, 585, 2356, 7633, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 7633, 9, 267, 754, 275, 8678, 8, 1494, 9, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 8678, 8, 2809, 63, 585, 9, 435, 754, 339, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 636, 66, 2010, 6574, 59, 16, 2189, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 754, 275, 8678, 8, 16, 3342, 78, 18584, 435, 754, 272, 340, 2582, 365, 440, 488, 436, 822, 8, 1099, 9, 1137, 2582, 26, 267, 372, 488, 339, 372, 754, 199, 199, 318, 9040, 8, 86, 304, 272, 408, 1767, 4337, 13, 2075, 9040, 4079, 641, 12002, 3912, 624, 272, 372, 12002, 3912, 14, 1222, 8, 8461, 3912, 14, 1222, 8, 86, 680, 5671, 8801, 5671, 3430, 16, 26, 20, 61, 199, 199, 318, 330, 2010, 2143, 63, 14823, 8, 86, 304, 272, 408, 66, 2010, 2143, 282, 1059, 12, 543, 4337, 13, 2075, 9040, 624, 272, 372, 330, 2010, 2143, 8, 86, 435, 9040, 8, 86, 430, 199, 199, 318, 330, 2010, 2708, 63, 14823, 8, 86, 304, 272, 408, 2708, 282, 1300, 2010, 1059, 12, 1104, 436, 2813, 9040, 624, 272, 754, 275, 330, 2010, 2708, 8, 86, 9, 272, 340, 754, 365, 488, 26, 267, 372, 488, 272, 394, 19, 275, 9040, 8, 1099, 4439, 20, 566, 272, 340, 754, 1988, 20, 2938, 508, 9040, 8, 1099, 4439, 20, 4682, 267, 372, 754, 4439, 20, 61, 272, 587, 26, 267, 372, 488, 199, 199, 318, 664, 63, 3776, 1562, 63, 1023, 8, 495, 1476, 304, 272, 408, 1803, 488, 340, 620, 1476, 365, 3866, 14, 221, 6630, 2529, 3000, 1015, 402, 2287, 14, 408, 272, 5552, 275, 330, 2010, 2708, 63, 14823, 8, 495, 1476, 9, 272, 340, 5552, 365, 488, 503, 822, 8, 2697, 9, 1111, 2025, 26, 372, 488, 272, 1015, 275, 5552, 59, 16, 61, 272, 372, 6206, 8, 1023, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 1379, 1930, 334, 504, 1455, 921, 3187, 16039, 1785, 14, 1308, 15, 22816, 15, 1548, 13, 1095, 2010, 14, 3187, 9, 272, 702, 664, 63, 3776, 1562, 63, 1023, 360, 1046, 54, 74, 1537, 19596, 25, 90, 3317, 33, 24, 18750, 23299, 3263, 38, 32605, 54, 90, 46, 23, 1148, 40, 2438, 35, 358, 365, 378, 272, 485, 79, 17945, 275, 283, 79, 394, 5789, 1370, 2143, 360, 4371, 358, 272, 485, 2791, 275, 330, 2010, 2143, 1547, 79, 17945, 9, 272, 702, 485, 2791, 508, 283, 11446, 34, 19, 79, 3053, 7, 272, 702, 330, 2010, 2708, 1547, 2791, 12, 959, 9, 508, 485, 79, 17945, 272, 870, 480, 2925, 3032, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 4734, 9061, 1300, 2010, 2644, 436, 15952, 14, 199, 199, 20409, 641, 4178, 921, 2075, 331, 442, 4878, 14, 1308, 15, 1080, 14, 8624, 31, 5746, 29, 32351, 14, 16, 334, 3455, 2881, 9, 199, 2344, 199, 646, 8337, 199, 199, 3, 367, 7163, 543, 2569, 1233, 1396, 199, 533, 12002, 3912, 26, 272, 892, 275, 8337, 14, 4835, 3912, 199, 199, 692, 620, 1137, 2783, 26, 272, 327, 2018, 650, 14, 88, 272, 347, 6206, 8, 67, 304, 267, 372, 286, 272, 347, 8678, 8, 78, 304, 267, 372, 2783, 8, 334, 78, 4258, 776, 199, 199, 363, 66, 2010, 6574, 275, 283, 11272, 22897, 22313, 14307, 45, 14970, 26018, 18677, 75, 19748, 21832, 7, 199, 363, 66, 2010, 1095, 275, 822, 3460, 66, 2010, 6574, 9, 199, 66, 2010, 6574, 275, 636, 66, 2010, 6574, 199, 199, 318, 330, 2010, 2143, 8, 86, 304, 272, 408, 3752, 373, 12, 1314, 365, 282, 1059, 402, 2783, 12, 370, 1300, 2010, 14, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 334, 3912, 538, 73, 9, 627, 6206, 8, 67, 9, 339, 754, 275, 2125, 272, 1830, 1846, 63, 585, 2356, 636, 66, 2010, 1095, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 636, 66, 2010, 1095, 9, 267, 754, 275, 636, 66, 2010, 6574, 59, 1494, 61, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 636, 66, 2010, 6574, 59, 2809, 63, 585, 61, 435, 754, 339, 327, 21158, 1630, 282, 12050, 9186, 13, 4262, 13, 12849, 26, 272, 327, 9186, 378, 13, 2394, 315, 314, 1324, 8649, 9186, 13, 17, 83, 272, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 1557, 16, 356, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 372, 25373, 66, 2010, 6574, 59, 16, 3672, 78, 18584, 9, 435, 754, 199, 199, 318, 330, 2010, 2708, 8, 86, 12, 2582, 275, 488, 304, 272, 408, 4849, 373, 1901, 282, 1059, 402, 822, 2783, 272, 408, 272, 1846, 63, 585, 275, 378, 272, 367, 334, 73, 12, 286, 9, 315, 3874, 8, 86, 14172, 17, 4682, 267, 1846, 63, 585, 847, 636, 66, 2010, 6574, 14, 1623, 8, 67, 9, 627, 25373, 66, 2010, 1095, 538, 73, 9, 339, 754, 275, 2783, 342, 272, 1830, 1846, 63, 585, 2356, 7633, 26, 267, 9073, 12, 3413, 275, 16438, 8, 2809, 63, 585, 12, 7633, 9, 267, 754, 275, 8678, 8, 1494, 9, 435, 754, 267, 1846, 63, 585, 275, 9073, 272, 754, 275, 8678, 8, 2809, 63, 585, 9, 435, 754, 339, 302, 18584, 275, 378, 272, 367, 286, 315, 373, 26, 267, 340, 286, 508, 636, 66, 2010, 6574, 59, 16, 2189, 302, 18584, 847, 413, 267, 587, 26, 2059, 339, 754, 275, 8678, 8, 16, 3342, 78, 18584, 435, 754, 272, 340, 2582, 365, 440, 488, 436, 822, 8, 1099, 9, 1137, 2582, 26, 267, 372, 488, 339, 372, 754, 199, 199, 318, 9040, 8, 86, 304, 272, 408, 1767, 4337, 13, 2075, 9040, 4079, 641, 12002, 3912, 624, 272, 372, 12002, 3912, 14, 1222, 8, 8461, 3912, 14, 1222, 8, 86, 680, 5671, 8801, 5671, 3430, 16, 26, 20, 61, 199, 199, 318, 330, 2010, 2143, 63, 14823, 8, 86, 304, 272, 408, 66, 2010, 2143, 282, 1059, 12, 543, 4337, 13, 2075, 9040, 624, 272, 372, 330, 2010, 2143, 8, 86, 435, 9040, 8, 86, 430, 199, 199, 318, 330, 2010, 2708, 63, 14823, 8, 86, 304, 272, 408, 2708, 282, 1300, 2010, 1059, 12, 1104, 436, 2813, 9040, 624, 272, 754, 275, 330, 2010, 2708, 8, 86, 9, 272, 340, 754, 365, 488, 26, 267, 372, 488, 272, 394, 19, 275, 9040, 8, 1099, 4439, 20, 566, 272, 340, 754, 1988, 20, 2938, 508, 9040, 8, 1099, 4439, 20, 4682, 267, 372, 754, 4439, 20, 61, 272, 587, 26, 267, 372, 488, 199, 199, 318, 664, 63, 3776, 1562, 63, 1023, 8, 495, 1476, 304, 272, 408, 1803, 488, 340, 620, 1476, 365, 3866, 14, 221, 6630, 2529, 3000, 1015, 402, 2287, 14, 408, 272, 5552, 275, 330, 2010, 2708, 63, 14823, 8, 495, 1476, 9, 272, 340, 5552, 365, 488, 503, 822, 8, 2697, 9, 1111, 2025, 26, 372, 488, 272, 1015, 275, 5552, 59, 16, 61, 272, 372, 6206, 8, 1023, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 1379, 1930, 334, 504, 1455, 921, 3187, 16039, 1785, 14, 1308, 15, 22816, 15, 1548, 13, 1095, 2010, 14, 3187, 9, 272, 702, 664, 63, 3776, 1562, 63, 1023, 360, 1046, 54, 74, 1537, 19596, 25, 90, 3317, 33, 24, 18750, 23299, 3263, 38, 32605, 54, 90, 46, 23, 1148, 40, 2438, 35, 358, 365, 378, 272, 485, 79, 17945, 275, 283, 79, 394, 5789, 1370, 2143, 360, 4371, 358, 272, 485, 2791, 275, 330, 2010, 2143, 1547, 79, 17945, 9, 272, 702, 485, 2791, 508, 283, 11446, 34, 19, 79, 3053, 7, 272, 702, 330, 2010, 2708, 1547, 2791, 12, 959, 9, 508, 485, 79, 17945, 272, 870, 480, 2925, 3032, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
arael120/App-Beicor
node_modules/node-gyp/gyp/pylib/gyp/generator/make.py
896
91092
# Copyright (c) 2013 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Notes: # # This is all roughly based on the Makefile system used by the Linux # kernel, but is a non-recursive make -- we put the entire dependency # graph in front of make and let it figure it out. # # The code below generates a separate .mk file for each target, but # all are sourced by the top-level Makefile. This means that all # variables in .mk-files clobber one another. Be careful to use := # where appropriate for immediate evaluation, and similarly to watch # that you're not relying on a variable value to last beween different # .mk files. # # TODOs: # # Global settings and utility functions are currently stuffed in the # toplevel Makefile. It may make sense to generate some .mk files on # the side to keep the the files readable. import os import re import sys import subprocess import gyp import gyp.common import gyp.xcode_emulation from gyp.common import GetEnvironFallback from gyp.common import GypError generator_default_variables = { 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'SHARED_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni', 'SHARED_INTERMEDIATE_DIR': '$(obj)/gen', 'PRODUCT_DIR': '$(builddir)', 'RULE_INPUT_ROOT': '%(INPUT_ROOT)s', # This gets expanded by Python. 'RULE_INPUT_DIRNAME': '%(INPUT_DIRNAME)s', # This gets expanded by Python. 'RULE_INPUT_PATH': '$(abspath $<)', 'RULE_INPUT_EXT': '$(suffix $<)', 'RULE_INPUT_NAME': '$(notdir $<)', 'CONFIGURATION_NAME': '$(BUILDTYPE)', } # Make supports multiple toolsets generator_supports_multiple_toolsets = True # Request sorted dependencies in the order from dependents to dependencies. generator_wants_sorted_dependencies = False # Placates pylint. generator_additional_non_configuration_keys = [] generator_additional_path_sections = [] generator_extra_sources_for_rules = [] generator_filelist_paths = None def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" flavor = gyp.common.GetFlavor(params) if flavor == 'mac': default_variables.setdefault('OS', 'mac') default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') default_variables.setdefault('SHARED_LIB_DIR', generator_default_variables['PRODUCT_DIR']) default_variables.setdefault('LIB_DIR', generator_default_variables['PRODUCT_DIR']) # Copy additional generator configuration data from Xcode, which is shared # by the Mac Make generator. import gyp.generator.xcode as xcode_generator global generator_additional_non_configuration_keys generator_additional_non_configuration_keys = getattr(xcode_generator, 'generator_additional_non_configuration_keys', []) global generator_additional_path_sections generator_additional_path_sections = getattr(xcode_generator, 'generator_additional_path_sections', []) global generator_extra_sources_for_rules generator_extra_sources_for_rules = getattr(xcode_generator, 'generator_extra_sources_for_rules', []) COMPILABLE_EXTENSIONS.update({'.m': 'objc', '.mm' : 'objcxx'}) else: operating_system = flavor if flavor == 'android': operating_system = 'linux' # Keep this legacy behavior for now. default_variables.setdefault('OS', operating_system) default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)') default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)') def CalculateGeneratorInputInfo(params): """Calculate the generator specific info that gets fed to input (called by gyp).""" generator_flags = params.get('generator_flags', {}) android_ndk_version = generator_flags.get('android_ndk_version', None) # Android NDK requires a strict link order. if android_ndk_version: global generator_wants_sorted_dependencies generator_wants_sorted_dependencies = True output_dir = params['options'].generator_output or \ params['options'].toplevel_dir builddir_name = generator_flags.get('output_dir', 'out') qualified_out_dir = os.path.normpath(os.path.join( output_dir, builddir_name, 'gypfiles')) global generator_filelist_paths generator_filelist_paths = { 'toplevel': params['options'].toplevel_dir, 'qualified_out_dir': qualified_out_dir, } # The .d checking code below uses these functions: # wildcard, sort, foreach, shell, wordlist # wildcard can handle spaces, the rest can't. # Since I could find no way to make foreach work with spaces in filenames # correctly, the .d files have spaces replaced with another character. The .d # file for # Chromium\ Framework.framework/foo # is for example # out/Release/.deps/out/Release/Chromium?Framework.framework/foo # This is the replacement character. SPACE_REPLACEMENT = '?' LINK_COMMANDS_LINUX = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) # Due to circular dependencies between libraries :(, we wrap the # special "figure out circular dependencies" flags around the entire # input list during linking. quiet_cmd_link = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) # We support two kinds of shared objects (.so): # 1) shared_library, which is just bundling together many dependent libraries # into a link line. # 2) loadable_module, which is generating a module intended for dlopen(). # # They differ only slightly: # In the former case, we want to package all dependent code into the .so. # In the latter case, we want to package just the API exposed by the # outermost module. # This means shared_library uses --whole-archive, while loadable_module doesn't. # (Note that --whole-archive is incompatible with the --start-group used in # normal linking.) # Other shared-object link notes: # - Set SONAME to the library filename so our binaries don't reference # the local, absolute paths used on the link command-line. quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) """ LINK_COMMANDS_MAC = """\ quiet_cmd_alink = LIBTOOL-STATIC $@ cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) quiet_cmd_link = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ LINK_COMMANDS_ANDROID = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) # Due to circular dependencies between libraries :(, we wrap the # special "figure out circular dependencies" flags around the entire # input list during linking. quiet_cmd_link = LINK($(TOOLSET)) $@ quiet_cmd_link_host = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) # Other shared-object link notes: # - Set SONAME to the library filename so our binaries don't reference # the local, absolute paths used on the link command-line. quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) quiet_cmd_solink_module_host = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module_host = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ LINK_COMMANDS_AIX = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X32_64 crs $@ $(filter %.o,$^) quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X32_64 crs $@ $(filter %.o,$^) quiet_cmd_link = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ # Header of toplevel Makefile. # This should go into the build tree, but it's easier to keep it here for now. SHARED_HEADER = ("""\ # We borrow heavily from the kernel build setup, though we are simpler since # we don't have Kconfig tweaking settings on us. # The implicit make rules have it looking for RCS files, among other things. # We instead explicitly write all the rules we care about. # It's even quicker (saves ~200ms) to pass -r on the command line. MAKEFLAGS=-r # The source directory tree. srcdir := %(srcdir)s abs_srcdir := $(abspath $(srcdir)) # The name of the builddir. builddir_name ?= %(builddir)s # The V=1 flag on command line makes us verbosely print command lines. ifdef V quiet= else quiet=quiet_ endif # Specify BUILDTYPE=Release on the command line for a release build. BUILDTYPE ?= %(default_configuration)s # Directory all our build output goes into. # Note that this must be two directories beneath src/ for unit tests to pass, # as they reach into the src/ directory for data with relative paths. builddir ?= $(builddir_name)/$(BUILDTYPE) abs_builddir := $(abspath $(builddir)) depsdir := $(builddir)/.deps # Object output directory. obj := $(builddir)/obj abs_obj := $(abspath $(obj)) # We build up a list of every single one of the targets so we can slurp in the # generated dependency rule Makefiles in one pass. all_deps := %(make_global_settings)s CC.target ?= %(CC.target)s CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS) CXX.target ?= %(CXX.target)s CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS) LINK.target ?= %(LINK.target)s LDFLAGS.target ?= $(LDFLAGS) AR.target ?= $(AR) # C++ apps need to be linked with g++. LINK ?= $(CXX.target) # TODO(evan): move all cross-compilation logic to gyp-time so we don't need # to replicate this environment fallback in make as well. CC.host ?= %(CC.host)s CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host) CXX.host ?= %(CXX.host)s CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host) LINK.host ?= %(LINK.host)s LDFLAGS.host ?= AR.host ?= %(AR.host)s # Define a dir function that can handle spaces. # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions # "leading spaces cannot appear in the text of the first argument as written. # These characters can be put into the argument value by variable substitution." empty := space := $(empty) $(empty) # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces replace_spaces = $(subst $(space),""" + SPACE_REPLACEMENT + """,$1) unreplace_spaces = $(subst """ + SPACE_REPLACEMENT + """,$(space),$1) dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) # Flags to make gcc output dependency info. Note that you need to be # careful here to use the flags that ccache and distcc can understand. # We write to a dep file on the side first and then rename at the end # so we can't end up with a broken dep file. depfile = $(depsdir)/$(call replace_spaces,$@).d DEPFLAGS = -MMD -MF $(depfile).raw # We have to fixup the deps output in a few ways. # (1) the file output should mention the proper .o file. # ccache or distcc lose the path to the target, so we convert a rule of # the form: # foobar.o: DEP1 DEP2 # into # path/to/foobar.o: DEP1 DEP2 # (2) we want missing files not to cause us to fail to build. # We want to rewrite # foobar.o: DEP1 DEP2 \\ # DEP3 # to # DEP1: # DEP2: # DEP3: # so if the files are missing, they're just considered phony rules. # We have to do some pretty insane escaping to get those backslashes # and dollar signs past make, the shell, and sed at the same time. # Doesn't work with spaces, but that's fine: .d files have spaces in # their names replaced with other characters.""" r""" define fixup_dep # The depfile may not exist if the input file didn't have any #includes. touch $(depfile).raw # Fixup path as in (1). sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) # Add extra rules as in (2). # We remove slashes and replace spaces with new lines; # remove blank lines; # delete the first line and append a colon to the remaining lines. sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ grep -v '^$$' |\ sed -e 1d -e 's|$$|:|' \ >> $(depfile) rm $(depfile).raw endef """ """ # Command definitions: # - cmd_foo is the actual command to run; # - quiet_cmd_foo is the brief-output summary of the command. quiet_cmd_cc = CC($(TOOLSET)) $@ cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< quiet_cmd_cxx = CXX($(TOOLSET)) $@ cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< %(extra_commands)s quiet_cmd_touch = TOUCH $@ cmd_touch = touch $@ quiet_cmd_copy = COPY $@ # send stderr to /dev/null to ignore messages when linking directories. cmd_copy = rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@" %(link_commands)s """ r""" # Define an escape_quotes function to escape single quotes. # This allows us to handle quotes properly as long as we always use # use single quotes and escape_quotes. escape_quotes = $(subst ','\'',$(1)) # This comment is here just to include a ' to unconfuse syntax highlighting. # Define an escape_vars function to escape '$' variable syntax. # This allows us to read/write command lines with shell variables (e.g. # $LD_LIBRARY_PATH), without triggering make substitution. escape_vars = $(subst $$,$$$$,$(1)) # Helper that expands to a shell command to echo a string exactly as it is in # make. This uses printf instead of echo because printf's behaviour with respect # to escape sequences is more portable than echo's across different shells # (e.g., dash, bash). exact_echo = printf '%%s\n' '$(call escape_quotes,$(1))' """ """ # Helper to compare the command we're about to run against the command # we logged the last time we ran the command. Produces an empty # string (false) when the commands match. # Tricky point: Make has no string-equality test function. # The kernel uses the following, but it seems like it would have false # positives, where one string reordered its arguments. # arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \\ # $(filter-out $(cmd_$@), $(cmd_$(1)))) # We instead substitute each for the empty string into the other, and # say they're equal if both substitutions produce the empty string. # .d files contain """ + SPACE_REPLACEMENT + \ """ instead of spaces, take that into account. command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\\ $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) # Helper that is non-empty when a prerequisite changes. # Normally make does this implicitly, but we force rules to always run # so we can check their command lines. # $? -- new prerequisites # $| -- order-only dependencies prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) # Helper that executes all postbuilds until one fails. define do_postbuilds @E=0;\\ for p in $(POSTBUILDS); do\\ eval $$p;\\ E=$$?;\\ if [ $$E -ne 0 ]; then\\ break;\\ fi;\\ done;\\ if [ $$E -ne 0 ]; then\\ rm -rf "$@";\\ exit $$E;\\ fi endef # do_cmd: run a command via the above cmd_foo names, if necessary. # Should always run for a given target to handle command-line changes. # Second argument, if non-zero, makes it do asm/C/C++ dependency munging. # Third argument, if non-zero, makes it do POSTBUILDS processing. # Note: We intentionally do NOT call dirx for depfile, since it contains """ + \ SPACE_REPLACEMENT + """ for # spaces already and dirx strips the """ + SPACE_REPLACEMENT + \ """ characters. define do_cmd $(if $(or $(command_changed),$(prereq_changed)), @$(call exact_echo, $($(quiet)cmd_$(1))) @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" $(if $(findstring flock,$(word %(flock_index)d,$(cmd_$1))), @$(cmd_$(1)) @echo " $(quiet_cmd_$(1)): Finished", @$(cmd_$(1)) ) @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) @$(if $(2),$(fixup_dep)) $(if $(and $(3), $(POSTBUILDS)), $(call do_postbuilds) ) ) endef # Declare the "%(default_target)s" target first so it is the default, # even though we don't have the deps yet. .PHONY: %(default_target)s %(default_target)s: # make looks for ways to re-generate included makefiles, but in our case, we # don't have a direct way. Explicitly telling make that it has nothing to do # for them makes it go faster. %%.d: ; # Use FORCE_DO_CMD to force a target to run. Should be coupled with # do_cmd. .PHONY: FORCE_DO_CMD FORCE_DO_CMD: """) SHARED_HEADER_MAC_COMMANDS = """ quiet_cmd_objc = CXX($(TOOLSET)) $@ cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< quiet_cmd_objcxx = CXX($(TOOLSET)) $@ cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< # Commands for precompiled header files. quiet_cmd_pch_c = CXX($(TOOLSET)) $@ cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< quiet_cmd_pch_m = CXX($(TOOLSET)) $@ cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< # gyp-mac-tool is written next to the root Makefile by gyp. # Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd # already. quiet_cmd_mac_tool = MACTOOL $(4) $< cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) quiet_cmd_infoplist = INFOPLIST $@ cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" """ def WriteRootHeaderSuffixRules(writer): extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) writer.write('# Suffix rules, putting all outputs into $(obj).\n') for ext in extensions: writer.write('$(obj).$(TOOLSET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD\n' % ext) writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) writer.write('\n# Try building from generated source, too.\n') for ext in extensions: writer.write( '$(obj).$(TOOLSET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD\n' % ext) writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) writer.write('\n') for ext in extensions: writer.write('$(obj).$(TOOLSET)/%%.o: $(obj)/%%%s FORCE_DO_CMD\n' % ext) writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) writer.write('\n') SHARED_HEADER_SUFFIX_RULES_COMMENT1 = ("""\ # Suffix rules, putting all outputs into $(obj). """) SHARED_HEADER_SUFFIX_RULES_COMMENT2 = ("""\ # Try building from generated source, too. """) SHARED_FOOTER = """\ # "all" is a concatenation of the "all" targets from all the included # sub-makefiles. This is just here to clarify. all: # Add in dependency-tracking rules. $(all_deps) is the list of every single # target in our tree. Only consider the ones with .d (dependency) info: d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) ifneq ($(d_files),) include $(d_files) endif """ header = """\ # This file is generated by gyp; do not edit. """ # Maps every compilable file extension to the do_cmd that compiles it. COMPILABLE_EXTENSIONS = { '.c': 'cc', '.cc': 'cxx', '.cpp': 'cxx', '.cxx': 'cxx', '.s': 'cc', '.S': 'cc', } def Compilable(filename): """Return true if the file is compilable (should be in OBJS).""" for res in (filename.endswith(e) for e in COMPILABLE_EXTENSIONS): if res: return True return False def Linkable(filename): """Return true if the file is linkable (should be on the link line).""" return filename.endswith('.o') def Target(filename): """Translate a compilable filename to its .o target.""" return os.path.splitext(filename)[0] + '.o' def EscapeShellArgument(s): """Quotes an argument so that it will be interpreted literally by a POSIX shell. Taken from http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python """ return "'" + s.replace("'", "'\\''") + "'" def EscapeMakeVariableExpansion(s): """Make has its own variable expansion syntax using $. We must escape it for string to be interpreted literally.""" return s.replace('$', '$$') def EscapeCppDefine(s): """Escapes a CPP define so that it will reach the compiler unaltered.""" s = EscapeShellArgument(s) s = EscapeMakeVariableExpansion(s) # '#' characters must be escaped even embedded in a string, else Make will # treat it as the start of a comment. return s.replace('#', r'\#') def QuoteIfNecessary(string): """TODO: Should this ideally be replaced with one or more of the above functions?""" if '"' in string: string = '"' + string.replace('"', '\\"') + '"' return string def StringToMakefileVariable(string): """Convert a string to a value that is acceptable as a make variable name.""" return re.sub('[^a-zA-Z0-9_]', '_', string) srcdir_prefix = '' def Sourceify(path): """Convert a path to its source directory form.""" if '$(' in path: return path if os.path.isabs(path): return path return srcdir_prefix + path def QuoteSpaces(s, quote=r'\ '): return s.replace(' ', quote) # TODO: Avoid code duplication with _ValidateSourcesForMSVSProject in msvs.py. def _ValidateSourcesForOSX(spec, all_sources): """Makes sure if duplicate basenames are not specified in the source list. Arguments: spec: The target dictionary containing the properties of the target. """ if spec.get('type', None) != 'static_library': return basenames = {} for source in all_sources: name, ext = os.path.splitext(source) is_compiled_file = ext in [ '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S'] if not is_compiled_file: continue basename = os.path.basename(name) # Don't include extension. basenames.setdefault(basename, []).append(source) error = '' for basename, files in basenames.iteritems(): if len(files) > 1: error += ' %s: %s\n' % (basename, ' '.join(files)) if error: print('static library %s has several files with the same basename:\n' % spec['target_name'] + error + 'libtool on OS X will generate' + ' warnings for them.') raise GypError('Duplicate basenames in sources section, see list above') # Map from qualified target to path to output. target_outputs = {} # Map from qualified target to any linkable output. A subset # of target_outputs. E.g. when mybinary depends on liba, we want to # include liba in the linker line; when otherbinary depends on # mybinary, we just want to build mybinary first. target_link_deps = {} class MakefileWriter(object): """MakefileWriter packages up the writing of one target-specific foobar.mk. Its only real entry point is Write(), and is mostly used for namespacing. """ def __init__(self, generator_flags, flavor): self.generator_flags = generator_flags self.flavor = flavor self.suffix_rules_srcdir = {} self.suffix_rules_objdir1 = {} self.suffix_rules_objdir2 = {} # Generate suffix rules for all compilable extensions. for ext in COMPILABLE_EXTENSIONS.keys(): # Suffix rules for source folder. self.suffix_rules_srcdir.update({ext: ("""\ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD @$(call do_cmd,%s,1) """ % (ext, COMPILABLE_EXTENSIONS[ext]))}) # Suffix rules for generated source files. self.suffix_rules_objdir1.update({ext: ("""\ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD @$(call do_cmd,%s,1) """ % (ext, COMPILABLE_EXTENSIONS[ext]))}) self.suffix_rules_objdir2.update({ext: ("""\ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD @$(call do_cmd,%s,1) """ % (ext, COMPILABLE_EXTENSIONS[ext]))}) def Write(self, qualified_target, base_path, output_filename, spec, configs, part_of_all): """The main entry point: writes a .mk file for a single target. Arguments: qualified_target: target we're generating base_path: path relative to source root we're building in, used to resolve target-relative paths output_filename: output .mk file name to write spec, configs: gyp info part_of_all: flag indicating this target is part of 'all' """ gyp.common.EnsureDirExists(output_filename) self.fp = open(output_filename, 'w') self.fp.write(header) self.qualified_target = qualified_target self.path = base_path self.target = spec['target_name'] self.type = spec['type'] self.toolset = spec['toolset'] self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) if self.flavor == 'mac': self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) else: self.xcode_settings = None deps, link_deps = self.ComputeDeps(spec) # Some of the generation below can add extra output, sources, or # link dependencies. All of the out params of the functions that # follow use names like extra_foo. extra_outputs = [] extra_sources = [] extra_link_deps = [] extra_mac_bundle_resources = [] mac_bundle_deps = [] if self.is_mac_bundle: self.output = self.ComputeMacBundleOutput(spec) self.output_binary = self.ComputeMacBundleBinaryOutput(spec) else: self.output = self.output_binary = self.ComputeOutput(spec) self.is_standalone_static_library = bool( spec.get('standalone_static_library', 0)) self._INSTALLABLE_TARGETS = ('executable', 'loadable_module', 'shared_library') if (self.is_standalone_static_library or self.type in self._INSTALLABLE_TARGETS): self.alias = os.path.basename(self.output) install_path = self._InstallableTargetInstallPath() else: self.alias = self.output install_path = self.output self.WriteLn("TOOLSET := " + self.toolset) self.WriteLn("TARGET := " + self.target) # Actions must come first, since they can generate more OBJs for use below. if 'actions' in spec: self.WriteActions(spec['actions'], extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all) # Rules must be early like actions. if 'rules' in spec: self.WriteRules(spec['rules'], extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all) if 'copies' in spec: self.WriteCopies(spec['copies'], extra_outputs, part_of_all) # Bundle resources. if self.is_mac_bundle: all_mac_bundle_resources = ( spec.get('mac_bundle_resources', []) + extra_mac_bundle_resources) self.WriteMacBundleResources(all_mac_bundle_resources, mac_bundle_deps) self.WriteMacInfoPlist(mac_bundle_deps) # Sources. all_sources = spec.get('sources', []) + extra_sources if all_sources: if self.flavor == 'mac': # libtool on OS X generates warnings for duplicate basenames in the same # target. _ValidateSourcesForOSX(spec, all_sources) self.WriteSources( configs, deps, all_sources, extra_outputs, extra_link_deps, part_of_all, gyp.xcode_emulation.MacPrefixHeader( self.xcode_settings, lambda p: Sourceify(self.Absolutify(p)), self.Pchify)) sources = filter(Compilable, all_sources) if sources: self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1) extensions = set([os.path.splitext(s)[1] for s in sources]) for ext in extensions: if ext in self.suffix_rules_srcdir: self.WriteLn(self.suffix_rules_srcdir[ext]) self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT2) for ext in extensions: if ext in self.suffix_rules_objdir1: self.WriteLn(self.suffix_rules_objdir1[ext]) for ext in extensions: if ext in self.suffix_rules_objdir2: self.WriteLn(self.suffix_rules_objdir2[ext]) self.WriteLn('# End of this set of suffix rules') # Add dependency from bundle to bundle binary. if self.is_mac_bundle: mac_bundle_deps.append(self.output_binary) self.WriteTarget(spec, configs, deps, extra_link_deps + link_deps, mac_bundle_deps, extra_outputs, part_of_all) # Update global list of target outputs, used in dependency tracking. target_outputs[qualified_target] = install_path # Update global list of link dependencies. if self.type in ('static_library', 'shared_library'): target_link_deps[qualified_target] = self.output_binary # Currently any versions have the same effect, but in future the behavior # could be different. if self.generator_flags.get('android_ndk_version', None): self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps) self.fp.close() def WriteSubMake(self, output_filename, makefile_path, targets, build_dir): """Write a "sub-project" Makefile. This is a small, wrapper Makefile that calls the top-level Makefile to build the targets from a single gyp file (i.e. a sub-project). Arguments: output_filename: sub-project Makefile name to write makefile_path: path to the top-level Makefile targets: list of "all" targets for this sub-project build_dir: build output directory, relative to the sub-project """ gyp.common.EnsureDirExists(output_filename) self.fp = open(output_filename, 'w') self.fp.write(header) # For consistency with other builders, put sub-project build output in the # sub-project dir (see test/subdirectory/gyptest-subdir-all.py). self.WriteLn('export builddir_name ?= %s' % os.path.join(os.path.dirname(output_filename), build_dir)) self.WriteLn('.PHONY: all') self.WriteLn('all:') if makefile_path: makefile_path = ' -C ' + makefile_path self.WriteLn('\t$(MAKE)%s %s' % (makefile_path, ' '.join(targets))) self.fp.close() def WriteActions(self, actions, extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all): """Write Makefile code for any 'actions' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these actions (used to make other pieces dependent on these actions) part_of_all: flag indicating this target is part of 'all' """ env = self.GetSortedXcodeEnv() for action in actions: name = StringToMakefileVariable('%s_%s' % (self.qualified_target, action['action_name'])) self.WriteLn('### Rules for action "%s":' % action['action_name']) inputs = action['inputs'] outputs = action['outputs'] # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set() for out in outputs: dir = os.path.split(out)[0] if dir: dirs.add(dir) if int(action.get('process_outputs_as_sources', False)): extra_sources += outputs if int(action.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs # Write the actual command. action_commands = action['action'] if self.flavor == 'mac': action_commands = [gyp.xcode_emulation.ExpandEnvVars(command, env) for command in action_commands] command = gyp.common.EncodePOSIXShellList(action_commands) if 'message' in action: self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, action['message'])) else: self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, name)) if len(dirs) > 0: command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command cd_action = 'cd %s; ' % Sourceify(self.path or '.') # command and cd_action get written to a toplevel variable called # cmd_foo. Toplevel variables can't handle things that change per # makefile like $(TARGET), so hardcode the target. command = command.replace('$(TARGET)', self.target) cd_action = cd_action.replace('$(TARGET)', self.target) # Set LD_LIBRARY_PATH in case the action runs an executable from this # build which links to shared libs from this build. # actions run on the host, so they should in theory only use host # libraries, but until everything is made cross-compile safe, also use # target libraries. # TODO(piman): when everything is cross-compile safe, remove lib.target self.WriteLn('cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:' '$(builddir)/lib.target:$$LD_LIBRARY_PATH; ' 'export LD_LIBRARY_PATH; ' '%s%s' % (name, cd_action, command)) self.WriteLn() outputs = map(self.Absolutify, outputs) # The makefile rules are all relative to the top dir, but the gyp actions # are defined relative to their containing dir. This replaces the obj # variable for the action rule with an absolute version so that the output # goes in the right place. # Only write the 'obj' and 'builddir' rules for the "primary" output (:1); # it's superfluous for the "extra outputs", and this avoids accidentally # writing duplicate dummy rules for those outputs. # Same for environment. self.WriteLn("%s: obj := $(abs_obj)" % QuoteSpaces(outputs[0])) self.WriteLn("%s: builddir := $(abs_builddir)" % QuoteSpaces(outputs[0])) self.WriteSortedXcodeEnv(outputs[0], self.GetSortedXcodeEnv()) for input in inputs: assert ' ' not in input, ( "Spaces in action input filenames not supported (%s)" % input) for output in outputs: assert ' ' not in output, ( "Spaces in action output filenames not supported (%s)" % output) # See the comment in WriteCopies about expanding env vars. outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs] inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs] self.WriteDoCmd(outputs, map(Sourceify, map(self.Absolutify, inputs)), part_of_all=part_of_all, command=name) # Stuff the outputs in a variable so we can refer to them later. outputs_variable = 'action_%s_outputs' % name self.WriteLn('%s := %s' % (outputs_variable, ' '.join(outputs))) extra_outputs.append('$(%s)' % outputs_variable) self.WriteLn() self.WriteLn() def WriteRules(self, rules, extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all): """Write Makefile code for any 'rules' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these rules (used to make other pieces dependent on these rules) part_of_all: flag indicating this target is part of 'all' """ env = self.GetSortedXcodeEnv() for rule in rules: name = StringToMakefileVariable('%s_%s' % (self.qualified_target, rule['rule_name'])) count = 0 self.WriteLn('### Generated for rule %s:' % name) all_outputs = [] for rule_source in rule.get('rule_sources', []): dirs = set() (rule_source_dirname, rule_source_basename) = os.path.split(rule_source) (rule_source_root, rule_source_ext) = \ os.path.splitext(rule_source_basename) outputs = [self.ExpandInputRoot(out, rule_source_root, rule_source_dirname) for out in rule['outputs']] for out in outputs: dir = os.path.dirname(out) if dir: dirs.add(dir) if int(rule.get('process_outputs_as_sources', False)): extra_sources += outputs if int(rule.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs inputs = map(Sourceify, map(self.Absolutify, [rule_source] + rule.get('inputs', []))) actions = ['$(call do_cmd,%s_%d)' % (name, count)] if name == 'resources_grit': # HACK: This is ugly. Grit intentionally doesn't touch the # timestamp of its output file when the file doesn't change, # which is fine in hash-based dependency systems like scons # and forge, but not kosher in the make world. After some # discussion, hacking around it here seems like the least # amount of pain. actions += ['@touch --no-create $@'] # See the comment in WriteCopies about expanding env vars. outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs] inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs] outputs = map(self.Absolutify, outputs) all_outputs += outputs # Only write the 'obj' and 'builddir' rules for the "primary" output # (:1); it's superfluous for the "extra outputs", and this avoids # accidentally writing duplicate dummy rules for those outputs. self.WriteLn('%s: obj := $(abs_obj)' % outputs[0]) self.WriteLn('%s: builddir := $(abs_builddir)' % outputs[0]) self.WriteMakeRule(outputs, inputs, actions, command="%s_%d" % (name, count)) # Spaces in rule filenames are not supported, but rule variables have # spaces in them (e.g. RULE_INPUT_PATH expands to '$(abspath $<)'). # The spaces within the variables are valid, so remove the variables # before checking. variables_with_spaces = re.compile(r'\$\([^ ]* \$<\)') for output in outputs: output = re.sub(variables_with_spaces, '', output) assert ' ' not in output, ( "Spaces in rule filenames not yet supported (%s)" % output) self.WriteLn('all_deps += %s' % ' '.join(outputs)) action = [self.ExpandInputRoot(ac, rule_source_root, rule_source_dirname) for ac in rule['action']] mkdirs = '' if len(dirs) > 0: mkdirs = 'mkdir -p %s; ' % ' '.join(dirs) cd_action = 'cd %s; ' % Sourceify(self.path or '.') # action, cd_action, and mkdirs get written to a toplevel variable # called cmd_foo. Toplevel variables can't handle things that change # per makefile like $(TARGET), so hardcode the target. if self.flavor == 'mac': action = [gyp.xcode_emulation.ExpandEnvVars(command, env) for command in action] action = gyp.common.EncodePOSIXShellList(action) action = action.replace('$(TARGET)', self.target) cd_action = cd_action.replace('$(TARGET)', self.target) mkdirs = mkdirs.replace('$(TARGET)', self.target) # Set LD_LIBRARY_PATH in case the rule runs an executable from this # build which links to shared libs from this build. # rules run on the host, so they should in theory only use host # libraries, but until everything is made cross-compile safe, also use # target libraries. # TODO(piman): when everything is cross-compile safe, remove lib.target self.WriteLn( "cmd_%(name)s_%(count)d = LD_LIBRARY_PATH=" "$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; " "export LD_LIBRARY_PATH; " "%(cd_action)s%(mkdirs)s%(action)s" % { 'action': action, 'cd_action': cd_action, 'count': count, 'mkdirs': mkdirs, 'name': name, }) self.WriteLn( 'quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@' % { 'count': count, 'name': name, }) self.WriteLn() count += 1 outputs_variable = 'rule_%s_outputs' % name self.WriteList(all_outputs, outputs_variable) extra_outputs.append('$(%s)' % outputs_variable) self.WriteLn('### Finished generating for rule: %s' % name) self.WriteLn() self.WriteLn('### Finished generating for all rules') self.WriteLn('') def WriteCopies(self, copies, extra_outputs, part_of_all): """Write Makefile code for any 'copies' from the gyp input. extra_outputs: a list that will be filled in with any outputs of this action (used to make other pieces dependent on this action) part_of_all: flag indicating this target is part of 'all' """ self.WriteLn('### Generated for copy rule.') variable = StringToMakefileVariable(self.qualified_target + '_copies') outputs = [] for copy in copies: for path in copy['files']: # Absolutify() may call normpath, and will strip trailing slashes. path = Sourceify(self.Absolutify(path)) filename = os.path.split(path)[1] output = Sourceify(self.Absolutify(os.path.join(copy['destination'], filename))) # If the output path has variables in it, which happens in practice for # 'copies', writing the environment as target-local doesn't work, # because the variables are already needed for the target name. # Copying the environment variables into global make variables doesn't # work either, because then the .d files will potentially contain spaces # after variable expansion, and .d file handling cannot handle spaces. # As a workaround, manually expand variables at gyp time. Since 'copies' # can't run scripts, there's no need to write the env then. # WriteDoCmd() will escape spaces for .d files. env = self.GetSortedXcodeEnv() output = gyp.xcode_emulation.ExpandEnvVars(output, env) path = gyp.xcode_emulation.ExpandEnvVars(path, env) self.WriteDoCmd([output], [path], 'copy', part_of_all) outputs.append(output) self.WriteLn('%s = %s' % (variable, ' '.join(map(QuoteSpaces, outputs)))) extra_outputs.append('$(%s)' % variable) self.WriteLn() def WriteMacBundleResources(self, resources, bundle_deps): """Writes Makefile code for 'mac_bundle_resources'.""" self.WriteLn('### Generated for mac_bundle_resources') for output, res in gyp.xcode_emulation.GetMacBundleResources( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, map(Sourceify, map(self.Absolutify, resources))): _, ext = os.path.splitext(output) if ext != '.xcassets': # Make does not supports '.xcassets' emulation. self.WriteDoCmd([output], [res], 'mac_tool,,,copy-bundle-resource', part_of_all=True) bundle_deps.append(output) def WriteMacInfoPlist(self, bundle_deps): """Write Makefile code for bundle Info.plist files.""" info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, lambda p: Sourceify(self.Absolutify(p))) if not info_plist: return if defines: # Create an intermediate file to store preprocessed results. intermediate_plist = ('$(obj).$(TOOLSET)/$(TARGET)/' + os.path.basename(info_plist)) self.WriteList(defines, intermediate_plist + ': INFOPLIST_DEFINES', '-D', quoter=EscapeCppDefine) self.WriteMakeRule([intermediate_plist], [info_plist], ['$(call do_cmd,infoplist)', # "Convert" the plist so that any weird whitespace changes from the # preprocessor do not affect the XML parser in mac_tool. '@plutil -convert xml1 $@ $@']) info_plist = intermediate_plist # plists can contain envvars and substitute them into the file. self.WriteSortedXcodeEnv( out, self.GetSortedXcodeEnv(additional_settings=extra_env)) self.WriteDoCmd([out], [info_plist], 'mac_tool,,,copy-info-plist', part_of_all=True) bundle_deps.append(out) def WriteSources(self, configs, deps, sources, extra_outputs, extra_link_deps, part_of_all, precompiled_header): """Write Makefile code for any 'sources' from the gyp input. These are source files necessary to build the current target. configs, deps, sources: input from gyp. extra_outputs: a list of extra outputs this action should be dependent on; used to serialize action/rules before compilation extra_link_deps: a list that will be filled in with any outputs of compilation (to be used in link lines) part_of_all: flag indicating this target is part of 'all' """ # Write configuration-specific variables for CFLAGS, etc. for configname in sorted(configs.keys()): config = configs[configname] self.WriteList(config.get('defines'), 'DEFS_%s' % configname, prefix='-D', quoter=EscapeCppDefine) if self.flavor == 'mac': cflags = self.xcode_settings.GetCflags(configname) cflags_c = self.xcode_settings.GetCflagsC(configname) cflags_cc = self.xcode_settings.GetCflagsCC(configname) cflags_objc = self.xcode_settings.GetCflagsObjC(configname) cflags_objcc = self.xcode_settings.GetCflagsObjCC(configname) else: cflags = config.get('cflags') cflags_c = config.get('cflags_c') cflags_cc = config.get('cflags_cc') self.WriteLn("# Flags passed to all source files."); self.WriteList(cflags, 'CFLAGS_%s' % configname) self.WriteLn("# Flags passed to only C files."); self.WriteList(cflags_c, 'CFLAGS_C_%s' % configname) self.WriteLn("# Flags passed to only C++ files."); self.WriteList(cflags_cc, 'CFLAGS_CC_%s' % configname) if self.flavor == 'mac': self.WriteLn("# Flags passed to only ObjC files."); self.WriteList(cflags_objc, 'CFLAGS_OBJC_%s' % configname) self.WriteLn("# Flags passed to only ObjC++ files."); self.WriteList(cflags_objcc, 'CFLAGS_OBJCC_%s' % configname) includes = config.get('include_dirs') if includes: includes = map(Sourceify, map(self.Absolutify, includes)) self.WriteList(includes, 'INCS_%s' % configname, prefix='-I') compilable = filter(Compilable, sources) objs = map(self.Objectify, map(self.Absolutify, map(Target, compilable))) self.WriteList(objs, 'OBJS') for obj in objs: assert ' ' not in obj, ( "Spaces in object filenames not supported (%s)" % obj) self.WriteLn('# Add to the list of files we specially track ' 'dependencies for.') self.WriteLn('all_deps += $(OBJS)') self.WriteLn() # Make sure our dependencies are built first. if deps: self.WriteMakeRule(['$(OBJS)'], deps, comment = 'Make sure our dependencies are built ' 'before any of us.', order_only = True) # Make sure the actions and rules run first. # If they generate any extra headers etc., the per-.o file dep tracking # will catch the proper rebuilds, so order only is still ok here. if extra_outputs: self.WriteMakeRule(['$(OBJS)'], extra_outputs, comment = 'Make sure our actions/rules run ' 'before any of us.', order_only = True) pchdeps = precompiled_header.GetObjDependencies(compilable, objs ) if pchdeps: self.WriteLn('# Dependencies from obj files to their precompiled headers') for source, obj, gch in pchdeps: self.WriteLn('%s: %s' % (obj, gch)) self.WriteLn('# End precompiled header dependencies') if objs: extra_link_deps.append('$(OBJS)') self.WriteLn("""\ # CFLAGS et al overrides must be target-local. # See "Target-specific Variable Values" in the GNU Make manual.""") self.WriteLn("$(OBJS): TOOLSET := $(TOOLSET)") self.WriteLn("$(OBJS): GYP_CFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('c') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_C_$(BUILDTYPE))") self.WriteLn("$(OBJS): GYP_CXXFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('cc') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_CC_$(BUILDTYPE))") if self.flavor == 'mac': self.WriteLn("$(OBJS): GYP_OBJCFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('m') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_C_$(BUILDTYPE)) " "$(CFLAGS_OBJC_$(BUILDTYPE))") self.WriteLn("$(OBJS): GYP_OBJCXXFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('mm') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_CC_$(BUILDTYPE)) " "$(CFLAGS_OBJCC_$(BUILDTYPE))") self.WritePchTargets(precompiled_header.GetPchBuildCommands()) # If there are any object files in our input file list, link them into our # output. extra_link_deps += filter(Linkable, sources) self.WriteLn() def WritePchTargets(self, pch_commands): """Writes make rules to compile prefix headers.""" if not pch_commands: return for gch, lang_flag, lang, input in pch_commands: extra_flags = { 'c': '$(CFLAGS_C_$(BUILDTYPE))', 'cc': '$(CFLAGS_CC_$(BUILDTYPE))', 'm': '$(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))', 'mm': '$(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))', }[lang] var_name = { 'c': 'GYP_PCH_CFLAGS', 'cc': 'GYP_PCH_CXXFLAGS', 'm': 'GYP_PCH_OBJCFLAGS', 'mm': 'GYP_PCH_OBJCXXFLAGS', }[lang] self.WriteLn("%s: %s := %s " % (gch, var_name, lang_flag) + "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "$(CFLAGS_$(BUILDTYPE)) " + extra_flags) self.WriteLn('%s: %s FORCE_DO_CMD' % (gch, input)) self.WriteLn('\t@$(call do_cmd,pch_%s,1)' % lang) self.WriteLn('') assert ' ' not in gch, ( "Spaces in gch filenames not supported (%s)" % gch) self.WriteLn('all_deps += %s' % gch) self.WriteLn('') def ComputeOutputBasename(self, spec): """Return the 'output basename' of a gyp spec. E.g., the loadable module 'foobar' in directory 'baz' will produce 'libfoobar.so' """ assert not self.is_mac_bundle if self.flavor == 'mac' and self.type in ( 'static_library', 'executable', 'shared_library', 'loadable_module'): return self.xcode_settings.GetExecutablePath() target = spec['target_name'] target_prefix = '' target_ext = '' if self.type == 'static_library': if target[:3] == 'lib': target = target[3:] target_prefix = 'lib' target_ext = '.a' elif self.type in ('loadable_module', 'shared_library'): if target[:3] == 'lib': target = target[3:] target_prefix = 'lib' target_ext = '.so' elif self.type == 'none': target = '%s.stamp' % target elif self.type != 'executable': print ("ERROR: What output file should be generated?", "type", self.type, "target", target) target_prefix = spec.get('product_prefix', target_prefix) target = spec.get('product_name', target) product_ext = spec.get('product_extension') if product_ext: target_ext = '.' + product_ext return target_prefix + target + target_ext def _InstallImmediately(self): return self.toolset == 'target' and self.flavor == 'mac' and self.type in ( 'static_library', 'executable', 'shared_library', 'loadable_module') def ComputeOutput(self, spec): """Return the 'output' (full output path) of a gyp spec. E.g., the loadable module 'foobar' in directory 'baz' will produce '$(obj)/baz/libfoobar.so' """ assert not self.is_mac_bundle path = os.path.join('$(obj).' + self.toolset, self.path) if self.type == 'executable' or self._InstallImmediately(): path = '$(builddir)' path = spec.get('product_dir', path) return os.path.join(path, self.ComputeOutputBasename(spec)) def ComputeMacBundleOutput(self, spec): """Return the 'output' (full output path) to a bundle output directory.""" assert self.is_mac_bundle path = generator_default_variables['PRODUCT_DIR'] return os.path.join(path, self.xcode_settings.GetWrapperName()) def ComputeMacBundleBinaryOutput(self, spec): """Return the 'output' (full output path) to the binary in a bundle.""" path = generator_default_variables['PRODUCT_DIR'] return os.path.join(path, self.xcode_settings.GetExecutablePath()) def ComputeDeps(self, spec): """Compute the dependencies of a gyp spec. Returns a tuple (deps, link_deps), where each is a list of filenames that will need to be put in front of make for either building (deps) or linking (link_deps). """ deps = [] link_deps = [] if 'dependencies' in spec: deps.extend([target_outputs[dep] for dep in spec['dependencies'] if target_outputs[dep]]) for dep in spec['dependencies']: if dep in target_link_deps: link_deps.append(target_link_deps[dep]) deps.extend(link_deps) # TODO: It seems we need to transitively link in libraries (e.g. -lfoo)? # This hack makes it work: # link_deps.extend(spec.get('libraries', [])) return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) def WriteDependencyOnExtraOutputs(self, target, extra_outputs): self.WriteMakeRule([self.output_binary], extra_outputs, comment = 'Build our special outputs first.', order_only = True) def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, extra_outputs, part_of_all): """Write Makefile code to produce the final target of the gyp spec. spec, configs: input from gyp. deps, link_deps: dependency lists; see ComputeDeps() extra_outputs: any extra outputs that our target should depend on part_of_all: flag indicating this target is part of 'all' """ self.WriteLn('### Rules for final target.') if extra_outputs: self.WriteDependencyOnExtraOutputs(self.output_binary, extra_outputs) self.WriteMakeRule(extra_outputs, deps, comment=('Preserve order dependency of ' 'special output on deps.'), order_only = True) target_postbuilds = {} if self.type != 'none': for configname in sorted(configs.keys()): config = configs[configname] if self.flavor == 'mac': ldflags = self.xcode_settings.GetLdflags(configname, generator_default_variables['PRODUCT_DIR'], lambda p: Sourceify(self.Absolutify(p))) # TARGET_POSTBUILDS_$(BUILDTYPE) is added to postbuilds later on. gyp_to_build = gyp.common.InvertRelativePath(self.path) target_postbuild = self.xcode_settings.AddImplicitPostbuilds( configname, QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, self.output))), QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, self.output_binary)))) if target_postbuild: target_postbuilds[configname] = target_postbuild else: ldflags = config.get('ldflags', []) # Compute an rpath for this output if needed. if any(dep.endswith('.so') or '.so.' in dep for dep in deps): # We want to get the literal string "$ORIGIN" into the link command, # so we need lots of escaping. ldflags.append(r'-Wl,-rpath=\$$ORIGIN/lib.%s/' % self.toolset) ldflags.append(r'-Wl,-rpath-link=\$(builddir)/lib.%s/' % self.toolset) library_dirs = config.get('library_dirs', []) ldflags += [('-L%s' % library_dir) for library_dir in library_dirs] self.WriteList(ldflags, 'LDFLAGS_%s' % configname) if self.flavor == 'mac': self.WriteList(self.xcode_settings.GetLibtoolflags(configname), 'LIBTOOLFLAGS_%s' % configname) libraries = spec.get('libraries') if libraries: # Remove duplicate entries libraries = gyp.common.uniquer(libraries) if self.flavor == 'mac': libraries = self.xcode_settings.AdjustLibraries(libraries) self.WriteList(libraries, 'LIBS') self.WriteLn('%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % QuoteSpaces(self.output_binary)) self.WriteLn('%s: LIBS := $(LIBS)' % QuoteSpaces(self.output_binary)) if self.flavor == 'mac': self.WriteLn('%s: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))' % QuoteSpaces(self.output_binary)) # Postbuild actions. Like actions, but implicitly depend on the target's # output. postbuilds = [] if self.flavor == 'mac': if target_postbuilds: postbuilds.append('$(TARGET_POSTBUILDS_$(BUILDTYPE))') postbuilds.extend( gyp.xcode_emulation.GetSpecPostbuildCommands(spec)) if postbuilds: # Envvars may be referenced by TARGET_POSTBUILDS_$(BUILDTYPE), # so we must output its definition first, since we declare variables # using ":=". self.WriteSortedXcodeEnv(self.output, self.GetSortedXcodePostbuildEnv()) for configname in target_postbuilds: self.WriteLn('%s: TARGET_POSTBUILDS_%s := %s' % (QuoteSpaces(self.output), configname, gyp.common.EncodePOSIXShellList(target_postbuilds[configname]))) # Postbuilds expect to be run in the gyp file's directory, so insert an # implicit postbuild to cd to there. postbuilds.insert(0, gyp.common.EncodePOSIXShellList(['cd', self.path])) for i in xrange(len(postbuilds)): if not postbuilds[i].startswith('$'): postbuilds[i] = EscapeShellArgument(postbuilds[i]) self.WriteLn('%s: builddir := $(abs_builddir)' % QuoteSpaces(self.output)) self.WriteLn('%s: POSTBUILDS := %s' % ( QuoteSpaces(self.output), ' '.join(postbuilds))) # A bundle directory depends on its dependencies such as bundle resources # and bundle binary. When all dependencies have been built, the bundle # needs to be packaged. if self.is_mac_bundle: # If the framework doesn't contain a binary, then nothing depends # on the actions -- make the framework depend on them directly too. self.WriteDependencyOnExtraOutputs(self.output, extra_outputs) # Bundle dependencies. Note that the code below adds actions to this # target, so if you move these two lines, move the lines below as well. self.WriteList(map(QuoteSpaces, bundle_deps), 'BUNDLE_DEPS') self.WriteLn('%s: $(BUNDLE_DEPS)' % QuoteSpaces(self.output)) # After the framework is built, package it. Needs to happen before # postbuilds, since postbuilds depend on this. if self.type in ('shared_library', 'loadable_module'): self.WriteLn('\t@$(call do_cmd,mac_package_framework,,,%s)' % self.xcode_settings.GetFrameworkVersion()) # Bundle postbuilds can depend on the whole bundle, so run them after # the bundle is packaged, not already after the bundle binary is done. if postbuilds: self.WriteLn('\t@$(call do_postbuilds)') postbuilds = [] # Don't write postbuilds for target's output. # Needed by test/mac/gyptest-rebuild.py. self.WriteLn('\t@true # No-op, used by tests') # Since this target depends on binary and resources which are in # nested subfolders, the framework directory will be older than # its dependencies usually. To prevent this rule from executing # on every build (expensive, especially with postbuilds), expliclity # update the time on the framework directory. self.WriteLn('\t@touch -c %s' % QuoteSpaces(self.output)) if postbuilds: assert not self.is_mac_bundle, ('Postbuilds for bundles should be done ' 'on the bundle, not the binary (target \'%s\')' % self.target) assert 'product_dir' not in spec, ('Postbuilds do not work with ' 'custom product_dir') if self.type == 'executable': self.WriteLn('%s: LD_INPUTS := %s' % ( QuoteSpaces(self.output_binary), ' '.join(map(QuoteSpaces, link_deps)))) if self.toolset == 'host' and self.flavor == 'android': self.WriteDoCmd([self.output_binary], link_deps, 'link_host', part_of_all, postbuilds=postbuilds) else: self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all, postbuilds=postbuilds) elif self.type == 'static_library': for link_dep in link_deps: assert ' ' not in link_dep, ( "Spaces in alink input filenames not supported (%s)" % link_dep) if (self.flavor not in ('mac', 'openbsd', 'netbsd', 'win') and not self.is_standalone_static_library): self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin', part_of_all, postbuilds=postbuilds) else: self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, postbuilds=postbuilds) elif self.type == 'shared_library': self.WriteLn('%s: LD_INPUTS := %s' % ( QuoteSpaces(self.output_binary), ' '.join(map(QuoteSpaces, link_deps)))) self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all, postbuilds=postbuilds) elif self.type == 'loadable_module': for link_dep in link_deps: assert ' ' not in link_dep, ( "Spaces in module input filenames not supported (%s)" % link_dep) if self.toolset == 'host' and self.flavor == 'android': self.WriteDoCmd([self.output_binary], link_deps, 'solink_module_host', part_of_all, postbuilds=postbuilds) else: self.WriteDoCmd( [self.output_binary], link_deps, 'solink_module', part_of_all, postbuilds=postbuilds) elif self.type == 'none': # Write a stamp line. self.WriteDoCmd([self.output_binary], deps, 'touch', part_of_all, postbuilds=postbuilds) else: print "WARNING: no output for", self.type, target # Add an alias for each target (if there are any outputs). # Installable target aliases are created below. if ((self.output and self.output != self.target) and (self.type not in self._INSTALLABLE_TARGETS)): self.WriteMakeRule([self.target], [self.output], comment='Add target alias', phony = True) if part_of_all: self.WriteMakeRule(['all'], [self.target], comment = 'Add target alias to "all" target.', phony = True) # Add special-case rules for our installable targets. # 1) They need to install to the build dir or "product" dir. # 2) They get shortcuts for building (e.g. "make chrome"). # 3) They are part of "make all". if (self.type in self._INSTALLABLE_TARGETS or self.is_standalone_static_library): if self.type == 'shared_library': file_desc = 'shared library' elif self.type == 'static_library': file_desc = 'static library' else: file_desc = 'executable' install_path = self._InstallableTargetInstallPath() installable_deps = [self.output] if (self.flavor == 'mac' and not 'product_dir' in spec and self.toolset == 'target'): # On mac, products are created in install_path immediately. assert install_path == self.output, '%s != %s' % ( install_path, self.output) # Point the target alias to the final binary output. self.WriteMakeRule([self.target], [install_path], comment='Add target alias', phony = True) if install_path != self.output: assert not self.is_mac_bundle # See comment a few lines above. self.WriteDoCmd([install_path], [self.output], 'copy', comment = 'Copy this to the %s output path.' % file_desc, part_of_all=part_of_all) installable_deps.append(install_path) if self.output != self.alias and self.alias != self.target: self.WriteMakeRule([self.alias], installable_deps, comment = 'Short alias for building this %s.' % file_desc, phony = True) if part_of_all: self.WriteMakeRule(['all'], [install_path], comment = 'Add %s to "all" target.' % file_desc, phony = True) def WriteList(self, value_list, variable=None, prefix='', quoter=QuoteIfNecessary): """Write a variable definition that is a list of values. E.g. WriteList(['a','b'], 'foo', prefix='blah') writes out foo = blaha blahb but in a pretty-printed style. """ values = '' if value_list: value_list = [quoter(prefix + l) for l in value_list] values = ' \\\n\t' + ' \\\n\t'.join(value_list) self.fp.write('%s :=%s\n\n' % (variable, values)) def WriteDoCmd(self, outputs, inputs, command, part_of_all, comment=None, postbuilds=False): """Write a Makefile rule that uses do_cmd. This makes the outputs dependent on the command line that was run, as well as support the V= make command line flag. """ suffix = '' if postbuilds: assert ',' not in command suffix = ',,1' # Tell do_cmd to honor $POSTBUILDS self.WriteMakeRule(outputs, inputs, actions = ['$(call do_cmd,%s%s)' % (command, suffix)], comment = comment, command = command, force = True) # Add our outputs to the list of targets we read depfiles from. # all_deps is only used for deps file reading, and for deps files we replace # spaces with ? because escaping doesn't work with make's $(sort) and # other functions. outputs = [QuoteSpaces(o, SPACE_REPLACEMENT) for o in outputs] self.WriteLn('all_deps += %s' % ' '.join(outputs)) def WriteMakeRule(self, outputs, inputs, actions=None, comment=None, order_only=False, force=False, phony=False, command=None): """Write a Makefile rule, with some extra tricks. outputs: a list of outputs for the rule (note: this is not directly supported by make; see comments below) inputs: a list of inputs for the rule actions: a list of shell commands to run for the rule comment: a comment to put in the Makefile above the rule (also useful for making this Python script's code self-documenting) order_only: if true, makes the dependency order-only force: if true, include FORCE_DO_CMD as an order-only dep phony: if true, the rule does not actually generate the named output, the output is just a name to run the rule command: (optional) command name to generate unambiguous labels """ outputs = map(QuoteSpaces, outputs) inputs = map(QuoteSpaces, inputs) if comment: self.WriteLn('# ' + comment) if phony: self.WriteLn('.PHONY: ' + ' '.join(outputs)) if actions: self.WriteLn("%s: TOOLSET := $(TOOLSET)" % outputs[0]) force_append = ' FORCE_DO_CMD' if force else '' if order_only: # Order only rule: Just write a simple rule. # TODO(evanm): just make order_only a list of deps instead of this hack. self.WriteLn('%s: | %s%s' % (' '.join(outputs), ' '.join(inputs), force_append)) elif len(outputs) == 1: # Regular rule, one output: Just write a simple rule. self.WriteLn('%s: %s%s' % (outputs[0], ' '.join(inputs), force_append)) else: # Regular rule, more than one output: Multiple outputs are tricky in # make. We will write three rules: # - All outputs depend on an intermediate file. # - Make .INTERMEDIATE depend on the intermediate. # - The intermediate file depends on the inputs and executes the # actual command. # - The intermediate recipe will 'touch' the intermediate file. # - The multi-output rule will have an do-nothing recipe. intermediate = "%s.intermediate" % (command if command else self.target) self.WriteLn('%s: %s' % (' '.join(outputs), intermediate)) self.WriteLn('\t%s' % '@:'); self.WriteLn('%s: %s' % ('.INTERMEDIATE', intermediate)) self.WriteLn('%s: %s%s' % (intermediate, ' '.join(inputs), force_append)) actions.insert(0, '$(call do_cmd,touch)') if actions: for action in actions: self.WriteLn('\t%s' % action) self.WriteLn() def WriteAndroidNdkModuleRule(self, module_name, all_sources, link_deps): """Write a set of LOCAL_XXX definitions for Android NDK. These variable definitions will be used by Android NDK but do nothing for non-Android applications. Arguments: module_name: Android NDK module name, which must be unique among all module names. all_sources: A list of source files (will be filtered by Compilable). link_deps: A list of link dependencies, which must be sorted in the order from dependencies to dependents. """ if self.type not in ('executable', 'shared_library', 'static_library'): return self.WriteLn('# Variable definitions for Android applications') self.WriteLn('include $(CLEAR_VARS)') self.WriteLn('LOCAL_MODULE := ' + module_name) self.WriteLn('LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) ' '$(DEFS_$(BUILDTYPE)) ' # LOCAL_CFLAGS is applied to both of C and C++. There is # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C # sources. '$(CFLAGS_C_$(BUILDTYPE)) ' # $(INCS_$(BUILDTYPE)) includes the prefix '-I' while # LOCAL_C_INCLUDES does not expect it. So put it in # LOCAL_CFLAGS. '$(INCS_$(BUILDTYPE))') # LOCAL_CXXFLAGS is obsolete and LOCAL_CPPFLAGS is preferred. self.WriteLn('LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))') self.WriteLn('LOCAL_C_INCLUDES :=') self.WriteLn('LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)') # Detect the C++ extension. cpp_ext = {'.cc': 0, '.cpp': 0, '.cxx': 0} default_cpp_ext = '.cpp' for filename in all_sources: ext = os.path.splitext(filename)[1] if ext in cpp_ext: cpp_ext[ext] += 1 if cpp_ext[ext] > cpp_ext[default_cpp_ext]: default_cpp_ext = ext self.WriteLn('LOCAL_CPP_EXTENSION := ' + default_cpp_ext) self.WriteList(map(self.Absolutify, filter(Compilable, all_sources)), 'LOCAL_SRC_FILES') # Filter out those which do not match prefix and suffix and produce # the resulting list without prefix and suffix. def DepsToModules(deps, prefix, suffix): modules = [] for filepath in deps: filename = os.path.basename(filepath) if filename.startswith(prefix) and filename.endswith(suffix): modules.append(filename[len(prefix):-len(suffix)]) return modules # Retrieve the default value of 'SHARED_LIB_SUFFIX' params = {'flavor': 'linux'} default_variables = {} CalculateVariables(default_variables, params) self.WriteList( DepsToModules(link_deps, generator_default_variables['SHARED_LIB_PREFIX'], default_variables['SHARED_LIB_SUFFIX']), 'LOCAL_SHARED_LIBRARIES') self.WriteList( DepsToModules(link_deps, generator_default_variables['STATIC_LIB_PREFIX'], generator_default_variables['STATIC_LIB_SUFFIX']), 'LOCAL_STATIC_LIBRARIES') if self.type == 'executable': self.WriteLn('include $(BUILD_EXECUTABLE)') elif self.type == 'shared_library': self.WriteLn('include $(BUILD_SHARED_LIBRARY)') elif self.type == 'static_library': self.WriteLn('include $(BUILD_STATIC_LIBRARY)') self.WriteLn() def WriteLn(self, text=''): self.fp.write(text + '\n') def GetSortedXcodeEnv(self, additional_settings=None): return gyp.xcode_emulation.GetSortedXcodeEnv( self.xcode_settings, "$(abs_builddir)", os.path.join("$(abs_srcdir)", self.path), "$(BUILDTYPE)", additional_settings) def GetSortedXcodePostbuildEnv(self): # CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack. # TODO(thakis): It would be nice to have some general mechanism instead. strip_save_file = self.xcode_settings.GetPerTargetSetting( 'CHROMIUM_STRIP_SAVE_FILE', '') # Even if strip_save_file is empty, explicitly write it. Else a postbuild # might pick up an export from an earlier target. return self.GetSortedXcodeEnv( additional_settings={'CHROMIUM_STRIP_SAVE_FILE': strip_save_file}) def WriteSortedXcodeEnv(self, target, env): for k, v in env: # For # foo := a\ b # the escaped space does the right thing. For # export foo := a\ b # it does not -- the backslash is written to the env as literal character. # So don't escape spaces in |env[k]|. self.WriteLn('%s: export %s := %s' % (QuoteSpaces(target), k, v)) def Objectify(self, path): """Convert a path to its output directory form.""" if '$(' in path: path = path.replace('$(obj)/', '$(obj).%s/$(TARGET)/' % self.toolset) if not '$(obj)' in path: path = '$(obj).%s/$(TARGET)/%s' % (self.toolset, path) return path def Pchify(self, path, lang): """Convert a prefix header path to its output directory form.""" path = self.Absolutify(path) if '$(' in path: path = path.replace('$(obj)/', '$(obj).%s/$(TARGET)/pch-%s' % (self.toolset, lang)) return path return '$(obj).%s/$(TARGET)/pch-%s/%s' % (self.toolset, lang, path) def Absolutify(self, path): """Convert a subdirectory-relative path into a base-relative path. Skips over paths that contain variables.""" if '$(' in path: # Don't call normpath in this case, as it might collapse the # path too aggressively if it features '..'. However it's still # important to strip trailing slashes. return path.rstrip('/') return os.path.normpath(os.path.join(self.path, path)) def ExpandInputRoot(self, template, expansion, dirname): if '%(INPUT_ROOT)s' not in template and '%(INPUT_DIRNAME)s' not in template: return template path = template % { 'INPUT_ROOT': expansion, 'INPUT_DIRNAME': dirname, } return path def _InstallableTargetInstallPath(self): """Returns the location of the final output for an installable target.""" # Xcode puts shared_library results into PRODUCT_DIR, and some gyp files # rely on this. Emulate this behavior for mac. # XXX(TooTallNate): disabling this code since we don't want this behavior... #if (self.type == 'shared_library' and # (self.flavor != 'mac' or self.toolset != 'target')): # # Install all shared libs into a common directory (per toolset) for # # convenient access with LD_LIBRARY_PATH. # return '$(builddir)/lib.%s/%s' % (self.toolset, self.alias) return '$(builddir)/' + self.alias def WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files): """Write the target to regenerate the Makefile.""" options = params['options'] build_files_args = [gyp.common.RelativePath(filename, options.toplevel_dir) for filename in params['build_files_arg']] gyp_binary = gyp.common.FixIfRelativePath(params['gyp_binary'], options.toplevel_dir) if not gyp_binary.startswith(os.sep): gyp_binary = os.path.join('.', gyp_binary) root_makefile.write( "quiet_cmd_regen_makefile = ACTION Regenerating $@\n" "cmd_regen_makefile = cd $(srcdir); %(cmd)s\n" "%(makefile_name)s: %(deps)s\n" "\t$(call do_cmd,regen_makefile)\n\n" % { 'makefile_name': makefile_name, 'deps': ' '.join(map(Sourceify, build_files)), 'cmd': gyp.common.EncodePOSIXShellList( [gyp_binary, '-fmake'] + gyp.RegenerateFlags(options) + build_files_args)}) def PerformBuild(data, configurations, params): options = params['options'] for config in configurations: arguments = ['make'] if options.toplevel_dir and options.toplevel_dir != '.': arguments += '-C', options.toplevel_dir arguments.append('BUILDTYPE=' + config) print 'Building [%s]: %s' % (config, arguments) subprocess.check_call(arguments) def GenerateOutput(target_list, target_dicts, data, params): options = params['options'] flavor = gyp.common.GetFlavor(params) generator_flags = params.get('generator_flags', {}) builddir_name = generator_flags.get('output_dir', 'out') android_ndk_version = generator_flags.get('android_ndk_version', None) default_target = generator_flags.get('default_target', 'all') def CalculateMakefilePath(build_file, base_name): """Determine where to write a Makefile for a given gyp file.""" # Paths in gyp files are relative to the .gyp file, but we want # paths relative to the source root for the master makefile. Grab # the path of the .gyp file as the base to relativize against. # E.g. "foo/bar" when we're constructing targets for "foo/bar/baz.gyp". base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.depth) # We write the file in the base_path directory. output_file = os.path.join(options.depth, base_path, base_name) if options.generator_output: output_file = os.path.join( options.depth, options.generator_output, base_path, base_name) base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.toplevel_dir) return base_path, output_file # TODO: search for the first non-'Default' target. This can go # away when we add verification that all targets have the # necessary configurations. default_configuration = None toolsets = set([target_dicts[target]['toolset'] for target in target_list]) for target in target_list: spec = target_dicts[target] if spec['default_configuration'] != 'Default': default_configuration = spec['default_configuration'] break if not default_configuration: default_configuration = 'Default' srcdir = '.' makefile_name = 'Makefile' + options.suffix makefile_path = os.path.join(options.toplevel_dir, makefile_name) if options.generator_output: global srcdir_prefix makefile_path = os.path.join( options.toplevel_dir, options.generator_output, makefile_name) srcdir = gyp.common.RelativePath(srcdir, options.generator_output) srcdir_prefix = '$(srcdir)/' flock_command= 'flock' copy_archive_arguments = '-af' header_params = { 'default_target': default_target, 'builddir': builddir_name, 'default_configuration': default_configuration, 'flock': flock_command, 'flock_index': 1, 'link_commands': LINK_COMMANDS_LINUX, 'extra_commands': '', 'srcdir': srcdir, 'copy_archive_args': copy_archive_arguments, } if flavor == 'mac': flock_command = './gyp-mac-tool flock' header_params.update({ 'flock': flock_command, 'flock_index': 2, 'link_commands': LINK_COMMANDS_MAC, 'extra_commands': SHARED_HEADER_MAC_COMMANDS, }) elif flavor == 'android': header_params.update({ 'link_commands': LINK_COMMANDS_ANDROID, }) elif flavor == 'solaris': header_params.update({ 'flock': './gyp-flock-tool flock', 'flock_index': 2, }) elif flavor == 'freebsd': # Note: OpenBSD has sysutils/flock. lockf seems to be FreeBSD specific. header_params.update({ 'flock': 'lockf', }) elif flavor == 'openbsd': copy_archive_arguments = '-pPRf' header_params.update({ 'copy_archive_args': copy_archive_arguments, }) elif flavor == 'aix': copy_archive_arguments = '-pPRf' header_params.update({ 'copy_archive_args': copy_archive_arguments, 'link_commands': LINK_COMMANDS_AIX, 'flock': './gyp-flock-tool flock', 'flock_index': 2, }) header_params.update({ 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'), 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'), 'LINK.target': GetEnvironFallback(('LINK_target', 'LINK'), '$(LINK)'), 'CC.host': GetEnvironFallback(('CC_host', 'CC'), 'gcc'), 'AR.host': GetEnvironFallback(('AR_host', 'AR'), 'ar'), 'CXX.host': GetEnvironFallback(('CXX_host', 'CXX'), 'g++'), 'LINK.host': GetEnvironFallback(('LINK_host', 'LINK'), '$(CXX.host)'), }) build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) make_global_settings_array = data[build_file].get('make_global_settings', []) wrappers = {} for key, value in make_global_settings_array: if key.endswith('_wrapper'): wrappers[key[:-len('_wrapper')]] = '$(abspath %s)' % value make_global_settings = '' for key, value in make_global_settings_array: if re.match('.*_wrapper', key): continue if value[0] != '$': value = '$(abspath %s)' % value wrapper = wrappers.get(key) if wrapper: value = '%s %s' % (wrapper, value) del wrappers[key] if key in ('CC', 'CC.host', 'CXX', 'CXX.host'): make_global_settings += ( 'ifneq (,$(filter $(origin %s), undefined default))\n' % key) # Let gyp-time envvars win over global settings. env_key = key.replace('.', '_') # CC.host -> CC_host if env_key in os.environ: value = os.environ[env_key] make_global_settings += ' %s = %s\n' % (key, value) make_global_settings += 'endif\n' else: make_global_settings += '%s ?= %s\n' % (key, value) # TODO(ukai): define cmd when only wrapper is specified in # make_global_settings. header_params['make_global_settings'] = make_global_settings gyp.common.EnsureDirExists(makefile_path) root_makefile = open(makefile_path, 'w') root_makefile.write(SHARED_HEADER % header_params) # Currently any versions have the same effect, but in future the behavior # could be different. if android_ndk_version: root_makefile.write( '# Define LOCAL_PATH for build of Android applications.\n' 'LOCAL_PATH := $(call my-dir)\n' '\n') for toolset in toolsets: root_makefile.write('TOOLSET := %s\n' % toolset) WriteRootHeaderSuffixRules(root_makefile) # Put build-time support tools next to the root Makefile. dest_path = os.path.dirname(makefile_path) gyp.common.CopyTool(flavor, dest_path) # Find the list of targets that derive from the gyp file(s) being built. needed_targets = set() for build_file in params['build_files']: for target in gyp.common.AllTargets(target_list, target_dicts, build_file): needed_targets.add(target) build_files = set() include_list = set() for qualified_target in target_list: build_file, target, toolset = gyp.common.ParseQualifiedTarget( qualified_target) this_make_global_settings = data[build_file].get('make_global_settings', []) assert make_global_settings_array == this_make_global_settings, ( "make_global_settings needs to be the same for all targets. %s vs. %s" % (this_make_global_settings, make_global_settings)) build_files.add(gyp.common.RelativePath(build_file, options.toplevel_dir)) included_files = data[build_file]['included_files'] for included_file in included_files: # The included_files entries are relative to the dir of the build file # that included them, so we have to undo that and then make them relative # to the root dir. relative_include_file = gyp.common.RelativePath( gyp.common.UnrelativePath(included_file, build_file), options.toplevel_dir) abs_include_file = os.path.abspath(relative_include_file) # If the include file is from the ~/.gyp dir, we should use absolute path # so that relocating the src dir doesn't break the path. if (params['home_dot_gyp'] and abs_include_file.startswith(params['home_dot_gyp'])): build_files.add(abs_include_file) else: build_files.add(relative_include_file) base_path, output_file = CalculateMakefilePath(build_file, target + '.' + toolset + options.suffix + '.mk') spec = target_dicts[qualified_target] configs = spec['configurations'] if flavor == 'mac': gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) writer = MakefileWriter(generator_flags, flavor) writer.Write(qualified_target, base_path, output_file, spec, configs, part_of_all=qualified_target in needed_targets) # Our root_makefile lives at the source root. Compute the relative path # from there to the output_file for including. mkfile_rel_path = gyp.common.RelativePath(output_file, os.path.dirname(makefile_path)) include_list.add(mkfile_rel_path) # Write out per-gyp (sub-project) Makefiles. depth_rel_path = gyp.common.RelativePath(options.depth, os.getcwd()) for build_file in build_files: # The paths in build_files were relativized above, so undo that before # testing against the non-relativized items in target_list and before # calculating the Makefile path. build_file = os.path.join(depth_rel_path, build_file) gyp_targets = [target_dicts[target]['target_name'] for target in target_list if target.startswith(build_file) and target in needed_targets] # Only generate Makefiles for gyp files with targets. if not gyp_targets: continue base_path, output_file = CalculateMakefilePath(build_file, os.path.splitext(os.path.basename(build_file))[0] + '.Makefile') makefile_rel_path = gyp.common.RelativePath(os.path.dirname(makefile_path), os.path.dirname(output_file)) writer.WriteSubMake(output_file, makefile_rel_path, gyp_targets, builddir_name) # Write out the sorted list of includes. root_makefile.write('\n') for include_file in sorted(include_list): # We wrap each .mk include in an if statement so users can tell make to # not load a file by setting NO_LOAD. The below make code says, only # load the .mk file if the .mk filename doesn't start with a token in # NO_LOAD. root_makefile.write( "ifeq ($(strip $(foreach prefix,$(NO_LOAD),\\\n" " $(findstring $(join ^,$(prefix)),\\\n" " $(join ^," + include_file + ")))),)\n") root_makefile.write(" include " + include_file + "\n") root_makefile.write("endif\n") root_makefile.write('\n') if (not generator_flags.get('standalone') and generator_flags.get('auto_regeneration', True)): WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) root_makefile.write(SHARED_FOOTER) root_makefile.close()
gpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 8144, 26, 199, 3, 199, 3, 961, 365, 1006, 28568, 590, 4079, 641, 314, 20618, 2656, 1202, 701, 314, 10130, 199, 3, 5114, 12, 1325, 365, 282, 2222, 13, 9931, 1852, 1553, 781, 5324, 314, 8039, 5936, 199, 3, 3343, 315, 13738, 402, 1852, 436, 4691, 652, 9658, 652, 734, 14, 199, 3, 199, 3, 710, 1233, 5084, 12821, 282, 7396, 1275, 3880, 570, 367, 1924, 1347, 12, 1325, 199, 3, 1006, 787, 1350, 68, 701, 314, 2746, 13, 1896, 20618, 14, 221, 961, 4910, 626, 1006, 199, 3, 2860, 315, 1275, 3880, 13, 1725, 286, 22669, 1373, 4573, 14, 221, 6423, 25082, 370, 675, 12952, 199, 3, 2382, 5827, 367, 8569, 11735, 12, 436, 8545, 590, 370, 9626, 199, 3, 626, 1265, 3984, 440, 295, 6670, 641, 282, 1750, 574, 370, 2061, 506, 3109, 3365, 199, 3, 1275, 3880, 1584, 14, 199, 3, 199, 3, 3254, 83, 26, 199, 3, 199, 3, 13641, 2202, 436, 11420, 3423, 787, 5544, 8292, 379, 315, 314, 199, 3, 13836, 20618, 14, 221, 2779, 1443, 1852, 12249, 370, 3550, 2005, 1275, 3880, 1584, 641, 199, 3, 314, 5366, 370, 4215, 314, 314, 1584, 12701, 14, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 3873, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 23227, 63, 3022, 356, 9774, 1113, 680, 6629, 16892, 2447, 6629, 9268, 2447, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 9774, 1113, 2447, 2268, 297, 523, 283, 14853, 63, 3022, 356, 9774, 21728, 3196, 523, 283, 13578, 63, 7321, 63, 5441, 356, 9487, 7321, 63, 5441, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 9487, 7321, 63, 3022, 2339, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3243, 356, 9774, 4832, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2472, 356, 9774, 4511, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2339, 356, 9774, 1397, 694, 2672, 28, 3196, 523, 283, 22212, 63, 2339, 356, 9774, 25682, 3196, 199, 93, 199, 199, 3, 4155, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 199, 3, 4784, 3355, 5124, 315, 314, 1865, 687, 11410, 83, 370, 5124, 14, 199, 4679, 63, 28789, 63, 5917, 63, 5714, 275, 756, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 8541, 275, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 9, 523, 340, 8541, 508, 283, 3088, 356, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 283, 3088, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 22305, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 339, 327, 11247, 4722, 4306, 2897, 666, 687, 10602, 12, 1314, 365, 5709, 272, 327, 701, 314, 10444, 4155, 4306, 14, 272, 492, 4902, 14, 4679, 14, 8701, 465, 13592, 63, 4679, 272, 2288, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 272, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 297, 3073, 272, 2288, 4306, 63, 8460, 63, 515, 63, 7786, 272, 4306, 63, 8460, 63, 515, 63, 7786, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 515, 63, 7786, 297, 3073, 272, 2288, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 272, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 297, 3073, 272, 16503, 1193, 2617, 63, 18451, 14, 873, 2561, 1370, 77, 356, 283, 27148, 297, 1987, 596, 7, 520, 283, 1113, 9634, 3071, 523, 587, 26, 272, 17406, 63, 2253, 275, 8541, 272, 340, 8541, 508, 283, 6238, 356, 489, 17406, 63, 2253, 275, 283, 5135, 7, 221, 327, 14797, 642, 12139, 5953, 367, 3063, 14, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 17406, 63, 2253, 9, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 1152, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 1673, 6629, 21728, 2447, 773, 24752, 16892, 5942, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 9774, 1113, 680, 6629, 16892, 5942, 421, 199, 318, 12707, 7599, 3205, 2354, 8, 1162, 304, 523, 408, 14860, 314, 4306, 2488, 2256, 626, 7545, 23036, 370, 1324, 334, 3527, 701, 523, 4902, 10477, 523, 4306, 63, 2469, 275, 1862, 14, 362, 360, 4679, 63, 2469, 297, 5009, 523, 15516, 63, 977, 75, 63, 1023, 275, 4306, 63, 2469, 14, 362, 360, 6238, 63, 977, 75, 63, 1023, 297, 488, 9, 523 ]
[ 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 8144, 26, 199, 3, 199, 3, 961, 365, 1006, 28568, 590, 4079, 641, 314, 20618, 2656, 1202, 701, 314, 10130, 199, 3, 5114, 12, 1325, 365, 282, 2222, 13, 9931, 1852, 1553, 781, 5324, 314, 8039, 5936, 199, 3, 3343, 315, 13738, 402, 1852, 436, 4691, 652, 9658, 652, 734, 14, 199, 3, 199, 3, 710, 1233, 5084, 12821, 282, 7396, 1275, 3880, 570, 367, 1924, 1347, 12, 1325, 199, 3, 1006, 787, 1350, 68, 701, 314, 2746, 13, 1896, 20618, 14, 221, 961, 4910, 626, 1006, 199, 3, 2860, 315, 1275, 3880, 13, 1725, 286, 22669, 1373, 4573, 14, 221, 6423, 25082, 370, 675, 12952, 199, 3, 2382, 5827, 367, 8569, 11735, 12, 436, 8545, 590, 370, 9626, 199, 3, 626, 1265, 3984, 440, 295, 6670, 641, 282, 1750, 574, 370, 2061, 506, 3109, 3365, 199, 3, 1275, 3880, 1584, 14, 199, 3, 199, 3, 3254, 83, 26, 199, 3, 199, 3, 13641, 2202, 436, 11420, 3423, 787, 5544, 8292, 379, 315, 314, 199, 3, 13836, 20618, 14, 221, 2779, 1443, 1852, 12249, 370, 3550, 2005, 1275, 3880, 1584, 641, 199, 3, 314, 5366, 370, 4215, 314, 314, 1584, 12701, 14, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 3873, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 23227, 63, 3022, 356, 9774, 1113, 680, 6629, 16892, 2447, 6629, 9268, 2447, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 9774, 1113, 2447, 2268, 297, 523, 283, 14853, 63, 3022, 356, 9774, 21728, 3196, 523, 283, 13578, 63, 7321, 63, 5441, 356, 9487, 7321, 63, 5441, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 9487, 7321, 63, 3022, 2339, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3243, 356, 9774, 4832, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2472, 356, 9774, 4511, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2339, 356, 9774, 1397, 694, 2672, 28, 3196, 523, 283, 22212, 63, 2339, 356, 9774, 25682, 3196, 199, 93, 199, 199, 3, 4155, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 199, 3, 4784, 3355, 5124, 315, 314, 1865, 687, 11410, 83, 370, 5124, 14, 199, 4679, 63, 28789, 63, 5917, 63, 5714, 275, 756, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 8541, 275, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 9, 523, 340, 8541, 508, 283, 3088, 356, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 283, 3088, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 22305, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 339, 327, 11247, 4722, 4306, 2897, 666, 687, 10602, 12, 1314, 365, 5709, 272, 327, 701, 314, 10444, 4155, 4306, 14, 272, 492, 4902, 14, 4679, 14, 8701, 465, 13592, 63, 4679, 272, 2288, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 272, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 297, 3073, 272, 2288, 4306, 63, 8460, 63, 515, 63, 7786, 272, 4306, 63, 8460, 63, 515, 63, 7786, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 515, 63, 7786, 297, 3073, 272, 2288, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 272, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 297, 3073, 272, 16503, 1193, 2617, 63, 18451, 14, 873, 2561, 1370, 77, 356, 283, 27148, 297, 1987, 596, 7, 520, 283, 1113, 9634, 3071, 523, 587, 26, 272, 17406, 63, 2253, 275, 8541, 272, 340, 8541, 508, 283, 6238, 356, 489, 17406, 63, 2253, 275, 283, 5135, 7, 221, 327, 14797, 642, 12139, 5953, 367, 3063, 14, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 17406, 63, 2253, 9, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 1152, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 1673, 6629, 21728, 2447, 773, 24752, 16892, 5942, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 9774, 1113, 680, 6629, 16892, 5942, 421, 199, 318, 12707, 7599, 3205, 2354, 8, 1162, 304, 523, 408, 14860, 314, 4306, 2488, 2256, 626, 7545, 23036, 370, 1324, 334, 3527, 701, 523, 4902, 10477, 523, 4306, 63, 2469, 275, 1862, 14, 362, 360, 4679, 63, 2469, 297, 5009, 523, 15516, 63, 977, 75, 63, 1023, 275, 4306, 63, 2469, 14, 362, 360, 6238, 63, 977, 75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, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
indro/t2c
libs/external_libs/python-openid-2.1.1/openid/test/test_openidyadis.py
87
4828
import unittest from openid.consumer.discover import \ OpenIDServiceEndpoint, OPENID_1_1_TYPE, OPENID_1_0_TYPE from openid.yadis.services import applyFilter XRDS_BOILERPLATE = '''\ <?xml version="1.0" encoding="UTF-8"?> <xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)" xmlns:openid="http://openid.net/xmlns/1.0"> <XRD> %s\ </XRD> </xrds:XRDS> ''' def mkXRDS(services): return XRDS_BOILERPLATE % (services,) def mkService(uris=None, type_uris=None, local_id=None, dent=' '): chunks = [dent, '<Service>\n'] dent2 = dent + ' ' if type_uris: for type_uri in type_uris: chunks.extend([dent2 + '<Type>', type_uri, '</Type>\n']) if uris: for uri in uris: if type(uri) is tuple: uri, prio = uri else: prio = None chunks.extend([dent2, '<URI']) if prio is not None: chunks.extend([' priority="', str(prio), '"']) chunks.extend(['>', uri, '</URI>\n']) if local_id: chunks.extend( [dent2, '<openid:Delegate>', local_id, '</openid:Delegate>\n']) chunks.extend([dent, '</Service>\n']) return ''.join(chunks) # Different sets of server URLs for use in the URI tag server_url_options = [ [], # This case should not generate an endpoint object ['http://server.url/'], ['https://server.url/'], ['https://server.url/', 'http://server.url/'], ['https://server.url/', 'http://server.url/', 'http://example.server.url/'], ] # Used for generating test data def subsets(l): """Generate all non-empty sublists of a list""" subsets_list = [[]] for x in l: subsets_list += [[x] + t for t in subsets_list] return subsets_list # A couple of example extension type URIs. These are not at all # official, but are just here for testing. ext_types = [ 'http://janrain.com/extension/blah', 'http://openid.net/sreg/1.0', ] # All valid combinations of Type tags that should produce an OpenID endpoint type_uri_options = [ exts + ts # All non-empty sublists of the valid OpenID type URIs for ts in subsets([OPENID_1_0_TYPE, OPENID_1_1_TYPE]) if ts # All combinations of extension types (including empty extenstion list) for exts in subsets(ext_types) ] # Range of valid Delegate tag values for generating test data local_id_options = [ None, 'http://vanity.domain/', 'https://somewhere/yadis/', ] # All combinations of valid URIs, Type URIs and Delegate tags data = [ (uris, type_uris, local_id) for uris in server_url_options for type_uris in type_uri_options for local_id in local_id_options ] class OpenIDYadisTest(unittest.TestCase): def __init__(self, uris, type_uris, local_id): unittest.TestCase.__init__(self) self.uris = uris self.type_uris = type_uris self.local_id = local_id def shortDescription(self): # XXX: return 'Successful OpenID Yadis parsing case' def setUp(self): self.yadis_url = 'http://unit.test/' # Create an XRDS document to parse services = mkService(uris=self.uris, type_uris=self.type_uris, local_id=self.local_id) self.xrds = mkXRDS(services) def runTest(self): # Parse into endpoint objects that we will check endpoints = applyFilter( self.yadis_url, self.xrds, OpenIDServiceEndpoint) # make sure there are the same number of endpoints as # URIs. This assumes that the type_uris contains at least one # OpenID type. self.failUnlessEqual(len(self.uris), len(endpoints)) # So that we can check equality on the endpoint types type_uris = list(self.type_uris) type_uris.sort() seen_uris = [] for endpoint in endpoints: seen_uris.append(endpoint.server_url) # All endpoints will have same yadis_url self.failUnlessEqual(self.yadis_url, endpoint.claimed_id) # and local_id self.failUnlessEqual(self.local_id, endpoint.local_id) # and types actual_types = list(endpoint.type_uris) actual_types.sort() self.failUnlessEqual(actual_types, type_uris) # So that they will compare equal, because we don't care what # order they are in seen_uris.sort() uris = list(self.uris) uris.sort() # Make sure we saw all URIs, and saw each one once self.failUnlessEqual(uris, seen_uris) def pyUnitTests(): cases = [] for args in data: cases.append(OpenIDYadisTest(*args)) return unittest.TestSuite(cases)
mit
[ 646, 2882, 199, 504, 24494, 14, 8542, 14, 18861, 492, 971, 1362, 25463, 3167, 11442, 12, 24164, 998, 63, 17, 63, 17, 63, 2711, 12, 24164, 998, 63, 17, 63, 16, 63, 2711, 199, 199, 504, 24494, 14, 11552, 2297, 14, 5950, 492, 4838, 4131, 421, 199, 12297, 3177, 63, 3973, 1193, 540, 2749, 1951, 275, 18087, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 15775, 795, 26, 12297, 3177, 9604, 26, 15775, 795, 628, 88, 322, 921, 4, 15775, 795, 2, 1779, 9604, 628, 88, 322, 921, 4, 88, 6883, 5830, 4, 86, 10, 18, 14, 16, 2924, 1779, 9604, 26, 15403, 628, 1014, 921, 15403, 14, 846, 15, 13991, 15, 17, 14, 16, 1743, 272, 665, 12297, 36, 30, 199, 5, 83, 60, 272, 3068, 12297, 36, 30, 199, 1108, 15775, 795, 26, 12297, 3177, 30, 199, 2344, 199, 199, 318, 9199, 12297, 3177, 8, 5950, 304, 272, 372, 1323, 50, 3177, 63, 3973, 1193, 540, 2749, 1951, 450, 334, 5950, 4258, 199, 199, 318, 9199, 3167, 8, 17656, 29, 403, 12, 730, 63, 17656, 29, 403, 12, 2257, 63, 344, 29, 403, 12, 477, 343, 534, 263, 18927, 272, 8291, 275, 359, 1326, 12, 2650, 3167, 3072, 78, 418, 272, 477, 343, 18, 275, 477, 343, 435, 283, 259, 283, 272, 340, 730, 63, 17656, 26, 267, 367, 730, 63, 2302, 315, 730, 63, 17656, 26, 288, 8291, 14, 2880, 779, 1326, 18, 435, 2650, 804, 4206, 730, 63, 2302, 12, 11936, 804, 3072, 78, 1105, 339, 340, 7629, 374, 26, 267, 367, 5108, 315, 7629, 374, 26, 288, 340, 730, 8, 2302, 9, 365, 2008, 26, 355, 5108, 12, 20449, 275, 5108, 288, 587, 26, 355, 20449, 275, 488, 953, 8291, 14, 2880, 779, 1326, 18, 12, 2650, 7639, 1105, 288, 340, 20449, 365, 440, 488, 26, 355, 8291, 14, 2880, 2941, 7464, 628, 297, 620, 8, 20572, 395, 5522, 1105, 288, 8291, 14, 2880, 2941, 4206, 5108, 12, 11936, 7639, 3072, 78, 1105, 339, 340, 2257, 63, 344, 26, 267, 8291, 14, 2880, 8, 288, 359, 1326, 18, 12, 2650, 15403, 26, 21553, 4206, 2257, 63, 344, 12, 11936, 15403, 26, 21553, 3072, 78, 1105, 339, 8291, 14, 2880, 779, 1326, 12, 11936, 3167, 3072, 78, 1105, 339, 372, 6522, 904, 8, 10660, 9, 199, 199, 3, 18029, 640, 5951, 402, 1654, 10867, 367, 675, 315, 314, 9022, 1947, 199, 1000, 63, 633, 63, 1419, 275, 359, 272, 990, 327, 961, 1930, 1077, 440, 3550, 376, 6037, 909, 272, 788, 1014, 921, 1000, 14, 633, 15, 995, 272, 788, 2859, 921, 1000, 14, 633, 15, 995, 272, 788, 2859, 921, 1000, 14, 633, 3678, 283, 1014, 921, 1000, 14, 633, 15, 995, 272, 788, 2859, 921, 1000, 14, 633, 3678, 1362, 283, 1014, 921, 1000, 14, 633, 3678, 1362, 283, 1014, 921, 2694, 14, 1000, 14, 633, 15, 995, 272, 1622, 199, 199, 3, 8051, 367, 12999, 511, 666, 199, 318, 30767, 8, 76, 304, 272, 408, 6864, 1006, 2222, 13, 1667, 1007, 6717, 402, 282, 769, 624, 272, 30767, 63, 513, 275, 3474, 2677, 272, 367, 671, 315, 634, 26, 267, 30767, 63, 513, 847, 3474, 88, 61, 435, 307, 367, 307, 315, 30767, 63, 513, 61, 272, 372, 30767, 63, 513, 199, 199, 3, 437, 17535, 402, 2893, 3329, 730, 30143, 14, 5723, 787, 440, 737, 1006, 199, 3, 25410, 12, 1325, 787, 2951, 2348, 367, 5343, 14, 199, 832, 63, 1313, 275, 359, 272, 283, 1014, 921, 24418, 6322, 14, 957, 15, 3435, 15, 12702, 297, 272, 283, 1014, 921, 15403, 14, 846, 15, 83, 1135, 15, 17, 14, 16, 297, 272, 1622, 199, 199, 3, 2900, 1686, 15821, 402, 2434, 3762, 626, 1077, 7389, 376, 25463, 6037, 199, 466, 63, 2302, 63, 1419, 275, 359, 272, 27688, 435, 6714, 339, 327, 2900, 2222, 13, 1667, 1007, 6717, 402, 314, 1686, 25463, 730, 30143, 272, 367, 6714, 315, 30767, 779, 9935, 998, 63, 17, 63, 16, 63, 2711, 12, 24164, 998, 63, 17, 63, 17, 63, 2711, 566, 272, 340, 6714, 339, 327, 2900, 15821, 402, 3329, 2943, 334, 15768, 2701, 2178, 270, 1636, 769, 9, 272, 367, 27688, 315, 30767, 8, 832, 63, 1313, 9, 272, 1622, 199, 199, 3, 13114, 402, 1686, 12035, 3237, 1947, 1338, 367, 12999, 511, 666, 199, 1832, 63, 344, 63, 1419, 275, 359, 272, 488, 12, 272, 283, 1014, 921, 86, 8945, 14, 2261, 3678, 272, 283, 2859, 921, 3972, 4509, 15, 11552, 2297, 3678, 272, 1622, 199, 199, 3, 2900, 15821, 402, 1686, 30143, 12, 2434, 30143, 436, 12035, 3237, 3762, 199, 576, 275, 359, 272, 334, 17656, 12, 730, 63, 17656, 12, 2257, 63, 344, 9, 272, 367, 7629, 374, 315, 1654, 63, 633, 63, 1419, 272, 367, 730, 63, 17656, 315, 730, 63, 2302, 63, 1419, 272, 367, 2257, 63, 344, 315, 2257, 63, 344, 63, 1419, 272, 1622, 199, 199, 533, 25463, 28786, 2297, 774, 8, 2796, 14, 1746, 304, 272, 347, 636, 826, 721, 277, 12, 7629, 374, 12, 730, 63, 17656, 12, 2257, 63, 344, 304, 267, 2882, 14, 1746, 855, 826, 721, 277, 9, 267, 291, 14, 17656, 275, 7629, 374, 267, 291, 14, 466, 63, 17656, 275, 730, 63, 17656, 267, 291, 14, 1832, 63, 344, 275, 2257, 63, 344, 339, 347, 3974, 5831, 8, 277, 304, 267, 327, 5787, 26, 267, 372, 283, 20839, 25463, 1488, 65, 2297, 6057, 1930, 7, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 11552, 2297, 63, 633, 275, 283, 1014, 921, 3248, 14, 396, 4805, 398, 327, 2790, 376, 1323, 50, 3177, 2213, 370, 2198, 267, 8500, 275, 9199, 3167, 8, 17656, 29, 277, 14, 17656, 12, 2490, 730, 63, 17656, 29, 277, 14, 466, 63, 17656, 12, 2490, 2257, 63, 344, 29, 277, 14, 1832, 63, 344, 9, 267, 291, 14, 15775, 795, 275, 9199, 12297, 3177, 8, 5950, 9, 339, 347, 29779, 8, 277, 304, 267, 327, 6077, 1901, 6037, 2251, 626, 781, 911, 1104, 267, 16173, 275, 4838, 4131, 8, 288, 291, 14, 11552, 2297, 63, 633, 12, 291, 14, 15775, 795, 12, 25463, 3167, 11442, 9, 398, 327, 1852 ]
[ 2882, 199, 504, 24494, 14, 8542, 14, 18861, 492, 971, 1362, 25463, 3167, 11442, 12, 24164, 998, 63, 17, 63, 17, 63, 2711, 12, 24164, 998, 63, 17, 63, 16, 63, 2711, 199, 199, 504, 24494, 14, 11552, 2297, 14, 5950, 492, 4838, 4131, 421, 199, 12297, 3177, 63, 3973, 1193, 540, 2749, 1951, 275, 18087, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 15775, 795, 26, 12297, 3177, 9604, 26, 15775, 795, 628, 88, 322, 921, 4, 15775, 795, 2, 1779, 9604, 628, 88, 322, 921, 4, 88, 6883, 5830, 4, 86, 10, 18, 14, 16, 2924, 1779, 9604, 26, 15403, 628, 1014, 921, 15403, 14, 846, 15, 13991, 15, 17, 14, 16, 1743, 272, 665, 12297, 36, 30, 199, 5, 83, 60, 272, 3068, 12297, 36, 30, 199, 1108, 15775, 795, 26, 12297, 3177, 30, 199, 2344, 199, 199, 318, 9199, 12297, 3177, 8, 5950, 304, 272, 372, 1323, 50, 3177, 63, 3973, 1193, 540, 2749, 1951, 450, 334, 5950, 4258, 199, 199, 318, 9199, 3167, 8, 17656, 29, 403, 12, 730, 63, 17656, 29, 403, 12, 2257, 63, 344, 29, 403, 12, 477, 343, 534, 263, 18927, 272, 8291, 275, 359, 1326, 12, 2650, 3167, 3072, 78, 418, 272, 477, 343, 18, 275, 477, 343, 435, 283, 259, 283, 272, 340, 730, 63, 17656, 26, 267, 367, 730, 63, 2302, 315, 730, 63, 17656, 26, 288, 8291, 14, 2880, 779, 1326, 18, 435, 2650, 804, 4206, 730, 63, 2302, 12, 11936, 804, 3072, 78, 1105, 339, 340, 7629, 374, 26, 267, 367, 5108, 315, 7629, 374, 26, 288, 340, 730, 8, 2302, 9, 365, 2008, 26, 355, 5108, 12, 20449, 275, 5108, 288, 587, 26, 355, 20449, 275, 488, 953, 8291, 14, 2880, 779, 1326, 18, 12, 2650, 7639, 1105, 288, 340, 20449, 365, 440, 488, 26, 355, 8291, 14, 2880, 2941, 7464, 628, 297, 620, 8, 20572, 395, 5522, 1105, 288, 8291, 14, 2880, 2941, 4206, 5108, 12, 11936, 7639, 3072, 78, 1105, 339, 340, 2257, 63, 344, 26, 267, 8291, 14, 2880, 8, 288, 359, 1326, 18, 12, 2650, 15403, 26, 21553, 4206, 2257, 63, 344, 12, 11936, 15403, 26, 21553, 3072, 78, 1105, 339, 8291, 14, 2880, 779, 1326, 12, 11936, 3167, 3072, 78, 1105, 339, 372, 6522, 904, 8, 10660, 9, 199, 199, 3, 18029, 640, 5951, 402, 1654, 10867, 367, 675, 315, 314, 9022, 1947, 199, 1000, 63, 633, 63, 1419, 275, 359, 272, 990, 327, 961, 1930, 1077, 440, 3550, 376, 6037, 909, 272, 788, 1014, 921, 1000, 14, 633, 15, 995, 272, 788, 2859, 921, 1000, 14, 633, 15, 995, 272, 788, 2859, 921, 1000, 14, 633, 3678, 283, 1014, 921, 1000, 14, 633, 15, 995, 272, 788, 2859, 921, 1000, 14, 633, 3678, 1362, 283, 1014, 921, 1000, 14, 633, 3678, 1362, 283, 1014, 921, 2694, 14, 1000, 14, 633, 15, 995, 272, 1622, 199, 199, 3, 8051, 367, 12999, 511, 666, 199, 318, 30767, 8, 76, 304, 272, 408, 6864, 1006, 2222, 13, 1667, 1007, 6717, 402, 282, 769, 624, 272, 30767, 63, 513, 275, 3474, 2677, 272, 367, 671, 315, 634, 26, 267, 30767, 63, 513, 847, 3474, 88, 61, 435, 307, 367, 307, 315, 30767, 63, 513, 61, 272, 372, 30767, 63, 513, 199, 199, 3, 437, 17535, 402, 2893, 3329, 730, 30143, 14, 5723, 787, 440, 737, 1006, 199, 3, 25410, 12, 1325, 787, 2951, 2348, 367, 5343, 14, 199, 832, 63, 1313, 275, 359, 272, 283, 1014, 921, 24418, 6322, 14, 957, 15, 3435, 15, 12702, 297, 272, 283, 1014, 921, 15403, 14, 846, 15, 83, 1135, 15, 17, 14, 16, 297, 272, 1622, 199, 199, 3, 2900, 1686, 15821, 402, 2434, 3762, 626, 1077, 7389, 376, 25463, 6037, 199, 466, 63, 2302, 63, 1419, 275, 359, 272, 27688, 435, 6714, 339, 327, 2900, 2222, 13, 1667, 1007, 6717, 402, 314, 1686, 25463, 730, 30143, 272, 367, 6714, 315, 30767, 779, 9935, 998, 63, 17, 63, 16, 63, 2711, 12, 24164, 998, 63, 17, 63, 17, 63, 2711, 566, 272, 340, 6714, 339, 327, 2900, 15821, 402, 3329, 2943, 334, 15768, 2701, 2178, 270, 1636, 769, 9, 272, 367, 27688, 315, 30767, 8, 832, 63, 1313, 9, 272, 1622, 199, 199, 3, 13114, 402, 1686, 12035, 3237, 1947, 1338, 367, 12999, 511, 666, 199, 1832, 63, 344, 63, 1419, 275, 359, 272, 488, 12, 272, 283, 1014, 921, 86, 8945, 14, 2261, 3678, 272, 283, 2859, 921, 3972, 4509, 15, 11552, 2297, 3678, 272, 1622, 199, 199, 3, 2900, 15821, 402, 1686, 30143, 12, 2434, 30143, 436, 12035, 3237, 3762, 199, 576, 275, 359, 272, 334, 17656, 12, 730, 63, 17656, 12, 2257, 63, 344, 9, 272, 367, 7629, 374, 315, 1654, 63, 633, 63, 1419, 272, 367, 730, 63, 17656, 315, 730, 63, 2302, 63, 1419, 272, 367, 2257, 63, 344, 315, 2257, 63, 344, 63, 1419, 272, 1622, 199, 199, 533, 25463, 28786, 2297, 774, 8, 2796, 14, 1746, 304, 272, 347, 636, 826, 721, 277, 12, 7629, 374, 12, 730, 63, 17656, 12, 2257, 63, 344, 304, 267, 2882, 14, 1746, 855, 826, 721, 277, 9, 267, 291, 14, 17656, 275, 7629, 374, 267, 291, 14, 466, 63, 17656, 275, 730, 63, 17656, 267, 291, 14, 1832, 63, 344, 275, 2257, 63, 344, 339, 347, 3974, 5831, 8, 277, 304, 267, 327, 5787, 26, 267, 372, 283, 20839, 25463, 1488, 65, 2297, 6057, 1930, 7, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 11552, 2297, 63, 633, 275, 283, 1014, 921, 3248, 14, 396, 4805, 398, 327, 2790, 376, 1323, 50, 3177, 2213, 370, 2198, 267, 8500, 275, 9199, 3167, 8, 17656, 29, 277, 14, 17656, 12, 2490, 730, 63, 17656, 29, 277, 14, 466, 63, 17656, 12, 2490, 2257, 63, 344, 29, 277, 14, 1832, 63, 344, 9, 267, 291, 14, 15775, 795, 275, 9199, 12297, 3177, 8, 5950, 9, 339, 347, 29779, 8, 277, 304, 267, 327, 6077, 1901, 6037, 2251, 626, 781, 911, 1104, 267, 16173, 275, 4838, 4131, 8, 288, 291, 14, 11552, 2297, 63, 633, 12, 291, 14, 15775, 795, 12, 25463, 3167, 11442, 9, 398, 327, 1852, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
JCBarahona/edX
lms/djangoapps/courseware/features/annotatable.py
158
3492
import textwrap from lettuce import world, steps from nose.tools import assert_in, assert_equals from common import i_am_registered_for_the_course, visit_scenario_item DATA_TEMPLATE = textwrap.dedent("""\ <annotatable> <instructions>Instruction text</instructions> <p>{}</p> </annotatable> """) ANNOTATION_TEMPLATE = textwrap.dedent("""\ Before {0}. <annotation title="region {0}" body="Comment {0}" highlight="yellow" problem="{0}"> Region Contents {0} </annotation> After {0}. """) PROBLEM_TEMPLATE = textwrap.dedent("""\ <problem max_attempts="1" weight=""> <annotationresponse> <annotationinput> <title>Question {number}</title> <text>Region Contents {number}</text> <comment>What number is this region?</comment> <comment_prompt>Type your response below:</comment_prompt> <tag_prompt>What number is this region?</tag_prompt> <options> {options} </options> </annotationinput> </annotationresponse> <solution> This problem is checking region {number} </solution> </problem> """) OPTION_TEMPLATE = """<option choice="{correctness}">{number}</option>""" def _correctness(choice, target): if choice == target: return "correct" elif abs(choice - target) == 1: return "partially-correct" else: return "incorrect" @steps class AnnotatableSteps(object): def __init__(self): self.annotations_count = None self.active_problem = None def define_component(self, step, count): r"""that a course has an annotatable component with (?P<count>\d+) annotations$""" count = int(count) coursenum = 'test_course' i_am_registered_for_the_course(step, coursenum) world.scenario_dict['ANNOTATION_VERTICAL'] = world.ItemFactory( parent_location=world.scenario_dict['SECTION'].location, category='vertical', display_name="Test Annotation Vertical" ) world.scenario_dict['ANNOTATABLE'] = world.ItemFactory( parent_location=world.scenario_dict['ANNOTATION_VERTICAL'].location, category='annotatable', display_name="Test Annotation Module", data=DATA_TEMPLATE.format("\n".join(ANNOTATION_TEMPLATE.format(i) for i in xrange(count))) ) self.annotations_count = count def view_component(self, step): r"""I view the annotatable component$""" visit_scenario_item('ANNOTATABLE') def check_rendered(self, step): r"""the annotatable component has rendered$""" world.wait_for_js_variable_truthy('$(".xblock-student_view[data-type=Annotatable]").data("initialized")') annotatable_text = world.css_find('.xblock-student_view[data-type=Annotatable]').first.text assert_in("Instruction text", annotatable_text) for i in xrange(self.annotations_count): assert_in("Region Contents {}".format(i), annotatable_text) def count_passages(self, step, count): r"""the annotatable component has (?P<count>\d+) highlighted passages$""" count = int(count) assert_equals(len(world.css_find('.annotatable-span')), count) assert_equals(len(world.css_find('.annotatable-span.highlight')), count) assert_equals(len(world.css_find('.annotatable-span.highlight-yellow')), count) # This line is required by @steps in order to actually bind the step # regexes AnnotatableSteps()
agpl-3.0
[ 646, 13390, 199, 199, 504, 4691, 84, 3683, 492, 6701, 12, 7124, 199, 504, 11354, 14, 2537, 492, 702, 63, 262, 12, 702, 63, 11332, 199, 199, 504, 2863, 492, 284, 63, 455, 63, 11616, 63, 509, 63, 1589, 63, 1972, 12, 5684, 63, 13444, 63, 1053, 199, 199, 3998, 63, 7433, 275, 13390, 14, 14674, 21723, 272, 665, 3226, 15511, 30, 267, 665, 20718, 30, 17700, 1318, 1108, 20718, 30, 267, 665, 80, 30, 2440, 1108, 80, 30, 272, 3068, 3226, 15511, 30, 199, 6141, 199, 199, 879, 4609, 2594, 63, 7433, 275, 13390, 14, 14674, 21723, 272, 21467, 469, 16, 5565, 272, 665, 9340, 2538, 628, 4551, 469, 16, 7063, 2396, 628, 7488, 469, 16, 7063, 11850, 628, 14514, 2, 5160, 18448, 16, 93, 1743, 267, 22240, 6646, 83, 469, 16, 93, 272, 3068, 9340, 30, 272, 12836, 469, 16, 5565, 199, 6141, 199, 199, 30533, 25847, 63, 7433, 275, 13390, 14, 14674, 21723, 199, 28, 6462, 1390, 63, 13143, 628, 17, 2, 5401, 9287, 30, 523, 665, 9340, 1310, 30, 272, 665, 9340, 1210, 30, 489, 665, 1213, 30, 16778, 469, 1955, 17890, 1213, 30, 489, 665, 505, 30, 10708, 6646, 83, 469, 1955, 17890, 505, 30, 489, 665, 3349, 30, 21015, 1329, 365, 642, 4897, 31, 1108, 3349, 30, 489, 665, 3349, 63, 7650, 30, 804, 2195, 1177, 5084, 9919, 3349, 63, 7650, 30, 489, 665, 1450, 63, 7650, 30, 21015, 1329, 365, 642, 4897, 31, 1108, 1450, 63, 7650, 30, 489, 665, 1419, 30, 489, 469, 1419, 93, 489, 3068, 1419, 30, 272, 3068, 9340, 1210, 30, 523, 3068, 9340, 1310, 30, 523, 665, 14458, 30, 272, 961, 5160, 365, 7907, 4897, 469, 1955, 93, 523, 3068, 14458, 30, 199, 1108, 6462, 30, 199, 6141, 199, 199, 13352, 63, 7433, 275, 8894, 1422, 7141, 18448, 4525, 4171, 93, 1743, 91, 1955, 17890, 1422, 11193, 421, 199, 318, 485, 4525, 4171, 8, 5095, 12, 1347, 304, 272, 340, 7141, 508, 1347, 26, 267, 372, 298, 4525, 2, 272, 916, 2853, 8, 5095, 446, 1347, 9, 508, 413, 26, 267, 372, 298, 462, 9406, 13, 4525, 2, 272, 587, 26, 267, 372, 298, 15448, 2, 421, 199, 32, 5895, 199, 533, 1626, 1397, 15511, 20960, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 11270, 63, 835, 275, 488, 267, 291, 14, 2682, 63, 6462, 275, 488, 339, 347, 5627, 63, 3173, 8, 277, 12, 3650, 12, 2338, 304, 267, 519, 624, 9099, 282, 2518, 965, 376, 7032, 15511, 3931, 543, 7558, 48, 28, 835, 3072, 68, 8771, 15538, 4, 624, 398, 2338, 275, 1109, 8, 835, 9, 267, 2518, 1507, 275, 283, 396, 63, 1972, 7, 267, 284, 63, 455, 63, 11616, 63, 509, 63, 1589, 63, 1972, 8, 2926, 12, 2518, 1507, 9, 398, 6701, 14, 13444, 63, 807, 459, 879, 4609, 2594, 63, 22634, 418, 275, 6701, 14, 2081, 2927, 8, 288, 1676, 63, 1985, 29, 7617, 14, 13444, 63, 807, 459, 13835, 2278, 1985, 12, 288, 4637, 534, 7870, 297, 288, 2929, 63, 354, 628, 774, 30793, 5444, 3294, 2, 267, 776, 398, 6701, 14, 13444, 63, 807, 459, 879, 4609, 619, 2617, 418, 275, 6701, 14, 2081, 2927, 8, 288, 1676, 63, 1985, 29, 7617, 14, 13444, 63, 807, 459, 879, 4609, 2594, 63, 22634, 2278, 1985, 12, 288, 4637, 534, 3226, 15511, 297, 288, 2929, 63, 354, 628, 774, 30793, 5673, 401, 288, 666, 29, 3998, 63, 7433, 14, 908, 4582, 78, 1674, 904, 8, 879, 4609, 2594, 63, 7433, 14, 908, 8, 73, 9, 367, 284, 315, 4945, 8, 835, 1724, 267, 776, 267, 291, 14, 11270, 63, 835, 275, 2338, 339, 347, 2455, 63, 3173, 8, 277, 12, 3650, 304, 267, 519, 624, 41, 2455, 314, 7032, 15511, 3931, 4, 624, 267, 5684, 63, 13444, 63, 1053, 360, 879, 4609, 619, 2617, 358, 339, 347, 1104, 63, 16841, 8, 277, 12, 3650, 304, 267, 519, 624, 1589, 7032, 15511, 3931, 965, 8018, 4, 624, 267, 6701, 14, 2573, 63, 509, 63, 3596, 63, 1975, 63, 17167, 89, 14676, 9520, 11283, 13, 5500, 63, 1345, 59, 576, 13, 466, 29, 21761, 15511, 61, 3471, 576, 480, 12486, 531, 358, 267, 7032, 15511, 63, 505, 275, 6701, 14, 3919, 63, 1623, 5175, 11283, 13, 5500, 63, 1345, 59, 576, 13, 466, 29, 21761, 15511, 61, 1959, 2246, 14, 505, 267, 702, 63, 262, 480, 17700, 1318, 401, 7032, 15511, 63, 505, 9, 398, 367, 284, 315, 4945, 8, 277, 14, 11270, 63, 835, 304, 288, 702, 63, 262, 480, 10708, 6646, 83, 8352, 908, 8, 73, 395, 7032, 15511, 63, 505, 9, 339, 347, 2338, 63, 1529, 7441, 8, 277, 12, 3650, 12, 2338, 304, 267, 519, 624, 1589, 7032, 15511, 3931, 965, 7558, 48, 28, 835, 3072, 68, 8771, 4721, 27883, 986, 7441, 4, 624, 267, 2338, 275, 1109, 8, 835, 9, 267, 702, 63, 11332, 8, 552, 8, 7617, 14, 3919, 63, 1623, 5175, 3226, 15511, 13, 3751, 3855, 2338, 9, 267, 702, 63, 11332, 8, 552, 8, 7617, 14, 3919, 63, 1623, 5175, 3226, 15511, 13, 3751, 14, 14337, 3855, 2338, 9, 267, 702, 63, 11332, 8, 552, 8, 7617, 14, 3919, 63, 1623, 5175, 3226, 15511, 13, 3751, 14, 14337, 13, 14514, 3855, 2338, 9, 199, 199, 3, 961, 1004, 365, 1415, 701, 768, 5895, 315, 1865, 370, 5965, 5398, 314, 3650, 199, 3, 5163, 397, 199, 21761, 15511, 20960, 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 ]
[ 13390, 199, 199, 504, 4691, 84, 3683, 492, 6701, 12, 7124, 199, 504, 11354, 14, 2537, 492, 702, 63, 262, 12, 702, 63, 11332, 199, 199, 504, 2863, 492, 284, 63, 455, 63, 11616, 63, 509, 63, 1589, 63, 1972, 12, 5684, 63, 13444, 63, 1053, 199, 199, 3998, 63, 7433, 275, 13390, 14, 14674, 21723, 272, 665, 3226, 15511, 30, 267, 665, 20718, 30, 17700, 1318, 1108, 20718, 30, 267, 665, 80, 30, 2440, 1108, 80, 30, 272, 3068, 3226, 15511, 30, 199, 6141, 199, 199, 879, 4609, 2594, 63, 7433, 275, 13390, 14, 14674, 21723, 272, 21467, 469, 16, 5565, 272, 665, 9340, 2538, 628, 4551, 469, 16, 7063, 2396, 628, 7488, 469, 16, 7063, 11850, 628, 14514, 2, 5160, 18448, 16, 93, 1743, 267, 22240, 6646, 83, 469, 16, 93, 272, 3068, 9340, 30, 272, 12836, 469, 16, 5565, 199, 6141, 199, 199, 30533, 25847, 63, 7433, 275, 13390, 14, 14674, 21723, 199, 28, 6462, 1390, 63, 13143, 628, 17, 2, 5401, 9287, 30, 523, 665, 9340, 1310, 30, 272, 665, 9340, 1210, 30, 489, 665, 1213, 30, 16778, 469, 1955, 17890, 1213, 30, 489, 665, 505, 30, 10708, 6646, 83, 469, 1955, 17890, 505, 30, 489, 665, 3349, 30, 21015, 1329, 365, 642, 4897, 31, 1108, 3349, 30, 489, 665, 3349, 63, 7650, 30, 804, 2195, 1177, 5084, 9919, 3349, 63, 7650, 30, 489, 665, 1450, 63, 7650, 30, 21015, 1329, 365, 642, 4897, 31, 1108, 1450, 63, 7650, 30, 489, 665, 1419, 30, 489, 469, 1419, 93, 489, 3068, 1419, 30, 272, 3068, 9340, 1210, 30, 523, 3068, 9340, 1310, 30, 523, 665, 14458, 30, 272, 961, 5160, 365, 7907, 4897, 469, 1955, 93, 523, 3068, 14458, 30, 199, 1108, 6462, 30, 199, 6141, 199, 199, 13352, 63, 7433, 275, 8894, 1422, 7141, 18448, 4525, 4171, 93, 1743, 91, 1955, 17890, 1422, 11193, 421, 199, 318, 485, 4525, 4171, 8, 5095, 12, 1347, 304, 272, 340, 7141, 508, 1347, 26, 267, 372, 298, 4525, 2, 272, 916, 2853, 8, 5095, 446, 1347, 9, 508, 413, 26, 267, 372, 298, 462, 9406, 13, 4525, 2, 272, 587, 26, 267, 372, 298, 15448, 2, 421, 199, 32, 5895, 199, 533, 1626, 1397, 15511, 20960, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 11270, 63, 835, 275, 488, 267, 291, 14, 2682, 63, 6462, 275, 488, 339, 347, 5627, 63, 3173, 8, 277, 12, 3650, 12, 2338, 304, 267, 519, 624, 9099, 282, 2518, 965, 376, 7032, 15511, 3931, 543, 7558, 48, 28, 835, 3072, 68, 8771, 15538, 4, 624, 398, 2338, 275, 1109, 8, 835, 9, 267, 2518, 1507, 275, 283, 396, 63, 1972, 7, 267, 284, 63, 455, 63, 11616, 63, 509, 63, 1589, 63, 1972, 8, 2926, 12, 2518, 1507, 9, 398, 6701, 14, 13444, 63, 807, 459, 879, 4609, 2594, 63, 22634, 418, 275, 6701, 14, 2081, 2927, 8, 288, 1676, 63, 1985, 29, 7617, 14, 13444, 63, 807, 459, 13835, 2278, 1985, 12, 288, 4637, 534, 7870, 297, 288, 2929, 63, 354, 628, 774, 30793, 5444, 3294, 2, 267, 776, 398, 6701, 14, 13444, 63, 807, 459, 879, 4609, 619, 2617, 418, 275, 6701, 14, 2081, 2927, 8, 288, 1676, 63, 1985, 29, 7617, 14, 13444, 63, 807, 459, 879, 4609, 2594, 63, 22634, 2278, 1985, 12, 288, 4637, 534, 3226, 15511, 297, 288, 2929, 63, 354, 628, 774, 30793, 5673, 401, 288, 666, 29, 3998, 63, 7433, 14, 908, 4582, 78, 1674, 904, 8, 879, 4609, 2594, 63, 7433, 14, 908, 8, 73, 9, 367, 284, 315, 4945, 8, 835, 1724, 267, 776, 267, 291, 14, 11270, 63, 835, 275, 2338, 339, 347, 2455, 63, 3173, 8, 277, 12, 3650, 304, 267, 519, 624, 41, 2455, 314, 7032, 15511, 3931, 4, 624, 267, 5684, 63, 13444, 63, 1053, 360, 879, 4609, 619, 2617, 358, 339, 347, 1104, 63, 16841, 8, 277, 12, 3650, 304, 267, 519, 624, 1589, 7032, 15511, 3931, 965, 8018, 4, 624, 267, 6701, 14, 2573, 63, 509, 63, 3596, 63, 1975, 63, 17167, 89, 14676, 9520, 11283, 13, 5500, 63, 1345, 59, 576, 13, 466, 29, 21761, 15511, 61, 3471, 576, 480, 12486, 531, 358, 267, 7032, 15511, 63, 505, 275, 6701, 14, 3919, 63, 1623, 5175, 11283, 13, 5500, 63, 1345, 59, 576, 13, 466, 29, 21761, 15511, 61, 1959, 2246, 14, 505, 267, 702, 63, 262, 480, 17700, 1318, 401, 7032, 15511, 63, 505, 9, 398, 367, 284, 315, 4945, 8, 277, 14, 11270, 63, 835, 304, 288, 702, 63, 262, 480, 10708, 6646, 83, 8352, 908, 8, 73, 395, 7032, 15511, 63, 505, 9, 339, 347, 2338, 63, 1529, 7441, 8, 277, 12, 3650, 12, 2338, 304, 267, 519, 624, 1589, 7032, 15511, 3931, 965, 7558, 48, 28, 835, 3072, 68, 8771, 4721, 27883, 986, 7441, 4, 624, 267, 2338, 275, 1109, 8, 835, 9, 267, 702, 63, 11332, 8, 552, 8, 7617, 14, 3919, 63, 1623, 5175, 3226, 15511, 13, 3751, 3855, 2338, 9, 267, 702, 63, 11332, 8, 552, 8, 7617, 14, 3919, 63, 1623, 5175, 3226, 15511, 13, 3751, 14, 14337, 3855, 2338, 9, 267, 702, 63, 11332, 8, 552, 8, 7617, 14, 3919, 63, 1623, 5175, 3226, 15511, 13, 3751, 14, 14337, 13, 14514, 3855, 2338, 9, 199, 199, 3, 961, 1004, 365, 1415, 701, 768, 5895, 315, 1865, 370, 5965, 5398, 314, 3650, 199, 3, 5163, 397, 199, 21761, 15511, 20960, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
CroceRossaItaliana/jorvik
formazione/migrations/0035_auto_20190510_1149.py
1
2215
# -*- coding: utf-8 -*- # Generated by Django 1.9.13 on 2019-05-10 11:49 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): dependencies = [ ('formazione', '0034_auto_20190408_1047'), ] operations = [ migrations.CreateModel( name='RelazioneCorso', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('creazione', models.DateTimeField(db_index=True, default=django.utils.timezone.now)), ('ultima_modifica', models.DateTimeField(auto_now=True, db_index=True)), ('note_esplicative', models.TextField(help_text='note esplicative in relazione ai cambiamenti effettuati rispetto alla programmazione approvata in fase di pianificazione iniziale del corso.', verbose_name='Note esplicative')), ('raggiungimento_obiettivi', models.TextField(help_text="Analisi sul raggiungimento degli obiettivi del corso (generali rispetto all'evento e specifici di apprendimento).", verbose_name='Raggiungimento degli obiettivi del corso')), ('annotazioni_corsisti', models.TextField(verbose_name='Annotazioni relative alla partecipazione dei corsisti')), ('annotazioni_risorse', models.TextField(help_text='Annotazioni relative a risorse e competenze di particolare rilevanza emerse durante il percorso formativo')), ('annotazioni_organizzazione_struttura', models.TextField(help_text="Annotazioni e segnalazioni sull'organizzazione e la logistica e della struttura ospitante il corso")), ('descrizione_attivita', models.TextField(help_text='Descrizione delle eventuali attività di tirocinio/affiancamento con indicazione dei Tutor')), ('corso', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='formazione.CorsoBase')), ], options={ 'verbose_name': 'Relazione del Direttore', 'verbose_name_plural': 'Relazioni dei Direttori', }, ), ]
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 25, 14, 969, 641, 20312, 13, 1717, 13, 709, 4119, 26, 1887, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 1639, 14, 1208, 14, 7145, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 10928, 16079, 368, 297, 283, 383, 1082, 63, 2495, 63, 14982, 966, 2036, 63, 709, 2417, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 5640, 30834, 8380, 1152, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 1353, 30834, 297, 1709, 14, 4626, 8, 697, 63, 1080, 29, 549, 12, 849, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 1826, 355, 661, 1141, 391, 63, 3729, 329, 696, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 4610, 63, 397, 80, 606, 1905, 297, 1709, 14, 6254, 8, 3437, 63, 505, 534, 4610, 325, 681, 606, 1905, 315, 13773, 16079, 368, 15933, 27570, 4492, 313, 78, 280, 10783, 386, 84, 1458, 280, 221, 5719, 8096, 475, 741, 416, 2240, 391, 16079, 368, 4286, 86, 419, 315, 289, 482, 487, 299, 5653, 1903, 696, 16079, 368, 315, 565, 73, 1895, 2150, 1970, 1152, 3130, 3376, 63, 354, 534, 7443, 325, 681, 606, 1905, 3855, 355, 661, 2527, 6153, 324, 6153, 434, 79, 63, 2873, 14077, 3804, 297, 1709, 14, 6254, 8, 3437, 63, 505, 628, 2493, 10874, 338, 308, 348, 660, 2721, 73, 324, 6153, 434, 79, 7926, 317, 2607, 14077, 3804, 2150, 1970, 1152, 334, 10706, 73, 221, 5719, 8096, 475, 1006, 7, 12056, 475, 325, 1106, 4294, 487, 2771, 657, 78, 328, 434, 79, 680, 401, 3376, 63, 354, 534, 50, 643, 6153, 324, 6153, 434, 79, 7926, 317, 2607, 14077, 3804, 2150, 1970, 1152, 3855, 355, 661, 3226, 4651, 1636, 73, 63, 989, 11734, 73, 297, 1709, 14, 6254, 8, 3832, 63, 354, 534, 21761, 4651, 1636, 73, 3847, 741, 416, 623, 266, 559, 387, 16079, 368, 477, 73, 1970, 11734, 73, 3855, 355, 661, 3226, 4651, 1636, 73, 63, 322, 1509, 261, 297, 1709, 14, 6254, 8, 3437, 63, 505, 534, 21761, 4651, 1636, 73, 3847, 282, 8012, 1509, 261, 325, 1013, 69, 724, 806, 487, 623, 280, 331, 29200, 8012, 6972, 19024, 325, 2626, 261, 366, 300, 8949, 21179, 1126, 989, 1152, 367, 391, 280, 2392, 3855, 355, 661, 3226, 4651, 1636, 73, 63, 19916, 28981, 30834, 63, 495, 337, 84, 12417, 297, 1709, 14, 6254, 8, 3437, 63, 505, 628, 21761, 4651, 1636, 73, 325, 542, 784, 279, 4651, 1636, 73, 308, 979, 7, 19916, 28981, 30834, 325, 1127, 30360, 65, 325, 2150, 416, 620, 337, 84, 12417, 312, 681, 390, 8949, 21179, 1970, 1152, 8150, 355, 661, 271, 729, 16079, 368, 63, 292, 280, 86, 21492, 297, 1709, 14, 6254, 8, 3437, 63, 505, 534, 16320, 16079, 368, 2150, 274, 1566, 1061, 73, 737, 280, 86, 390, 26482, 487, 3367, 26786, 262, 2308, 15, 27054, 18595, 14040, 79, 406, 2539, 696, 16079, 368, 477, 73, 377, 4139, 3855, 355, 661, 989, 1152, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 10928, 16079, 368, 14, 8380, 1152, 1563, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 5640, 30834, 2150, 3757, 3292, 475, 264, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 5640, 4651, 1636, 73, 477, 73, 3757, 3292, 8270, 73, 297, 288, 1660, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 25, 14, 969, 641, 20312, 13, 1717, 13, 709, 4119, 26, 1887, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 1639, 14, 1208, 14, 7145, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 10928, 16079, 368, 297, 283, 383, 1082, 63, 2495, 63, 14982, 966, 2036, 63, 709, 2417, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 5640, 30834, 8380, 1152, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 1353, 30834, 297, 1709, 14, 4626, 8, 697, 63, 1080, 29, 549, 12, 849, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 1826, 355, 661, 1141, 391, 63, 3729, 329, 696, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 4610, 63, 397, 80, 606, 1905, 297, 1709, 14, 6254, 8, 3437, 63, 505, 534, 4610, 325, 681, 606, 1905, 315, 13773, 16079, 368, 15933, 27570, 4492, 313, 78, 280, 10783, 386, 84, 1458, 280, 221, 5719, 8096, 475, 741, 416, 2240, 391, 16079, 368, 4286, 86, 419, 315, 289, 482, 487, 299, 5653, 1903, 696, 16079, 368, 315, 565, 73, 1895, 2150, 1970, 1152, 3130, 3376, 63, 354, 534, 7443, 325, 681, 606, 1905, 3855, 355, 661, 2527, 6153, 324, 6153, 434, 79, 63, 2873, 14077, 3804, 297, 1709, 14, 6254, 8, 3437, 63, 505, 628, 2493, 10874, 338, 308, 348, 660, 2721, 73, 324, 6153, 434, 79, 7926, 317, 2607, 14077, 3804, 2150, 1970, 1152, 334, 10706, 73, 221, 5719, 8096, 475, 1006, 7, 12056, 475, 325, 1106, 4294, 487, 2771, 657, 78, 328, 434, 79, 680, 401, 3376, 63, 354, 534, 50, 643, 6153, 324, 6153, 434, 79, 7926, 317, 2607, 14077, 3804, 2150, 1970, 1152, 3855, 355, 661, 3226, 4651, 1636, 73, 63, 989, 11734, 73, 297, 1709, 14, 6254, 8, 3832, 63, 354, 534, 21761, 4651, 1636, 73, 3847, 741, 416, 623, 266, 559, 387, 16079, 368, 477, 73, 1970, 11734, 73, 3855, 355, 661, 3226, 4651, 1636, 73, 63, 322, 1509, 261, 297, 1709, 14, 6254, 8, 3437, 63, 505, 534, 21761, 4651, 1636, 73, 3847, 282, 8012, 1509, 261, 325, 1013, 69, 724, 806, 487, 623, 280, 331, 29200, 8012, 6972, 19024, 325, 2626, 261, 366, 300, 8949, 21179, 1126, 989, 1152, 367, 391, 280, 2392, 3855, 355, 661, 3226, 4651, 1636, 73, 63, 19916, 28981, 30834, 63, 495, 337, 84, 12417, 297, 1709, 14, 6254, 8, 3437, 63, 505, 628, 21761, 4651, 1636, 73, 325, 542, 784, 279, 4651, 1636, 73, 308, 979, 7, 19916, 28981, 30834, 325, 1127, 30360, 65, 325, 2150, 416, 620, 337, 84, 12417, 312, 681, 390, 8949, 21179, 1970, 1152, 8150, 355, 661, 271, 729, 16079, 368, 63, 292, 280, 86, 21492, 297, 1709, 14, 6254, 8, 3437, 63, 505, 534, 16320, 16079, 368, 2150, 274, 1566, 1061, 73, 737, 280, 86, 390, 26482, 487, 3367, 26786, 262, 2308, 15, 27054, 18595, 14040, 79, 406, 2539, 696, 16079, 368, 477, 73, 377, 4139, 3855, 355, 661, 989, 1152, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 10928, 16079, 368, 14, 8380, 1152, 1563, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 5640, 30834, 2150, 3757, 3292, 475, 264, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 5640, 4651, 1636, 73, 477, 73, 3757, 3292, 8270, 73, 297, 288, 1660, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shashisp/blumix-webpy
app/gluon/contrib/pyrtf/Constants.py
44
4082
class ViewKind : """An integer (0-5) that represents the view mode of the document.""" NONE = 0 PageLayout = 1 Outline = 2 MasterDocument = 3 Normal = 4 OnlineLayout = 5 DEFAULT = PageLayout def _IsValid( cls, value ) : return value in [ 0, 1, 2, 3, 4, 5 ] IsValid = classmethod( _IsValid ) class ViewScale : """Zoom level of the document; the N argument is a value representing a percentage (the default is 100).""" def _IsValid( cls, value ) : return value is None or (0 < value < 101) IsValid = classmethod( _IsValid ) class ViewZoomKind : """An integer (0 to 2) that represents the zoom kind of the document.""" NONE = 0 FullPage = 1 BestFit = 2 def _IsValid( cls, value ) : return value in [ None, 0, 1, 2 ] IsValid = classmethod( _IsValid ) class Languages : NoLanguage = 1024 Albanian = 1052 Arabic = 1025 Bahasa = 1057 BelgianDutch = 2067 BelgianFrench = 2060 BrazilianPortuguese = 1046 Bulgarian = 1026 Catalan = 1027 CroatoSerbianLatin = 1050 Czech = 1029 Danish = 1030 Dutch = 1043 EnglishAustralian = 3081 EnglishUK = 2057 EnglishUS = 1033 Finnish = 1035 French = 1036 FrenchCanadian = 3084 German = 1031 Greek = 1032 Hebrew = 1037 Hungarian = 1038 Icelandic = 1039 Italian = 1040 Japanese = 1041 Korean = 1042 NorwegianBokmal = 1044 NorwegianNynorsk = 2068 Polish = 1045 Portuguese = 2070 RhaetoRomanic = 1047 Romanian = 1048 Russian = 1049 SerboCroatianCyrillic = 2074 SimplifiedChinese = 2052 Slovak = 1051 SpanishCastilian = 1034 SpanishMexican = 2058 Swedish = 1053 SwissFrench = 4108 SwissGerman = 2055 SwissItalian = 2064 Thai = 1054 TraditionalChinese = 1028 Turkish = 1055 Urdu = 1056 SesothoSotho = 1072 Afrikaans = 1078 Zulu = 1077 Xhosa = 1076 Venda = 1075 Tswana = 1074 Tsonga = 1073 FarsiPersian = 1065 Codes = [ 1024, 1052, 1025, 1057, 2067, 2060, 1046, 1026, 1027, 1050, 1029, 1030, 1043, 3081, 2057, 1033, 1035, 1036, 3084, 1031, 1032, 1037, 1038, 1039, 1040, 1041, 1042, 1044, 2068, 1045, 2070, 1047, 1048, 1049, 2074, 2052, 1051, 1034, 2058, 1053, 4108, 2055, 2064, 1054, 1028, 1055, 1056, 1072, 1078, 1077, 1076, 1075, 1074, 1073, 1065 ] # make it Australian as that is what I use most of the time DEFAULT = EnglishAustralian def _IsValid( cls, value ) : return value in cls.Codes IsValid = classmethod( _IsValid ) if __name__ == '__main__' : PrintHexTable()
mit
[ 533, 10935, 13028, 520, 272, 408, 2493, 3000, 334, 16, 13, 21, 9, 626, 8469, 314, 2455, 818, 402, 314, 2213, 1041, 339, 653, 4817, 3698, 275, 378, 272, 10331, 4798, 258, 275, 413, 272, 6219, 604, 263, 275, 499, 272, 26728, 5564, 275, 650, 272, 11514, 260, 275, 841, 272, 4068, 604, 4798, 257, 275, 959, 339, 6186, 275, 10331, 4798, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 315, 359, 378, 12, 413, 12, 499, 12, 650, 12, 841, 12, 959, 1622, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 199, 199, 533, 10935, 9944, 520, 272, 408, 26798, 2166, 402, 314, 2213, 27, 314, 653, 1423, 365, 282, 574, 6144, 282, 16327, 334, 1589, 849, 365, 2948, 10477, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 365, 488, 503, 334, 16, 665, 574, 665, 14313, 9, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 199, 199, 533, 10935, 26798, 13028, 520, 272, 408, 2493, 3000, 334, 16, 370, 499, 9, 626, 8469, 314, 16935, 4928, 402, 314, 2213, 1041, 339, 653, 4817, 258, 275, 378, 272, 16579, 3276, 275, 413, 272, 699, 597, 13776, 221, 275, 499, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 315, 359, 488, 12, 378, 12, 413, 12, 499, 1622, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 421, 199, 533, 8466, 83, 520, 272, 3091, 8493, 3322, 275, 6619, 272, 4580, 13206, 5653, 4519, 275, 1616, 2528, 272, 437, 24176, 4483, 275, 1616, 821, 272, 699, 65, 1989, 65, 4483, 275, 1616, 1641, 272, 699, 352, 71, 5653, 36, 337, 335, 3515, 275, 499, 19338, 272, 699, 352, 71, 5653, 38, 15148, 260, 275, 499, 18857, 272, 32377, 90, 1638, 290, 4313, 1518, 310, 261, 257, 275, 413, 13702, 272, 699, 27092, 15289, 3777, 275, 12996, 22, 272, 445, 7539, 290, 5185, 275, 12996, 23, 272, 445, 293, 11318, 1505, 9662, 27317, 259, 275, 1616, 1400, 272, 445, 806, 335, 463, 275, 12996, 25, 272, 24747, 2453, 4483, 275, 1616, 1216, 272, 577, 337, 335, 463, 275, 413, 5882, 272, 20144, 33, 11409, 25861, 258, 275, 650, 19896, 272, 20144, 26667, 3777, 275, 3388, 1641, 272, 20144, 1668, 3777, 275, 1616, 1153, 272, 11711, 78, 2453, 5185, 275, 1616, 1276, 272, 481, 15148, 4483, 275, 1616, 1344, 272, 481, 15148, 6049, 65, 6268, 263, 275, 4233, 1349, 272, 22261, 1237, 4483, 275, 1616, 2192, 272, 598, 14291, 463, 275, 1616, 708, 272, 19771, 4483, 275, 1616, 1401, 272, 869, 25364, 3777, 275, 1616, 1703, 272, 473, 301, 1502, 5000, 3777, 275, 1616, 1355, 272, 2779, 25861, 5185, 275, 413, 11189, 272, 1603, 30699, 4519, 275, 413, 10531, 272, 1804, 16293, 4483, 275, 413, 13011, 272, 653, 269, 1129, 71, 5653, 34, 745, 2174, 755, 275, 413, 9111, 272, 653, 269, 1129, 71, 5653, 46, 1236, 269, 1339, 420, 275, 499, 19846, 272, 4376, 1891, 4483, 275, 413, 12618, 272, 10977, 1518, 310, 261, 3322, 275, 499, 19235, 272, 820, 2411, 16876, 50, 21604, 530, 260, 275, 413, 12931, 272, 820, 21604, 5653, 4519, 275, 413, 9941, 272, 820, 8630, 5185, 275, 413, 12809, 272, 3739, 656, 35, 293, 2159, 290, 9156, 11909, 275, 3388, 1342, 272, 29094, 30200, 1049, 26883, 258, 275, 499, 19730, 272, 428, 32555, 1151, 4483, 275, 1616, 2869, 272, 32091, 2453, 24654, 1638, 290, 420, 275, 1616, 1082, 272, 32091, 2453, 45, 476, 530, 290, 263, 275, 499, 18009, 272, 428, 1129, 29159, 5185, 275, 1616, 2481, 272, 16666, 19857, 38, 15148, 3698, 275, 841, 8079, 272, 16666, 19857, 27866, 1237, 3698, 275, 3388, 1229, 272, 16666, 19857, 7940, 25861, 3515, 275, 3388, 772, 272, 377, 17945, 8295, 275, 1616, 1477, 272, 12643, 2603, 1049, 26883, 259, 275, 12996, 24, 272, 377, 300, 75, 2453, 5185, 275, 1616, 1229, 272, 738, 82, 2033, 8295, 275, 1616, 1367, 272, 428, 397, 79, 273, 79, 5158, 273, 79, 3515, 275, 1616, 2819, 272, 437, 25876, 7351, 796, 3777, 275, 1616, 2277, 272, 3107, 348, 85, 8295, 275, 1616, 1138, 272, 1323, 526, 2231, 463, 275, 1616, 2114, 272, 812, 29162, 463, 275, 1616, 2194, 272, 377, 3519, 6738, 4483, 275, 1616, 1342, 272, 377, 834, 5294, 4483, 275, 1616, 2898, 272, 481, 285, 338, 2623, 6214, 3515, 275, 1616, 2182, 339, 5495, 83, 275, 359, 6619, 12, 1598, 1616, 2528, 12, 1598, 1616, 821, 12, 1598, 1616, 1641, 12, 1598, 499, 19338, 12, 1598, 499, 18857, 12, 1598, 413, 13702, 12, 1598, 12996, 22, 12, 1598, 12996, 23, 12, 1598, 1616, 1400, 12, 1598, 12996, 25, 12, 1598, 1616, 1216, 12, 1598, 413, 5882, 12, 1598, 650, 19896, 12, 1598, 3388, 1641, 12, 1598, 1616, 1153, 12, 1598, 1616, 1276, 12, 1598, 1616, 1344, 12, 1598, 4233, 1349, 12, 1598, 1616, 2192, 12, 1598, 1616, 708, 12, 1598, 1616, 1401, 12, 1598, 1616, 1703, 12, 1598, 1616, 1355, 12, 1598, 413, 11189, 12, 1598, 413, 10531, 12, 1598, 413, 13011, 12, 1598, 413, 9111, 12, 1598, 499, 19846, 12, 1598, 413, 12618, 12, 1598, 499, 19235, 12, 1598, 413, 12931, 12, 1598, 413, 9941, 12, 1598, 413, 12809, 12, 1598, 3388, 1342, 12, 1598, 499, 19730, 12, 1598, 1616, 2869, 12, 1598, 1616, 1082, 12, 1598, 499, 18009, 12, 1598, 1616, 2481, 12, 1598, 841, 8079, 12, 1598, 3388, 1229, 12, 1598, 3388, 772, 12, 1598, 1616, 1477, 12, 1598, 12996, 24, 12, 1598, 1616, 1229, 12, 1598, 1616, 1367, 12, 1598, 1616, 2819, 12, 1598, 1616, 2277, 12, 1598, 1616, 1138, 12, 1598, 1616, 2114, 12, 1598, 1616, 2194, 12, 1598, 1616, 1342, 12, 1598, 1616, 2898, 12, 1598, 1616, 2182, 1622, 339, 327, 221, 1852, 652, 437, 11409, 25861, 465, 626, 365, 4052, 473, 675, 4750, 402, 314, 900, 272, 6186, 275, 20144, 33, 11409, 25861, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 315, 843, 14, 14060, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 12217, 520, 272, 9101, 10373, 3186, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10935, 13028, 520, 272, 408, 2493, 3000, 334, 16, 13, 21, 9, 626, 8469, 314, 2455, 818, 402, 314, 2213, 1041, 339, 653, 4817, 3698, 275, 378, 272, 10331, 4798, 258, 275, 413, 272, 6219, 604, 263, 275, 499, 272, 26728, 5564, 275, 650, 272, 11514, 260, 275, 841, 272, 4068, 604, 4798, 257, 275, 959, 339, 6186, 275, 10331, 4798, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 315, 359, 378, 12, 413, 12, 499, 12, 650, 12, 841, 12, 959, 1622, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 199, 199, 533, 10935, 9944, 520, 272, 408, 26798, 2166, 402, 314, 2213, 27, 314, 653, 1423, 365, 282, 574, 6144, 282, 16327, 334, 1589, 849, 365, 2948, 10477, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 365, 488, 503, 334, 16, 665, 574, 665, 14313, 9, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 199, 199, 533, 10935, 26798, 13028, 520, 272, 408, 2493, 3000, 334, 16, 370, 499, 9, 626, 8469, 314, 16935, 4928, 402, 314, 2213, 1041, 339, 653, 4817, 258, 275, 378, 272, 16579, 3276, 275, 413, 272, 699, 597, 13776, 221, 275, 499, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 315, 359, 488, 12, 378, 12, 413, 12, 499, 1622, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 421, 199, 533, 8466, 83, 520, 272, 3091, 8493, 3322, 275, 6619, 272, 4580, 13206, 5653, 4519, 275, 1616, 2528, 272, 437, 24176, 4483, 275, 1616, 821, 272, 699, 65, 1989, 65, 4483, 275, 1616, 1641, 272, 699, 352, 71, 5653, 36, 337, 335, 3515, 275, 499, 19338, 272, 699, 352, 71, 5653, 38, 15148, 260, 275, 499, 18857, 272, 32377, 90, 1638, 290, 4313, 1518, 310, 261, 257, 275, 413, 13702, 272, 699, 27092, 15289, 3777, 275, 12996, 22, 272, 445, 7539, 290, 5185, 275, 12996, 23, 272, 445, 293, 11318, 1505, 9662, 27317, 259, 275, 1616, 1400, 272, 445, 806, 335, 463, 275, 12996, 25, 272, 24747, 2453, 4483, 275, 1616, 1216, 272, 577, 337, 335, 463, 275, 413, 5882, 272, 20144, 33, 11409, 25861, 258, 275, 650, 19896, 272, 20144, 26667, 3777, 275, 3388, 1641, 272, 20144, 1668, 3777, 275, 1616, 1153, 272, 11711, 78, 2453, 5185, 275, 1616, 1276, 272, 481, 15148, 4483, 275, 1616, 1344, 272, 481, 15148, 6049, 65, 6268, 263, 275, 4233, 1349, 272, 22261, 1237, 4483, 275, 1616, 2192, 272, 598, 14291, 463, 275, 1616, 708, 272, 19771, 4483, 275, 1616, 1401, 272, 869, 25364, 3777, 275, 1616, 1703, 272, 473, 301, 1502, 5000, 3777, 275, 1616, 1355, 272, 2779, 25861, 5185, 275, 413, 11189, 272, 1603, 30699, 4519, 275, 413, 10531, 272, 1804, 16293, 4483, 275, 413, 13011, 272, 653, 269, 1129, 71, 5653, 34, 745, 2174, 755, 275, 413, 9111, 272, 653, 269, 1129, 71, 5653, 46, 1236, 269, 1339, 420, 275, 499, 19846, 272, 4376, 1891, 4483, 275, 413, 12618, 272, 10977, 1518, 310, 261, 3322, 275, 499, 19235, 272, 820, 2411, 16876, 50, 21604, 530, 260, 275, 413, 12931, 272, 820, 21604, 5653, 4519, 275, 413, 9941, 272, 820, 8630, 5185, 275, 413, 12809, 272, 3739, 656, 35, 293, 2159, 290, 9156, 11909, 275, 3388, 1342, 272, 29094, 30200, 1049, 26883, 258, 275, 499, 19730, 272, 428, 32555, 1151, 4483, 275, 1616, 2869, 272, 32091, 2453, 24654, 1638, 290, 420, 275, 1616, 1082, 272, 32091, 2453, 45, 476, 530, 290, 263, 275, 499, 18009, 272, 428, 1129, 29159, 5185, 275, 1616, 2481, 272, 16666, 19857, 38, 15148, 3698, 275, 841, 8079, 272, 16666, 19857, 27866, 1237, 3698, 275, 3388, 1229, 272, 16666, 19857, 7940, 25861, 3515, 275, 3388, 772, 272, 377, 17945, 8295, 275, 1616, 1477, 272, 12643, 2603, 1049, 26883, 259, 275, 12996, 24, 272, 377, 300, 75, 2453, 5185, 275, 1616, 1229, 272, 738, 82, 2033, 8295, 275, 1616, 1367, 272, 428, 397, 79, 273, 79, 5158, 273, 79, 3515, 275, 1616, 2819, 272, 437, 25876, 7351, 796, 3777, 275, 1616, 2277, 272, 3107, 348, 85, 8295, 275, 1616, 1138, 272, 1323, 526, 2231, 463, 275, 1616, 2114, 272, 812, 29162, 463, 275, 1616, 2194, 272, 377, 3519, 6738, 4483, 275, 1616, 1342, 272, 377, 834, 5294, 4483, 275, 1616, 2898, 272, 481, 285, 338, 2623, 6214, 3515, 275, 1616, 2182, 339, 5495, 83, 275, 359, 6619, 12, 1598, 1616, 2528, 12, 1598, 1616, 821, 12, 1598, 1616, 1641, 12, 1598, 499, 19338, 12, 1598, 499, 18857, 12, 1598, 413, 13702, 12, 1598, 12996, 22, 12, 1598, 12996, 23, 12, 1598, 1616, 1400, 12, 1598, 12996, 25, 12, 1598, 1616, 1216, 12, 1598, 413, 5882, 12, 1598, 650, 19896, 12, 1598, 3388, 1641, 12, 1598, 1616, 1153, 12, 1598, 1616, 1276, 12, 1598, 1616, 1344, 12, 1598, 4233, 1349, 12, 1598, 1616, 2192, 12, 1598, 1616, 708, 12, 1598, 1616, 1401, 12, 1598, 1616, 1703, 12, 1598, 1616, 1355, 12, 1598, 413, 11189, 12, 1598, 413, 10531, 12, 1598, 413, 13011, 12, 1598, 413, 9111, 12, 1598, 499, 19846, 12, 1598, 413, 12618, 12, 1598, 499, 19235, 12, 1598, 413, 12931, 12, 1598, 413, 9941, 12, 1598, 413, 12809, 12, 1598, 3388, 1342, 12, 1598, 499, 19730, 12, 1598, 1616, 2869, 12, 1598, 1616, 1082, 12, 1598, 499, 18009, 12, 1598, 1616, 2481, 12, 1598, 841, 8079, 12, 1598, 3388, 1229, 12, 1598, 3388, 772, 12, 1598, 1616, 1477, 12, 1598, 12996, 24, 12, 1598, 1616, 1229, 12, 1598, 1616, 1367, 12, 1598, 1616, 2819, 12, 1598, 1616, 2277, 12, 1598, 1616, 1138, 12, 1598, 1616, 2114, 12, 1598, 1616, 2194, 12, 1598, 1616, 1342, 12, 1598, 1616, 2898, 12, 1598, 1616, 2182, 1622, 339, 327, 221, 1852, 652, 437, 11409, 25861, 465, 626, 365, 4052, 473, 675, 4750, 402, 314, 900, 272, 6186, 275, 20144, 33, 11409, 25861, 339, 347, 485, 1831, 3490, 8, 843, 12, 574, 776, 520, 267, 372, 574, 315, 843, 14, 14060, 272, 6596, 3490, 275, 18990, 8, 485, 1831, 3490, 776, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 12217, 520, 272, 9101, 10373, 3186, 342, 421, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kgullikson88/General
Analyze_CCF.py
1
9048
""" This is a module to read in an HDF5 file with CCFs. Use this to determine the best parameters, and plot the best CCF for each star/date """ from collections import defaultdict import logging import h5py import numpy as np import pandas as pd from scipy.interpolate import InterpolatedUnivariateSpline as spline class CCF_Interface(object): def __init__(self, filename, vel=np.arange(-900, 900, 1)): self.hdf5 = h5py.File(filename, 'r') self.velocities = vel self._df = None def __getitem__(self, path): return self.hdf5[path] def list_stars(self, print2screen=False): """ List the stars available in the HDF5 file, and the dates available for each :return: A list of the stars """ if print2screen: for star in sorted(self.hdf5.keys()): print(star) for date in sorted(self.hdf5[star].keys()): print('\t{}'.format(date)) return sorted(self.hdf5.keys()) def list_dates(self, star, print2screen=False): """ List the dates available for the given star :param star: The name of the star :return: A list of dates the star was observed """ if print2screen: for date in sorted(self.hdf5[star].keys()): print(date) return sorted(self.hdf5[star].keys()) def load_cache(self, addmode='simple'): """ Read in the whole HDF5 file. This will take a while and take a few Gb of memory, but will speed things up considerably :keyword addmode: The way the individual CCFs were added. Options are: - 'simple' - 'ml' - 'all' (saves all addmodes) """ self._df = self._compile_data(addmode=addmode) def _compile_data(self, starname=None, date=None, addmode='simple', read_ccf=True): """ Private function. This reads in all the datasets for the given star and date :param starname: the name of the star. Must be in self.hdf5 :param date: The date to search. Must be in self.hdf5[star] :keyword addmode: The way the individual CCFs were added. Options are: - 'simple' - 'ml' - 'all' (saves all addmodes) :return: a pandas DataFrame with the columns: - star - date - temperature - log(g) - [Fe/H] - vsini - addmode - rv (at maximum CCF value) - CCF height (maximum) """ if starname is None: df_list = [] star_list = self.list_stars() for star in star_list: date_list = self.list_dates(star) for date in date_list: logging.debug('Reading in metadata for star {}, date {}'.format(star, date)) df_list.append(self._compile_data(star, date, addmode=addmode, read_ccf=read_ccf)) return pd.concat(df_list, ignore_index=True) elif starname is not None and date is None: df_list = [] date_list = self.list_dates(starname) for date in date_list: logging.debug('Reading in metadata for date {}'.format(date)) df_list.append(self._compile_data(starname, date, addmode=addmode, read_ccf=read_ccf)) return pd.concat(df_list, ignore_index=True) else: if self._df is not None: return self._df.loc[(self._df['Star'] == starname) & (self._df['Date'] == date)].copy() #print('Stars: ', self.list_stars()) datasets = self.hdf5[starname][date].keys() data = defaultdict(list) for ds_name, ds in self.hdf5[starname][date].iteritems(): # in datasets: #ds = self.hdf5[starname][date][ds_name] try: am = ds.attrs['addmode'] if addmode == 'all' or addmode == am: data['T'].append(ds.attrs['T']) data['logg'].append(ds.attrs['logg']) data['[Fe/H]'].append(ds.attrs['[Fe/H]']) data['vsini'].append(ds.attrs['vsini']) data['addmode'].append(am) data['name'].append(ds.name) try: data['ccf_max'].append(ds.attrs['ccf_max']) data['vel_max'].append(ds.attrs['vel_max']) except KeyError: vel, corr = ds.value idx = np.argmax(corr) data['ccf_max'].append(corr[idx]) data['vel_max'].append(vel[idx]) if read_ccf: v = ds.value vel, corr = v[0], v[1] sorter = np.argsort(vel) fcn = spline(vel[sorter], corr[sorter]) data['ccf'].append(fcn(self.velocities)) except: raise IOError('Something weird happened with dataset {}!'.format(ds.name)) data['Star'] = [starname] * len(data['T']) data['Date'] = [date] * len(data['T']) df = pd.DataFrame(data=data) return df def get_temperature_run(self, starname=None, date=None, df=None): """ Return the maximum ccf height for each temperature. Either starname AND date, or df must be given :param starname: The name of the star :param date: The date of the observation :param df: Input dataframe, such as from _compile_data. Overrides starname and date, if given :return: a pandas DataFrame with all the best parameters for each temperature """ # Get the dataframe if it isn't given if df is None: if starname is None or date is None: raise ValueError('Must give either starname or date to get_temperature_run!') df = self._compile_data(starname, date) # Find the maximum CCF for each set of parameters fcn = lambda row: (np.max(row), self.velocities[np.argmax(row)]) vals = df['ccf'].map(fcn) df['ccf_max'] = vals.map(lambda l: l[0]) df['rv'] = vals.map(lambda l: l[1]) # Find the best parameters for each temperature d = defaultdict(list) temperatures = pd.unique(df['T']) for T in temperatures: good = df.loc[df['T'] == T] best = good.loc[good.ccf_max == good.ccf_max.max()] d['vsini'].append(best['vsini'].item()) d['logg'].append(best['logg'].item()) d['[Fe/H]'].append(best['[Fe/H]'].item()) d['rv'].append(best['rv'].item()) d['ccf_value'].append(best.ccf_max.item()) d['T'].append(T) d['metal'].append(best['[Fe/H]'].item()) return pd.DataFrame(data=d) def get_ccf(self, params, df=None): """ Get the ccf with the given parameters. A dataframe can be given to speed things up :param params: All the parameters necessary to define a single ccf. This should be a python dictionary with the keys: - 'starname': The name of the star. Try self.list_stars() for the options. - 'date': The UT date of the observations. Try self.list_dates() for the options. - 'T': temperature of the model - 'logg': the log(g) of the model - 'vsini': the vsini by which the model was broadened before correlation - '[Fe/H]': the metallicity of the model - 'addmode': The way the order CCFs were added to make a total one. Can be: - 'simple' - 'ml' - 'weighted' - 'dc' :param df: a pandas DataFrame such as outputted by _compile_data :return: a pandas DataFrame with columns of velocity and CCF power """ if df is None: try: df = self._compile_data(params['starname'], params['date']) except KeyError: raise KeyError('Must give get_ccf params with starname and date keywords, if df is not given!') Tvals = df['T'].unique() T = Tvals[np.argmin(abs(Tvals - params['T']))] good = df.loc[(df['T'] == T) & (df.logg == params['logg']) & (df.vsini == params['vsini']) \ & (df['[Fe/H]'] == params['[Fe/H]']) & (df.addmode == params['addmode'])] return pd.DataFrame(data={'velocity': self.velocities, 'CCF': good['ccf'].item()})
gpl-3.0
[ 624, 199, 2765, 365, 282, 859, 370, 1586, 315, 376, 24521, 21, 570, 543, 445, 5487, 83, 14, 199, 6119, 642, 370, 6705, 314, 5526, 2633, 12, 436, 5137, 314, 5526, 445, 5487, 367, 1924, 14664, 15, 602, 199, 624, 199, 504, 5055, 492, 10018, 199, 646, 2050, 199, 199, 646, 394, 21, 647, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 504, 7026, 14, 21294, 492, 6551, 2515, 972, 1358, 23225, 27558, 465, 30213, 421, 199, 533, 445, 5487, 63, 4267, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1788, 12, 373, 352, 29, 1590, 14, 5605, 2801, 17518, 12, 27151, 12, 413, 2298, 267, 291, 14, 19912, 21, 275, 394, 21, 647, 14, 1173, 8, 1501, 12, 283, 82, 358, 267, 291, 14, 3419, 18207, 275, 373, 352, 267, 291, 423, 1587, 275, 488, 339, 347, 636, 6095, 721, 277, 12, 931, 304, 267, 372, 291, 14, 19912, 21, 59, 515, 61, 2378, 347, 769, 63, 270, 4291, 8, 277, 12, 870, 18, 5410, 29, 797, 304, 267, 408, 267, 3820, 314, 410, 4291, 2808, 315, 314, 24521, 21, 570, 12, 436, 314, 10831, 2808, 367, 1924, 267, 520, 1107, 26, 437, 769, 402, 314, 410, 4291, 267, 408, 267, 340, 870, 18, 5410, 26, 288, 367, 14664, 315, 3355, 8, 277, 14, 19912, 21, 14, 1612, 5109, 355, 870, 8, 7848, 9, 355, 367, 1434, 315, 3355, 8, 277, 14, 19912, 21, 59, 7848, 1055, 1612, 5109, 490, 870, 2258, 84, 11123, 908, 8, 602, 430, 267, 372, 3355, 8, 277, 14, 19912, 21, 14, 1612, 1012, 2378, 347, 769, 63, 9356, 8, 277, 12, 14664, 12, 870, 18, 5410, 29, 797, 304, 267, 408, 267, 3820, 314, 10831, 2808, 367, 314, 1627, 14664, 267, 520, 635, 14664, 26, 710, 536, 402, 314, 14664, 267, 520, 1107, 26, 437, 769, 402, 10831, 314, 14664, 1990, 20802, 267, 408, 267, 340, 870, 18, 5410, 26, 288, 367, 1434, 315, 3355, 8, 277, 14, 19912, 21, 59, 7848, 1055, 1612, 5109, 355, 870, 8, 602, 9, 267, 372, 3355, 8, 277, 14, 19912, 21, 59, 7848, 1055, 1612, 1012, 339, 347, 2248, 63, 1637, 8, 277, 12, 1050, 632, 534, 4129, 735, 267, 408, 267, 5574, 315, 314, 8852, 24521, 21, 570, 14, 961, 911, 5452, 282, 1830, 436, 5452, 282, 9284, 598, 66, 402, 4402, 12, 1325, 911, 8112, 7645, 1536, 8219, 14411, 590, 267, 520, 6691, 1050, 632, 26, 710, 4340, 314, 8212, 445, 5487, 83, 4898, 3483, 14, 8394, 787, 26, 2079, 446, 283, 4129, 7, 2079, 446, 283, 757, 7, 2079, 446, 283, 452, 7, 221, 334, 83, 7047, 1006, 1050, 10433, 9, 267, 408, 267, 291, 423, 1587, 275, 291, 423, 2014, 63, 576, 8, 525, 632, 29, 525, 632, 9, 2378, 347, 485, 2014, 63, 576, 8, 277, 12, 14664, 354, 29, 403, 12, 1434, 29, 403, 12, 1050, 632, 534, 4129, 297, 1586, 63, 31427, 29, 549, 304, 267, 408, 267, 18551, 805, 14, 961, 11597, 315, 1006, 314, 13148, 367, 314, 1627, 14664, 436, 1434, 267, 520, 635, 14664, 354, 26, 314, 536, 402, 314, 14664, 14, 9498, 506, 315, 291, 14, 19912, 21, 267, 520, 635, 1434, 26, 710, 1434, 370, 2754, 14, 9498, 506, 315, 291, 14, 19912, 21, 59, 7848, 61, 267, 520, 6691, 1050, 632, 26, 710, 4340, 314, 8212, 445, 5487, 83, 4898, 3483, 14, 8394, 787, 26, 2079, 446, 283, 4129, 7, 2079, 446, 283, 757, 7, 2079, 446, 283, 452, 7, 221, 334, 83, 7047, 1006, 1050, 10433, 9, 267, 520, 1107, 26, 282, 10634, 10071, 543, 314, 4362, 26, 2116, 446, 14664, 2116, 446, 1434, 2116, 446, 14843, 2116, 446, 943, 8, 71, 9, 2116, 446, 359, 3456, 15, 40, 61, 2116, 446, 8118, 2730, 2116, 446, 1050, 632, 2116, 446, 4336, 334, 292, 5696, 445, 5487, 574, 9, 2116, 446, 445, 5487, 4569, 334, 11555, 9, 267, 408, 267, 340, 14664, 354, 365, 488, 26, 288, 4051, 63, 513, 275, 942, 288, 14664, 63, 513, 275, 291, 14, 513, 63, 270, 4291, 342, 288, 367, 14664, 315, 14664, 63, 513, 26, 355, 1434, 63, 513, 275, 291, 14, 513, 63, 9356, 8, 7848, 9, 355, 367, 1434, 315, 1434, 63, 513, 26, 272, 490, 2050, 14, 1757, 360, 20568, 315, 3341, 367, 14664, 5479, 1434, 9499, 908, 8, 7848, 12, 1434, 430, 490, 4051, 63, 513, 14, 740, 8, 277, 423, 2014, 63, 576, 8, 7848, 12, 1434, 12, 1050, 632, 29, 525, 632, 12, 1586, 63, 31427, 29, 739, 63, 31427, 430, 288, 372, 6454, 14, 9419, 8, 1587, 63, 513, 12, 3686, 63, 1080, 29, 549, 9, 10631, 916, 14664, 354, 365, 440, 488, 436, 1434, 365, 488, 26, 288, 4051, 63, 513, 275, 942, 288, 1434, 63, 513, 275, 291, 14, 513, 63, 9356, 8, 7848, 354, 9, 288, 367, 1434, 315, 1434, 63, 513, 26, 355, 2050, 14, 1757, 360, 20568, 315, 3341, 367, 1434, 9499, 908, 8, 602, 430, 355, 4051, 63, 513, 14, 740, 8, 277, 423, 2014, 63, 576, 8, 7848, 354, 12, 1434, 12, 1050, 632, 29, 525, 632, 12, 1586, 63, 31427, 29, 739, 63, 31427, 430, 288, 372, 6454, 14, 9419, 8, 1587, 63, 513, 12, 3686, 63, 1080, 29, 549, 9, 10631, 587, 26, 288, 340, 291, 423, 1587, 365, 440, 488, 26, 355, 372, 291, 423, 1587, 14, 2102, 7528, 277, 423, 1587, 459, 23197, 418, 508, 14664, 354, 9, 1253, 334, 277, 423, 1587, 459, 2506, 418, 508, 1434, 22509, 1574, 342, 288, 327, 1361, 360, 933, 4291, 26, 1656, 291, 14, 513, 63, 270, 4291, 1012, 288, 13148, 275, 291, 14, 19912, 21, 59, 7848, 354, 1527, 602, 1055, 1612, 342, 288, 666, 275, 10018, 8, 513, 9, 288, 367, 6364, 63, 354, 12, 6364, 315, 291, 14, 19912, 21, 59, 7848, 354, 1527, 602, 1055, 4611, 837, 221, 327, 315, 13148, 26, 355, 327, 795, 275, 291, 14, 19912, 21, 59, 7848, 354, 1527, 602, 1527, 795, 63, 354, 61, 355, 862, 26, 490, 8140, 275, 6364, 14, 3288, 459, 525, 632, 418, 490, 340, 1050, 632, 508, 283, 452, 7, 503, 1050, 632, 508, 8140 ]
[ 199, 2765, 365, 282, 859, 370, 1586, 315, 376, 24521, 21, 570, 543, 445, 5487, 83, 14, 199, 6119, 642, 370, 6705, 314, 5526, 2633, 12, 436, 5137, 314, 5526, 445, 5487, 367, 1924, 14664, 15, 602, 199, 624, 199, 504, 5055, 492, 10018, 199, 646, 2050, 199, 199, 646, 394, 21, 647, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 504, 7026, 14, 21294, 492, 6551, 2515, 972, 1358, 23225, 27558, 465, 30213, 421, 199, 533, 445, 5487, 63, 4267, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1788, 12, 373, 352, 29, 1590, 14, 5605, 2801, 17518, 12, 27151, 12, 413, 2298, 267, 291, 14, 19912, 21, 275, 394, 21, 647, 14, 1173, 8, 1501, 12, 283, 82, 358, 267, 291, 14, 3419, 18207, 275, 373, 352, 267, 291, 423, 1587, 275, 488, 339, 347, 636, 6095, 721, 277, 12, 931, 304, 267, 372, 291, 14, 19912, 21, 59, 515, 61, 2378, 347, 769, 63, 270, 4291, 8, 277, 12, 870, 18, 5410, 29, 797, 304, 267, 408, 267, 3820, 314, 410, 4291, 2808, 315, 314, 24521, 21, 570, 12, 436, 314, 10831, 2808, 367, 1924, 267, 520, 1107, 26, 437, 769, 402, 314, 410, 4291, 267, 408, 267, 340, 870, 18, 5410, 26, 288, 367, 14664, 315, 3355, 8, 277, 14, 19912, 21, 14, 1612, 5109, 355, 870, 8, 7848, 9, 355, 367, 1434, 315, 3355, 8, 277, 14, 19912, 21, 59, 7848, 1055, 1612, 5109, 490, 870, 2258, 84, 11123, 908, 8, 602, 430, 267, 372, 3355, 8, 277, 14, 19912, 21, 14, 1612, 1012, 2378, 347, 769, 63, 9356, 8, 277, 12, 14664, 12, 870, 18, 5410, 29, 797, 304, 267, 408, 267, 3820, 314, 10831, 2808, 367, 314, 1627, 14664, 267, 520, 635, 14664, 26, 710, 536, 402, 314, 14664, 267, 520, 1107, 26, 437, 769, 402, 10831, 314, 14664, 1990, 20802, 267, 408, 267, 340, 870, 18, 5410, 26, 288, 367, 1434, 315, 3355, 8, 277, 14, 19912, 21, 59, 7848, 1055, 1612, 5109, 355, 870, 8, 602, 9, 267, 372, 3355, 8, 277, 14, 19912, 21, 59, 7848, 1055, 1612, 1012, 339, 347, 2248, 63, 1637, 8, 277, 12, 1050, 632, 534, 4129, 735, 267, 408, 267, 5574, 315, 314, 8852, 24521, 21, 570, 14, 961, 911, 5452, 282, 1830, 436, 5452, 282, 9284, 598, 66, 402, 4402, 12, 1325, 911, 8112, 7645, 1536, 8219, 14411, 590, 267, 520, 6691, 1050, 632, 26, 710, 4340, 314, 8212, 445, 5487, 83, 4898, 3483, 14, 8394, 787, 26, 2079, 446, 283, 4129, 7, 2079, 446, 283, 757, 7, 2079, 446, 283, 452, 7, 221, 334, 83, 7047, 1006, 1050, 10433, 9, 267, 408, 267, 291, 423, 1587, 275, 291, 423, 2014, 63, 576, 8, 525, 632, 29, 525, 632, 9, 2378, 347, 485, 2014, 63, 576, 8, 277, 12, 14664, 354, 29, 403, 12, 1434, 29, 403, 12, 1050, 632, 534, 4129, 297, 1586, 63, 31427, 29, 549, 304, 267, 408, 267, 18551, 805, 14, 961, 11597, 315, 1006, 314, 13148, 367, 314, 1627, 14664, 436, 1434, 267, 520, 635, 14664, 354, 26, 314, 536, 402, 314, 14664, 14, 9498, 506, 315, 291, 14, 19912, 21, 267, 520, 635, 1434, 26, 710, 1434, 370, 2754, 14, 9498, 506, 315, 291, 14, 19912, 21, 59, 7848, 61, 267, 520, 6691, 1050, 632, 26, 710, 4340, 314, 8212, 445, 5487, 83, 4898, 3483, 14, 8394, 787, 26, 2079, 446, 283, 4129, 7, 2079, 446, 283, 757, 7, 2079, 446, 283, 452, 7, 221, 334, 83, 7047, 1006, 1050, 10433, 9, 267, 520, 1107, 26, 282, 10634, 10071, 543, 314, 4362, 26, 2116, 446, 14664, 2116, 446, 1434, 2116, 446, 14843, 2116, 446, 943, 8, 71, 9, 2116, 446, 359, 3456, 15, 40, 61, 2116, 446, 8118, 2730, 2116, 446, 1050, 632, 2116, 446, 4336, 334, 292, 5696, 445, 5487, 574, 9, 2116, 446, 445, 5487, 4569, 334, 11555, 9, 267, 408, 267, 340, 14664, 354, 365, 488, 26, 288, 4051, 63, 513, 275, 942, 288, 14664, 63, 513, 275, 291, 14, 513, 63, 270, 4291, 342, 288, 367, 14664, 315, 14664, 63, 513, 26, 355, 1434, 63, 513, 275, 291, 14, 513, 63, 9356, 8, 7848, 9, 355, 367, 1434, 315, 1434, 63, 513, 26, 272, 490, 2050, 14, 1757, 360, 20568, 315, 3341, 367, 14664, 5479, 1434, 9499, 908, 8, 7848, 12, 1434, 430, 490, 4051, 63, 513, 14, 740, 8, 277, 423, 2014, 63, 576, 8, 7848, 12, 1434, 12, 1050, 632, 29, 525, 632, 12, 1586, 63, 31427, 29, 739, 63, 31427, 430, 288, 372, 6454, 14, 9419, 8, 1587, 63, 513, 12, 3686, 63, 1080, 29, 549, 9, 10631, 916, 14664, 354, 365, 440, 488, 436, 1434, 365, 488, 26, 288, 4051, 63, 513, 275, 942, 288, 1434, 63, 513, 275, 291, 14, 513, 63, 9356, 8, 7848, 354, 9, 288, 367, 1434, 315, 1434, 63, 513, 26, 355, 2050, 14, 1757, 360, 20568, 315, 3341, 367, 1434, 9499, 908, 8, 602, 430, 355, 4051, 63, 513, 14, 740, 8, 277, 423, 2014, 63, 576, 8, 7848, 354, 12, 1434, 12, 1050, 632, 29, 525, 632, 12, 1586, 63, 31427, 29, 739, 63, 31427, 430, 288, 372, 6454, 14, 9419, 8, 1587, 63, 513, 12, 3686, 63, 1080, 29, 549, 9, 10631, 587, 26, 288, 340, 291, 423, 1587, 365, 440, 488, 26, 355, 372, 291, 423, 1587, 14, 2102, 7528, 277, 423, 1587, 459, 23197, 418, 508, 14664, 354, 9, 1253, 334, 277, 423, 1587, 459, 2506, 418, 508, 1434, 22509, 1574, 342, 288, 327, 1361, 360, 933, 4291, 26, 1656, 291, 14, 513, 63, 270, 4291, 1012, 288, 13148, 275, 291, 14, 19912, 21, 59, 7848, 354, 1527, 602, 1055, 1612, 342, 288, 666, 275, 10018, 8, 513, 9, 288, 367, 6364, 63, 354, 12, 6364, 315, 291, 14, 19912, 21, 59, 7848, 354, 1527, 602, 1055, 4611, 837, 221, 327, 315, 13148, 26, 355, 327, 795, 275, 291, 14, 19912, 21, 59, 7848, 354, 1527, 602, 1527, 795, 63, 354, 61, 355, 862, 26, 490, 8140, 275, 6364, 14, 3288, 459, 525, 632, 418, 490, 340, 1050, 632, 508, 283, 452, 7, 503, 1050, 632, 508, 8140, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alubbock/pysb
pysb/jacobian.py
5
4629
import pysb, pysb.bng, warnings, re, sympy class JacobianGenerator(object): def __init__(self, model): self.model = model self.indent_level = 0 self.__content = None def get_content(self, sim_length=1): if self.__content == None: self.generate_content(sim_length=sim_length) assert self.indent_level == 0, "missing %d outdent call(s)" % self.indent_level return self.__content def emit(self, text=''): self.__content += self.indent_level * 2 * ' ' + text + "\n" def indent(self): self.indent_level += 1 def outdent(self): assert self.indent_level > 0, "called outdent without matching indent" self.indent_level -= 1 def generate_content(self, sim_length): pysb.bng.generate_equations(self.model) self.__content = '' self.emit("DECLARE") self.indent() self.generate_types() self.outdent() self.emit("END") self.emit() self.emit("MODEL %s" % self.model.name) self.indent() self.generate_parameters() self.generate_variables() self.generate_equations() self.outdent() self.emit("END") self.emit() self.emit("SIMULATION SIM") self.indent() self.generate_options() self.generate_units() self.generate_set() self.generate_initial() self.generate_schedule(sim_length) self.outdent() self.emit("END") def generate_types(self): self.emit("TYPE"); self.indent() self.emit("NOTYPE = 0.0 : -1E300 : 1E300") self.outdent() def generate_parameters(self): self.emit("PARAMETER") self.indent() #for param_group in self.make_groups(self.model.parameters, 5): for param_group in self.make_groups([p for p in self.model.parameters if p.name[-2:] != '_0'], 5): self.emit(', '.join([p.name for p in param_group]) + ' AS REAL') self.outdent() def generate_variables(self): self.emit("VARIABLE") self.indent() obs_names = list(self.model.observable_groups.keys()) for obs_group in self.make_groups(obs_names, 5): self.emit(', '.join(obs_group) + ' AS NOTYPE') var_names = ['s%d' % i for i in range(len(self.model.species))] for var_group in self.make_groups(var_names, 5): self.emit(', '.join(var_group) + ' AS NOTYPE') self.outdent() def generate_equations(self): self.emit("EQUATION") self.indent() obs_names = list(self.model.observable_groups.keys()) obs_exprs = [' + '.join('%g * s%s' % g for g in self.model.observable_groups[name]) for name in obs_names] for obs in zip(obs_names, obs_exprs): self.emit('%s = %s;' % obs) var_names = ['s%d' % i for i in range(len(self.model.species))] for (name, ode) in zip(var_names, self.model.odes): expression = sympy.sstr(ode) expression = re.sub(r'\*\*', '^', expression) self.emit('$%s = %s;' % (name, expression)) self.outdent() def generate_options(self): self.emit("OPTIONS") self.indent() self.outdent() def generate_units(self): self.emit("UNIT") self.indent() self.emit("M AS " + self.model.name) self.outdent() def generate_set(self): self.emit("SET") self.indent() for p in self.model.parameters: #self.emit("M.%s := %g;" % (p.name, p.value)) if p.name[-2:] != '_0': self.emit("M.%s := %g;" % (p.name, p.value)) self.outdent() def generate_initial(self): self.emit("INITIAL") self.indent() vars_unseen = set(['s%d' % i for i in range(len(self.model.species))]) for ic in self.model.initials: sname = 's%d' % self.model.get_species_index(ic.pattern) vars_unseen.remove(sname) self.emit("M.%s = %g;" % (sname, ic.value.value)) for sname in sorted(vars_unseen): self.emit("M.%s = 0;" % sname) self.outdent() def generate_schedule(self, sim_length): self.emit("SCHEDULE") self.indent() self.emit("CONTINUE FOR %d" % sim_length); self.outdent() def make_groups(self, elements, size): groups = [] offsets = list(range(0, len(elements), size)) + [None] for i in range(0, len(offsets) - 1): groups.append(elements[offsets[i]:offsets[i+1]]) return groups
bsd-2-clause
[ 646, 10382, 66, 12, 10382, 66, 14, 66, 2753, 12, 3598, 12, 295, 12, 5840, 421, 199, 533, 30633, 7599, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1402, 304, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 3724, 63, 1896, 275, 378, 267, 291, 855, 1317, 275, 488, 339, 347, 664, 63, 1317, 8, 277, 12, 4389, 63, 1267, 29, 17, 304, 267, 340, 291, 855, 1317, 508, 488, 26, 288, 291, 14, 4208, 63, 1317, 8, 5206, 63, 1267, 29, 5206, 63, 1267, 9, 267, 702, 291, 14, 3724, 63, 1896, 508, 378, 12, 298, 4752, 450, 68, 734, 1326, 1240, 8, 83, 2924, 450, 291, 14, 3724, 63, 1896, 267, 372, 291, 855, 1317, 339, 347, 8689, 8, 277, 12, 1318, 9280, 267, 291, 855, 1317, 847, 291, 14, 3724, 63, 1896, 627, 499, 627, 283, 283, 435, 1318, 435, 1867, 78, 2, 339, 347, 4363, 8, 277, 304, 267, 291, 14, 3724, 63, 1896, 847, 413, 339, 347, 734, 1326, 8, 277, 304, 267, 702, 291, 14, 3724, 63, 1896, 690, 378, 12, 298, 3527, 734, 1326, 1928, 4877, 4363, 2, 267, 291, 14, 3724, 63, 1896, 4862, 413, 339, 347, 3550, 63, 1317, 8, 277, 12, 4389, 63, 1267, 304, 267, 10382, 66, 14, 66, 2753, 14, 4208, 63, 15788, 1298, 8, 277, 14, 1238, 9, 267, 291, 855, 1317, 275, 2125, 267, 291, 14, 8159, 480, 27402, 8693, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 4208, 63, 1313, 342, 267, 291, 14, 548, 1326, 342, 267, 291, 14, 8159, 480, 3902, 531, 267, 291, 14, 8159, 342, 267, 291, 14, 8159, 480, 11429, 450, 83, 2, 450, 291, 14, 1238, 14, 354, 9, 267, 291, 14, 3724, 342, 267, 291, 14, 4208, 63, 3214, 342, 267, 291, 14, 4208, 63, 3669, 342, 267, 291, 14, 4208, 63, 15788, 1298, 342, 267, 291, 14, 548, 1326, 342, 267, 291, 14, 8159, 480, 3902, 531, 267, 291, 14, 8159, 342, 267, 291, 14, 8159, 480, 16590, 19531, 428, 1469, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 4208, 63, 1419, 342, 267, 291, 14, 4208, 63, 5260, 342, 267, 291, 14, 4208, 63, 409, 342, 267, 291, 14, 4208, 63, 2747, 342, 267, 291, 14, 4208, 63, 7211, 8, 5206, 63, 1267, 9, 267, 291, 14, 548, 1326, 342, 267, 291, 14, 8159, 480, 3902, 531, 339, 347, 3550, 63, 1313, 8, 277, 304, 267, 291, 14, 8159, 480, 2711, 3547, 267, 291, 14, 3724, 342, 267, 291, 14, 8159, 480, 4609, 4948, 275, 378, 14, 16, 520, 446, 17, 37, 5863, 520, 413, 37, 5863, 531, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 3214, 8, 277, 304, 267, 291, 14, 8159, 480, 14472, 531, 267, 291, 14, 3724, 342, 267, 327, 509, 1215, 63, 923, 315, 291, 14, 1875, 63, 2634, 8, 277, 14, 1238, 14, 3214, 12, 959, 304, 267, 367, 1215, 63, 923, 315, 291, 14, 1875, 63, 2634, 779, 80, 367, 299, 315, 291, 14, 1238, 14, 3214, 340, 299, 14, 354, 1988, 18, 2938, 1137, 2513, 16, 995, 959, 304, 288, 291, 14, 8159, 5102, 1987, 904, 779, 80, 14, 354, 367, 299, 315, 1215, 63, 923, 566, 435, 283, 4319, 5363, 748, 358, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 3669, 8, 277, 304, 267, 291, 14, 8159, 480, 23129, 531, 267, 291, 14, 3724, 342, 267, 16087, 63, 1247, 275, 769, 8, 277, 14, 1238, 14, 2873, 29454, 63, 2634, 14, 1612, 1012, 267, 367, 16087, 63, 923, 315, 291, 14, 1875, 63, 2634, 8, 11226, 63, 1247, 12, 959, 304, 288, 291, 14, 8159, 5102, 1987, 904, 8, 11226, 63, 923, 9, 435, 283, 4319, 2845, 4948, 358, 267, 2729, 63, 1247, 275, 788, 83, 5, 68, 7, 450, 284, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1238, 14, 17168, 10524, 267, 367, 2729, 63, 923, 315, 291, 14, 1875, 63, 2634, 8, 1391, 63, 1247, 12, 959, 304, 288, 291, 14, 8159, 5102, 1987, 904, 8, 1391, 63, 923, 9, 435, 283, 4319, 2845, 4948, 358, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 15788, 1298, 8, 277, 304, 267, 291, 14, 8159, 480, 37, 2328, 2594, 531, 267, 291, 14, 3724, 342, 267, 16087, 63, 1247, 275, 769, 8, 277, 14, 1238, 14, 2873, 29454, 63, 2634, 14, 1612, 1012, 267, 16087, 63, 16006, 275, 788, 435, 1987, 904, 3508, 71, 627, 308, 5, 83, 7, 450, 486, 367, 486, 315, 291, 14, 1238, 14, 2873, 29454, 63, 2634, 59, 354, 566, 367, 536, 315, 16087, 63, 1247, 61, 267, 367, 16087, 315, 3482, 8, 11226, 63, 1247, 12, 16087, 63, 16006, 304, 288, 291, 14, 8159, 3508, 83, 275, 450, 83, 8942, 450, 16087, 9, 267, 2729, 63, 1247, 275, 788, 83, 5, 68, 7, 450, 284, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1238, 14, 17168, 10524, 267, 367, 334, 354, 12, 312, 271, 9, 315, 3482, 8, 1391, 63, 1247, 12, 291, 14, 1238, 14, 380, 83, 304, 288, 3965, 275, 5840, 14, 83, 495, 8, 380, 9, 288, 3965, 275, 295, 14, 954, 8, 82, 1154, 7590, 7693, 14452, 297, 3965, 9, 288, 291, 14, 8159, 14676, 5, 83, 275, 450, 83, 8942, 450, 334, 354, 12, 3965, 430, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 1419, 8, 277, 304, 267, 291, 14, 8159, 480, 8808, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 5260, 8, 277, 304, 267, 291, 14, 8159, 480, 15505, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 8159, 480, 45, 4319, 298, 435, 291, 14, 1238, 14, 354, 9, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 409, 8, 277, 304, 267, 291, 14, 8159, 480, 3597, 531, 267, 291, 14, 3724, 342, 267, 367, 299, 315, 291, 14, 1238, 14, 3214, 26, 288, 327, 277, 14, 8159, 480, 45, 4111, 83, 12952, 450, 71, 9426, 450, 334, 80, 14, 354, 12, 299, 14, 585, 430, 288, 340, 299, 14, 354, 1988, 18, 2938, 1137, 2513, 16, 356, 355 ]
[ 10382, 66, 12, 10382, 66, 14, 66, 2753, 12, 3598, 12, 295, 12, 5840, 421, 199, 533, 30633, 7599, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1402, 304, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 3724, 63, 1896, 275, 378, 267, 291, 855, 1317, 275, 488, 339, 347, 664, 63, 1317, 8, 277, 12, 4389, 63, 1267, 29, 17, 304, 267, 340, 291, 855, 1317, 508, 488, 26, 288, 291, 14, 4208, 63, 1317, 8, 5206, 63, 1267, 29, 5206, 63, 1267, 9, 267, 702, 291, 14, 3724, 63, 1896, 508, 378, 12, 298, 4752, 450, 68, 734, 1326, 1240, 8, 83, 2924, 450, 291, 14, 3724, 63, 1896, 267, 372, 291, 855, 1317, 339, 347, 8689, 8, 277, 12, 1318, 9280, 267, 291, 855, 1317, 847, 291, 14, 3724, 63, 1896, 627, 499, 627, 283, 283, 435, 1318, 435, 1867, 78, 2, 339, 347, 4363, 8, 277, 304, 267, 291, 14, 3724, 63, 1896, 847, 413, 339, 347, 734, 1326, 8, 277, 304, 267, 702, 291, 14, 3724, 63, 1896, 690, 378, 12, 298, 3527, 734, 1326, 1928, 4877, 4363, 2, 267, 291, 14, 3724, 63, 1896, 4862, 413, 339, 347, 3550, 63, 1317, 8, 277, 12, 4389, 63, 1267, 304, 267, 10382, 66, 14, 66, 2753, 14, 4208, 63, 15788, 1298, 8, 277, 14, 1238, 9, 267, 291, 855, 1317, 275, 2125, 267, 291, 14, 8159, 480, 27402, 8693, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 4208, 63, 1313, 342, 267, 291, 14, 548, 1326, 342, 267, 291, 14, 8159, 480, 3902, 531, 267, 291, 14, 8159, 342, 267, 291, 14, 8159, 480, 11429, 450, 83, 2, 450, 291, 14, 1238, 14, 354, 9, 267, 291, 14, 3724, 342, 267, 291, 14, 4208, 63, 3214, 342, 267, 291, 14, 4208, 63, 3669, 342, 267, 291, 14, 4208, 63, 15788, 1298, 342, 267, 291, 14, 548, 1326, 342, 267, 291, 14, 8159, 480, 3902, 531, 267, 291, 14, 8159, 342, 267, 291, 14, 8159, 480, 16590, 19531, 428, 1469, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 4208, 63, 1419, 342, 267, 291, 14, 4208, 63, 5260, 342, 267, 291, 14, 4208, 63, 409, 342, 267, 291, 14, 4208, 63, 2747, 342, 267, 291, 14, 4208, 63, 7211, 8, 5206, 63, 1267, 9, 267, 291, 14, 548, 1326, 342, 267, 291, 14, 8159, 480, 3902, 531, 339, 347, 3550, 63, 1313, 8, 277, 304, 267, 291, 14, 8159, 480, 2711, 3547, 267, 291, 14, 3724, 342, 267, 291, 14, 8159, 480, 4609, 4948, 275, 378, 14, 16, 520, 446, 17, 37, 5863, 520, 413, 37, 5863, 531, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 3214, 8, 277, 304, 267, 291, 14, 8159, 480, 14472, 531, 267, 291, 14, 3724, 342, 267, 327, 509, 1215, 63, 923, 315, 291, 14, 1875, 63, 2634, 8, 277, 14, 1238, 14, 3214, 12, 959, 304, 267, 367, 1215, 63, 923, 315, 291, 14, 1875, 63, 2634, 779, 80, 367, 299, 315, 291, 14, 1238, 14, 3214, 340, 299, 14, 354, 1988, 18, 2938, 1137, 2513, 16, 995, 959, 304, 288, 291, 14, 8159, 5102, 1987, 904, 779, 80, 14, 354, 367, 299, 315, 1215, 63, 923, 566, 435, 283, 4319, 5363, 748, 358, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 3669, 8, 277, 304, 267, 291, 14, 8159, 480, 23129, 531, 267, 291, 14, 3724, 342, 267, 16087, 63, 1247, 275, 769, 8, 277, 14, 1238, 14, 2873, 29454, 63, 2634, 14, 1612, 1012, 267, 367, 16087, 63, 923, 315, 291, 14, 1875, 63, 2634, 8, 11226, 63, 1247, 12, 959, 304, 288, 291, 14, 8159, 5102, 1987, 904, 8, 11226, 63, 923, 9, 435, 283, 4319, 2845, 4948, 358, 267, 2729, 63, 1247, 275, 788, 83, 5, 68, 7, 450, 284, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1238, 14, 17168, 10524, 267, 367, 2729, 63, 923, 315, 291, 14, 1875, 63, 2634, 8, 1391, 63, 1247, 12, 959, 304, 288, 291, 14, 8159, 5102, 1987, 904, 8, 1391, 63, 923, 9, 435, 283, 4319, 2845, 4948, 358, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 15788, 1298, 8, 277, 304, 267, 291, 14, 8159, 480, 37, 2328, 2594, 531, 267, 291, 14, 3724, 342, 267, 16087, 63, 1247, 275, 769, 8, 277, 14, 1238, 14, 2873, 29454, 63, 2634, 14, 1612, 1012, 267, 16087, 63, 16006, 275, 788, 435, 1987, 904, 3508, 71, 627, 308, 5, 83, 7, 450, 486, 367, 486, 315, 291, 14, 1238, 14, 2873, 29454, 63, 2634, 59, 354, 566, 367, 536, 315, 16087, 63, 1247, 61, 267, 367, 16087, 315, 3482, 8, 11226, 63, 1247, 12, 16087, 63, 16006, 304, 288, 291, 14, 8159, 3508, 83, 275, 450, 83, 8942, 450, 16087, 9, 267, 2729, 63, 1247, 275, 788, 83, 5, 68, 7, 450, 284, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1238, 14, 17168, 10524, 267, 367, 334, 354, 12, 312, 271, 9, 315, 3482, 8, 1391, 63, 1247, 12, 291, 14, 1238, 14, 380, 83, 304, 288, 3965, 275, 5840, 14, 83, 495, 8, 380, 9, 288, 3965, 275, 295, 14, 954, 8, 82, 1154, 7590, 7693, 14452, 297, 3965, 9, 288, 291, 14, 8159, 14676, 5, 83, 275, 450, 83, 8942, 450, 334, 354, 12, 3965, 430, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 1419, 8, 277, 304, 267, 291, 14, 8159, 480, 8808, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 5260, 8, 277, 304, 267, 291, 14, 8159, 480, 15505, 531, 267, 291, 14, 3724, 342, 267, 291, 14, 8159, 480, 45, 4319, 298, 435, 291, 14, 1238, 14, 354, 9, 267, 291, 14, 548, 1326, 342, 339, 347, 3550, 63, 409, 8, 277, 304, 267, 291, 14, 8159, 480, 3597, 531, 267, 291, 14, 3724, 342, 267, 367, 299, 315, 291, 14, 1238, 14, 3214, 26, 288, 327, 277, 14, 8159, 480, 45, 4111, 83, 12952, 450, 71, 9426, 450, 334, 80, 14, 354, 12, 299, 14, 585, 430, 288, 340, 299, 14, 354, 1988, 18, 2938, 1137, 2513, 16, 356, 355, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
miipl-naveen/optibizz
addons/account_bank_statement_extensions/__init__.py
442
1153
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # # Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import account_bank_statement import res_partner_bank import report import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 258, 199, 3, 259, 1898, 334, 67, 9, 7760, 3091, 433, 292, 26510, 15, 2231, 334, 1544, 14, 889, 433, 292, 14, 1235, 680, 2900, 4481, 4644, 14, 199, 3, 221, 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, 646, 2933, 63, 9860, 63, 6242, 199, 646, 522, 63, 3899, 63, 9860, 199, 646, 3622, 199, 646, 12262, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 258, 199, 3, 259, 1898, 334, 67, 9, 7760, 3091, 433, 292, 26510, 15, 2231, 334, 1544, 14, 889, 433, 292, 14, 1235, 680, 2900, 4481, 4644, 14, 199, 3, 221, 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, 646, 2933, 63, 9860, 63, 6242, 199, 646, 522, 63, 3899, 63, 9860, 199, 646, 3622, 199, 646, 12262, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
andreparrish/python-for-android
python3-alpha/python3-src/Lib/xml/etree/__init__.py
1200
1604
# $Id: __init__.py 3375 2008-02-13 08:05:08Z fredrik $ # elementtree package # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2008 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/psf/license for licensing details.
apache-2.0
[ 3, 2672, 1304, 26, 636, 826, 4343, 647, 650, 9946, 9079, 13, 996, 13, 969, 19363, 26, 1717, 26, 2036, 58, 289, 581, 25844, 2672, 199, 3, 1819, 2350, 2559, 199, 199, 3, 23567, 199, 3, 710, 13139, 4744, 6065, 365, 199, 3, 199, 3, 1898, 334, 67, 9, 21300, 13, 9300, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 23580, 491, 2101, 14840, 503, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 5795, 11771, 491, 27851, 14840, 2401, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 5795, 11771, 491, 27851, 14840, 1549, 2334, 17632, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 199, 3, 1634, 5749, 4141, 14, 199, 3, 23567, 199, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 1666, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 1190, 70, 15, 1682, 367, 32572, 2436, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2672, 1304, 26, 636, 826, 4343, 647, 650, 9946, 9079, 13, 996, 13, 969, 19363, 26, 1717, 26, 2036, 58, 289, 581, 25844, 2672, 199, 3, 1819, 2350, 2559, 199, 199, 3, 23567, 199, 3, 710, 13139, 4744, 6065, 365, 199, 3, 199, 3, 1898, 334, 67, 9, 21300, 13, 9300, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 23580, 491, 2101, 14840, 503, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 5795, 11771, 491, 27851, 14840, 2401, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 5795, 11771, 491, 27851, 14840, 1549, 2334, 17632, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 199, 3, 1634, 5749, 4141, 14, 199, 3, 23567, 199, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 1666, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 1190, 70, 15, 1682, 367, 32572, 2436, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
clausqr/HTPC-Manager
modules/qbittorrent.py
1
12490
#!/usr/bin/env python # -*- coding: utf-8 -*- import htpc import cherrypy import json import logging import time import math from cherrypy.lib.auth2 import require from htpc.helpers import striphttp, sizeof import requests from requests.auth import HTTPDigestAuth class Qbittorrent(object): session = requests.Session() def __init__(self): self.logger = logging.getLogger('modules.qbittorrent') self.newapi = False self.authenticated = False self.testapi = None htpc.MODULES.append({ 'name': 'qBittorrent', 'id': 'qbittorrent', 'test': htpc.WEBDIR + 'qbittorrent/ping', 'fields': [ {'type': 'bool', 'label': 'Enable', 'name': 'qbittorrent_enable'}, {'type': 'text', 'label': 'Menu name', 'name': 'qbittorrent_name'}, {'type': 'text', 'label': 'IP / Host', 'placeholder': 'localhost', 'name': 'qbittorrent_host'}, {'type': 'text', 'label': 'Port', 'placeholder': '8080', 'name': 'qbittorrent_port'}, {'type': 'text', 'label': 'Username', 'name': 'qbittorrent_username'}, {'type': 'password', 'label': 'Password', 'name': 'qbittorrent_password'}, {'type': 'bool', 'label': 'Use SSL', 'name': 'qbittorrent_ssl'}, {'type': 'text', 'label': 'Reverse proxy link', 'placeholder': '', 'desc': 'Reverse proxy link ex: https://qbt.domain.com', 'name': 'qbittorrent_reverse_proxy_link'}, ] }) @cherrypy.expose() @require() def index(self): return htpc.LOOKUP.get_template('qbittorrent.html').render(scriptname='qbittorrent', webinterface=self.webinterface()) def webinterface(self): host = striphttp(htpc.settings.get('qbittorrent_host', '')) port = htpc.settings.get('qbittorrent_port', '') ssl = 's' if htpc.settings.get('qbittorrent_ssl', 0) else '' url = 'http%s://%s:%s/' % (ssl, host, port) if htpc.settings.get('qbittorrent_reverse_proxy_link'): url = htpc.settings.get('qbittorrent_reverse_proxy_link') return url def qbturl(self): host = striphttp(htpc.settings.get('qbittorrent_host', '')) port = htpc.settings.get('qbittorrent_port', '') ssl = 's' if htpc.settings.get('qbittorrent_ssl', 0) else '' url = 'http%s://%s:%s/' % (ssl, host, port) return url @cherrypy.expose() @require() def login(self): self.logger.debug('Trying to login to qbittorrent') try: d = {'username': htpc.settings.get('qbittorrent_username', ''), 'password': htpc.settings.get('qbittorrent_password', '') } # F33d da cookie monster r = self.session.post(self.qbturl() + 'login', data=d, verify=False, timeout=5) if r.content == 'Ok.': self.logger.debug('Successfully logged in with new api') self.authenticated = True self.newapi = True else: self.logger.error('Check your username and password') return r.content except Exception as e: self.logger.error('Failed to auth with new api %s' % e) return def _fetch(self, u, post=False, params={}, data=None): host = striphttp(htpc.settings.get('qbittorrent_host', '')) port = htpc.settings.get('qbittorrent_port', '') ssl = 's' if htpc.settings.get('qbittorrent_ssl') else '' url = 'http%s://%s:%s/' % (ssl, host, port) username = htpc.settings.get('qbittorrent_username', '') password = htpc.settings.get('qbittorrent_password', '') url += u if self.testapi is None: self.ping() if self.newapi: if self.authenticated is False: self.login() if post: if self.newapi: r = self.session.post(url, data=data, verify=False, timeout=8) else: r = self.session.post(url, data=data, verify=False, timeout=8, auth=HTTPDigestAuth(username, password)) else: if self.newapi: r = self.session.get(url, verify=False, timeout=8) else: r = self.session.get(url, verify=False, timeout=8, auth=HTTPDigestAuth(username, password)) return r @cherrypy.expose() @require() @cherrypy.tools.json_out() def fetch(self): try: if self.newapi: result = self._fetch('query/torrents?filter=all&sort=size&reverse=false') torrents = result.json() l = [] for torrent in torrents: t = {} for k, v in torrent.items(): t[k] = v if k == 'size': t['size'] = sizeof(int(v)) if k == 'eta': eta = time.strftime('%H:%M:%S', time.gmtime(v)) if eta == '00:00:00': eta = u'\u221E' t['eta'] = eta if k == 'ratio': t['ratio'] = math.ceil(v) l.append(t) return l else: result = self._fetch('json/torrents') # r.json() does not like the infinity return json.loads(result.content) except Exception as e: self.logger.error("Couldn't get torrents %s" % e) @cherrypy.expose() @require() @cherrypy.tools.json_out() def get_speed(self): ''' Get total download and upload speed ''' try: d = {} if not self.newapi: result = self._fetch('json/transferInfo/') result = result.json() speeddown = result['dl_info'] speedup = result['up_info'] list_of_down = speeddown.split() list_of_up = speedup.split() ds = list_of_down[1] + ' ' + list_of_down[2] dlstat = list_of_down[5] + ' ' + list_of_down[6] us = list_of_up[1] + ' ' + list_of_up[2] ulstat = list_of_down[5] + ' ' + list_of_down[6] d = { 'qbittorrent_speed_down': ds, 'qbittorrent_speed_up': us, 'qbittorrent_total_dl': dlstat, 'qbittorrent_total_ul': ulstat } else: # new api stuff result = self._fetch('query/transferInfo') result = result.json() d = { 'qbittorrent_speed_down': sizeof(result['dl_info_speed']), 'qbittorrent_speed_up': sizeof(result['up_info_speed']), 'qbittorrent_total_dl': sizeof(result['dl_info_data']), 'qbittorrent_total_ul': sizeof(result['up_info_data']) } return d except Exception as e: self.logger.error("Couldn't get total download and uploads speed %s" % e) def get_global_dl_limit(self): try: result = self._fetch('command/getGlobalDlLimit/') speed = int(result.content) speed /= 1024 return speed except Exception as e: self.logger.error("Couldn't get global download limit %s" % e) def get_global_ul_limit(self): try: result = self._fetch('command/getGlobalUpLimit') speed = int(result.content) speed /= 1024 return speed except Exception as e: self.logger.error("Couldn't get global upload limit %s" % e) @cherrypy.expose() @require() @cherrypy.tools.json_out() def get_global_limit(self): try: d = {} d['dl_limit'] = self.get_global_dl_limit() d['ul_limit'] = self.get_global_ul_limit() return d except Exception as e: self.logger.debug("Couldn't get global upload and download limits %s" % e) @cherrypy.expose() @require() def command(self, cmd=None, hash=None, name=None, dlurl=None): ''' Handles pause, resume, delete singel torrents ''' try: self.logger.debug('%s %s' % (cmd, name)) data = {} if cmd == 'delete': data['hashes'] = hash elif cmd == 'download': data['urls'] = dlurl elif cmd == 'resumeall' or cmd == 'pauseall': # this does not work, bug in qbt see # https://github.com/qbittorrent/qBittorrent/issues/3016 if self.newapi: cmd = cmd[:-3] + 'All' else: data['hash'] = hash url = 'command/%s' % cmd # data is form encode.. r = self._fetch(url, post=True, data=data) return r.content except Exception as e: self.logger.error('Failed at %s %s %s %s' % (cmd, name, hash, e)) @cherrypy.expose() @require() def to_client(self, link, torrentname, **kwargs): ''' Is used by torrent search ''' try: url = 'command/download/' data = {} data['urls'] = link return self._fetch(url, data=data, post=True) self.logger.info('%s %s is sendt to qBittorrent' % (torrentname, link)) except Exception as e: self.logger.error('Failed to send %s %s to qBittorrent %s' % (link, torrentname, e)) @cherrypy.expose() @require() def set_speedlimit(self, type=None, speed=None): ''' Sets global upload and download speed ''' try: self.logger.debug('Setting %s to %s' % (type, speed)) speed = int(speed) if speed == 0: speed = 0 else: speed = speed * 1024 url = 'command/' + type + '/' data = {} data['limit'] = speed r = self._fetch(url, data=data, post=True) return r.content except Exception as e: self.logger.error('Failed to set %s to %s %s' % (type, speed, e)) @cherrypy.expose() @require() @cherrypy.tools.json_out() def ping(self, qbittorrent_host='', qbittorrent_port='', qbittorrent_username='', qbittorrent_password='', qbittorrent_ssl=False, **kw): self.logger.debug('Trying to connect to qBittorret') host = qbittorrent_host or htpc.settings.get('qbittorrent_host') port = qbittorrent_port or htpc.settings.get('qbittorrent_port') username = qbittorrent_username or htpc.settings.get('qbittorrent_username') password = qbittorrent_password or htpc.settings.get('qbittorrent_password') ssl = 's' if qbittorrent_ssl or htpc.settings.get('qbittorrent_ssl') else '' url = 'http%s://%s:%s/' % (ssl, host, port) self.newapi = False self.authenticated = False try: # We assume that its atleast 3.2 if this works. r = requests.get(url + 'version/api', timeout=8, verify=False) self.logger.debug('Trying to connect with new API %s' % r.url) # Old api returns a empty page if r.content != '' and r.ok: self.newapi = r.content self.testapi = True return r.content else: raise requests.ConnectionError except Exception as e: self.logger.debug('Failed to figure out what api version, trying old API') try: r = requests.post(url + 'json/torrents', auth=HTTPDigestAuth(username, password), timeout=10, verify=False) if r.ok: self.logger.debug('Old API works %s' % r.url) # Disable new api stuff self.testapi = True self.newapi = False self.authenticated = False except Exception as e: self.newapi = False self.authenticated = False self.logger.debug('Failed to contact qBittorrent via old and newapi') self.logger.error('Cant contact qBittorrent, check you settings and try again %s' % e)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 394, 683, 67, 199, 646, 13397, 199, 646, 2022, 199, 646, 2050, 199, 646, 900, 199, 646, 3473, 199, 504, 13397, 14, 773, 14, 1178, 18, 492, 4409, 199, 504, 394, 683, 67, 14, 7546, 492, 6202, 1014, 12, 13855, 199, 646, 4145, 199, 504, 4145, 14, 1178, 492, 3101, 18541, 2817, 421, 199, 533, 1413, 2075, 14101, 8, 785, 304, 272, 2351, 275, 4145, 14, 4434, 342, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2921, 275, 2050, 14, 5572, 360, 3112, 14, 81, 2075, 14101, 358, 267, 291, 14, 1222, 1246, 275, 756, 267, 291, 14, 12177, 275, 756, 267, 291, 14, 396, 1246, 275, 488, 267, 394, 683, 67, 14, 21194, 14, 740, 2561, 288, 283, 354, 356, 283, 81, 4734, 14101, 297, 288, 283, 344, 356, 283, 81, 2075, 14101, 297, 288, 283, 396, 356, 394, 683, 67, 14, 13166, 3022, 435, 283, 81, 2075, 14101, 15, 4073, 297, 288, 283, 955, 356, 359, 355, 791, 466, 356, 283, 2245, 297, 283, 1302, 356, 283, 6476, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 4296, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 5977, 536, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 354, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 1772, 1182, 10891, 297, 283, 6199, 356, 283, 5967, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 1102, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 4313, 297, 283, 6199, 356, 283, 15844, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 719, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 13355, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 2473, 2267, 355, 791, 466, 356, 283, 2060, 297, 283, 1302, 356, 283, 6139, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 2060, 2267, 355, 791, 466, 356, 283, 2245, 297, 283, 1302, 356, 283, 6119, 7799, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 4266, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 14987, 4566, 2142, 297, 283, 6199, 356, 3260, 283, 3257, 356, 283, 14987, 4566, 2142, 444, 26, 4178, 921, 81, 13061, 14, 2261, 14, 957, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 4471, 63, 3280, 63, 1073, 2267, 953, 1622, 267, 3828, 339, 768, 23438, 14, 20586, 342, 272, 768, 4365, 342, 272, 347, 1478, 8, 277, 304, 267, 372, 394, 683, 67, 14, 29149, 14, 362, 63, 1160, 360, 81, 2075, 14101, 14, 1360, 1959, 3352, 8, 1579, 354, 534, 81, 2075, 14101, 297, 3330, 3266, 29, 277, 14, 2520, 3266, 1012, 339, 347, 3330, 3266, 8, 277, 304, 267, 1591, 275, 6202, 1014, 8, 517, 2352, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 1102, 297, 12381, 267, 1844, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 719, 297, 4074, 267, 6149, 275, 283, 83, 7, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4266, 297, 378, 9, 587, 2125, 267, 1166, 275, 283, 1014, 5, 83, 13827, 83, 2689, 83, 4805, 450, 334, 4266, 12, 1591, 12, 1844, 9, 267, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4471, 63, 3280, 63, 1073, 735, 288, 1166, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4471, 63, 3280, 63, 1073, 358, 267, 372, 1166, 339, 347, 1894, 13061, 633, 8, 277, 304, 267, 1591, 275, 6202, 1014, 8, 517, 2352, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 1102, 297, 12381, 267, 1844, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 719, 297, 4074, 267, 6149, 275, 283, 83, 7, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4266, 297, 378, 9, 587, 2125, 267, 1166, 275, 283, 1014, 5, 83, 13827, 83, 2689, 83, 4805, 450, 334, 4266, 12, 1591, 12, 1844, 9, 267, 372, 1166, 339, 768, 23438, 14, 20586, 342, 272, 768, 4365, 342, 272, 347, 4676, 8, 277, 304, 267, 291, 14, 2921, 14, 1757, 360, 27693, 370, 4676, 370, 1894, 2075, 14101, 358, 267, 862, 26, 288, 366, 275, 791, 2473, 356, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2473, 297, 9929, 326, 283, 2060, 356, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2060, 297, 4074, 326, 789, 288, 327, 481, 1153, 68, 12927, 5494, 3485, 11652, 288, 519, 275, 291, 14, 1730, 14, 1932, 8, 277, 14, 81, 13061, 633, 342, 435, 283, 2886, 297, 666, 29, 68, 12, 4911, 29, 797, 12, 2653, 29, 21, 9, 288, 340, 519, 14, 1317, 508, 283, 11622, 10586, 355, 291, 14, 2921, 14, 1757, 360, 25001, 10367, 315, 543, 892, 2986, 358, 355, 291, 14, 12177, 275, 715, 355, 291, 14, 1222, 1246, 275, 715, 288, 587, 26, 355, 291, 14, 2921, 14, 705, 360, 1799, 2195, 3434, 436, 2505, 358, 288, 372, 519, 14, 1317, 267, 871, 2186, 465, 325, 26, 288, 291, 14, 2921, 14, 705, 360, 4276, 370, 1790, 543, 892, 2986, 450, 83, 7, 450, 325, 9, 288, 372, 339, 347, 485, 3535, 8, 277, 12, 399, 12, 2963, 29, 797, 12, 1862, 10324, 666, 29, 403, 304, 267, 1591, 275, 6202, 1014, 8, 517, 2352, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 1102, 297, 12381, 267, 1844, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 719, 297, 4074, 267, 6149, 275, 283, 83, 7, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4266, 358, 587, 2125, 267, 1166, 275, 283, 1014, 5, 83, 13827, 83, 2689, 83, 4805, 450, 334, 4266, 12, 1591, 12, 1844, 9, 267, 3434, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2473, 297, 4074, 267, 2505, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2060 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 394, 683, 67, 199, 646, 13397, 199, 646, 2022, 199, 646, 2050, 199, 646, 900, 199, 646, 3473, 199, 504, 13397, 14, 773, 14, 1178, 18, 492, 4409, 199, 504, 394, 683, 67, 14, 7546, 492, 6202, 1014, 12, 13855, 199, 646, 4145, 199, 504, 4145, 14, 1178, 492, 3101, 18541, 2817, 421, 199, 533, 1413, 2075, 14101, 8, 785, 304, 272, 2351, 275, 4145, 14, 4434, 342, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2921, 275, 2050, 14, 5572, 360, 3112, 14, 81, 2075, 14101, 358, 267, 291, 14, 1222, 1246, 275, 756, 267, 291, 14, 12177, 275, 756, 267, 291, 14, 396, 1246, 275, 488, 267, 394, 683, 67, 14, 21194, 14, 740, 2561, 288, 283, 354, 356, 283, 81, 4734, 14101, 297, 288, 283, 344, 356, 283, 81, 2075, 14101, 297, 288, 283, 396, 356, 394, 683, 67, 14, 13166, 3022, 435, 283, 81, 2075, 14101, 15, 4073, 297, 288, 283, 955, 356, 359, 355, 791, 466, 356, 283, 2245, 297, 283, 1302, 356, 283, 6476, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 4296, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 5977, 536, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 354, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 1772, 1182, 10891, 297, 283, 6199, 356, 283, 5967, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 1102, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 4313, 297, 283, 6199, 356, 283, 15844, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 719, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 13355, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 2473, 2267, 355, 791, 466, 356, 283, 2060, 297, 283, 1302, 356, 283, 6139, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 2060, 2267, 355, 791, 466, 356, 283, 2245, 297, 283, 1302, 356, 283, 6119, 7799, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 4266, 2267, 355, 791, 466, 356, 283, 505, 297, 283, 1302, 356, 283, 14987, 4566, 2142, 297, 283, 6199, 356, 3260, 283, 3257, 356, 283, 14987, 4566, 2142, 444, 26, 4178, 921, 81, 13061, 14, 2261, 14, 957, 297, 283, 354, 356, 283, 81, 2075, 14101, 63, 4471, 63, 3280, 63, 1073, 2267, 953, 1622, 267, 3828, 339, 768, 23438, 14, 20586, 342, 272, 768, 4365, 342, 272, 347, 1478, 8, 277, 304, 267, 372, 394, 683, 67, 14, 29149, 14, 362, 63, 1160, 360, 81, 2075, 14101, 14, 1360, 1959, 3352, 8, 1579, 354, 534, 81, 2075, 14101, 297, 3330, 3266, 29, 277, 14, 2520, 3266, 1012, 339, 347, 3330, 3266, 8, 277, 304, 267, 1591, 275, 6202, 1014, 8, 517, 2352, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 1102, 297, 12381, 267, 1844, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 719, 297, 4074, 267, 6149, 275, 283, 83, 7, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4266, 297, 378, 9, 587, 2125, 267, 1166, 275, 283, 1014, 5, 83, 13827, 83, 2689, 83, 4805, 450, 334, 4266, 12, 1591, 12, 1844, 9, 267, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4471, 63, 3280, 63, 1073, 735, 288, 1166, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4471, 63, 3280, 63, 1073, 358, 267, 372, 1166, 339, 347, 1894, 13061, 633, 8, 277, 304, 267, 1591, 275, 6202, 1014, 8, 517, 2352, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 1102, 297, 12381, 267, 1844, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 719, 297, 4074, 267, 6149, 275, 283, 83, 7, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4266, 297, 378, 9, 587, 2125, 267, 1166, 275, 283, 1014, 5, 83, 13827, 83, 2689, 83, 4805, 450, 334, 4266, 12, 1591, 12, 1844, 9, 267, 372, 1166, 339, 768, 23438, 14, 20586, 342, 272, 768, 4365, 342, 272, 347, 4676, 8, 277, 304, 267, 291, 14, 2921, 14, 1757, 360, 27693, 370, 4676, 370, 1894, 2075, 14101, 358, 267, 862, 26, 288, 366, 275, 791, 2473, 356, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2473, 297, 9929, 326, 283, 2060, 356, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2060, 297, 4074, 326, 789, 288, 327, 481, 1153, 68, 12927, 5494, 3485, 11652, 288, 519, 275, 291, 14, 1730, 14, 1932, 8, 277, 14, 81, 13061, 633, 342, 435, 283, 2886, 297, 666, 29, 68, 12, 4911, 29, 797, 12, 2653, 29, 21, 9, 288, 340, 519, 14, 1317, 508, 283, 11622, 10586, 355, 291, 14, 2921, 14, 1757, 360, 25001, 10367, 315, 543, 892, 2986, 358, 355, 291, 14, 12177, 275, 715, 355, 291, 14, 1222, 1246, 275, 715, 288, 587, 26, 355, 291, 14, 2921, 14, 705, 360, 1799, 2195, 3434, 436, 2505, 358, 288, 372, 519, 14, 1317, 267, 871, 2186, 465, 325, 26, 288, 291, 14, 2921, 14, 705, 360, 4276, 370, 1790, 543, 892, 2986, 450, 83, 7, 450, 325, 9, 288, 372, 339, 347, 485, 3535, 8, 277, 12, 399, 12, 2963, 29, 797, 12, 1862, 10324, 666, 29, 403, 304, 267, 1591, 275, 6202, 1014, 8, 517, 2352, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 1102, 297, 12381, 267, 1844, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 719, 297, 4074, 267, 6149, 275, 283, 83, 7, 340, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 4266, 358, 587, 2125, 267, 1166, 275, 283, 1014, 5, 83, 13827, 83, 2689, 83, 4805, 450, 334, 4266, 12, 1591, 12, 1844, 9, 267, 3434, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2473, 297, 4074, 267, 2505, 275, 394, 683, 67, 14, 1751, 14, 362, 360, 81, 2075, 14101, 63, 2060, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
fumen/gae-fumen
lib/werkzeug/useragents.py
86
5640
# -*- coding: utf-8 -*- """ werkzeug.useragents ~~~~~~~~~~~~~~~~~~~ This module provides a helper to inspect user agent strings. This module is far from complete but should work for most of the currently available browsers. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re class UserAgentParser(object): """A simple user agent parser. Used by the `UserAgent`.""" platforms = ( ('cros', 'chromeos'), ('iphone|ios', 'iphone'), ('ipad', 'ipad'), (r'darwin|mac|os\s*x', 'macos'), ('win', 'windows'), (r'android', 'android'), ('netbsd', 'netbsd'), ('openbsd', 'openbsd'), ('freebsd', 'freebsd'), ('dragonfly', 'dragonflybsd'), ('(sun|i86)os', 'solaris'), (r'x11|lin(\b|ux)?', 'linux'), (r'nintendo\s+wii', 'wii'), ('irix', 'irix'), ('hp-?ux', 'hpux'), ('aix', 'aix'), ('sco|unix_sv', 'sco'), ('bsd', 'bsd'), ('amiga', 'amiga'), ('blackberry|playbook', 'blackberry'), ('symbian', 'symbian') ) browsers = ( ('googlebot', 'google'), ('msnbot', 'msn'), ('yahoo', 'yahoo'), ('ask jeeves', 'ask'), (r'aol|america\s+online\s+browser', 'aol'), ('opera', 'opera'), ('chrome', 'chrome'), ('seamonkey', 'seamonkey'), ('firefox|firebird|phoenix|iceweasel', 'firefox'), ('galeon', 'galeon'), ('safari|version', 'safari'), ('webkit', 'webkit'), ('camino', 'camino'), ('konqueror', 'konqueror'), ('k-meleon', 'kmeleon'), ('netscape', 'netscape'), (r'msie|microsoft\s+internet\s+explorer|trident/.+? rv:', 'msie'), ('lynx', 'lynx'), ('links', 'links'), ('Baiduspider', 'baidu'), ('bingbot', 'bing'), ('mozilla', 'mozilla') ) _browser_version_re = r'(?:%s)[/\sa-z(]*(\d+[.\da-z]+)?' _language_re = re.compile( r'(?:;\s*|\s+)(\b\w{2}\b(?:-\b\w{2}\b)?)\s*;|' r'(?:\(|\[|;)\s*(\b\w{2}\b(?:-\b\w{2}\b)?)\s*(?:\]|\)|;)' ) def __init__(self): self.platforms = [(b, re.compile(a, re.I)) for a, b in self.platforms] self.browsers = [(b, re.compile(self._browser_version_re % a, re.I)) for a, b in self.browsers] def __call__(self, user_agent): for platform, regex in self.platforms: match = regex.search(user_agent) if match is not None: break else: platform = None for browser, regex in self.browsers: match = regex.search(user_agent) if match is not None: version = match.group(1) break else: browser = version = None match = self._language_re.search(user_agent) if match is not None: language = match.group(1) or match.group(2) else: language = None return platform, browser, version, language class UserAgent(object): """Represents a user agent. Pass it a WSGI environment or a user agent string and you can inspect some of the details from the user agent string via the attributes. The following attributes exist: .. attribute:: string the raw user agent string .. attribute:: platform the browser platform. The following platforms are currently recognized: - `aix` - `amiga` - `android` - `bsd` - `chromeos` - `hpux` - `iphone` - `ipad` - `irix` - `linux` - `macos` - `sco` - `solaris` - `wii` - `windows` .. attribute:: browser the name of the browser. The following browsers are currently recognized: - `aol` * - `ask` * - `camino` - `chrome` - `firefox` - `galeon` - `google` * - `kmeleon` - `konqueror` - `links` - `lynx` - `msie` - `msn` - `netscape` - `opera` - `safari` - `seamonkey` - `webkit` - `yahoo` * (Browsers maked with a star (``*``) are crawlers.) .. attribute:: version the version of the browser .. attribute:: language the language of the browser """ _parser = UserAgentParser() def __init__(self, environ_or_string): if isinstance(environ_or_string, dict): environ_or_string = environ_or_string.get('HTTP_USER_AGENT', '') self.string = environ_or_string self.platform, self.browser, self.version, self.language = \ self._parser(environ_or_string) def to_header(self): return self.string def __str__(self): return self.string def __nonzero__(self): return bool(self.browser) __bool__ = __nonzero__ def __repr__(self): return '<%s %r/%s>' % ( self.__class__.__name__, self.browser, self.version ) # conceptionally this belongs in this module but because we want to lazily # load the user agent module (which happens in wrappers.py) we have to import # it afterwards. The class itself has the module set to this module so # pickle, inspect and similar modules treat the object as if it was really # implemented here. from werkzeug.wrappers import UserAgentMixin # noqa
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 751, 14250, 272, 18294, 23597, 339, 961, 859, 6571, 282, 5922, 370, 6485, 922, 6631, 3326, 14, 221, 961, 859, 272, 365, 12474, 687, 4890, 1325, 1077, 1736, 367, 4750, 402, 314, 5544, 2808, 272, 23776, 14, 2378, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 421, 199, 533, 2876, 7788, 2842, 8, 785, 304, 339, 408, 33, 3486, 922, 6631, 1798, 14, 221, 8051, 701, 314, 658, 1899, 7788, 17105, 339, 10677, 275, 334, 267, 661, 20363, 297, 283, 9887, 736, 659, 267, 661, 28303, 92, 9207, 297, 283, 28303, 659, 267, 661, 711, 350, 297, 283, 711, 350, 659, 267, 334, 82, 5121, 22822, 92, 3088, 92, 736, 60, 83, 10, 88, 297, 283, 391, 5197, 659, 267, 661, 2676, 297, 283, 8258, 659, 267, 334, 82, 7, 6238, 297, 283, 6238, 659, 267, 661, 846, 15746, 297, 283, 846, 15746, 659, 267, 661, 1490, 15746, 297, 283, 1490, 15746, 659, 267, 661, 29629, 297, 283, 29629, 659, 267, 661, 14479, 265, 21600, 297, 283, 14479, 265, 21600, 15746, 659, 267, 23845, 11846, 92, 73, 1184, 9, 736, 297, 283, 7873, 4663, 659, 267, 334, 82, 7, 88, 845, 92, 472, 2961, 66, 92, 2521, 5547, 297, 283, 5135, 659, 267, 334, 82, 7, 28693, 724, 1117, 60, 83, 11, 87, 5908, 297, 283, 87, 5908, 659, 267, 661, 73, 1904, 297, 283, 73, 1904, 659, 267, 661, 12025, 13, 31, 2521, 297, 283, 12025, 2521, 659, 267, 661, 65, 1148, 297, 283, 65, 1148, 659, 267, 661, 20845, 92, 11864, 63, 2772, 297, 283, 20845, 659, 267, 661, 15746, 297, 283, 15746, 659, 267, 661, 455, 29055, 297, 283, 455, 29055, 659, 267, 661, 8399, 605, 651, 92, 14205, 297, 283, 8399, 605, 651, 659, 267, 661, 1786, 887, 5653, 297, 283, 1786, 887, 5653, 358, 272, 776, 272, 23776, 275, 334, 267, 661, 3098, 3018, 297, 283, 3098, 659, 267, 661, 706, 78, 3018, 297, 283, 706, 78, 659, 267, 661, 27231, 297, 283, 27231, 659, 267, 661, 813, 1335, 1024, 2310, 297, 283, 813, 659, 267, 334, 82, 7, 65, 393, 92, 313, 7127, 60, 83, 11, 15178, 60, 83, 11, 5750, 297, 283, 65, 393, 659, 267, 661, 2262, 65, 297, 283, 2262, 65, 659, 267, 661, 9887, 297, 283, 9887, 659, 267, 661, 261, 455, 265, 498, 297, 283, 261, 455, 265, 498, 659, 267, 661, 15394, 92, 8935, 22488, 92, 21936, 287, 1148, 92, 1885, 1129, 482, 76, 297, 283, 15394, 659, 267, 661, 71, 1895, 265, 297, 283, 71, 1895, 265, 659, 267, 661, 2231, 70, 759, 92, 1023, 297, 283, 2231, 70, 759, 659, 267, 661, 12554, 297, 283, 12554, 659, 267, 661, 15176, 10175, 297, 283, 15176, 10175, 659, 267, 661, 75, 265, 16891, 269, 297, 283, 75, 265, 16891, 269, 659, 267, 661, 75, 13, 278, 274, 265, 297, 283, 75, 278, 274, 265, 659, 267, 661, 846, 3588, 297, 283, 846, 3588, 659, 267, 334, 82, 6704, 23994, 92, 17040, 60, 83, 11, 4901, 60, 83, 11, 16971, 3859, 92, 599, 1326, 15, 11198, 4336, 6536, 283, 77, 23994, 659, 267, 661, 590, 7343, 297, 283, 590, 7343, 659, 267, 661, 4614, 297, 283, 4614, 659, 267, 661, 13864, 344, 527, 12508, 297, 283, 2470, 344, 85, 659, 267, 661, 10911, 3018, 297, 283, 10911, 659, 267, 661, 12102, 297, 283, 12102, 358, 272, 776, 339, 485, 5750, 63, 1023, 63, 264, 275, 519, 10120, 2689, 83, 2788, 6307, 2231, 13, 90, 8, 3672, 2961, 68, 21324, 3134, 983, 13, 90, 23763, 7, 272, 485, 3671, 63, 264, 275, 295, 14, 2014, 8, 267, 519, 20459, 3779, 83, 10, 6113, 83, 27860, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 27, 5227, 267, 519, 10120, 3427, 8, 6113, 59, 92, 27, 2862, 83, 22588, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 15840, 61, 6113, 8636, 27, 3171, 272, 776, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 19601, 275, 3842, 66, 12, 295, 14, 2014, 8, 65, 12, 295, 14, 41, 430, 367, 282, 12, 330, 315, 291, 14, 19601, 61, 267, 291, 14, 5750, 83, 275, 3842, 66, 12, 295, 14, 2014, 8, 277, 423, 5750, 63, 1023, 63, 264, 450, 282, 12, 295, 14, 41, 430, 586, 367, 282, 12, 330, 315, 291, 14, 5750, 83, 61, 339, 347, 636, 1250, 721, 277, 12, 922, 63, 4054, 304, 267, 367, 4298, 12, 5163, 315, 291, 14, 19601, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 2059, 267, 587, 26, 288, 4298, 275, 488, 267, 367, 7042, 12, 5163, 315, 291, 14, 5750, 83, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 1015, 275, 1336, 14, 923, 8, 17, 9, 355, 2059, 267, 587, 26, 288, 7042, 275, 1015, 275, 488, 267, 1336, 275, 291, 423, 3671, 63, 264, 14, 1733, 8, 751, 63, 4054, 9, 267, 340, 1336, 365, 440, 488, 26, 288, 2637, 275, 1336, 14, 923, 8, 17, 9, 503, 1336, 14, 923, 8, 18, 9, 267, 587, 26, 288, 2637, 275, 488, 267, 372, 4298, 12, 7042, 12, 1015, 12, 2637, 421, 199, 533, 2876, 7788, 8, 785, 304, 339, 408, 18089, 282, 922, 6631, 14, 221, 8325, 652, 282, 9279, 3734, 503, 282, 922, 6631, 272, 1059, 436, 1265, 883, 6485, 2005, 402, 314, 2436, 687, 314, 922, 6631, 272, 1059, 4799, 314, 3004, 14, 221, 710, 2569, 3004, 2187, 26, 339, 2508, 2225, 447, 1059, 10817, 314, 3066, 922, 6631, 1059, 339, 2508, 2225, 447, 4298, 10817, 314, 7042, 4298, 14, 221, 710, 2569, 10677, 787, 5544, 2126, 18054, 26, 10817, 446, 257, 658, 65, 1148, 64, 2126, 446, 257, 658, 455, 29055 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 751, 14250, 272, 18294, 23597, 339, 961, 859, 6571, 282, 5922, 370, 6485, 922, 6631, 3326, 14, 221, 961, 859, 272, 365, 12474, 687, 4890, 1325, 1077, 1736, 367, 4750, 402, 314, 5544, 2808, 272, 23776, 14, 2378, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 421, 199, 533, 2876, 7788, 2842, 8, 785, 304, 339, 408, 33, 3486, 922, 6631, 1798, 14, 221, 8051, 701, 314, 658, 1899, 7788, 17105, 339, 10677, 275, 334, 267, 661, 20363, 297, 283, 9887, 736, 659, 267, 661, 28303, 92, 9207, 297, 283, 28303, 659, 267, 661, 711, 350, 297, 283, 711, 350, 659, 267, 334, 82, 5121, 22822, 92, 3088, 92, 736, 60, 83, 10, 88, 297, 283, 391, 5197, 659, 267, 661, 2676, 297, 283, 8258, 659, 267, 334, 82, 7, 6238, 297, 283, 6238, 659, 267, 661, 846, 15746, 297, 283, 846, 15746, 659, 267, 661, 1490, 15746, 297, 283, 1490, 15746, 659, 267, 661, 29629, 297, 283, 29629, 659, 267, 661, 14479, 265, 21600, 297, 283, 14479, 265, 21600, 15746, 659, 267, 23845, 11846, 92, 73, 1184, 9, 736, 297, 283, 7873, 4663, 659, 267, 334, 82, 7, 88, 845, 92, 472, 2961, 66, 92, 2521, 5547, 297, 283, 5135, 659, 267, 334, 82, 7, 28693, 724, 1117, 60, 83, 11, 87, 5908, 297, 283, 87, 5908, 659, 267, 661, 73, 1904, 297, 283, 73, 1904, 659, 267, 661, 12025, 13, 31, 2521, 297, 283, 12025, 2521, 659, 267, 661, 65, 1148, 297, 283, 65, 1148, 659, 267, 661, 20845, 92, 11864, 63, 2772, 297, 283, 20845, 659, 267, 661, 15746, 297, 283, 15746, 659, 267, 661, 455, 29055, 297, 283, 455, 29055, 659, 267, 661, 8399, 605, 651, 92, 14205, 297, 283, 8399, 605, 651, 659, 267, 661, 1786, 887, 5653, 297, 283, 1786, 887, 5653, 358, 272, 776, 272, 23776, 275, 334, 267, 661, 3098, 3018, 297, 283, 3098, 659, 267, 661, 706, 78, 3018, 297, 283, 706, 78, 659, 267, 661, 27231, 297, 283, 27231, 659, 267, 661, 813, 1335, 1024, 2310, 297, 283, 813, 659, 267, 334, 82, 7, 65, 393, 92, 313, 7127, 60, 83, 11, 15178, 60, 83, 11, 5750, 297, 283, 65, 393, 659, 267, 661, 2262, 65, 297, 283, 2262, 65, 659, 267, 661, 9887, 297, 283, 9887, 659, 267, 661, 261, 455, 265, 498, 297, 283, 261, 455, 265, 498, 659, 267, 661, 15394, 92, 8935, 22488, 92, 21936, 287, 1148, 92, 1885, 1129, 482, 76, 297, 283, 15394, 659, 267, 661, 71, 1895, 265, 297, 283, 71, 1895, 265, 659, 267, 661, 2231, 70, 759, 92, 1023, 297, 283, 2231, 70, 759, 659, 267, 661, 12554, 297, 283, 12554, 659, 267, 661, 15176, 10175, 297, 283, 15176, 10175, 659, 267, 661, 75, 265, 16891, 269, 297, 283, 75, 265, 16891, 269, 659, 267, 661, 75, 13, 278, 274, 265, 297, 283, 75, 278, 274, 265, 659, 267, 661, 846, 3588, 297, 283, 846, 3588, 659, 267, 334, 82, 6704, 23994, 92, 17040, 60, 83, 11, 4901, 60, 83, 11, 16971, 3859, 92, 599, 1326, 15, 11198, 4336, 6536, 283, 77, 23994, 659, 267, 661, 590, 7343, 297, 283, 590, 7343, 659, 267, 661, 4614, 297, 283, 4614, 659, 267, 661, 13864, 344, 527, 12508, 297, 283, 2470, 344, 85, 659, 267, 661, 10911, 3018, 297, 283, 10911, 659, 267, 661, 12102, 297, 283, 12102, 358, 272, 776, 339, 485, 5750, 63, 1023, 63, 264, 275, 519, 10120, 2689, 83, 2788, 6307, 2231, 13, 90, 8, 3672, 2961, 68, 21324, 3134, 983, 13, 90, 23763, 7, 272, 485, 3671, 63, 264, 275, 295, 14, 2014, 8, 267, 519, 20459, 3779, 83, 10, 6113, 83, 27860, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 27, 5227, 267, 519, 10120, 3427, 8, 6113, 59, 92, 27, 2862, 83, 22588, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 15840, 61, 6113, 8636, 27, 3171, 272, 776, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 19601, 275, 3842, 66, 12, 295, 14, 2014, 8, 65, 12, 295, 14, 41, 430, 367, 282, 12, 330, 315, 291, 14, 19601, 61, 267, 291, 14, 5750, 83, 275, 3842, 66, 12, 295, 14, 2014, 8, 277, 423, 5750, 63, 1023, 63, 264, 450, 282, 12, 295, 14, 41, 430, 586, 367, 282, 12, 330, 315, 291, 14, 5750, 83, 61, 339, 347, 636, 1250, 721, 277, 12, 922, 63, 4054, 304, 267, 367, 4298, 12, 5163, 315, 291, 14, 19601, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 2059, 267, 587, 26, 288, 4298, 275, 488, 267, 367, 7042, 12, 5163, 315, 291, 14, 5750, 83, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 1015, 275, 1336, 14, 923, 8, 17, 9, 355, 2059, 267, 587, 26, 288, 7042, 275, 1015, 275, 488, 267, 1336, 275, 291, 423, 3671, 63, 264, 14, 1733, 8, 751, 63, 4054, 9, 267, 340, 1336, 365, 440, 488, 26, 288, 2637, 275, 1336, 14, 923, 8, 17, 9, 503, 1336, 14, 923, 8, 18, 9, 267, 587, 26, 288, 2637, 275, 488, 267, 372, 4298, 12, 7042, 12, 1015, 12, 2637, 421, 199, 533, 2876, 7788, 8, 785, 304, 339, 408, 18089, 282, 922, 6631, 14, 221, 8325, 652, 282, 9279, 3734, 503, 282, 922, 6631, 272, 1059, 436, 1265, 883, 6485, 2005, 402, 314, 2436, 687, 314, 922, 6631, 272, 1059, 4799, 314, 3004, 14, 221, 710, 2569, 3004, 2187, 26, 339, 2508, 2225, 447, 1059, 10817, 314, 3066, 922, 6631, 1059, 339, 2508, 2225, 447, 4298, 10817, 314, 7042, 4298, 14, 221, 710, 2569, 10677, 787, 5544, 2126, 18054, 26, 10817, 446, 257, 658, 65, 1148, 64, 2126, 446, 257, 658, 455, 29055, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Acehaidrey/incubator-airflow
tests/providers/google/cloud/transfers/test_gcs_to_bigquery_system.py
10
1324
# # 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 pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_BIGQUERY_KEY from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_BIGQUERY_KEY) class TestGoogleCloudStorageToBigQueryExample(GoogleSystemTest): @provide_gcp_context(GCP_BIGQUERY_KEY) def test_run_example_dag_gcs_to_bigquery_operator(self): self.run_dag('example_gcs_to_bigquery_operator', CLOUD_DAG_FOLDER)
apache-2.0
[ 3, 199, 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, 4613, 199, 199, 504, 2295, 14, 9710, 14, 3098, 14, 4091, 14, 1208, 14, 20622, 63, 1178, 21345, 492, 30902, 63, 18643, 11938, 63, 3078, 199, 504, 2295, 14, 396, 63, 1208, 14, 20622, 63, 2253, 63, 7546, 492, 445, 1484, 3383, 63, 28211, 63, 19041, 12, 4475, 3989, 774, 12, 5647, 63, 20622, 63, 1100, 421, 199, 32, 4462, 14, 1657, 14, 4620, 480, 8644, 401, 298, 10675, 531, 199, 32, 4462, 14, 1657, 14, 15591, 63, 493, 8, 39, 2890, 63, 18643, 11938, 63, 3078, 9, 199, 533, 1379, 13266, 9089, 6408, 1378, 7279, 3227, 9846, 8, 13266, 3989, 774, 304, 272, 768, 20824, 63, 20622, 63, 1100, 8, 39, 2890, 63, 18643, 11938, 63, 3078, 9, 272, 347, 511, 63, 1065, 63, 2694, 63, 7406, 63, 21757, 63, 475, 63, 23256, 63, 3856, 8, 277, 304, 267, 291, 14, 1065, 63, 7406, 360, 2694, 63, 21757, 63, 475, 63, 23256, 63, 3856, 297, 445, 1484, 3383, 63, 28211, 63, 19041, 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 ]
[ 199, 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, 4613, 199, 199, 504, 2295, 14, 9710, 14, 3098, 14, 4091, 14, 1208, 14, 20622, 63, 1178, 21345, 492, 30902, 63, 18643, 11938, 63, 3078, 199, 504, 2295, 14, 396, 63, 1208, 14, 20622, 63, 2253, 63, 7546, 492, 445, 1484, 3383, 63, 28211, 63, 19041, 12, 4475, 3989, 774, 12, 5647, 63, 20622, 63, 1100, 421, 199, 32, 4462, 14, 1657, 14, 4620, 480, 8644, 401, 298, 10675, 531, 199, 32, 4462, 14, 1657, 14, 15591, 63, 493, 8, 39, 2890, 63, 18643, 11938, 63, 3078, 9, 199, 533, 1379, 13266, 9089, 6408, 1378, 7279, 3227, 9846, 8, 13266, 3989, 774, 304, 272, 768, 20824, 63, 20622, 63, 1100, 8, 39, 2890, 63, 18643, 11938, 63, 3078, 9, 272, 347, 511, 63, 1065, 63, 2694, 63, 7406, 63, 21757, 63, 475, 63, 23256, 63, 3856, 8, 277, 304, 267, 291, 14, 1065, 63, 7406, 360, 2694, 63, 21757, 63, 475, 63, 23256, 63, 3856, 297, 445, 1484, 3383, 63, 28211, 63, 19041, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vimagick/youtube-dl
youtube_dl/extractor/keezmovies.py
107
1802
from __future__ import unicode_literals import os import re from .common import InfoExtractor from ..compat import ( compat_urllib_parse_urlparse, compat_urllib_request, ) class KeezMoviesIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?keezmovies\.com/video/.+?(?P<id>[0-9]+)(?:[/?&]|$)' _TEST = { 'url': 'http://www.keezmovies.com/video/petite-asian-lady-mai-playing-in-bathtub-1214711', 'md5': '6e297b7e789329923fcf83abb67c9289', 'info_dict': { 'id': '1214711', 'ext': 'mp4', 'title': 'Petite Asian Lady Mai Playing In Bathtub', 'age_limit': 18, } } def _real_extract(self, url): video_id = self._match_id(url) req = compat_urllib_request.Request(url) req.add_header('Cookie', 'age_verified=1') webpage = self._download_webpage(req, video_id) # embedded video mobj = re.search(r'href="([^"]+)"></iframe>', webpage) if mobj: embedded_url = mobj.group(1) return self.url_result(embedded_url) video_title = self._html_search_regex( r'<h1 [^>]*>([^<]+)', webpage, 'title') video_url = self._html_search_regex( r'(?s)html5VideoPlayer = .*?src="([^"]+)"', webpage, 'video URL') path = compat_urllib_parse_urlparse(video_url).path extension = os.path.splitext(path)[1][1:] format = path.split('/')[4].split('_')[:2] format = "-".join(format) age_limit = self._rta_search(webpage) return { 'id': video_id, 'title': video_title, 'url': video_url, 'ext': extension, 'format': format, 'format_id': format, 'age_limit': age_limit, }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 63, 10290, 12, 272, 8434, 63, 4078, 63, 1069, 12, 199, 9, 421, 199, 533, 1804, 1024, 90, 3716, 14484, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 415, 27263, 20888, 4537, 957, 15, 3722, 15, 11198, 2229, 48, 28, 344, 9514, 16, 13, 25, 11896, 25060, 10197, 6, 11752, 4, 3171, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 415, 27263, 20888, 14, 957, 15, 3722, 15, 321, 280, 266, 13, 305, 5653, 13, 76, 350, 89, 13, 391, 73, 13, 22224, 13, 262, 13, 66, 1619, 84, 456, 13, 713, 11160, 845, 297, 267, 283, 1064, 21, 356, 283, 22, 69, 12615, 66, 23, 69, 24407, 708, 1020, 1789, 70, 2177, 2658, 12198, 1822, 67, 2942, 1407, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 713, 11160, 845, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 8070, 280, 266, 437, 6214, 491, 350, 89, 603, 5789, 16527, 316, 1010, 699, 1619, 84, 456, 297, 288, 283, 474, 63, 3097, 356, 6155, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 2648, 275, 8434, 63, 4078, 63, 1069, 14, 2017, 8, 633, 9, 267, 2648, 14, 525, 63, 1291, 360, 7810, 297, 283, 474, 63, 12949, 29, 17, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 2103, 12, 3991, 63, 344, 9, 398, 327, 12169, 3991, 267, 14208, 275, 295, 14, 1733, 8, 82, 7, 6399, 24296, 8771, 10070, 20052, 4206, 9248, 9, 267, 340, 14208, 26, 288, 12169, 63, 633, 275, 14208, 14, 923, 8, 17, 9, 288, 372, 291, 14, 633, 63, 1099, 8, 18757, 63, 633, 9, 398, 3991, 63, 1213, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 72, 17, 359, 62, 30, 3672, 30, 31204, 28798, 9248, 12, 283, 1213, 358, 267, 3991, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 10120, 83, 9, 1360, 21, 9166, 10921, 275, 1275, 15279, 2164, 32391, 297, 9248, 12, 283, 3722, 2851, 358, 267, 931, 275, 8434, 63, 4078, 63, 1122, 63, 10290, 8, 3722, 63, 633, 680, 515, 267, 3329, 275, 747, 14, 515, 14, 7973, 8, 515, 2788, 17, 1527, 17, 2938, 267, 1475, 275, 931, 14, 1294, 30746, 20, 1055, 1294, 26341, 1491, 18, 61, 267, 1475, 275, 3905, 1674, 904, 8, 908, 9, 398, 11437, 63, 3097, 275, 291, 423, 82, 502, 63, 1733, 8, 12022, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 3991, 63, 1213, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 832, 356, 3329, 12, 288, 283, 908, 356, 1475, 12, 288, 283, 908, 63, 344, 356, 1475, 12, 288, 283, 474, 63, 3097, 356, 11437, 63, 3097, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 63, 10290, 12, 272, 8434, 63, 4078, 63, 1069, 12, 199, 9, 421, 199, 533, 1804, 1024, 90, 3716, 14484, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 415, 27263, 20888, 4537, 957, 15, 3722, 15, 11198, 2229, 48, 28, 344, 9514, 16, 13, 25, 11896, 25060, 10197, 6, 11752, 4, 3171, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 415, 27263, 20888, 14, 957, 15, 3722, 15, 321, 280, 266, 13, 305, 5653, 13, 76, 350, 89, 13, 391, 73, 13, 22224, 13, 262, 13, 66, 1619, 84, 456, 13, 713, 11160, 845, 297, 267, 283, 1064, 21, 356, 283, 22, 69, 12615, 66, 23, 69, 24407, 708, 1020, 1789, 70, 2177, 2658, 12198, 1822, 67, 2942, 1407, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 713, 11160, 845, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 8070, 280, 266, 437, 6214, 491, 350, 89, 603, 5789, 16527, 316, 1010, 699, 1619, 84, 456, 297, 288, 283, 474, 63, 3097, 356, 6155, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 2648, 275, 8434, 63, 4078, 63, 1069, 14, 2017, 8, 633, 9, 267, 2648, 14, 525, 63, 1291, 360, 7810, 297, 283, 474, 63, 12949, 29, 17, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 2103, 12, 3991, 63, 344, 9, 398, 327, 12169, 3991, 267, 14208, 275, 295, 14, 1733, 8, 82, 7, 6399, 24296, 8771, 10070, 20052, 4206, 9248, 9, 267, 340, 14208, 26, 288, 12169, 63, 633, 275, 14208, 14, 923, 8, 17, 9, 288, 372, 291, 14, 633, 63, 1099, 8, 18757, 63, 633, 9, 398, 3991, 63, 1213, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 72, 17, 359, 62, 30, 3672, 30, 31204, 28798, 9248, 12, 283, 1213, 358, 267, 3991, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 10120, 83, 9, 1360, 21, 9166, 10921, 275, 1275, 15279, 2164, 32391, 297, 9248, 12, 283, 3722, 2851, 358, 267, 931, 275, 8434, 63, 4078, 63, 1122, 63, 10290, 8, 3722, 63, 633, 680, 515, 267, 3329, 275, 747, 14, 515, 14, 7973, 8, 515, 2788, 17, 1527, 17, 2938, 267, 1475, 275, 931, 14, 1294, 30746, 20, 1055, 1294, 26341, 1491, 18, 61, 267, 1475, 275, 3905, 1674, 904, 8, 908, 9, 398, 11437, 63, 3097, 275, 291, 423, 82, 502, 63, 1733, 8, 12022, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 3991, 63, 1213, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 832, 356, 3329, 12, 288, 283, 908, 356, 1475, 12, 288, 283, 908, 63, 344, 356, 1475, 12, 288, 283, 474, 63, 3097, 356, 11437, 63, 3097, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
adesignsk/wpbedrock
web/app/themes/tepelnecerpadlo/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py
1558
4945
# Copyright (c) 2011 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import re import os def XmlToString(content, encoding='utf-8', pretty=False): """ Writes the XML content to disk, touching the file only if it has changed. Visual Studio files have a lot of pre-defined structures. This function makes it easy to represent these structures as Python data structures, instead of having to create a lot of function calls. Each XML element of the content is represented as a list composed of: 1. The name of the element, a string, 2. The attributes of the element, a dictionary (optional), and 3+. The content of the element, if any. Strings are simple text nodes and lists are child elements. Example 1: <test/> becomes ['test'] Example 2: <myelement a='value1' b='value2'> <childtype>This is</childtype> <childtype>it!</childtype> </myelement> becomes ['myelement', {'a':'value1', 'b':'value2'}, ['childtype', 'This is'], ['childtype', 'it!'], ] Args: content: The structured content to be converted. encoding: The encoding to report on the first XML line. pretty: True if we want pretty printing with indents and new lines. Returns: The XML content as a string. """ # We create a huge list of all the elements of the file. xml_parts = ['<?xml version="1.0" encoding="%s"?>' % encoding] if pretty: xml_parts.append('\n') _ConstructContentList(xml_parts, content, pretty) # Convert it to a string return ''.join(xml_parts) def _ConstructContentList(xml_parts, specification, pretty, level=0): """ Appends the XML parts corresponding to the specification. Args: xml_parts: A list of XML parts to be appended to. specification: The specification of the element. See EasyXml docs. pretty: True if we want pretty printing with indents and new lines. level: Indentation level. """ # The first item in a specification is the name of the element. if pretty: indentation = ' ' * level new_line = '\n' else: indentation = '' new_line = '' name = specification[0] if not isinstance(name, str): raise Exception('The first item of an EasyXml specification should be ' 'a string. Specification was ' + str(specification)) xml_parts.append(indentation + '<' + name) # Optionally in second position is a dictionary of the attributes. rest = specification[1:] if rest and isinstance(rest[0], dict): for at, val in sorted(rest[0].iteritems()): xml_parts.append(' %s="%s"' % (at, _XmlEscape(val, attr=True))) rest = rest[1:] if rest: xml_parts.append('>') all_strings = reduce(lambda x, y: x and isinstance(y, str), rest, True) multi_line = not all_strings if multi_line and new_line: xml_parts.append(new_line) for child_spec in rest: # If it's a string, append a text node. # Otherwise recurse over that child definition if isinstance(child_spec, str): xml_parts.append(_XmlEscape(child_spec)) else: _ConstructContentList(xml_parts, child_spec, pretty, level + 1) if multi_line and indentation: xml_parts.append(indentation) xml_parts.append('</%s>%s' % (name, new_line)) else: xml_parts.append('/>%s' % new_line) def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False, win32=False): """ Writes the XML content to disk, touching the file only if it has changed. Args: content: The structured content to be written. path: Location of the file. encoding: The encoding to report on the first line of the XML file. pretty: True if we want pretty printing with indents and new lines. """ xml_string = XmlToString(content, encoding, pretty) if win32 and os.linesep != '\r\n': xml_string = xml_string.replace('\n', '\r\n') try: xml_string = xml_string.encode(encoding) except Exception: xml_string = unicode(xml_string, 'latin-1').encode(encoding) # Get the old content try: f = open(path, 'r') existing = f.read() f.close() except: existing = None # It has changed, write it if existing != xml_string: f = open(path, 'w') f.write(xml_string) f.close() _xml_escape_map = { '"': '&quot;', "'": '&apos;', '<': '&lt;', '>': '&gt;', '&': '&amp;', '\n': '&#xA;', '\r': '&#xD;', } _xml_escape_re = re.compile( "(%s)" % "|".join(map(re.escape, _xml_escape_map.keys()))) def _XmlEscape(value, attr=False): """ Escape a string for inclusion in XML.""" def replace(match): m = match.string[match.start() : match.end()] # don't replace single quotes in attrs if attr and m == "'": return m return _xml_escape_map[m] return _xml_escape_re.sub(replace, value)
gpl-3.0
[ 3, 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 295, 199, 646, 747, 421, 199, 318, 24881, 7756, 8, 1317, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 14702, 13225, 1584, 1172, 282, 13918, 402, 876, 13, 4037, 13955, 14, 221, 961, 805, 7704, 523, 652, 8837, 370, 2954, 3520, 13955, 465, 2018, 666, 13955, 12, 3140, 402, 523, 9445, 370, 1218, 282, 13918, 402, 805, 4882, 14, 819, 7048, 4692, 1819, 402, 314, 1564, 365, 11159, 465, 282, 769, 26356, 402, 26, 523, 413, 14, 710, 536, 402, 314, 1819, 12, 282, 1059, 12, 523, 499, 14, 710, 3004, 402, 314, 1819, 12, 282, 2600, 334, 4144, 395, 436, 523, 650, 26240, 710, 1564, 402, 314, 1819, 12, 340, 1263, 14, 221, 24361, 787, 3486, 1318, 3380, 436, 489, 5548, 787, 1982, 4008, 14, 819, 5679, 413, 26, 489, 665, 396, 3133, 523, 15410, 489, 788, 396, 418, 819, 5679, 499, 26, 489, 665, 1662, 2108, 282, 534, 585, 17, 7, 330, 534, 585, 18, 8423, 268, 665, 1739, 466, 30, 2765, 365, 1108, 1739, 466, 30, 268, 665, 1739, 466, 30, 390, 28718, 1739, 466, 30, 489, 3068, 1662, 2108, 30, 819, 15410, 489, 788, 1662, 2108, 297, 791, 65, 5242, 585, 17, 297, 283, 66, 5242, 585, 18, 2267, 268, 788, 1739, 466, 297, 283, 2765, 365, 995, 268, 788, 1739, 466, 297, 283, 390, 1, 995, 489, 1622, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 6702, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 4692, 1004, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 819, 1803, 26, 272, 710, 4692, 1564, 465, 282, 1059, 14, 523, 408, 523, 327, 2136, 1218, 282, 27791, 769, 402, 1006, 314, 4008, 402, 314, 570, 14, 523, 2748, 63, 4181, 275, 12329, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 5961, 83, 14863, 3524, 450, 2644, 61, 523, 340, 7268, 26, 272, 2748, 63, 4181, 14, 740, 2258, 78, 358, 523, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1564, 12, 7268, 9, 819, 327, 7905, 652, 370, 282, 1059, 523, 372, 6522, 904, 8, 1652, 63, 4181, 9, 421, 199, 318, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 8929, 12, 7268, 12, 2166, 29, 16, 304, 523, 408, 4693, 3198, 314, 4692, 4184, 5226, 370, 314, 8929, 14, 819, 3033, 26, 272, 2748, 63, 4181, 26, 437, 769, 402, 4692, 4184, 370, 506, 11544, 370, 14, 272, 8929, 26, 221, 710, 8929, 402, 314, 1819, 14, 221, 1666, 18951, 8672, 9149, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 272, 2166, 26, 1010, 1326, 425, 2166, 14, 523, 408, 523, 327, 710, 1642, 1242, 315, 282, 8929, 365, 314, 536, 402, 314, 1819, 14, 523, 340, 7268, 26, 272, 14311, 275, 283, 221, 283, 627, 2166, 272, 892, 63, 604, 275, 1557, 78, 7, 523, 587, 26, 272, 14311, 275, 2125, 272, 892, 63, 604, 275, 2125, 523, 536, 275, 8929, 59, 16, 61, 523, 340, 440, 1228, 8, 354, 12, 620, 304, 272, 746, 2186, 360, 1918, 1642, 1242, 402, 376, 18951, 8672, 8929, 1077, 506, 283, 490, 283, 65, 1059, 14, 221, 5367, 3477, 1990, 283, 435, 620, 8, 22271, 430, 523, 2748, 63, 4181, 14, 740, 8, 25152, 435, 24958, 435, 536, 9, 819, 327, 22383, 315, 3499, 3421, 365, 282, 2600, 402, 314, 3004, 14, 523, 4618, 275, 8929, 59, 17, 2938, 523, 340, 4618, 436, 1228, 8, 3911, 59, 16, 467, 1211, 304, 272, 367, 737, 12, 1139, 315, 3355, 8, 3911, 59, 16, 1055, 4611, 5109, 489, 2748, 63, 4181, 14, 740, 360, 450, 83, 5961, 83, 4507, 450, 334, 292, 12, 485, 8672, 10260, 8, 637, 12, 1921, 29, 549, 1724, 272, 4618, 275, 4618, 59, 17, 2938, 523, 340, 4618, 26, 272, 2748, 63, 4181, 14, 740, 28781, 272, 1006, 63, 5465, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 436, 1228, 8, 89, 12, 620, 395, 4618, 12, 715, 9, 272, 3510, 63, 604, 275, 440, 1006, 63, 5465, 272, 340, 3510, 63, 604, 436, 892, 63, 604, 26, 489, 2748, 63, 4181, 14, 740, 8, 1222, 63, 604, 9, 272, 367, 1982, 63, 1650, 315, 4618, 26, 489, 327, 982, 652, 1159, 282, 1059, 12, 5666, 282, 1318, 1031, 14, 489, 327, 6630, 18011, 1806, 626, 1982, 5492, 489, 340, 1228, 8, 1739, 63, 1650, 12, 620, 304, 2126, 2748, 63, 4181, 14, 740, 1547, 8672, 10260, 8, 1739, 63, 1650, 430, 489, 587, 26, 267, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1982, 63, 1650, 12, 7268, 12, 2166, 435, 413, 9, 272, 340, 3510, 63, 604, 436, 14311, 26, 489, 2748, 63, 4181, 14, 740, 8, 25152, 9, 272, 2748, 63, 4181, 14, 740, 26576, 83, 6598, 83, 7, 450, 334, 354, 12, 892, 63, 604, 430, 523, 587, 26, 272, 2748, 63, 4181, 14, 740, 2336, 6598, 83, 7, 450, 892, 63, 604, 9, 421, 199, 318, 6990, 8672, 3917, 6970, 8, 1317, 12, 931, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 12, 1993, 4747, 708, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 5313, 14, 272, 931, 26, 12625, 402, 314, 570, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 1004, 402, 314, 4692, 570, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 523, 408, 523, 2748, 63, 875, 275, 24881, 7756, 8, 1317, 12, 2644, 12, 7268, 9, 523, 340, 4747, 708, 436, 747, 14, 19254, 1137, 1557, 82, 60, 78 ]
[ 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 295, 199, 646, 747, 421, 199, 318, 24881, 7756, 8, 1317, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 14702, 13225, 1584, 1172, 282, 13918, 402, 876, 13, 4037, 13955, 14, 221, 961, 805, 7704, 523, 652, 8837, 370, 2954, 3520, 13955, 465, 2018, 666, 13955, 12, 3140, 402, 523, 9445, 370, 1218, 282, 13918, 402, 805, 4882, 14, 819, 7048, 4692, 1819, 402, 314, 1564, 365, 11159, 465, 282, 769, 26356, 402, 26, 523, 413, 14, 710, 536, 402, 314, 1819, 12, 282, 1059, 12, 523, 499, 14, 710, 3004, 402, 314, 1819, 12, 282, 2600, 334, 4144, 395, 436, 523, 650, 26240, 710, 1564, 402, 314, 1819, 12, 340, 1263, 14, 221, 24361, 787, 3486, 1318, 3380, 436, 489, 5548, 787, 1982, 4008, 14, 819, 5679, 413, 26, 489, 665, 396, 3133, 523, 15410, 489, 788, 396, 418, 819, 5679, 499, 26, 489, 665, 1662, 2108, 282, 534, 585, 17, 7, 330, 534, 585, 18, 8423, 268, 665, 1739, 466, 30, 2765, 365, 1108, 1739, 466, 30, 268, 665, 1739, 466, 30, 390, 28718, 1739, 466, 30, 489, 3068, 1662, 2108, 30, 819, 15410, 489, 788, 1662, 2108, 297, 791, 65, 5242, 585, 17, 297, 283, 66, 5242, 585, 18, 2267, 268, 788, 1739, 466, 297, 283, 2765, 365, 995, 268, 788, 1739, 466, 297, 283, 390, 1, 995, 489, 1622, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 6702, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 4692, 1004, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 819, 1803, 26, 272, 710, 4692, 1564, 465, 282, 1059, 14, 523, 408, 523, 327, 2136, 1218, 282, 27791, 769, 402, 1006, 314, 4008, 402, 314, 570, 14, 523, 2748, 63, 4181, 275, 12329, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 5961, 83, 14863, 3524, 450, 2644, 61, 523, 340, 7268, 26, 272, 2748, 63, 4181, 14, 740, 2258, 78, 358, 523, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1564, 12, 7268, 9, 819, 327, 7905, 652, 370, 282, 1059, 523, 372, 6522, 904, 8, 1652, 63, 4181, 9, 421, 199, 318, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 8929, 12, 7268, 12, 2166, 29, 16, 304, 523, 408, 4693, 3198, 314, 4692, 4184, 5226, 370, 314, 8929, 14, 819, 3033, 26, 272, 2748, 63, 4181, 26, 437, 769, 402, 4692, 4184, 370, 506, 11544, 370, 14, 272, 8929, 26, 221, 710, 8929, 402, 314, 1819, 14, 221, 1666, 18951, 8672, 9149, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 272, 2166, 26, 1010, 1326, 425, 2166, 14, 523, 408, 523, 327, 710, 1642, 1242, 315, 282, 8929, 365, 314, 536, 402, 314, 1819, 14, 523, 340, 7268, 26, 272, 14311, 275, 283, 221, 283, 627, 2166, 272, 892, 63, 604, 275, 1557, 78, 7, 523, 587, 26, 272, 14311, 275, 2125, 272, 892, 63, 604, 275, 2125, 523, 536, 275, 8929, 59, 16, 61, 523, 340, 440, 1228, 8, 354, 12, 620, 304, 272, 746, 2186, 360, 1918, 1642, 1242, 402, 376, 18951, 8672, 8929, 1077, 506, 283, 490, 283, 65, 1059, 14, 221, 5367, 3477, 1990, 283, 435, 620, 8, 22271, 430, 523, 2748, 63, 4181, 14, 740, 8, 25152, 435, 24958, 435, 536, 9, 819, 327, 22383, 315, 3499, 3421, 365, 282, 2600, 402, 314, 3004, 14, 523, 4618, 275, 8929, 59, 17, 2938, 523, 340, 4618, 436, 1228, 8, 3911, 59, 16, 467, 1211, 304, 272, 367, 737, 12, 1139, 315, 3355, 8, 3911, 59, 16, 1055, 4611, 5109, 489, 2748, 63, 4181, 14, 740, 360, 450, 83, 5961, 83, 4507, 450, 334, 292, 12, 485, 8672, 10260, 8, 637, 12, 1921, 29, 549, 1724, 272, 4618, 275, 4618, 59, 17, 2938, 523, 340, 4618, 26, 272, 2748, 63, 4181, 14, 740, 28781, 272, 1006, 63, 5465, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 436, 1228, 8, 89, 12, 620, 395, 4618, 12, 715, 9, 272, 3510, 63, 604, 275, 440, 1006, 63, 5465, 272, 340, 3510, 63, 604, 436, 892, 63, 604, 26, 489, 2748, 63, 4181, 14, 740, 8, 1222, 63, 604, 9, 272, 367, 1982, 63, 1650, 315, 4618, 26, 489, 327, 982, 652, 1159, 282, 1059, 12, 5666, 282, 1318, 1031, 14, 489, 327, 6630, 18011, 1806, 626, 1982, 5492, 489, 340, 1228, 8, 1739, 63, 1650, 12, 620, 304, 2126, 2748, 63, 4181, 14, 740, 1547, 8672, 10260, 8, 1739, 63, 1650, 430, 489, 587, 26, 267, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1982, 63, 1650, 12, 7268, 12, 2166, 435, 413, 9, 272, 340, 3510, 63, 604, 436, 14311, 26, 489, 2748, 63, 4181, 14, 740, 8, 25152, 9, 272, 2748, 63, 4181, 14, 740, 26576, 83, 6598, 83, 7, 450, 334, 354, 12, 892, 63, 604, 430, 523, 587, 26, 272, 2748, 63, 4181, 14, 740, 2336, 6598, 83, 7, 450, 892, 63, 604, 9, 421, 199, 318, 6990, 8672, 3917, 6970, 8, 1317, 12, 931, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 12, 1993, 4747, 708, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 5313, 14, 272, 931, 26, 12625, 402, 314, 570, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 1004, 402, 314, 4692, 570, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 523, 408, 523, 2748, 63, 875, 275, 24881, 7756, 8, 1317, 12, 2644, 12, 7268, 9, 523, 340, 4747, 708, 436, 747, 14, 19254, 1137, 1557, 82, 60, 78, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MounirMesselmeni/django
django/db/backends/oracle/utils.py
539
1252
import datetime from django.utils.encoding import force_bytes, force_text from .base import Database # Check whether cx_Oracle was compiled with the WITH_UNICODE option if cx_Oracle is pre-5.1. This will # also be True for cx_Oracle 5.1 and in Python 3.0. See #19606 if int(Database.version.split('.', 1)[0]) >= 5 and \ (int(Database.version.split('.', 2)[1]) >= 1 or not hasattr(Database, 'UNICODE')): convert_unicode = force_text else: convert_unicode = force_bytes class InsertIdVar(object): """ A late-binding cursor variable that can be passed to Cursor.execute as a parameter, in order to receive the id of the row created by an insert statement. """ def bind_parameter(self, cursor): param = cursor.cursor.var(Database.NUMBER) cursor._insert_id_var = param return param class Oracle_datetime(datetime.datetime): """ A datetime object, with an additional class attribute to tell cx_Oracle to save the microseconds too. """ input_size = Database.TIMESTAMP @classmethod def from_datetime(cls, dt): return Oracle_datetime( dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond, )
bsd-3-clause
[ 646, 2197, 199, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 505, 199, 199, 504, 1275, 1095, 492, 8692, 199, 199, 3, 2670, 3775, 17280, 63, 21202, 1990, 10311, 543, 314, 1663, 63, 12819, 945, 340, 17280, 63, 21202, 365, 876, 13, 21, 14, 17, 14, 961, 911, 199, 3, 2597, 506, 715, 367, 17280, 63, 21202, 959, 14, 17, 436, 315, 2018, 650, 14, 16, 14, 1666, 327, 10800, 1690, 199, 692, 1109, 8, 7243, 14, 1023, 14, 1294, 14078, 413, 2788, 16, 566, 2356, 959, 436, 971, 267, 334, 442, 8, 7243, 14, 1023, 14, 1294, 14078, 499, 2788, 17, 566, 2356, 413, 503, 268, 440, 2688, 8, 7243, 12, 283, 12819, 8109, 272, 3957, 63, 2975, 275, 3542, 63, 505, 199, 2836, 26, 272, 3957, 63, 2975, 275, 3542, 63, 2394, 421, 199, 533, 15496, 1304, 5894, 8, 785, 304, 272, 408, 272, 437, 2465, 13, 9140, 3920, 1750, 626, 883, 506, 3032, 370, 20385, 14, 2526, 272, 465, 282, 2725, 12, 315, 1865, 370, 9128, 314, 1305, 402, 314, 1962, 2737, 701, 376, 272, 5518, 5164, 14, 272, 408, 339, 347, 5398, 63, 5329, 8, 277, 12, 3920, 304, 267, 1215, 275, 3920, 14, 3937, 14, 1391, 8, 7243, 14, 9190, 9, 267, 3920, 423, 3176, 63, 344, 63, 1391, 275, 1215, 267, 372, 1215, 421, 199, 533, 15309, 63, 2083, 8, 2083, 14, 2083, 304, 272, 408, 272, 437, 2197, 909, 12, 543, 376, 4722, 1021, 2225, 272, 370, 11480, 17280, 63, 21202, 370, 3354, 314, 21574, 4634, 14, 272, 408, 272, 1324, 63, 890, 275, 8692, 14, 20277, 339, 768, 3744, 272, 347, 687, 63, 2083, 8, 1886, 12, 4487, 304, 267, 372, 15309, 63, 2083, 8, 288, 4487, 14, 3403, 12, 4487, 14, 4482, 12, 4487, 14, 2977, 12, 288, 4487, 14, 5180, 12, 4487, 14, 10698, 12, 4487, 14, 4375, 12, 4487, 14, 16627, 12, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 199, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 505, 199, 199, 504, 1275, 1095, 492, 8692, 199, 199, 3, 2670, 3775, 17280, 63, 21202, 1990, 10311, 543, 314, 1663, 63, 12819, 945, 340, 17280, 63, 21202, 365, 876, 13, 21, 14, 17, 14, 961, 911, 199, 3, 2597, 506, 715, 367, 17280, 63, 21202, 959, 14, 17, 436, 315, 2018, 650, 14, 16, 14, 1666, 327, 10800, 1690, 199, 692, 1109, 8, 7243, 14, 1023, 14, 1294, 14078, 413, 2788, 16, 566, 2356, 959, 436, 971, 267, 334, 442, 8, 7243, 14, 1023, 14, 1294, 14078, 499, 2788, 17, 566, 2356, 413, 503, 268, 440, 2688, 8, 7243, 12, 283, 12819, 8109, 272, 3957, 63, 2975, 275, 3542, 63, 505, 199, 2836, 26, 272, 3957, 63, 2975, 275, 3542, 63, 2394, 421, 199, 533, 15496, 1304, 5894, 8, 785, 304, 272, 408, 272, 437, 2465, 13, 9140, 3920, 1750, 626, 883, 506, 3032, 370, 20385, 14, 2526, 272, 465, 282, 2725, 12, 315, 1865, 370, 9128, 314, 1305, 402, 314, 1962, 2737, 701, 376, 272, 5518, 5164, 14, 272, 408, 339, 347, 5398, 63, 5329, 8, 277, 12, 3920, 304, 267, 1215, 275, 3920, 14, 3937, 14, 1391, 8, 7243, 14, 9190, 9, 267, 3920, 423, 3176, 63, 344, 63, 1391, 275, 1215, 267, 372, 1215, 421, 199, 533, 15309, 63, 2083, 8, 2083, 14, 2083, 304, 272, 408, 272, 437, 2197, 909, 12, 543, 376, 4722, 1021, 2225, 272, 370, 11480, 17280, 63, 21202, 370, 3354, 314, 21574, 4634, 14, 272, 408, 272, 1324, 63, 890, 275, 8692, 14, 20277, 339, 768, 3744, 272, 347, 687, 63, 2083, 8, 1886, 12, 4487, 304, 267, 372, 15309, 63, 2083, 8, 288, 4487, 14, 3403, 12, 4487, 14, 4482, 12, 4487, 14, 2977, 12, 288, 4487, 14, 5180, 12, 4487, 14, 10698, 12, 4487, 14, 4375, 12, 4487, 14, 16627, 12, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
Obus/scikit-learn
sklearn/setup.py
225
2856
import os from os.path import join import warnings def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info, BlasNotFoundError import numpy libraries = [] if os.name == 'posix': libraries.append('m') config = Configuration('sklearn', parent_package, top_path) config.add_subpackage('__check_build') config.add_subpackage('svm') config.add_subpackage('datasets') config.add_subpackage('datasets/tests') config.add_subpackage('feature_extraction') config.add_subpackage('feature_extraction/tests') config.add_subpackage('cluster') config.add_subpackage('cluster/tests') config.add_subpackage('covariance') config.add_subpackage('covariance/tests') config.add_subpackage('cross_decomposition') config.add_subpackage('decomposition') config.add_subpackage('decomposition/tests') config.add_subpackage("ensemble") config.add_subpackage("ensemble/tests") config.add_subpackage('feature_selection') config.add_subpackage('feature_selection/tests') config.add_subpackage('utils') config.add_subpackage('utils/tests') config.add_subpackage('externals') config.add_subpackage('mixture') config.add_subpackage('mixture/tests') config.add_subpackage('gaussian_process') config.add_subpackage('gaussian_process/tests') config.add_subpackage('neighbors') config.add_subpackage('neural_network') config.add_subpackage('preprocessing') config.add_subpackage('manifold') config.add_subpackage('metrics') config.add_subpackage('semi_supervised') config.add_subpackage("tree") config.add_subpackage("tree/tests") config.add_subpackage('metrics/tests') config.add_subpackage('metrics/cluster') config.add_subpackage('metrics/cluster/tests') # add cython extension module for isotonic regression config.add_extension( '_isotonic', sources=['_isotonic.c'], include_dirs=[numpy.get_include()], libraries=libraries, ) # some libs needs cblas, fortran-compiled BLAS will not be sufficient blas_info = get_info('blas_opt', 0) if (not blas_info) or ( ('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', [])): config.add_library('cblas', sources=[join('src', 'cblas', '*.c')]) warnings.warn(BlasNotFoundError.__doc__) # the following packages depend on cblas, so they have to be build # after the above. config.add_subpackage('linear_model') config.add_subpackage('utils') # add the test directory config.add_subpackage('tests') return config if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration(top_path='').todict())
bsd-3-clause
[ 646, 747, 199, 504, 747, 14, 515, 492, 4263, 199, 646, 3598, 421, 199, 318, 2897, 8, 1708, 63, 2491, 4581, 2746, 63, 515, 29, 403, 304, 272, 687, 2680, 14, 13350, 14, 9923, 63, 1974, 492, 11595, 272, 687, 2680, 14, 13350, 14, 2253, 63, 815, 492, 664, 63, 815, 12, 699, 12536, 10870, 272, 492, 2680, 339, 8363, 275, 942, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 8363, 14, 740, 360, 77, 358, 339, 1101, 275, 11595, 360, 27993, 297, 1676, 63, 2491, 12, 2746, 63, 515, 9, 339, 1101, 14, 525, 63, 954, 2491, 10714, 1074, 63, 1506, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 16820, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 12281, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 12281, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 24020, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 24020, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4201, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4201, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 15024, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 15024, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 7925, 63, 31384, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 31384, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 31384, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 480, 15628, 531, 272, 1101, 14, 525, 63, 954, 2491, 480, 15628, 15, 2219, 531, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 5592, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 5592, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1208, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1208, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 24688, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 2664, 4167, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 2664, 4167, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 22911, 63, 1412, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 22911, 63, 1412, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 11113, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 685, 4889, 63, 1200, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 21402, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1237, 32294, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 19290, 63, 4792, 17311, 358, 272, 1101, 14, 525, 63, 954, 2491, 480, 2350, 531, 272, 1101, 14, 525, 63, 954, 2491, 480, 2350, 15, 2219, 531, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 15, 4201, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 15, 4201, 15, 2219, 358, 339, 327, 1050, 29348, 3329, 859, 367, 365, 18692, 10864, 272, 1101, 14, 525, 63, 3435, 8, 267, 2513, 374, 18692, 297, 267, 5274, 2968, 63, 374, 18692, 14, 67, 995, 267, 2387, 63, 3220, 1524, 4714, 14, 362, 63, 2613, 15618, 267, 8363, 29, 10159, 12, 272, 776, 339, 327, 2005, 20314, 4839, 286, 21044, 12, 289, 14522, 13, 8427, 15979, 1179, 911, 440, 506, 19258, 272, 6826, 305, 63, 815, 275, 664, 63, 815, 360, 21044, 63, 2992, 297, 378, 9, 272, 340, 334, 1397, 6826, 305, 63, 815, 9, 503, 334, 288, 661, 2826, 63, 619, 44, 1179, 63, 4531, 297, 413, 9, 315, 6826, 305, 63, 815, 14, 362, 360, 4640, 63, 16358, 297, 3073, 304, 267, 1101, 14, 525, 63, 4342, 360, 2894, 12536, 297, 2574, 5274, 1524, 904, 360, 2164, 297, 283, 2894, 12536, 297, 11937, 67, 2023, 267, 3598, 14, 4050, 8, 34, 12536, 10870, 855, 1301, 3368, 339, 327, 314, 2569, 6117, 11687, 641, 286, 21044, 12, 880, 2985, 1172, 370, 506, 1900, 272, 327, 2410, 314, 3432, 14, 272, 1101, 14, 525, 63, 954, 2491, 360, 6676, 63, 1238, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1208, 358, 339, 327, 1050, 314, 511, 2082, 272, 1101, 14, 525, 63, 954, 2491, 360, 2219, 358, 339, 372, 1101, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 2680, 14, 13350, 14, 1018, 492, 3272, 272, 3272, 3682, 4758, 8, 2119, 63, 515, 534, 1959, 475, 807, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 504, 747, 14, 515, 492, 4263, 199, 646, 3598, 421, 199, 318, 2897, 8, 1708, 63, 2491, 4581, 2746, 63, 515, 29, 403, 304, 272, 687, 2680, 14, 13350, 14, 9923, 63, 1974, 492, 11595, 272, 687, 2680, 14, 13350, 14, 2253, 63, 815, 492, 664, 63, 815, 12, 699, 12536, 10870, 272, 492, 2680, 339, 8363, 275, 942, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 8363, 14, 740, 360, 77, 358, 339, 1101, 275, 11595, 360, 27993, 297, 1676, 63, 2491, 12, 2746, 63, 515, 9, 339, 1101, 14, 525, 63, 954, 2491, 10714, 1074, 63, 1506, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 16820, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 12281, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 12281, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 24020, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 24020, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4201, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4201, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 15024, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 15024, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 7925, 63, 31384, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 31384, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 31384, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 480, 15628, 531, 272, 1101, 14, 525, 63, 954, 2491, 480, 15628, 15, 2219, 531, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 5592, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 4445, 63, 5592, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1208, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1208, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 24688, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 2664, 4167, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 2664, 4167, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 22911, 63, 1412, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 22911, 63, 1412, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 11113, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 685, 4889, 63, 1200, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 21402, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1237, 32294, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 19290, 63, 4792, 17311, 358, 272, 1101, 14, 525, 63, 954, 2491, 480, 2350, 531, 272, 1101, 14, 525, 63, 954, 2491, 480, 2350, 15, 2219, 531, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 15, 2219, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 15, 4201, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 6759, 15, 4201, 15, 2219, 358, 339, 327, 1050, 29348, 3329, 859, 367, 365, 18692, 10864, 272, 1101, 14, 525, 63, 3435, 8, 267, 2513, 374, 18692, 297, 267, 5274, 2968, 63, 374, 18692, 14, 67, 995, 267, 2387, 63, 3220, 1524, 4714, 14, 362, 63, 2613, 15618, 267, 8363, 29, 10159, 12, 272, 776, 339, 327, 2005, 20314, 4839, 286, 21044, 12, 289, 14522, 13, 8427, 15979, 1179, 911, 440, 506, 19258, 272, 6826, 305, 63, 815, 275, 664, 63, 815, 360, 21044, 63, 2992, 297, 378, 9, 272, 340, 334, 1397, 6826, 305, 63, 815, 9, 503, 334, 288, 661, 2826, 63, 619, 44, 1179, 63, 4531, 297, 413, 9, 315, 6826, 305, 63, 815, 14, 362, 360, 4640, 63, 16358, 297, 3073, 304, 267, 1101, 14, 525, 63, 4342, 360, 2894, 12536, 297, 2574, 5274, 1524, 904, 360, 2164, 297, 283, 2894, 12536, 297, 11937, 67, 2023, 267, 3598, 14, 4050, 8, 34, 12536, 10870, 855, 1301, 3368, 339, 327, 314, 2569, 6117, 11687, 641, 286, 21044, 12, 880, 2985, 1172, 370, 506, 1900, 272, 327, 2410, 314, 3432, 14, 272, 1101, 14, 525, 63, 954, 2491, 360, 6676, 63, 1238, 358, 272, 1101, 14, 525, 63, 954, 2491, 360, 1208, 358, 339, 327, 1050, 314, 511, 2082, 272, 1101, 14, 525, 63, 954, 2491, 360, 2219, 358, 339, 372, 1101, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 2680, 14, 13350, 14, 1018, 492, 3272, 272, 3272, 3682, 4758, 8, 2119, 63, 515, 534, 1959, 475, 807, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Jazz-823/kernel_lge_hammerhead
tools/perf/scripts/python/syscall-counts-by-pid.py
11180
1927
# system call counts, by pid # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts-by-pid.py [comm]\n"; for_comm = None for_pid = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: try: for_pid = int(sys.argv[1]) except: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return try: syscalls[common_comm][common_pid][id] += 1 except TypeError: syscalls[common_comm][common_pid][id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events by comm/pid:\n\n", print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: print "\n%s [%d]\n" % (comm, pid), id_keys = syscalls[comm][pid].keys() for id, val in sorted(syscalls[comm][pid].iteritems(), \ key = lambda(k, v): (v, k), reverse = True): print " %-38s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
mrquim/repository.mrquim
repo/plugin.program.indigo/libs/requests/packages/urllib3/util/retry.py
86
14123
from __future__ import absolute_import import time import logging from collections import namedtuple from itertools import takewhile import email import re from ..exceptions import ( ConnectTimeoutError, MaxRetryError, ProtocolError, ReadTimeoutError, ResponseError, InvalidHeader, ) from ..packages import six log = logging.getLogger(__name__) # Data structure for representing the metadata of requests that result in a retry. RequestHistory = namedtuple('RequestHistory', ["method", "url", "error", "status", "redirect_location"]) class Retry(object): """ Retry configuration. Each retry attempt will create a new Retry object with updated values, so they can be safely reused. Retries can be defined as a default for a pool:: retries = Retry(connect=5, read=2, redirect=5) http = PoolManager(retries=retries) response = http.request('GET', 'http://example.com/') Or per-request (which overrides the default for the pool):: response = http.request('GET', 'http://example.com/', retries=Retry(10)) Retries can be disabled by passing ``False``:: response = http.request('GET', 'http://example.com/', retries=False) Errors will be wrapped in :class:`~urllib3.exceptions.MaxRetryError` unless retries are disabled, in which case the causing exception will be raised. :param int total: Total number of retries to allow. Takes precedence over other counts. Set to ``None`` to remove this constraint and fall back on other counts. It's a good idea to set this to some sensibly-high value to account for unexpected edge cases and avoid infinite retry loops. Set to ``0`` to fail on the first retry. Set to ``False`` to disable and imply ``raise_on_redirect=False``. :param int connect: How many connection-related errors to retry on. These are errors raised before the request is sent to the remote server, which we assume has not triggered the server to process the request. Set to ``0`` to fail on the first retry of this type. :param int read: How many times to retry on read errors. These errors are raised after the request was sent to the server, so the request may have side-effects. Set to ``0`` to fail on the first retry of this type. :param int redirect: How many redirects to perform. Limit this to avoid infinite redirect loops. A redirect is a HTTP response with a status code 301, 302, 303, 307 or 308. Set to ``0`` to fail on the first retry of this type. Set to ``False`` to disable and imply ``raise_on_redirect=False``. :param iterable method_whitelist: Set of uppercased HTTP method verbs that we should retry on. By default, we only retry on methods which are considered to be idempotent (multiple requests with the same parameters end with the same state). See :attr:`Retry.DEFAULT_METHOD_WHITELIST`. Set to a ``False`` value to retry on any verb. :param iterable status_forcelist: A set of integer HTTP status codes that we should force a retry on. A retry is initiated if the request method is in ``method_whitelist`` and the response status code is in ``status_forcelist``. By default, this is disabled with ``None``. :param float backoff_factor: A backoff factor to apply between attempts after the second try (most errors are resolved immediately by a second try without a delay). urllib3 will sleep for:: {backoff factor} * (2 ^ ({number of total retries} - 1)) seconds. If the backoff_factor is 0.1, then :func:`.sleep` will sleep for [0.0s, 0.2s, 0.4s, ...] between retries. It will never be longer than :attr:`Retry.BACKOFF_MAX`. By default, backoff is disabled (set to 0). :param bool raise_on_redirect: Whether, if the number of redirects is exhausted, to raise a MaxRetryError, or to return a response with a response code in the 3xx range. :param bool raise_on_status: Similar meaning to ``raise_on_redirect``: whether we should raise an exception, or return a response, if status falls in ``status_forcelist`` range and retries have been exhausted. :param tuple history: The history of the request encountered during each call to :meth:`~Retry.increment`. The list is in the order the requests occurred. Each list item is of class :class:`RequestHistory`. :param bool respect_retry_after_header: Whether to respect Retry-After header on status codes defined as :attr:`Retry.RETRY_AFTER_STATUS_CODES` or not. """ DEFAULT_METHOD_WHITELIST = frozenset([ 'HEAD', 'GET', 'PUT', 'DELETE', 'OPTIONS', 'TRACE']) RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503]) #: Maximum backoff time. BACKOFF_MAX = 120 def __init__(self, total=10, connect=None, read=None, redirect=None, method_whitelist=DEFAULT_METHOD_WHITELIST, status_forcelist=None, backoff_factor=0, raise_on_redirect=True, raise_on_status=True, history=None, respect_retry_after_header=True): self.total = total self.connect = connect self.read = read if redirect is False or total is False: redirect = 0 raise_on_redirect = False self.redirect = redirect self.status_forcelist = status_forcelist or set() self.method_whitelist = method_whitelist self.backoff_factor = backoff_factor self.raise_on_redirect = raise_on_redirect self.raise_on_status = raise_on_status self.history = history or tuple() self.respect_retry_after_header = respect_retry_after_header def new(self, **kw): params = dict( total=self.total, connect=self.connect, read=self.read, redirect=self.redirect, method_whitelist=self.method_whitelist, status_forcelist=self.status_forcelist, backoff_factor=self.backoff_factor, raise_on_redirect=self.raise_on_redirect, raise_on_status=self.raise_on_status, history=self.history, ) params.update(kw) return type(self)(**params) @classmethod def from_int(cls, retries, redirect=True, default=None): """ Backwards-compatibility for the old retries format.""" if retries is None: retries = default if default is not None else cls.DEFAULT if isinstance(retries, Retry): return retries redirect = bool(redirect) and None new_retries = cls(retries, redirect=redirect) log.debug("Converted retries value: %r -> %r", retries, new_retries) return new_retries def get_backoff_time(self): """ Formula for computing the current backoff :rtype: float """ # We want to consider only the last consecutive errors sequence (Ignore redirects). consecutive_errors_len = len(list(takewhile(lambda x: x.redirect_location is None, reversed(self.history)))) if consecutive_errors_len <= 1: return 0 backoff_value = self.backoff_factor * (2 ** (consecutive_errors_len - 1)) return min(self.BACKOFF_MAX, backoff_value) def parse_retry_after(self, retry_after): # Whitespace: https://tools.ietf.org/html/rfc7230#section-3.2.4 if re.match(r"^\s*[0-9]+\s*$", retry_after): seconds = int(retry_after) else: retry_date_tuple = email.utils.parsedate(retry_after) if retry_date_tuple is None: raise InvalidHeader("Invalid Retry-After header: %s" % retry_after) retry_date = time.mktime(retry_date_tuple) seconds = retry_date - time.time() if seconds < 0: seconds = 0 return seconds def get_retry_after(self, response): """ Get the value of Retry-After in seconds. """ retry_after = response.getheader("Retry-After") if retry_after is None: return None return self.parse_retry_after(retry_after) def sleep_for_retry(self, response=None): retry_after = self.get_retry_after(response) if retry_after: time.sleep(retry_after) return True return False def _sleep_backoff(self): backoff = self.get_backoff_time() if backoff <= 0: return time.sleep(backoff) def sleep(self, response=None): """ Sleep between retry attempts. This method will respect a server's ``Retry-After`` response header and sleep the duration of the time requested. If that is not present, it will use an exponential backoff. By default, the backoff factor is 0 and this method will return immediately. """ if response: slept = self.sleep_for_retry(response) if slept: return self._sleep_backoff() def _is_connection_error(self, err): """ Errors when we're fairly sure that the server did not receive the request, so it should be safe to retry. """ return isinstance(err, ConnectTimeoutError) def _is_read_error(self, err): """ Errors that occur after the request has been started, so we should assume that the server began processing it. """ return isinstance(err, (ReadTimeoutError, ProtocolError)) def _is_method_retryable(self, method): """ Checks if a given HTTP method should be retried upon, depending if it is included on the method whitelist. """ if self.method_whitelist and method.upper() not in self.method_whitelist: return False return True def is_retry(self, method, status_code, has_retry_after=False): """ Is this method/status code retryable? (Based on whitelists and control variables such as the number of total retries to allow, whether to respect the Retry-After header, whether this header is present, and whether the returned status code is on the list of status codes to be retried upon on the presence of the aforementioned header) """ if not self._is_method_retryable(method): return False if self.status_forcelist and status_code in self.status_forcelist: return True return (self.total and self.respect_retry_after_header and has_retry_after and (status_code in self.RETRY_AFTER_STATUS_CODES)) def is_exhausted(self): """ Are we out of retries? """ retry_counts = (self.total, self.connect, self.read, self.redirect) retry_counts = list(filter(None, retry_counts)) if not retry_counts: return False return min(retry_counts) < 0 def increment(self, method=None, url=None, response=None, error=None, _pool=None, _stacktrace=None): """ Return a new Retry object with incremented retry counters. :param response: A response object, or None, if the server did not return a response. :type response: :class:`~urllib3.response.HTTPResponse` :param Exception error: An error encountered during the request, or None if the response was received successfully. :return: A new ``Retry`` object. """ if self.total is False and error: # Disabled, indicate to re-raise the error. raise six.reraise(type(error), error, _stacktrace) total = self.total if total is not None: total -= 1 connect = self.connect read = self.read redirect = self.redirect cause = 'unknown' status = None redirect_location = None if error and self._is_connection_error(error): # Connect retry? if connect is False: raise six.reraise(type(error), error, _stacktrace) elif connect is not None: connect -= 1 elif error and self._is_read_error(error): # Read retry? if read is False or not self._is_method_retryable(method): raise six.reraise(type(error), error, _stacktrace) elif read is not None: read -= 1 elif response and response.get_redirect_location(): # Redirect retry? if redirect is not None: redirect -= 1 cause = 'too many redirects' redirect_location = response.get_redirect_location() status = response.status else: # Incrementing because of a server error like a 500 in # status_forcelist and a the given method is in the whitelist cause = ResponseError.GENERIC_ERROR if response and response.status: cause = ResponseError.SPECIFIC_ERROR.format( status_code=response.status) status = response.status history = self.history + (RequestHistory(method, url, error, status, redirect_location),) new_retry = self.new( total=total, connect=connect, read=read, redirect=redirect, history=history) if new_retry.is_exhausted(): raise MaxRetryError(_pool, url, error or ResponseError(cause)) log.debug("Incremented Retry for (url='%s'): %r", url, new_retry) return new_retry def __repr__(self): return ('{cls.__name__}(total={self.total}, connect={self.connect}, ' 'read={self.read}, redirect={self.redirect})').format( cls=type(self), self=self) # For backwards compatibility (equivalent to pre-v1.9): Retry.DEFAULT = Retry(3)
gpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 900, 199, 646, 2050, 199, 504, 5055, 492, 12863, 199, 504, 7975, 492, 5452, 6710, 199, 646, 3031, 199, 646, 295, 199, 199, 504, 2508, 3924, 492, 334, 272, 15175, 19382, 12, 272, 8228, 12989, 547, 12, 272, 30797, 12, 272, 5574, 19382, 12, 272, 7232, 547, 12, 272, 6378, 2567, 12, 199, 9, 199, 504, 2508, 5154, 492, 3816, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3, 3918, 5523, 367, 6144, 314, 3341, 402, 4145, 626, 754, 315, 282, 7269, 14, 199, 2017, 12114, 275, 12863, 360, 2017, 12114, 297, 2097, 765, 401, 298, 633, 401, 298, 705, 401, 6901, 298, 1205, 401, 298, 4876, 63, 1985, 3135, 421, 199, 533, 20506, 8, 785, 304, 272, 408, 20506, 2897, 14, 339, 7048, 7269, 7427, 911, 1218, 282, 892, 20506, 909, 543, 4588, 1338, 12, 880, 272, 2985, 883, 506, 19353, 24826, 14, 339, 8747, 1996, 883, 506, 3247, 465, 282, 849, 367, 282, 4203, 447, 398, 10086, 275, 20506, 8, 2242, 29, 21, 12, 1586, 29, 18, 12, 4660, 29, 21, 9, 267, 1455, 275, 15553, 2988, 8, 10937, 29, 10937, 9, 267, 1177, 275, 1455, 14, 1069, 360, 2970, 297, 283, 1014, 921, 2694, 14, 957, 6217, 339, 4236, 1126, 13, 1069, 334, 6777, 10580, 314, 849, 367, 314, 4203, 304, 26, 398, 1177, 275, 1455, 14, 1069, 360, 2970, 297, 283, 1014, 921, 2694, 14, 957, 3678, 10086, 29, 12989, 8, 709, 430, 339, 8747, 1996, 883, 506, 6980, 701, 9476, 1124, 797, 1040, 447, 398, 1177, 275, 1455, 14, 1069, 360, 2970, 297, 283, 1014, 921, 2694, 14, 957, 3678, 10086, 29, 797, 9, 339, 20456, 911, 506, 8072, 315, 520, 533, 6054, 4078, 19, 14, 3924, 14, 4261, 12989, 547, 64, 7444, 272, 10086, 787, 6980, 12, 315, 1314, 1930, 314, 25498, 1919, 911, 506, 4915, 14, 339, 520, 635, 1109, 3141, 26, 267, 19271, 1329, 402, 10086, 370, 2040, 14, 17415, 13823, 1806, 1163, 8242, 14, 398, 2494, 370, 1124, 403, 1040, 370, 2813, 642, 5828, 436, 11264, 1771, 641, 1163, 267, 8242, 14, 2779, 1159, 282, 6954, 16819, 370, 663, 642, 370, 2005, 4334, 9312, 13, 6260, 574, 370, 267, 2933, 367, 10537, 6275, 5560, 436, 5126, 15258, 7269, 17222, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 14, 398, 2494, 370, 1124, 797, 1040, 370, 3507, 436, 1742, 590, 1124, 3730, 63, 265, 63, 4876, 29, 797, 4345, 339, 520, 635, 1109, 4907, 26, 267, 7494, 5002, 1950, 13, 2407, 2552, 370, 7269, 641, 14, 398, 5723, 787, 2552, 4915, 2544, 314, 1056, 365, 4847, 370, 314, 3982, 1654, 12, 267, 1314, 781, 5534, 965, 440, 15572, 314, 1654, 370, 2112, 314, 1056, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 402, 642, 730, 14, 339, 520, 635, 1109, 1586, 26, 267, 7494, 5002, 5431, 370, 7269, 641, 1586, 2552, 14, 398, 5723, 2552, 787, 4915, 2410, 314, 1056, 1990, 4847, 370, 314, 1654, 12, 880, 314, 267, 1056, 1443, 1172, 5366, 13, 27626, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 402, 642, 730, 14, 339, 520, 635, 1109, 4660, 26, 267, 7494, 5002, 17784, 370, 5147, 14, 22672, 642, 370, 5126, 15258, 4660, 267, 17222, 14, 398, 437, 4660, 365, 282, 3101, 1177, 543, 282, 2004, 1233, 19660, 12, 11485, 12, 25989, 12, 26959, 503, 267, 650, 2036, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 402, 642, 730, 14, 398, 2494, 370, 1124, 797, 1040, 370, 3507, 436, 1742, 590, 1124, 3730, 63, 265, 63, 4876, 29, 797, 4345, 339, 520, 635, 6076, 1083, 63, 14189, 26, 267, 2494, 402, 22681, 68, 3101, 1083, 809, 1533, 626, 781, 1077, 7269, 641, 14, 398, 4885, 849, 12, 781, 1454, 7269, 641, 3102, 1314, 787, 8652, 370, 506, 267, 32122, 334, 6048, 4145, 543, 314, 2011, 2633, 1284, 543, 314, 267, 2011, 1174, 680, 1666, 520, 962, 1705, 12989, 14, 3472, 63, 9977, 63, 18817, 4924, 2313, 398, 2494, 370, 282, 1124, 797, 1040, 574, 370, 7269, 641, 1263, 16041, 14, 339, 520, 635, 6076, 2004, 63, 3990, 513, 26, 267, 437, 663, 402, 3000, 3101, 2004, 9479, 626, 781, 1077, 3542, 282, 7269, 641, 14, 267, 437, 7269, 365, 11023, 972, 340, 314, 1056, 1083, 365, 315, 1124, 765, 63, 14189, 1040, 267, 436, 314, 1177, 2004, 1233, 365, 315, 1124, 1205, 63, 3990, 513, 4345, 398, 4885, 849, 12, 642, 365, 6980, 543, 1124, 403, 4345, 339, 520, 635, 2069, 22735, 63, 4778, 26, 267, 437, 22735, 6535, 370, 4838, 3382, 12454, 2410, 314, 3499, 862, 267, 334, 2786, 2552, 787, 12152, 9939, 701, 282, 3499, 862, 1928, 282, 267, 7339, 680, 4011, 19, 911, 9435, 367, 447, 953, 469, 21061, 6535, 93, 627, 334, 18, 7167, 11459, 1955, 402, 3141, 10086, 93, 446, 413, 430, 398, 4696, 14, 982, 314, 22735, 63, 4778, 365, 378, 14, 17, 12, 2066, 520, 1532, 5026, 4532, 64, 911, 9435, 267, 367, 359, 16, 14, 16, 83, 12, 378, 14, 18, 83, 12, 378, 14, 20, 83, 12, 21214, 3382, 10086, 14, 2779, 911, 7078, 506, 8088, 267, 2419, 520, 962, 1705, 12989, 14, 7111, 7517, 63, 4283, 2313, 398, 4885, 849, 12, 22735, 365, 6980, 334, 409, 370, 378, 680, 339, 520, 635, 2155, 746, 63, 265, 63, 4876, 26, 7480, 12, 340, 314, 1329, 402, 17784, 365, 267, 31103, 12, 370, 746, 282, 8228, 12989, 547, 12, 503, 370, 372, 282, 1177, 543, 282, 267, 1177, 1233, 315, 314, 650, 2154, 1425, 14, 339, 520, 635, 2155, 746, 63, 265, 63, 1205, 26, 20046, 11150, 370, 1124, 3730, 63, 265, 63, 4876, 18983, 267, 3775, 781, 1077, 746, 376, 1919, 12, 503, 372, 282, 1177, 12, 267, 340, 2004, 26945, 315, 1124, 1205, 63, 3990, 513, 1040, 1425, 436, 10086, 1172, 267, 2757, 31103, 14, 339, 520, 635, 2008, 7994, 26, 710, 7994, 402, 314, 1056, 14556, 5309, 267, 1924, 1240, 370, 520, 5247, 6054, 12989, 14, 9728, 2313, 710, 769, 365, 315, 314, 1865, 267, 314, 4145, 8920 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 900, 199, 646, 2050, 199, 504, 5055, 492, 12863, 199, 504, 7975, 492, 5452, 6710, 199, 646, 3031, 199, 646, 295, 199, 199, 504, 2508, 3924, 492, 334, 272, 15175, 19382, 12, 272, 8228, 12989, 547, 12, 272, 30797, 12, 272, 5574, 19382, 12, 272, 7232, 547, 12, 272, 6378, 2567, 12, 199, 9, 199, 504, 2508, 5154, 492, 3816, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3, 3918, 5523, 367, 6144, 314, 3341, 402, 4145, 626, 754, 315, 282, 7269, 14, 199, 2017, 12114, 275, 12863, 360, 2017, 12114, 297, 2097, 765, 401, 298, 633, 401, 298, 705, 401, 6901, 298, 1205, 401, 298, 4876, 63, 1985, 3135, 421, 199, 533, 20506, 8, 785, 304, 272, 408, 20506, 2897, 14, 339, 7048, 7269, 7427, 911, 1218, 282, 892, 20506, 909, 543, 4588, 1338, 12, 880, 272, 2985, 883, 506, 19353, 24826, 14, 339, 8747, 1996, 883, 506, 3247, 465, 282, 849, 367, 282, 4203, 447, 398, 10086, 275, 20506, 8, 2242, 29, 21, 12, 1586, 29, 18, 12, 4660, 29, 21, 9, 267, 1455, 275, 15553, 2988, 8, 10937, 29, 10937, 9, 267, 1177, 275, 1455, 14, 1069, 360, 2970, 297, 283, 1014, 921, 2694, 14, 957, 6217, 339, 4236, 1126, 13, 1069, 334, 6777, 10580, 314, 849, 367, 314, 4203, 304, 26, 398, 1177, 275, 1455, 14, 1069, 360, 2970, 297, 283, 1014, 921, 2694, 14, 957, 3678, 10086, 29, 12989, 8, 709, 430, 339, 8747, 1996, 883, 506, 6980, 701, 9476, 1124, 797, 1040, 447, 398, 1177, 275, 1455, 14, 1069, 360, 2970, 297, 283, 1014, 921, 2694, 14, 957, 3678, 10086, 29, 797, 9, 339, 20456, 911, 506, 8072, 315, 520, 533, 6054, 4078, 19, 14, 3924, 14, 4261, 12989, 547, 64, 7444, 272, 10086, 787, 6980, 12, 315, 1314, 1930, 314, 25498, 1919, 911, 506, 4915, 14, 339, 520, 635, 1109, 3141, 26, 267, 19271, 1329, 402, 10086, 370, 2040, 14, 17415, 13823, 1806, 1163, 8242, 14, 398, 2494, 370, 1124, 403, 1040, 370, 2813, 642, 5828, 436, 11264, 1771, 641, 1163, 267, 8242, 14, 2779, 1159, 282, 6954, 16819, 370, 663, 642, 370, 2005, 4334, 9312, 13, 6260, 574, 370, 267, 2933, 367, 10537, 6275, 5560, 436, 5126, 15258, 7269, 17222, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 14, 398, 2494, 370, 1124, 797, 1040, 370, 3507, 436, 1742, 590, 1124, 3730, 63, 265, 63, 4876, 29, 797, 4345, 339, 520, 635, 1109, 4907, 26, 267, 7494, 5002, 1950, 13, 2407, 2552, 370, 7269, 641, 14, 398, 5723, 787, 2552, 4915, 2544, 314, 1056, 365, 4847, 370, 314, 3982, 1654, 12, 267, 1314, 781, 5534, 965, 440, 15572, 314, 1654, 370, 2112, 314, 1056, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 402, 642, 730, 14, 339, 520, 635, 1109, 1586, 26, 267, 7494, 5002, 5431, 370, 7269, 641, 1586, 2552, 14, 398, 5723, 2552, 787, 4915, 2410, 314, 1056, 1990, 4847, 370, 314, 1654, 12, 880, 314, 267, 1056, 1443, 1172, 5366, 13, 27626, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 402, 642, 730, 14, 339, 520, 635, 1109, 4660, 26, 267, 7494, 5002, 17784, 370, 5147, 14, 22672, 642, 370, 5126, 15258, 4660, 267, 17222, 14, 398, 437, 4660, 365, 282, 3101, 1177, 543, 282, 2004, 1233, 19660, 12, 11485, 12, 25989, 12, 26959, 503, 267, 650, 2036, 14, 398, 2494, 370, 1124, 16, 1040, 370, 2449, 641, 314, 1642, 7269, 402, 642, 730, 14, 398, 2494, 370, 1124, 797, 1040, 370, 3507, 436, 1742, 590, 1124, 3730, 63, 265, 63, 4876, 29, 797, 4345, 339, 520, 635, 6076, 1083, 63, 14189, 26, 267, 2494, 402, 22681, 68, 3101, 1083, 809, 1533, 626, 781, 1077, 7269, 641, 14, 398, 4885, 849, 12, 781, 1454, 7269, 641, 3102, 1314, 787, 8652, 370, 506, 267, 32122, 334, 6048, 4145, 543, 314, 2011, 2633, 1284, 543, 314, 267, 2011, 1174, 680, 1666, 520, 962, 1705, 12989, 14, 3472, 63, 9977, 63, 18817, 4924, 2313, 398, 2494, 370, 282, 1124, 797, 1040, 574, 370, 7269, 641, 1263, 16041, 14, 339, 520, 635, 6076, 2004, 63, 3990, 513, 26, 267, 437, 663, 402, 3000, 3101, 2004, 9479, 626, 781, 1077, 3542, 282, 7269, 641, 14, 267, 437, 7269, 365, 11023, 972, 340, 314, 1056, 1083, 365, 315, 1124, 765, 63, 14189, 1040, 267, 436, 314, 1177, 2004, 1233, 365, 315, 1124, 1205, 63, 3990, 513, 4345, 398, 4885, 849, 12, 642, 365, 6980, 543, 1124, 403, 4345, 339, 520, 635, 2069, 22735, 63, 4778, 26, 267, 437, 22735, 6535, 370, 4838, 3382, 12454, 2410, 314, 3499, 862, 267, 334, 2786, 2552, 787, 12152, 9939, 701, 282, 3499, 862, 1928, 282, 267, 7339, 680, 4011, 19, 911, 9435, 367, 447, 953, 469, 21061, 6535, 93, 627, 334, 18, 7167, 11459, 1955, 402, 3141, 10086, 93, 446, 413, 430, 398, 4696, 14, 982, 314, 22735, 63, 4778, 365, 378, 14, 17, 12, 2066, 520, 1532, 5026, 4532, 64, 911, 9435, 267, 367, 359, 16, 14, 16, 83, 12, 378, 14, 18, 83, 12, 378, 14, 20, 83, 12, 21214, 3382, 10086, 14, 2779, 911, 7078, 506, 8088, 267, 2419, 520, 962, 1705, 12989, 14, 7111, 7517, 63, 4283, 2313, 398, 4885, 849, 12, 22735, 365, 6980, 334, 409, 370, 378, 680, 339, 520, 635, 2155, 746, 63, 265, 63, 4876, 26, 7480, 12, 340, 314, 1329, 402, 17784, 365, 267, 31103, 12, 370, 746, 282, 8228, 12989, 547, 12, 503, 370, 372, 282, 1177, 543, 282, 267, 1177, 1233, 315, 314, 650, 2154, 1425, 14, 339, 520, 635, 2155, 746, 63, 265, 63, 1205, 26, 20046, 11150, 370, 1124, 3730, 63, 265, 63, 4876, 18983, 267, 3775, 781, 1077, 746, 376, 1919, 12, 503, 372, 282, 1177, 12, 267, 340, 2004, 26945, 315, 1124, 1205, 63, 3990, 513, 1040, 1425, 436, 10086, 1172, 267, 2757, 31103, 14, 339, 520, 635, 2008, 7994, 26, 710, 7994, 402, 314, 1056, 14556, 5309, 267, 1924, 1240, 370, 520, 5247, 6054, 12989, 14, 9728, 2313, 710, 769, 365, 315, 314, 1865, 267, 314, 4145, 8920, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
KaranToor/MA450
google-cloud-sdk/lib/surface/compute/vpn_tunnels/list.py
7
1103
# Copyright 2014 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Command for listing VPN tunnels.""" from googlecloudsdk.api_lib.compute import base_classes class List(base_classes.RegionalLister): """List VPN tunnels.""" # Placeholder to indicate that a detailed_help field exists and should # be set outside the class definition. detailed_help = None @property def service(self): return self.compute.vpnTunnels @property def resource_type(self): return 'vpnTunnels' List.detailed_help = base_classes.GetRegionalListerHelp('VPN tunnels')
apache-2.0
[ 3, 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 3110, 367, 13778, 29057, 21496, 83, 1041, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 3357, 492, 1300, 63, 2888, 421, 199, 533, 3820, 8, 1095, 63, 2888, 14, 10708, 279, 44, 1429, 304, 523, 408, 1296, 29057, 21496, 83, 1041, 819, 327, 10902, 4302, 370, 6623, 626, 282, 16212, 63, 3437, 901, 3495, 436, 1077, 523, 327, 506, 663, 9682, 314, 1021, 5492, 14, 523, 16212, 63, 3437, 275, 488, 819, 768, 1829, 523, 347, 2435, 8, 277, 304, 272, 372, 291, 14, 3357, 14, 9702, 22664, 2715, 83, 819, 768, 1829, 523, 347, 2073, 63, 466, 8, 277, 304, 272, 372, 283, 9702, 22664, 2715, 83, 7, 421, 199, 1296, 14, 19170, 63, 3437, 275, 1300, 63, 2888, 14, 1002, 10708, 279, 44, 1429, 8673, 360, 54, 9060, 21496, 83, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 3110, 367, 13778, 29057, 21496, 83, 1041, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 3357, 492, 1300, 63, 2888, 421, 199, 533, 3820, 8, 1095, 63, 2888, 14, 10708, 279, 44, 1429, 304, 523, 408, 1296, 29057, 21496, 83, 1041, 819, 327, 10902, 4302, 370, 6623, 626, 282, 16212, 63, 3437, 901, 3495, 436, 1077, 523, 327, 506, 663, 9682, 314, 1021, 5492, 14, 523, 16212, 63, 3437, 275, 488, 819, 768, 1829, 523, 347, 2435, 8, 277, 304, 272, 372, 291, 14, 3357, 14, 9702, 22664, 2715, 83, 819, 768, 1829, 523, 347, 2073, 63, 466, 8, 277, 304, 272, 372, 283, 9702, 22664, 2715, 83, 7, 421, 199, 1296, 14, 19170, 63, 3437, 275, 1300, 63, 2888, 14, 1002, 10708, 279, 44, 1429, 8673, 360, 54, 9060, 21496, 83, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
SpaceGroupUCL/qgisSpaceSyntaxToolkit
esstoolkit/external/networkx/algorithms/swap.py
4
9829
"""Swap edges in a graph. """ import math from networkx.utils import py_random_state import networkx as nx __all__ = ["double_edge_swap", "connected_double_edge_swap"] @py_random_state(3) def double_edge_swap(G, nswap=1, max_tries=100, seed=None): """Swap two edges in the graph while keeping the node degrees fixed. A double-edge swap removes two randomly chosen edges u-v and x-y and creates the new edges u-x and v-y:: u--v u v becomes | | x--y x y If either the edge u-x or v-y already exist no swap is performed and another attempt is made to find a suitable edge pair. Parameters ---------- G : graph An undirected graph nswap : integer (optional, default=1) Number of double-edge swaps to perform max_tries : integer (optional) Maximum number of attempts to swap edges seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness<randomness>`. Returns ------- G : graph The graph after double edge swaps. Notes ----- Does not enforce any connectivity constraints. The graph G is modified in place. """ if G.is_directed(): raise nx.NetworkXError("double_edge_swap() not defined for directed graphs.") if nswap > max_tries: raise nx.NetworkXError("Number of swaps > number of tries allowed.") if len(G) < 4: raise nx.NetworkXError("Graph has less than four nodes.") # Instead of choosing uniformly at random from a generated edge list, # this algorithm chooses nonuniformly from the set of nodes with # probability weighted by degree. n = 0 swapcount = 0 keys, degrees = zip(*G.degree()) # keys, degree cdf = nx.utils.cumulative_distribution(degrees) # cdf of degree discrete_sequence = nx.utils.discrete_sequence while swapcount < nswap: # if random.random() < 0.5: continue # trick to avoid periodicities? # pick two random edges without creating edge list # choose source node indices from discrete distribution (ui, xi) = discrete_sequence(2, cdistribution=cdf, seed=seed) if ui == xi: continue # same source, skip u = keys[ui] # convert index to label x = keys[xi] # choose target uniformly from neighbors v = seed.choice(list(G[u])) y = seed.choice(list(G[x])) if v == y: continue # same target, skip if (x not in G[u]) and (y not in G[v]): # don't create parallel edges G.add_edge(u, x) G.add_edge(v, y) G.remove_edge(u, v) G.remove_edge(x, y) swapcount += 1 if n >= max_tries: e = ( f"Maximum number of swap attempts ({n}) exceeded " f"before desired swaps achieved ({nswap})." ) raise nx.NetworkXAlgorithmError(e) n += 1 return G @py_random_state(3) def connected_double_edge_swap(G, nswap=1, _window_threshold=3, seed=None): """Attempts the specified number of double-edge swaps in the graph `G`. A double-edge swap removes two randomly chosen edges `(u, v)` and `(x, y)` and creates the new edges `(u, x)` and `(v, y)`:: u--v u v becomes | | x--y x y If either `(u, x)` or `(v, y)` already exist, then no swap is performed so the actual number of swapped edges is always *at most* `nswap`. Parameters ---------- G : graph An undirected graph nswap : integer (optional, default=1) Number of double-edge swaps to perform _window_threshold : integer The window size below which connectedness of the graph will be checked after each swap. The "window" in this function is a dynamically updated integer that represents the number of swap attempts to make before checking if the graph remains connected. It is an optimization used to decrease the running time of the algorithm in exchange for increased complexity of implementation. If the window size is below this threshold, then the algorithm checks after each swap if the graph remains connected by checking if there is a path joining the two nodes whose edge was just removed. If the window size is above this threshold, then the algorithm performs do all the swaps in the window and only then check if the graph is still connected. seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness<randomness>`. Returns ------- int The number of successful swaps Raises ------ NetworkXError If the input graph is not connected, or if the graph has fewer than four nodes. Notes ----- The initial graph `G` must be connected, and the resulting graph is connected. The graph `G` is modified in place. References ---------- .. [1] C. Gkantsidis and M. Mihail and E. Zegura, The Markov chain simulation method for generating connected power law random graphs, 2003. http://citeseer.ist.psu.edu/gkantsidis03markov.html """ if not nx.is_connected(G): raise nx.NetworkXError("Graph not connected") if len(G) < 4: raise nx.NetworkXError("Graph has less than four nodes.") n = 0 swapcount = 0 deg = G.degree() # Label key for nodes dk = list(n for n, d in G.degree()) cdf = nx.utils.cumulative_distribution(list(d for n, d in G.degree())) discrete_sequence = nx.utils.discrete_sequence window = 1 while n < nswap: wcount = 0 swapped = [] # If the window is small, we just check each time whether the graph is # connected by checking if the nodes that were just separated are still # connected. if window < _window_threshold: # This Boolean keeps track of whether there was a failure or not. fail = False while wcount < window and n < nswap: # Pick two random edges without creating the edge list. Choose # source nodes from the discrete degree distribution. (ui, xi) = discrete_sequence(2, cdistribution=cdf, seed=seed) # If the source nodes are the same, skip this pair. if ui == xi: continue # Convert an index to a node label. u = dk[ui] x = dk[xi] # Choose targets uniformly from neighbors. v = seed.choice(list(G.neighbors(u))) y = seed.choice(list(G.neighbors(x))) # If the target nodes are the same, skip this pair. if v == y: continue if x not in G[u] and y not in G[v]: G.remove_edge(u, v) G.remove_edge(x, y) G.add_edge(u, x) G.add_edge(v, y) swapped.append((u, v, x, y)) swapcount += 1 n += 1 # If G remains connected... if nx.has_path(G, u, v): wcount += 1 # Otherwise, undo the changes. else: G.add_edge(u, v) G.add_edge(x, y) G.remove_edge(u, x) G.remove_edge(v, y) swapcount -= 1 fail = True # If one of the swaps failed, reduce the window size. if fail: window = int(math.ceil(window / 2)) else: window += 1 # If the window is large, then there is a good chance that a bunch of # swaps will work. It's quicker to do all those swaps first and then # check if the graph remains connected. else: while wcount < window and n < nswap: # Pick two random edges without creating the edge list. Choose # source nodes from the discrete degree distribution. (ui, xi) = nx.utils.discrete_sequence(2, cdistribution=cdf) # If the source nodes are the same, skip this pair. if ui == xi: continue # Convert an index to a node label. u = dk[ui] x = dk[xi] # Choose targets uniformly from neighbors. v = seed.choice(list(G.neighbors(u))) y = seed.choice(list(G.neighbors(x))) # If the target nodes are the same, skip this pair. if v == y: continue if x not in G[u] and y not in G[v]: G.remove_edge(u, v) G.remove_edge(x, y) G.add_edge(u, x) G.add_edge(v, y) swapped.append((u, v, x, y)) swapcount += 1 n += 1 wcount += 1 # If the graph remains connected, increase the window size. if nx.is_connected(G): window += 1 # Otherwise, undo the changes from the previous window and decrease # the window size. else: while swapped: (u, v, x, y) = swapped.pop() G.add_edge(u, v) G.add_edge(x, y) G.remove_edge(u, x) G.remove_edge(v, y) swapcount -= 1 window = int(math.ceil(window / 2)) return swapcount
gpl-3.0
[ 624, 18385, 8207, 315, 282, 3343, 14, 199, 624, 199, 199, 646, 3473, 199, 504, 24313, 14, 1208, 492, 1134, 63, 2355, 63, 929, 199, 199, 646, 24313, 465, 8484, 199, 199, 363, 452, 363, 275, 2097, 3157, 63, 5173, 63, 9286, 401, 298, 7113, 63, 3157, 63, 5173, 63, 9286, 937, 421, 199, 32, 647, 63, 2355, 63, 929, 8, 19, 9, 199, 318, 4270, 63, 5173, 63, 9286, 8, 39, 12, 700, 25529, 29, 17, 12, 1390, 63, 6264, 29, 1960, 12, 6347, 29, 403, 304, 272, 408, 18385, 2877, 8207, 315, 314, 3343, 1830, 22181, 314, 1031, 14358, 6317, 14, 339, 437, 4270, 13, 5173, 11413, 14185, 2877, 19311, 12414, 8207, 399, 13, 86, 436, 671, 13, 89, 272, 436, 8491, 314, 892, 8207, 399, 13, 88, 436, 373, 13, 89, 447, 10813, 399, 306, 86, 3322, 399, 221, 373, 288, 15410, 221, 1204, 221, 1204, 1362, 671, 306, 89, 3322, 671, 221, 612, 339, 982, 1902, 314, 6275, 399, 13, 88, 503, 373, 13, 89, 2575, 2187, 949, 11413, 365, 10585, 272, 436, 4573, 7427, 365, 6326, 370, 2342, 282, 11233, 6275, 4092, 14, 339, 3897, 272, 4143, 272, 598, 520, 3343, 2126, 1626, 625, 12080, 3343, 339, 700, 25529, 520, 3000, 334, 4144, 12, 849, 29, 17, 9, 2126, 4860, 402, 4270, 13, 5173, 5584, 7461, 370, 5147, 339, 1390, 63, 6264, 520, 3000, 334, 4144, 9, 2126, 14212, 1329, 402, 12454, 370, 11413, 8207, 339, 6347, 520, 3000, 12, 2196, 63, 929, 12, 503, 488, 334, 885, 9, 267, 1010, 5000, 707, 402, 2196, 1329, 10152, 1174, 14, 267, 1666, 520, 1121, 1705, 3883, 4171, 28, 2355, 4171, 14943, 339, 1803, 272, 5514, 272, 598, 520, 3343, 2126, 710, 3343, 2410, 4270, 6275, 5584, 7461, 14, 339, 8144, 272, 9063, 272, 12078, 440, 15814, 1263, 20170, 9565, 14, 339, 710, 3343, 598, 365, 6042, 315, 4192, 14, 272, 408, 272, 340, 598, 14, 374, 63, 12080, 837, 267, 746, 8484, 14, 4491, 29356, 480, 3157, 63, 5173, 63, 9286, 342, 440, 3247, 367, 23667, 18312, 2685, 272, 340, 700, 25529, 690, 1390, 63, 6264, 26, 267, 746, 8484, 14, 4491, 29356, 480, 3259, 402, 5584, 7461, 690, 1329, 402, 11275, 4370, 2685, 272, 340, 822, 8, 39, 9, 665, 841, 26, 267, 746, 8484, 14, 4491, 29356, 480, 4578, 965, 6656, 2419, 11648, 3380, 2685, 272, 327, 15345, 402, 2468, 26056, 14818, 590, 737, 2196, 687, 282, 4046, 6275, 769, 12, 272, 327, 642, 5563, 2468, 32128, 2222, 8830, 590, 687, 314, 663, 402, 3380, 543, 272, 327, 12224, 14609, 701, 13666, 14, 272, 302, 275, 378, 272, 11413, 835, 275, 378, 272, 2883, 12, 14358, 275, 3482, 2031, 39, 14, 10956, 1012, 221, 327, 2883, 12, 13666, 272, 26037, 275, 8484, 14, 1208, 14, 11898, 16813, 63, 4972, 8, 20251, 9, 221, 327, 26037, 402, 13666, 272, 24635, 63, 4041, 275, 8484, 14, 1208, 14, 23591, 63, 4041, 272, 1830, 11413, 835, 665, 700, 25529, 26, 267, 327, 263, 340, 2196, 14, 2355, 342, 665, 378, 14, 21, 26, 1980, 327, 20907, 370, 5126, 1126, 2308, 328, 18207, 31, 267, 327, 3732, 2877, 2196, 8207, 1928, 6425, 6275, 769, 267, 327, 11496, 1350, 1031, 4918, 687, 24635, 4084, 267, 334, 1907, 12, 19905, 9, 275, 24635, 63, 4041, 8, 18, 12, 286, 4972, 29, 10790, 12, 6347, 29, 5176, 9, 267, 340, 8574, 508, 19905, 26, 288, 1980, 221, 327, 2011, 1350, 12, 3372, 267, 399, 275, 2883, 59, 1907, 61, 221, 327, 3957, 1478, 370, 1768, 267, 671, 275, 2883, 59, 6865, 61, 267, 327, 11496, 1347, 14818, 590, 687, 15845, 267, 373, 275, 6347, 14, 5095, 8, 513, 8, 39, 59, 85, 2459, 267, 612, 275, 6347, 14, 5095, 8, 513, 8, 39, 59, 88, 2459, 267, 340, 373, 508, 612, 26, 288, 1980, 221, 327, 2011, 1347, 12, 3372, 267, 340, 334, 88, 440, 315, 598, 59, 85, 566, 436, 334, 89, 440, 315, 598, 59, 86, 4682, 221, 327, 2793, 1133, 1218, 9861, 8207, 288, 598, 14, 525, 63, 5173, 8, 85, 12, 671, 9, 288, 598, 14, 525, 63, 5173, 8, 86, 12, 612, 9, 288, 598, 14, 2168, 63, 5173, 8, 85, 12, 373, 9, 288, 598, 14, 2168, 63, 5173, 8, 88, 12, 612, 9, 288, 11413, 835, 847, 413, 267, 340, 302, 2356, 1390, 63, 6264, 26, 288, 325, 275, 334, 355, 289, 2, 10915, 1329, 402, 11413, 12454, 11459, 78, 1552, 22007, 298, 355, 289, 2, 5182, 6387, 5584, 7461, 22175, 1354, 11459, 561, 25529, 93, 17617, 288, 776, 288, 746, 8484, 14, 4491, 56, 11570, 547, 8, 69, 9, 267, 302, 847, 413, 272, 372, 598, 421, 199, 32, 647, 63, 2355, 63, 929, 8, 19, 9, 199, 318, 8539, 63, 3157, 63, 5173, 63, 9286, 8, 39, 12, 700, 25529, 29, 17, 12, 485, 3806, 63, 7227, 29, 19, 12, 6347, 29, 403, 304, 272, 408, 15322, 1086, 314, 2013, 1329, 402, 4270, 13, 5173, 5584, 7461, 315, 314, 3343, 658, 39, 2313, 339, 437, 4270, 13, 5173, 11413, 14185, 2877, 19311, 12414, 8207, 16918, 85, 12, 373, 12544, 436, 16918, 88, 12, 272, 612, 12544, 436, 8491, 314, 892, 8207, 16918, 85, 12, 671, 12544, 436, 16918, 86, 12, 612, 12544, 447, 10813, 399, 306, 86, 3322, 399, 221, 373, 288, 15410, 221, 1204, 221, 1204, 1362, 671, 306, 89, 3322, 671, 221, 612, 339, 982, 1902, 16918, 85, 12, 671, 12544, 503, 16918, 86, 12, 612, 12544, 2575, 2187, 12, 2066, 949, 11413, 365, 10585, 272, 880, 314, 3503, 1329, 402, 25072, 8207, 365, 3544, 627, 292, 4750, 10, 658, 561, 25529, 2313, 339, 3897, 272, 4143, 272, 598, 520, 3343, 2126, 1626, 625, 12080, 3343, 339, 700, 25529, 520, 3000, 334, 4144, 12, 849, 29, 17, 9, 2126, 4860, 402, 4270, 13, 5173, 5584, 7461, 370, 5147, 339, 485, 3806, 63, 7227, 520, 3000, 10817, 710, 4353, 1568, 5084, 1314, 8539, 4171, 402, 314, 3343, 911, 506, 7923, 2126, 2410, 1924, 11413, 14, 10817, 710, 298, 3806, 2, 315, 642, 805, 365, 282, 18774, 4588, 3000, 626, 2126, 8469, 314, 1329, 402, 11413, 12454, 370, 1852, 2544, 7907, 340, 314, 2126, 3343, 25803 ]
[ 18385, 8207, 315, 282, 3343, 14, 199, 624, 199, 199, 646, 3473, 199, 504, 24313, 14, 1208, 492, 1134, 63, 2355, 63, 929, 199, 199, 646, 24313, 465, 8484, 199, 199, 363, 452, 363, 275, 2097, 3157, 63, 5173, 63, 9286, 401, 298, 7113, 63, 3157, 63, 5173, 63, 9286, 937, 421, 199, 32, 647, 63, 2355, 63, 929, 8, 19, 9, 199, 318, 4270, 63, 5173, 63, 9286, 8, 39, 12, 700, 25529, 29, 17, 12, 1390, 63, 6264, 29, 1960, 12, 6347, 29, 403, 304, 272, 408, 18385, 2877, 8207, 315, 314, 3343, 1830, 22181, 314, 1031, 14358, 6317, 14, 339, 437, 4270, 13, 5173, 11413, 14185, 2877, 19311, 12414, 8207, 399, 13, 86, 436, 671, 13, 89, 272, 436, 8491, 314, 892, 8207, 399, 13, 88, 436, 373, 13, 89, 447, 10813, 399, 306, 86, 3322, 399, 221, 373, 288, 15410, 221, 1204, 221, 1204, 1362, 671, 306, 89, 3322, 671, 221, 612, 339, 982, 1902, 314, 6275, 399, 13, 88, 503, 373, 13, 89, 2575, 2187, 949, 11413, 365, 10585, 272, 436, 4573, 7427, 365, 6326, 370, 2342, 282, 11233, 6275, 4092, 14, 339, 3897, 272, 4143, 272, 598, 520, 3343, 2126, 1626, 625, 12080, 3343, 339, 700, 25529, 520, 3000, 334, 4144, 12, 849, 29, 17, 9, 2126, 4860, 402, 4270, 13, 5173, 5584, 7461, 370, 5147, 339, 1390, 63, 6264, 520, 3000, 334, 4144, 9, 2126, 14212, 1329, 402, 12454, 370, 11413, 8207, 339, 6347, 520, 3000, 12, 2196, 63, 929, 12, 503, 488, 334, 885, 9, 267, 1010, 5000, 707, 402, 2196, 1329, 10152, 1174, 14, 267, 1666, 520, 1121, 1705, 3883, 4171, 28, 2355, 4171, 14943, 339, 1803, 272, 5514, 272, 598, 520, 3343, 2126, 710, 3343, 2410, 4270, 6275, 5584, 7461, 14, 339, 8144, 272, 9063, 272, 12078, 440, 15814, 1263, 20170, 9565, 14, 339, 710, 3343, 598, 365, 6042, 315, 4192, 14, 272, 408, 272, 340, 598, 14, 374, 63, 12080, 837, 267, 746, 8484, 14, 4491, 29356, 480, 3157, 63, 5173, 63, 9286, 342, 440, 3247, 367, 23667, 18312, 2685, 272, 340, 700, 25529, 690, 1390, 63, 6264, 26, 267, 746, 8484, 14, 4491, 29356, 480, 3259, 402, 5584, 7461, 690, 1329, 402, 11275, 4370, 2685, 272, 340, 822, 8, 39, 9, 665, 841, 26, 267, 746, 8484, 14, 4491, 29356, 480, 4578, 965, 6656, 2419, 11648, 3380, 2685, 272, 327, 15345, 402, 2468, 26056, 14818, 590, 737, 2196, 687, 282, 4046, 6275, 769, 12, 272, 327, 642, 5563, 2468, 32128, 2222, 8830, 590, 687, 314, 663, 402, 3380, 543, 272, 327, 12224, 14609, 701, 13666, 14, 272, 302, 275, 378, 272, 11413, 835, 275, 378, 272, 2883, 12, 14358, 275, 3482, 2031, 39, 14, 10956, 1012, 221, 327, 2883, 12, 13666, 272, 26037, 275, 8484, 14, 1208, 14, 11898, 16813, 63, 4972, 8, 20251, 9, 221, 327, 26037, 402, 13666, 272, 24635, 63, 4041, 275, 8484, 14, 1208, 14, 23591, 63, 4041, 272, 1830, 11413, 835, 665, 700, 25529, 26, 267, 327, 263, 340, 2196, 14, 2355, 342, 665, 378, 14, 21, 26, 1980, 327, 20907, 370, 5126, 1126, 2308, 328, 18207, 31, 267, 327, 3732, 2877, 2196, 8207, 1928, 6425, 6275, 769, 267, 327, 11496, 1350, 1031, 4918, 687, 24635, 4084, 267, 334, 1907, 12, 19905, 9, 275, 24635, 63, 4041, 8, 18, 12, 286, 4972, 29, 10790, 12, 6347, 29, 5176, 9, 267, 340, 8574, 508, 19905, 26, 288, 1980, 221, 327, 2011, 1350, 12, 3372, 267, 399, 275, 2883, 59, 1907, 61, 221, 327, 3957, 1478, 370, 1768, 267, 671, 275, 2883, 59, 6865, 61, 267, 327, 11496, 1347, 14818, 590, 687, 15845, 267, 373, 275, 6347, 14, 5095, 8, 513, 8, 39, 59, 85, 2459, 267, 612, 275, 6347, 14, 5095, 8, 513, 8, 39, 59, 88, 2459, 267, 340, 373, 508, 612, 26, 288, 1980, 221, 327, 2011, 1347, 12, 3372, 267, 340, 334, 88, 440, 315, 598, 59, 85, 566, 436, 334, 89, 440, 315, 598, 59, 86, 4682, 221, 327, 2793, 1133, 1218, 9861, 8207, 288, 598, 14, 525, 63, 5173, 8, 85, 12, 671, 9, 288, 598, 14, 525, 63, 5173, 8, 86, 12, 612, 9, 288, 598, 14, 2168, 63, 5173, 8, 85, 12, 373, 9, 288, 598, 14, 2168, 63, 5173, 8, 88, 12, 612, 9, 288, 11413, 835, 847, 413, 267, 340, 302, 2356, 1390, 63, 6264, 26, 288, 325, 275, 334, 355, 289, 2, 10915, 1329, 402, 11413, 12454, 11459, 78, 1552, 22007, 298, 355, 289, 2, 5182, 6387, 5584, 7461, 22175, 1354, 11459, 561, 25529, 93, 17617, 288, 776, 288, 746, 8484, 14, 4491, 56, 11570, 547, 8, 69, 9, 267, 302, 847, 413, 272, 372, 598, 421, 199, 32, 647, 63, 2355, 63, 929, 8, 19, 9, 199, 318, 8539, 63, 3157, 63, 5173, 63, 9286, 8, 39, 12, 700, 25529, 29, 17, 12, 485, 3806, 63, 7227, 29, 19, 12, 6347, 29, 403, 304, 272, 408, 15322, 1086, 314, 2013, 1329, 402, 4270, 13, 5173, 5584, 7461, 315, 314, 3343, 658, 39, 2313, 339, 437, 4270, 13, 5173, 11413, 14185, 2877, 19311, 12414, 8207, 16918, 85, 12, 373, 12544, 436, 16918, 88, 12, 272, 612, 12544, 436, 8491, 314, 892, 8207, 16918, 85, 12, 671, 12544, 436, 16918, 86, 12, 612, 12544, 447, 10813, 399, 306, 86, 3322, 399, 221, 373, 288, 15410, 221, 1204, 221, 1204, 1362, 671, 306, 89, 3322, 671, 221, 612, 339, 982, 1902, 16918, 85, 12, 671, 12544, 503, 16918, 86, 12, 612, 12544, 2575, 2187, 12, 2066, 949, 11413, 365, 10585, 272, 880, 314, 3503, 1329, 402, 25072, 8207, 365, 3544, 627, 292, 4750, 10, 658, 561, 25529, 2313, 339, 3897, 272, 4143, 272, 598, 520, 3343, 2126, 1626, 625, 12080, 3343, 339, 700, 25529, 520, 3000, 334, 4144, 12, 849, 29, 17, 9, 2126, 4860, 402, 4270, 13, 5173, 5584, 7461, 370, 5147, 339, 485, 3806, 63, 7227, 520, 3000, 10817, 710, 4353, 1568, 5084, 1314, 8539, 4171, 402, 314, 3343, 911, 506, 7923, 2126, 2410, 1924, 11413, 14, 10817, 710, 298, 3806, 2, 315, 642, 805, 365, 282, 18774, 4588, 3000, 626, 2126, 8469, 314, 1329, 402, 11413, 12454, 370, 1852, 2544, 7907, 340, 314, 2126, 3343, 25803, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
IllusionRom-deprecated/android_platform_external_chromium_org
chrome/common/extensions/docs/server2/cron_servlet_test.py
23
9487
#!/usr/bin/env python # Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import unittest from appengine_wrappers import GetAppVersion from app_yaml_helper import AppYamlHelper from cron_servlet import CronServlet from empty_dir_file_system import EmptyDirFileSystem from extensions_paths import ( APP_YAML, CONTENT_PROVIDERS, EXTENSIONS, PUBLIC_TEMPLATES, SERVER2, STATIC_DOCS) from github_file_system_provider import GithubFileSystemProvider from host_file_system_provider import HostFileSystemProvider from local_file_system import LocalFileSystem from mock_file_system import MockFileSystem from servlet import Request from test_branch_utility import TestBranchUtility from test_file_system import MoveTo, TestFileSystem from test_util import EnableLogging, ReadFile # NOTE(kalman): The ObjectStore created by the CronServlet is backed onto our # fake AppEngine memcache/datastore, so the tests aren't isolated. Of course, # if the host file systems have different identities, they will be, sort of. class _TestDelegate(CronServlet.Delegate): def __init__(self, create_file_system): self.file_systems = [] # A callback taking a revision and returning a file system. self._create_file_system = create_file_system self._app_version = GetAppVersion() def CreateBranchUtility(self, object_store_creator): return TestBranchUtility.CreateWithCannedData() def CreateHostFileSystemProvider(self, object_store_creator, max_trunk_revision=None): def constructor(branch=None, revision=None): file_system = self._create_file_system(revision) self.file_systems.append(file_system) return file_system return HostFileSystemProvider(object_store_creator, max_trunk_revision=max_trunk_revision, constructor_for_test=constructor) def CreateGithubFileSystemProvider(self, object_store_creator): return GithubFileSystemProvider.ForEmpty() def GetAppVersion(self): return self._app_version # (non-Delegate method). def SetAppVersion(self, app_version): self._app_version = app_version class CronServletTest(unittest.TestCase): @EnableLogging('info') def testEverything(self): # All these tests are dependent (see above comment) so lump everything in # the one test. delegate = _TestDelegate(lambda _: MockFileSystem(LocalFileSystem.Create())) # Test that the cron runs successfully. response = CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(200, response.status) # Save the file systems created, start with a fresh set for the next run. first_run_file_systems = delegate.file_systems[:] delegate.file_systems[:] = [] # When re-running, all file systems should be Stat()d the same number of # times, but the second round shouldn't have been re-Read() since the # Stats haven't changed. response = CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(200, response.status) self.assertEqual(len(first_run_file_systems), len(delegate.file_systems)) for i, second_run_file_system in enumerate(delegate.file_systems): self.assertTrue(*second_run_file_system.CheckAndReset( read_count=0, stat_count=first_run_file_systems[i].GetStatCount())) def testSafeRevision(self): test_data = { 'api': { '_api_features.json': '{}', '_manifest_features.json': '{}', '_permission_features.json': '{}', }, 'docs': { 'examples': { 'examples.txt': 'examples.txt contents' }, 'server2': { 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') }, 'static': { 'static.txt': 'static.txt contents' }, 'templates': { 'private': { 'table_of_contents.html': 'table_of_contents.html contents', }, 'public': { 'apps': { 'storage.html': '<h1>storage.html</h1> contents' }, 'extensions': { 'storage.html': '<h1>storage.html</h1> contents' }, }, 'json': { 'content_providers.json': ReadFile(CONTENT_PROVIDERS), 'manifest.json': '{}', 'permissions.json': '{}', 'strings.json': '{}', 'apps_sidenav.json': '{}', 'extensions_sidenav.json': '{}', }, } } } updates = [] def app_yaml_update(version): return MoveTo(SERVER2, { 'app.yaml': AppYamlHelper.GenerateAppYaml(version) }) def storage_html_update(update): return MoveTo(PUBLIC_TEMPLATES, { 'apps': {'storage.html': update} }) def static_txt_update(update): return MoveTo(STATIC_DOCS, { 'static.txt': update }) storage_html_path = '%s/apps/storage.html' % PUBLIC_TEMPLATES static_txt_path = '%s/static.txt' % STATIC_DOCS def create_file_system(revision=None): '''Creates a MockFileSystem at |revision| by applying that many |updates| to it. ''' mock_file_system = MockFileSystem( TestFileSystem(test_data, relative_to=EXTENSIONS)) updates_for_revision = ( updates if revision is None else updates[:int(revision)]) for update in updates_for_revision: mock_file_system.Update(update) return mock_file_system delegate = _TestDelegate(create_file_system) delegate.SetAppVersion('2-0-8') file_systems = delegate.file_systems # No updates applied yet. CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>storage.html</h1> contents', file_systems[-1].ReadSingle(storage_html_path).Get()) # Apply updates to storage.html. updates.append(storage_html_update('interim contents')) updates.append(storage_html_update('<h1>new</h1> contents')) CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>new</h1> contents', file_systems[-1].ReadSingle(storage_html_path).Get()) # Apply several updates to storage.html and app.yaml. The file system # should be pinned at the version before app.yaml changed. updates.append(storage_html_update('<h1>stuck here</h1> contents')) double_update = storage_html_update('<h1>newer</h1> contents') double_update.update(app_yaml_update('2-0-10')) updates.append(double_update) updates.append(storage_html_update('never gonna reach here')) CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>stuck here</h1> contents', file_systems[-1].ReadSingle(storage_html_path).Get()) # Further pushes to storage.html will keep it pinned. updates.append(storage_html_update('<h1>y</h1> u not update!')) CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>stuck here</h1> contents', file_systems[-1].ReadSingle(storage_html_path).Get()) # Likewise app.yaml. updates.append(app_yaml_update('2-1-0')) CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>stuck here</h1> contents', file_systems[-1].ReadSingle(storage_html_path).Get()) # And updates to other content won't happen either. updates.append(static_txt_update('important content!')) CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>stuck here</h1> contents', file_systems[-1].ReadSingle(storage_html_path).Get()) self.assertEqual('static.txt contents', file_systems[-1].ReadSingle(static_txt_path).Get()) # Lastly - when the app version changes, everything should no longer be # pinned. delegate.SetAppVersion('2-1-0') CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), file_systems[-1].ReadSingle(APP_YAML).Get()) self.assertEqual('<h1>y</h1> u not update!', file_systems[-1].ReadSingle(storage_html_path).Get()) self.assertEqual('important content!', file_systems[-1].ReadSingle(static_txt_path).Get()) if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 504, 1145, 3908, 63, 21148, 492, 2372, 2640, 3353, 199, 504, 1145, 63, 5963, 63, 3676, 492, 4693, 57, 3935, 4433, 199, 504, 19818, 63, 7297, 2723, 492, 445, 2641, 1505, 86, 2723, 199, 504, 2701, 63, 694, 63, 493, 63, 2253, 492, 9630, 3567, 17521, 199, 504, 5478, 63, 3771, 492, 334, 272, 19525, 63, 23103, 12, 29417, 63, 21403, 3960, 12, 20203, 17427, 12, 21755, 63, 25437, 12, 23578, 18, 12, 272, 27815, 63, 30072, 9, 199, 504, 12869, 63, 493, 63, 2253, 63, 3780, 492, 598, 4049, 17521, 6663, 199, 504, 1591, 63, 493, 63, 2253, 63, 3780, 492, 10891, 17521, 6663, 199, 504, 2257, 63, 493, 63, 2253, 492, 10111, 17521, 199, 504, 1683, 63, 493, 63, 2253, 492, 4420, 17521, 199, 504, 27415, 2723, 492, 4784, 199, 504, 511, 63, 4694, 63, 16877, 492, 1379, 12526, 17505, 199, 504, 511, 63, 493, 63, 2253, 492, 14171, 1378, 12, 1379, 17521, 199, 504, 511, 63, 1974, 492, 12030, 14054, 12, 5574, 1173, 421, 199, 3, 6944, 8, 26446, 1237, 304, 710, 6935, 5502, 2737, 701, 314, 445, 2641, 1505, 86, 2723, 365, 1771, 379, 14602, 4154, 199, 3, 4026, 4693, 8524, 21598, 15, 11450, 12, 880, 314, 2295, 10621, 1133, 23348, 14, 24545, 2518, 12, 199, 3, 340, 314, 1591, 570, 10460, 1172, 3365, 6120, 5080, 12, 2985, 911, 506, 12, 4069, 402, 14, 199, 533, 485, 774, 21553, 8, 35, 2641, 1505, 86, 2723, 14, 21553, 304, 523, 347, 636, 826, 721, 277, 12, 1218, 63, 493, 63, 2253, 304, 272, 291, 14, 493, 63, 19135, 275, 942, 272, 327, 437, 3233, 16466, 282, 6974, 436, 8152, 282, 570, 2656, 14, 272, 291, 423, 981, 63, 493, 63, 2253, 275, 1218, 63, 493, 63, 2253, 272, 291, 423, 571, 63, 1023, 275, 2372, 2640, 3353, 342, 819, 347, 2790, 12526, 17505, 8, 277, 12, 909, 63, 1617, 63, 9986, 304, 272, 372, 1379, 12526, 17505, 14, 2499, 3007, 35, 9386, 1451, 342, 819, 347, 2790, 4965, 17521, 6663, 8, 277, 12, 3303, 909, 63, 1617, 63, 9986, 12, 3303, 1390, 63, 13409, 63, 5792, 29, 403, 304, 272, 347, 3787, 8, 4694, 29, 403, 12, 6974, 29, 403, 304, 489, 570, 63, 2253, 275, 291, 423, 981, 63, 493, 63, 2253, 8, 5792, 9, 489, 291, 14, 493, 63, 19135, 14, 740, 8, 493, 63, 2253, 9, 489, 372, 570, 63, 2253, 272, 372, 10891, 17521, 6663, 8, 785, 63, 1617, 63, 9986, 12, 3303, 1390, 63, 13409, 63, 5792, 29, 988, 63, 13409, 63, 5792, 12, 3303, 3787, 63, 509, 63, 396, 29, 1880, 9, 819, 347, 2790, 14772, 17521, 6663, 8, 277, 12, 909, 63, 1617, 63, 9986, 304, 272, 372, 598, 4049, 17521, 6663, 14, 1858, 4699, 342, 819, 347, 2372, 2640, 3353, 8, 277, 304, 272, 372, 291, 423, 571, 63, 1023, 819, 327, 334, 2865, 13, 21553, 1083, 680, 523, 347, 2494, 2640, 3353, 8, 277, 12, 1145, 63, 1023, 304, 272, 291, 423, 571, 63, 1023, 275, 1145, 63, 1023, 199, 199, 533, 445, 2641, 1505, 86, 2723, 774, 8, 2796, 14, 1746, 304, 523, 768, 6476, 14054, 360, 815, 358, 523, 347, 511, 24527, 2127, 8, 277, 304, 272, 327, 2900, 3520, 2295, 787, 11410, 334, 3239, 3432, 3721, 9, 880, 634, 1220, 8137, 315, 272, 327, 314, 1373, 511, 14, 272, 13080, 275, 485, 774, 21553, 8, 2734, 24700, 4420, 17521, 8, 5339, 17521, 14, 2499, 4059, 339, 327, 1379, 626, 314, 19818, 7858, 8792, 14, 272, 1177, 275, 445, 2641, 1505, 86, 2723, 8, 2017, 14, 1858, 774, 360, 13409, 659, 2574, 13080, 63, 509, 63, 396, 29, 15286, 680, 1002, 342, 272, 291, 14, 629, 8, 1840, 12, 1177, 14, 1205, 9, 339, 327, 11063, 314, 570, 10460, 2737, 12, 1343, 543, 282, 17480, 663, 367, 314, 2163, 1255, 14, 272, 1642, 63, 1065, 63, 493, 63, 19135, 275, 13080, 14, 493, 63, 19135, 5873, 272, 13080, 14, 493, 63, 19135, 5873, 275, 942, 339, 327, 3979, 295, 13, 5720, 12, 1006, 570, 10460, 1077, 506, 27673, 342, 68, 314, 2011, 1329, 402, 272, 327, 5431, 12, 1325, 314, 3499, 6168, 9296, 1133, 1172, 2757, 295, 13, 3284, 342, 3967, 314, 272, 327, 29062, 19051, 1133, 2896, 14, 272, 1177, 275, 445, 2641, 1505, 86, 2723, 8, 2017, 14, 1858, 774, 360, 13409, 659, 2574, 13080, 63, 509, 63, 396, 29, 15286, 680, 1002, 342, 272, 291, 14, 629, 8, 1840, 12, 1177, 14, 1205, 9, 339, 291, 14, 629, 8, 552, 8, 2246, 63, 1065, 63, 493, 63, 19135, 395, 822, 8, 15286, 14, 493, 63, 19135, 430, 272, 367, 284, 12, 3499, 63, 1065, 63, 493, 63, 2253, 315, 3874, 8, 15286, 14, 493, 63, 19135, 304, 489, 291, 14, 1815, 2031, 4375, 63, 1065, 63, 493, 63, 2253, 14, 1799, 3325, 9637, 8, 881, 1586, 63, 835, 29, 16, 12, 881, 5672, 63, 835, 29, 2246, 63, 1065, 63, 493, 63, 19135, 59, 73, 1055, 1002, 11232, 2353, 4059, 819, 347, 511, 11090, 12714, 8, 277, 304, 272, 511, 63, 576, 275, 469, 489, 283, 1246, 356, 469, 267, 2513, 1246, 63, 3179, 14, 1001, 356, 9005, 297, 267, 2513, 6418, 63, 3179, 14, 1001, 356, 9005, 297, 267, 2513, 5693, 63, 3179, 14, 1001, 356, 9005, 297, 489, 1660, 489, 283, 4757, 356, 469, 267, 283, 8589, 356, 469, 881, 283, 8589, 14, 2424, 356, 283, 8589, 14, 2424, 4072, 7, 267, 1660, 267, 283, 1000, 18, 356, 469, 881, 283, 571, 14, 5963, 356, 4693, 57, 3935, 4433, 14, 6864, 2640, 57, 3935, 360, 18, 13, 16, 13, 24, 358, 267, 1660, 267, 283, 1986, 356, 469, 881, 283, 1986, 14, 2424, 356, 283, 1986, 14, 2424, 4072, 7, 267, 1660, 267, 283, 5876, 356, 469, 881, 283, 4239, 356, 469, 288, 283, 1224, 63, 1618, 63, 4407, 14, 1360, 356, 283, 1224 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2882, 199, 199, 504, 1145, 3908, 63, 21148, 492, 2372, 2640, 3353, 199, 504, 1145, 63, 5963, 63, 3676, 492, 4693, 57, 3935, 4433, 199, 504, 19818, 63, 7297, 2723, 492, 445, 2641, 1505, 86, 2723, 199, 504, 2701, 63, 694, 63, 493, 63, 2253, 492, 9630, 3567, 17521, 199, 504, 5478, 63, 3771, 492, 334, 272, 19525, 63, 23103, 12, 29417, 63, 21403, 3960, 12, 20203, 17427, 12, 21755, 63, 25437, 12, 23578, 18, 12, 272, 27815, 63, 30072, 9, 199, 504, 12869, 63, 493, 63, 2253, 63, 3780, 492, 598, 4049, 17521, 6663, 199, 504, 1591, 63, 493, 63, 2253, 63, 3780, 492, 10891, 17521, 6663, 199, 504, 2257, 63, 493, 63, 2253, 492, 10111, 17521, 199, 504, 1683, 63, 493, 63, 2253, 492, 4420, 17521, 199, 504, 27415, 2723, 492, 4784, 199, 504, 511, 63, 4694, 63, 16877, 492, 1379, 12526, 17505, 199, 504, 511, 63, 493, 63, 2253, 492, 14171, 1378, 12, 1379, 17521, 199, 504, 511, 63, 1974, 492, 12030, 14054, 12, 5574, 1173, 421, 199, 3, 6944, 8, 26446, 1237, 304, 710, 6935, 5502, 2737, 701, 314, 445, 2641, 1505, 86, 2723, 365, 1771, 379, 14602, 4154, 199, 3, 4026, 4693, 8524, 21598, 15, 11450, 12, 880, 314, 2295, 10621, 1133, 23348, 14, 24545, 2518, 12, 199, 3, 340, 314, 1591, 570, 10460, 1172, 3365, 6120, 5080, 12, 2985, 911, 506, 12, 4069, 402, 14, 199, 533, 485, 774, 21553, 8, 35, 2641, 1505, 86, 2723, 14, 21553, 304, 523, 347, 636, 826, 721, 277, 12, 1218, 63, 493, 63, 2253, 304, 272, 291, 14, 493, 63, 19135, 275, 942, 272, 327, 437, 3233, 16466, 282, 6974, 436, 8152, 282, 570, 2656, 14, 272, 291, 423, 981, 63, 493, 63, 2253, 275, 1218, 63, 493, 63, 2253, 272, 291, 423, 571, 63, 1023, 275, 2372, 2640, 3353, 342, 819, 347, 2790, 12526, 17505, 8, 277, 12, 909, 63, 1617, 63, 9986, 304, 272, 372, 1379, 12526, 17505, 14, 2499, 3007, 35, 9386, 1451, 342, 819, 347, 2790, 4965, 17521, 6663, 8, 277, 12, 3303, 909, 63, 1617, 63, 9986, 12, 3303, 1390, 63, 13409, 63, 5792, 29, 403, 304, 272, 347, 3787, 8, 4694, 29, 403, 12, 6974, 29, 403, 304, 489, 570, 63, 2253, 275, 291, 423, 981, 63, 493, 63, 2253, 8, 5792, 9, 489, 291, 14, 493, 63, 19135, 14, 740, 8, 493, 63, 2253, 9, 489, 372, 570, 63, 2253, 272, 372, 10891, 17521, 6663, 8, 785, 63, 1617, 63, 9986, 12, 3303, 1390, 63, 13409, 63, 5792, 29, 988, 63, 13409, 63, 5792, 12, 3303, 3787, 63, 509, 63, 396, 29, 1880, 9, 819, 347, 2790, 14772, 17521, 6663, 8, 277, 12, 909, 63, 1617, 63, 9986, 304, 272, 372, 598, 4049, 17521, 6663, 14, 1858, 4699, 342, 819, 347, 2372, 2640, 3353, 8, 277, 304, 272, 372, 291, 423, 571, 63, 1023, 819, 327, 334, 2865, 13, 21553, 1083, 680, 523, 347, 2494, 2640, 3353, 8, 277, 12, 1145, 63, 1023, 304, 272, 291, 423, 571, 63, 1023, 275, 1145, 63, 1023, 199, 199, 533, 445, 2641, 1505, 86, 2723, 774, 8, 2796, 14, 1746, 304, 523, 768, 6476, 14054, 360, 815, 358, 523, 347, 511, 24527, 2127, 8, 277, 304, 272, 327, 2900, 3520, 2295, 787, 11410, 334, 3239, 3432, 3721, 9, 880, 634, 1220, 8137, 315, 272, 327, 314, 1373, 511, 14, 272, 13080, 275, 485, 774, 21553, 8, 2734, 24700, 4420, 17521, 8, 5339, 17521, 14, 2499, 4059, 339, 327, 1379, 626, 314, 19818, 7858, 8792, 14, 272, 1177, 275, 445, 2641, 1505, 86, 2723, 8, 2017, 14, 1858, 774, 360, 13409, 659, 2574, 13080, 63, 509, 63, 396, 29, 15286, 680, 1002, 342, 272, 291, 14, 629, 8, 1840, 12, 1177, 14, 1205, 9, 339, 327, 11063, 314, 570, 10460, 2737, 12, 1343, 543, 282, 17480, 663, 367, 314, 2163, 1255, 14, 272, 1642, 63, 1065, 63, 493, 63, 19135, 275, 13080, 14, 493, 63, 19135, 5873, 272, 13080, 14, 493, 63, 19135, 5873, 275, 942, 339, 327, 3979, 295, 13, 5720, 12, 1006, 570, 10460, 1077, 506, 27673, 342, 68, 314, 2011, 1329, 402, 272, 327, 5431, 12, 1325, 314, 3499, 6168, 9296, 1133, 1172, 2757, 295, 13, 3284, 342, 3967, 314, 272, 327, 29062, 19051, 1133, 2896, 14, 272, 1177, 275, 445, 2641, 1505, 86, 2723, 8, 2017, 14, 1858, 774, 360, 13409, 659, 2574, 13080, 63, 509, 63, 396, 29, 15286, 680, 1002, 342, 272, 291, 14, 629, 8, 1840, 12, 1177, 14, 1205, 9, 339, 291, 14, 629, 8, 552, 8, 2246, 63, 1065, 63, 493, 63, 19135, 395, 822, 8, 15286, 14, 493, 63, 19135, 430, 272, 367, 284, 12, 3499, 63, 1065, 63, 493, 63, 2253, 315, 3874, 8, 15286, 14, 493, 63, 19135, 304, 489, 291, 14, 1815, 2031, 4375, 63, 1065, 63, 493, 63, 2253, 14, 1799, 3325, 9637, 8, 881, 1586, 63, 835, 29, 16, 12, 881, 5672, 63, 835, 29, 2246, 63, 1065, 63, 493, 63, 19135, 59, 73, 1055, 1002, 11232, 2353, 4059, 819, 347, 511, 11090, 12714, 8, 277, 304, 272, 511, 63, 576, 275, 469, 489, 283, 1246, 356, 469, 267, 2513, 1246, 63, 3179, 14, 1001, 356, 9005, 297, 267, 2513, 6418, 63, 3179, 14, 1001, 356, 9005, 297, 267, 2513, 5693, 63, 3179, 14, 1001, 356, 9005, 297, 489, 1660, 489, 283, 4757, 356, 469, 267, 283, 8589, 356, 469, 881, 283, 8589, 14, 2424, 356, 283, 8589, 14, 2424, 4072, 7, 267, 1660, 267, 283, 1000, 18, 356, 469, 881, 283, 571, 14, 5963, 356, 4693, 57, 3935, 4433, 14, 6864, 2640, 57, 3935, 360, 18, 13, 16, 13, 24, 358, 267, 1660, 267, 283, 1986, 356, 469, 881, 283, 1986, 14, 2424, 356, 283, 1986, 14, 2424, 4072, 7, 267, 1660, 267, 283, 5876, 356, 469, 881, 283, 4239, 356, 469, 288, 283, 1224, 63, 1618, 63, 4407, 14, 1360, 356, 283, 1224, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MSOpenTech/python-social-auth
social/apps/flask_app/routes.py
36
1507
from flask import g, Blueprint, request from flask.ext.login import login_required, login_user from social.actions import do_auth, do_complete, do_disconnect from social.apps.flask_app.utils import psa social_auth = Blueprint('social', __name__) @social_auth.route('/login/<string:backend>/', methods=('GET', 'POST')) @psa('social.complete') def auth(backend): return do_auth(g.backend) @social_auth.route('/complete/<string:backend>/', methods=('GET', 'POST')) @psa('social.complete') def complete(backend, *args, **kwargs): """Authentication complete view, override this view if transaction management doesn't suit your needs.""" return do_complete(g.backend, login=do_login, user=g.user, *args, **kwargs) @social_auth.route('/disconnect/<string:backend>/', methods=('POST',)) @social_auth.route('/disconnect/<string:backend>/<int:association_id>/', methods=('POST',)) @social_auth.route('/disconnect/<string:backend>/<string:association_id>/', methods=('POST',)) @login_required @psa() def disconnect(backend, association_id=None): """Disconnects given backend from current logged in user.""" return do_disconnect(g.backend, g.user, association_id) def do_login(backend, user, social_user): return login_user(user, remember=request.cookies.get('remember') or request.args.get('remember') or request.form.get('remember') or False)
bsd-3-clause
[ 504, 7209, 492, 486, 12, 22447, 1361, 12, 1056, 199, 504, 7209, 14, 832, 14, 2886, 492, 4676, 63, 2427, 12, 4676, 63, 751, 199, 199, 504, 20295, 14, 3723, 492, 886, 63, 1178, 12, 886, 63, 4883, 12, 886, 63, 10673, 199, 504, 20295, 14, 5181, 14, 15720, 63, 571, 14, 1208, 492, 299, 2231, 421, 199, 13574, 63, 1178, 275, 22447, 1361, 360, 13574, 297, 636, 354, 3368, 421, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 2886, 8316, 875, 26, 4620, 30, 3678, 3102, 7782, 2970, 297, 283, 4030, 1333, 199, 32, 1190, 65, 360, 13574, 14, 4883, 358, 199, 318, 1790, 8, 4620, 304, 272, 372, 886, 63, 1178, 8, 71, 14, 4620, 9, 421, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 4883, 8316, 875, 26, 4620, 30, 3678, 3102, 7782, 2970, 297, 283, 4030, 1333, 199, 32, 1190, 65, 360, 13574, 14, 4883, 358, 199, 318, 4890, 8, 4620, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 10348, 4890, 2455, 12, 4278, 642, 2455, 340, 6008, 272, 10041, 3181, 1133, 308, 4993, 2195, 4839, 1041, 272, 372, 886, 63, 4883, 8, 71, 14, 4620, 12, 4676, 29, 1117, 63, 2886, 12, 922, 29, 71, 14, 751, 12, 2432, 627, 589, 12, 1011, 958, 9, 421, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 10673, 8316, 875, 26, 4620, 30, 3678, 3102, 7782, 4030, 16829, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 10673, 8316, 875, 26, 4620, 23220, 442, 26, 20252, 63, 344, 30, 3678, 673, 3102, 7782, 4030, 16829, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 10673, 8316, 875, 26, 4620, 23220, 875, 26, 20252, 63, 344, 30, 3678, 673, 3102, 7782, 4030, 16829, 199, 32, 2886, 63, 2427, 199, 32, 1190, 65, 342, 199, 318, 17639, 8, 4620, 12, 20640, 63, 344, 29, 403, 304, 272, 408, 16761, 83, 1627, 4865, 687, 1453, 10367, 315, 922, 1041, 272, 372, 886, 63, 10673, 8, 71, 14, 4620, 12, 486, 14, 751, 12, 20640, 63, 344, 9, 421, 199, 318, 886, 63, 2886, 8, 4620, 12, 922, 12, 20295, 63, 751, 304, 272, 372, 4676, 63, 751, 8, 751, 12, 21027, 29, 1069, 14, 7792, 14, 362, 360, 264, 1114, 358, 503, 3660, 1056, 14, 589, 14, 362, 360, 264, 1114, 358, 503, 3660, 1056, 14, 964, 14, 362, 360, 264, 1114, 358, 503, 756, 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 ]
[ 7209, 492, 486, 12, 22447, 1361, 12, 1056, 199, 504, 7209, 14, 832, 14, 2886, 492, 4676, 63, 2427, 12, 4676, 63, 751, 199, 199, 504, 20295, 14, 3723, 492, 886, 63, 1178, 12, 886, 63, 4883, 12, 886, 63, 10673, 199, 504, 20295, 14, 5181, 14, 15720, 63, 571, 14, 1208, 492, 299, 2231, 421, 199, 13574, 63, 1178, 275, 22447, 1361, 360, 13574, 297, 636, 354, 3368, 421, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 2886, 8316, 875, 26, 4620, 30, 3678, 3102, 7782, 2970, 297, 283, 4030, 1333, 199, 32, 1190, 65, 360, 13574, 14, 4883, 358, 199, 318, 1790, 8, 4620, 304, 272, 372, 886, 63, 1178, 8, 71, 14, 4620, 9, 421, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 4883, 8316, 875, 26, 4620, 30, 3678, 3102, 7782, 2970, 297, 283, 4030, 1333, 199, 32, 1190, 65, 360, 13574, 14, 4883, 358, 199, 318, 4890, 8, 4620, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 10348, 4890, 2455, 12, 4278, 642, 2455, 340, 6008, 272, 10041, 3181, 1133, 308, 4993, 2195, 4839, 1041, 272, 372, 886, 63, 4883, 8, 71, 14, 4620, 12, 4676, 29, 1117, 63, 2886, 12, 922, 29, 71, 14, 751, 12, 2432, 627, 589, 12, 1011, 958, 9, 421, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 10673, 8316, 875, 26, 4620, 30, 3678, 3102, 7782, 4030, 16829, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 10673, 8316, 875, 26, 4620, 23220, 442, 26, 20252, 63, 344, 30, 3678, 673, 3102, 7782, 4030, 16829, 199, 32, 13574, 63, 1178, 14, 4449, 2336, 10673, 8316, 875, 26, 4620, 23220, 875, 26, 20252, 63, 344, 30, 3678, 673, 3102, 7782, 4030, 16829, 199, 32, 2886, 63, 2427, 199, 32, 1190, 65, 342, 199, 318, 17639, 8, 4620, 12, 20640, 63, 344, 29, 403, 304, 272, 408, 16761, 83, 1627, 4865, 687, 1453, 10367, 315, 922, 1041, 272, 372, 886, 63, 10673, 8, 71, 14, 4620, 12, 486, 14, 751, 12, 20640, 63, 344, 9, 421, 199, 318, 886, 63, 2886, 8, 4620, 12, 922, 12, 20295, 63, 751, 304, 272, 372, 4676, 63, 751, 8, 751, 12, 21027, 29, 1069, 14, 7792, 14, 362, 360, 264, 1114, 358, 503, 3660, 1056, 14, 589, 14, 362, 360, 264, 1114, 358, 503, 3660, 1056, 14, 964, 14, 362, 360, 264, 1114, 358, 503, 756, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xpol/gyp
test/ninja/action_dependencies/gyptest-action-dependencies.py
34
2086
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Verify that building an object file correctly depends on running actions in dependent targets, but not the targets themselves. """ import os import sys if sys.platform == 'win32': print "This test is currently disabled: https://crbug.com/483696." sys.exit(0) import TestGyp # NOTE(piman): This test will not work with other generators because: # - it explicitly tests the optimization, which is not implemented (yet?) on # other generators # - it relies on the exact path to output object files, which is generator # dependent, and actually, relies on the ability to build only that object file, # which I don't think is available on all generators. # TODO(piman): Extend to other generators when possible. test = TestGyp.TestGyp(formats=['ninja']) # xcode-ninja doesn't support building single object files by design. if test.format == 'xcode-ninja': test.skip_test() test.run_gyp('action_dependencies.gyp', chdir='src') chdir = 'relocate/src' test.relocate('src', chdir) objext = '.obj' if sys.platform == 'win32' else '.o' test.build('action_dependencies.gyp', os.path.join('obj', 'b.b' + objext), chdir=chdir) # The 'a' actions should be run (letting b.c compile), but the a static library # should not be built. test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir) test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir) test.built_file_must_exist(os.path.join('obj', 'b.b' + objext), chdir=chdir) test.build('action_dependencies.gyp', os.path.join('obj', 'c.c' + objext), chdir=chdir) # 'a' and 'b' should be built, so that the 'c' action succeeds, letting c.c # compile test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir) test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir) test.built_file_must_exist(os.path.join('obj', 'c.c' + objext), chdir=chdir) test.pass_test()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 7496, 626, 10015, 376, 909, 570, 6657, 8350, 641, 3879, 5445, 315, 199, 7106, 4545, 12, 1325, 440, 314, 4545, 17279, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 523, 870, 298, 2765, 511, 365, 5544, 6980, 26, 4178, 921, 1556, 1266, 14, 957, 15, 2006, 1344, 2534, 2122, 523, 984, 14, 2224, 8, 16, 9, 421, 199, 646, 25688, 199, 199, 3, 6944, 8, 80, 1017, 290, 304, 961, 511, 911, 440, 1736, 543, 1163, 16952, 2952, 26, 199, 3, 446, 652, 7662, 2295, 314, 13712, 12, 1314, 365, 440, 6366, 334, 28064, 17076, 641, 199, 3, 1163, 16952, 199, 3, 446, 652, 25749, 641, 314, 5835, 931, 370, 1072, 909, 1584, 12, 1314, 365, 4306, 199, 3, 11410, 12, 436, 5965, 12, 25749, 641, 314, 21255, 370, 1900, 1454, 626, 909, 570, 12, 199, 3, 1314, 473, 2793, 1133, 13516, 365, 2808, 641, 1006, 16952, 14, 199, 3, 3254, 8, 80, 1017, 290, 304, 1316, 7169, 370, 1163, 16952, 1380, 3962, 14, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8675, 1105, 199, 3, 13592, 13, 8675, 3181, 1133, 2291, 10015, 2849, 909, 1584, 701, 12899, 14, 199, 692, 511, 14, 908, 508, 283, 8701, 13, 8675, 356, 523, 511, 14, 2759, 63, 396, 342, 199, 199, 396, 14, 1065, 63, 6179, 360, 1287, 63, 5714, 14, 6179, 297, 13097, 534, 2164, 358, 199, 199, 8563, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 18919, 360, 2164, 297, 13097, 9, 199, 199, 1113, 832, 275, 1987, 1113, 7, 340, 984, 14, 3246, 508, 283, 2676, 708, 7, 587, 1987, 79, 7, 199, 199, 396, 14, 1506, 360, 1287, 63, 5714, 14, 6179, 297, 1779, 747, 14, 515, 14, 904, 360, 1113, 297, 283, 66, 14, 66, 7, 435, 1559, 832, 395, 1779, 13097, 29, 8563, 9, 199, 199, 3, 710, 283, 65, 7, 5445, 1077, 506, 1255, 334, 2723, 1337, 330, 14, 67, 6555, 395, 1325, 314, 282, 2955, 3555, 199, 3, 1077, 440, 506, 6137, 14, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 1397, 63, 4494, 360, 65, 297, 730, 29, 396, 14, 10449, 63, 5617, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 1397, 63, 4494, 360, 66, 297, 730, 29, 396, 14, 10449, 63, 5617, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 736, 14, 515, 14, 904, 360, 1113, 297, 283, 66, 14, 66, 7, 435, 1559, 832, 395, 13097, 29, 8563, 9, 199, 199, 396, 14, 1506, 360, 1287, 63, 5714, 14, 6179, 297, 1779, 747, 14, 515, 14, 904, 360, 1113, 297, 283, 67, 14, 67, 7, 435, 1559, 832, 395, 1779, 13097, 29, 8563, 9, 199, 199, 3, 283, 65, 7, 436, 283, 66, 7, 1077, 506, 6137, 12, 880, 626, 314, 283, 67, 7, 1595, 24611, 12, 4691, 1337, 286, 14, 67, 199, 3, 6555, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 65, 297, 730, 29, 396, 14, 10449, 63, 5617, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 66, 297, 730, 29, 396, 14, 21623, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 736, 14, 515, 14, 904, 360, 1113, 297, 283, 67, 14, 67, 7, 435, 1559, 832, 395, 13097, 29, 8563, 9, 421, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 7496, 626, 10015, 376, 909, 570, 6657, 8350, 641, 3879, 5445, 315, 199, 7106, 4545, 12, 1325, 440, 314, 4545, 17279, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 523, 870, 298, 2765, 511, 365, 5544, 6980, 26, 4178, 921, 1556, 1266, 14, 957, 15, 2006, 1344, 2534, 2122, 523, 984, 14, 2224, 8, 16, 9, 421, 199, 646, 25688, 199, 199, 3, 6944, 8, 80, 1017, 290, 304, 961, 511, 911, 440, 1736, 543, 1163, 16952, 2952, 26, 199, 3, 446, 652, 7662, 2295, 314, 13712, 12, 1314, 365, 440, 6366, 334, 28064, 17076, 641, 199, 3, 1163, 16952, 199, 3, 446, 652, 25749, 641, 314, 5835, 931, 370, 1072, 909, 1584, 12, 1314, 365, 4306, 199, 3, 11410, 12, 436, 5965, 12, 25749, 641, 314, 21255, 370, 1900, 1454, 626, 909, 570, 12, 199, 3, 1314, 473, 2793, 1133, 13516, 365, 2808, 641, 1006, 16952, 14, 199, 3, 3254, 8, 80, 1017, 290, 304, 1316, 7169, 370, 1163, 16952, 1380, 3962, 14, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8675, 1105, 199, 3, 13592, 13, 8675, 3181, 1133, 2291, 10015, 2849, 909, 1584, 701, 12899, 14, 199, 692, 511, 14, 908, 508, 283, 8701, 13, 8675, 356, 523, 511, 14, 2759, 63, 396, 342, 199, 199, 396, 14, 1065, 63, 6179, 360, 1287, 63, 5714, 14, 6179, 297, 13097, 534, 2164, 358, 199, 199, 8563, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 18919, 360, 2164, 297, 13097, 9, 199, 199, 1113, 832, 275, 1987, 1113, 7, 340, 984, 14, 3246, 508, 283, 2676, 708, 7, 587, 1987, 79, 7, 199, 199, 396, 14, 1506, 360, 1287, 63, 5714, 14, 6179, 297, 1779, 747, 14, 515, 14, 904, 360, 1113, 297, 283, 66, 14, 66, 7, 435, 1559, 832, 395, 1779, 13097, 29, 8563, 9, 199, 199, 3, 710, 283, 65, 7, 5445, 1077, 506, 1255, 334, 2723, 1337, 330, 14, 67, 6555, 395, 1325, 314, 282, 2955, 3555, 199, 3, 1077, 440, 506, 6137, 14, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 1397, 63, 4494, 360, 65, 297, 730, 29, 396, 14, 10449, 63, 5617, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 1397, 63, 4494, 360, 66, 297, 730, 29, 396, 14, 10449, 63, 5617, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 736, 14, 515, 14, 904, 360, 1113, 297, 283, 66, 14, 66, 7, 435, 1559, 832, 395, 13097, 29, 8563, 9, 199, 199, 396, 14, 1506, 360, 1287, 63, 5714, 14, 6179, 297, 1779, 747, 14, 515, 14, 904, 360, 1113, 297, 283, 67, 14, 67, 7, 435, 1559, 832, 395, 1779, 13097, 29, 8563, 9, 199, 199, 3, 283, 65, 7, 436, 283, 66, 7, 1077, 506, 6137, 12, 880, 626, 314, 283, 67, 7, 1595, 24611, 12, 4691, 1337, 286, 14, 67, 199, 3, 6555, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 65, 297, 730, 29, 396, 14, 10449, 63, 5617, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 66, 297, 730, 29, 396, 14, 21623, 12, 13097, 29, 8563, 9, 199, 396, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 736, 14, 515, 14, 904, 360, 1113, 297, 283, 67, 14, 67, 7, 435, 1559, 832, 395, 13097, 29, 8563, 9, 421, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
newvem/pytz
pytz/zoneinfo/America/Indiana/Vincennes.py
9
4532
'''tzinfo timezone information for America/Indiana/Vincennes.''' from pytz.tzinfo import DstTzInfo from pytz.tzinfo import memorized_datetime as d from pytz.tzinfo import memorized_ttinfo as i class Vincennes(DstTzInfo): '''America/Indiana/Vincennes timezone definition. See datetime.tzinfo for details''' zone = 'America/Indiana/Vincennes' _utc_transition_times = [ d(1,1,1,0,0,0), d(1918,3,31,8,0,0), d(1918,10,27,7,0,0), d(1919,3,30,8,0,0), d(1919,10,26,7,0,0), d(1942,2,9,8,0,0), d(1945,8,14,23,0,0), d(1945,9,30,7,0,0), d(1946,4,28,8,0,0), d(1946,9,29,7,0,0), d(1953,4,26,8,0,0), d(1953,9,27,7,0,0), d(1954,4,25,8,0,0), d(1954,9,26,7,0,0), d(1955,5,1,6,0,0), d(1955,9,25,7,0,0), d(1956,4,29,8,0,0), d(1956,9,30,7,0,0), d(1957,4,28,8,0,0), d(1957,9,29,7,0,0), d(1958,4,27,8,0,0), d(1958,9,28,7,0,0), d(1959,4,26,8,0,0), d(1959,9,27,7,0,0), d(1960,4,24,8,0,0), d(1960,10,30,7,0,0), d(1961,4,30,8,0,0), d(1961,9,24,7,0,0), d(1962,4,29,8,0,0), d(1962,10,28,7,0,0), d(1963,4,28,8,0,0), d(1963,10,27,7,0,0), d(1964,4,26,8,0,0), d(1969,4,27,7,0,0), d(1969,10,26,6,0,0), d(1970,4,26,7,0,0), d(1970,10,25,6,0,0), d(2006,4,2,7,0,0), d(2006,10,29,7,0,0), d(2007,3,11,8,0,0), d(2007,11,4,7,0,0), d(2008,3,9,8,0,0), d(2008,11,2,7,0,0), d(2009,3,8,8,0,0), d(2009,11,1,7,0,0), d(2010,3,14,8,0,0), d(2010,11,7,7,0,0), d(2011,3,13,8,0,0), d(2011,11,6,7,0,0), d(2012,3,11,8,0,0), d(2012,11,4,7,0,0), d(2013,3,10,8,0,0), d(2013,11,3,7,0,0), d(2014,3,9,8,0,0), d(2014,11,2,7,0,0), d(2015,3,8,8,0,0), d(2015,11,1,7,0,0), d(2016,3,13,8,0,0), d(2016,11,6,7,0,0), d(2017,3,12,8,0,0), d(2017,11,5,7,0,0), d(2018,3,11,8,0,0), d(2018,11,4,7,0,0), d(2019,3,10,8,0,0), d(2019,11,3,7,0,0), d(2020,3,8,8,0,0), d(2020,11,1,7,0,0), d(2021,3,14,8,0,0), d(2021,11,7,7,0,0), d(2022,3,13,8,0,0), d(2022,11,6,7,0,0), d(2023,3,12,8,0,0), d(2023,11,5,7,0,0), d(2024,3,10,8,0,0), d(2024,11,3,7,0,0), d(2025,3,9,8,0,0), d(2025,11,2,7,0,0), d(2026,3,8,8,0,0), d(2026,11,1,7,0,0), d(2027,3,14,8,0,0), d(2027,11,7,7,0,0), d(2028,3,12,8,0,0), d(2028,11,5,7,0,0), d(2029,3,11,8,0,0), d(2029,11,4,7,0,0), d(2030,3,10,8,0,0), d(2030,11,3,7,0,0), d(2031,3,9,8,0,0), d(2031,11,2,7,0,0), d(2032,3,14,8,0,0), d(2032,11,7,7,0,0), d(2033,3,13,8,0,0), d(2033,11,6,7,0,0), d(2034,3,12,8,0,0), d(2034,11,5,7,0,0), d(2035,3,11,8,0,0), d(2035,11,4,7,0,0), d(2036,3,9,8,0,0), d(2036,11,2,7,0,0), d(2037,3,8,8,0,0), d(2037,11,1,7,0,0), ] _transition_info = [ i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CWT'), i(-18000,3600,'CPT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,0,'EST'), i(-14400,3600,'EDT'), i(-18000,0,'EST'), i(-14400,3600,'EDT'), i(-18000,0,'EST'), i(-18000,0,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), i(-18000,3600,'CDT'), i(-21600,0,'CST'), ] Vincennes = Vincennes()
mit
[ 2344, 9374, 7137, 2556, 367, 437, 8534, 15, 28741, 65, 15, 54, 262, 2497, 17775, 10595, 199, 504, 15444, 14, 9374, 492, 577, 270, 52, 90, 2354, 199, 504, 15444, 14, 9374, 492, 7573, 269, 1759, 63, 2083, 465, 366, 199, 504, 15444, 14, 9374, 492, 7573, 269, 1759, 63, 6215, 815, 465, 284, 199, 199, 533, 28882, 2497, 17775, 8, 31413, 52, 90, 2354, 304, 272, 1449, 8841, 15, 28741, 65, 15, 54, 262, 2497, 17775, 7137, 5492, 14, 1666, 2197, 14, 9374, 367, 2436, 2344, 339, 5718, 275, 283, 8841, 15, 28741, 65, 15, 54, 262, 2497, 17775, 7, 339, 485, 5834, 63, 14143, 63, 4508, 275, 359, 199, 68, 8, 17, 12, 17, 12, 17, 12, 16, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1085, 12, 19, 12, 2192, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1085, 12, 709, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1167, 12, 19, 12, 1216, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1167, 12, 709, 12, 1479, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2260, 12, 18, 12, 25, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2322, 12, 24, 12, 1079, 12, 1789, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2322, 12, 25, 12, 1216, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2466, 12, 20, 12, 1651, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2466, 12, 25, 12, 1398, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2481, 12, 20, 12, 1479, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2481, 12, 25, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1477, 12, 20, 12, 821, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1477, 12, 25, 12, 1479, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1229, 12, 21, 12, 17, 12, 22, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1229, 12, 25, 12, 821, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1367, 12, 20, 12, 1398, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1367, 12, 25, 12, 1216, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1641, 12, 20, 12, 1651, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1641, 12, 25, 12, 1398, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2010, 12, 20, 12, 1465, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2010, 12, 25, 12, 1651, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1427, 12, 20, 12, 1479, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1427, 12, 25, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2259, 12, 20, 12, 1194, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2259, 12, 709, 12, 1216, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2976, 12, 20, 12, 1216, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2976, 12, 25, 12, 1194, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2789, 12, 20, 12, 1398, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2789, 12, 709, 12, 1651, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2766, 12, 20, 12, 1651, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2766, 12, 709, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 772, 12, 20, 12, 1479, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1876, 12, 20, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1876, 12, 709, 12, 1479, 12, 22, 12, 16, 12, 16, 395, 199, 68, 8, 21740, 12, 20, 12, 1479, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 21740, 12, 709, 12, 821, 12, 22, 12, 16, 12, 16, 395, 199, 68, 8, 7968, 12, 20, 12, 18, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7968, 12, 709, 12, 1398, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 9488, 12, 19, 12, 845, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 9488, 12, 845, 12, 20, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 9300, 12, 19, 12, 25, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 9300, 12, 845, 12, 18, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 8664, 12, 19, 12, 24, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 8664, 12, 845, 12, 17, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 6542, 12, 19, 12, 1079, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 6542, 12, 845, 12, 23, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 8128, 12, 19, 12, 969, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 8128, 12, 845, 12, 22, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7409, 12, 19, 12, 845, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 7409, 12, 845, 12, 20, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 6965, 12, 19, 12, 709, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 6965, 12, 845, 12, 19, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7280, 12, 19, 12, 25, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 7280, 12, 845, 12, 18, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7806, 12, 19, 12, 24, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 7806, 12, 845, 12, 17, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 9261, 12, 19, 12, 969, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 9261, 12, 845, 12, 22, 12, 23 ]
[ 9374, 7137, 2556, 367, 437, 8534, 15, 28741, 65, 15, 54, 262, 2497, 17775, 10595, 199, 504, 15444, 14, 9374, 492, 577, 270, 52, 90, 2354, 199, 504, 15444, 14, 9374, 492, 7573, 269, 1759, 63, 2083, 465, 366, 199, 504, 15444, 14, 9374, 492, 7573, 269, 1759, 63, 6215, 815, 465, 284, 199, 199, 533, 28882, 2497, 17775, 8, 31413, 52, 90, 2354, 304, 272, 1449, 8841, 15, 28741, 65, 15, 54, 262, 2497, 17775, 7137, 5492, 14, 1666, 2197, 14, 9374, 367, 2436, 2344, 339, 5718, 275, 283, 8841, 15, 28741, 65, 15, 54, 262, 2497, 17775, 7, 339, 485, 5834, 63, 14143, 63, 4508, 275, 359, 199, 68, 8, 17, 12, 17, 12, 17, 12, 16, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1085, 12, 19, 12, 2192, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1085, 12, 709, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1167, 12, 19, 12, 1216, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1167, 12, 709, 12, 1479, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2260, 12, 18, 12, 25, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2322, 12, 24, 12, 1079, 12, 1789, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2322, 12, 25, 12, 1216, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2466, 12, 20, 12, 1651, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2466, 12, 25, 12, 1398, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2481, 12, 20, 12, 1479, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2481, 12, 25, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1477, 12, 20, 12, 821, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1477, 12, 25, 12, 1479, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1229, 12, 21, 12, 17, 12, 22, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1229, 12, 25, 12, 821, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1367, 12, 20, 12, 1398, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1367, 12, 25, 12, 1216, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1641, 12, 20, 12, 1651, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1641, 12, 25, 12, 1398, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2010, 12, 20, 12, 1465, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2010, 12, 25, 12, 1651, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1427, 12, 20, 12, 1479, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1427, 12, 25, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2259, 12, 20, 12, 1194, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2259, 12, 709, 12, 1216, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2976, 12, 20, 12, 1216, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2976, 12, 25, 12, 1194, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2789, 12, 20, 12, 1398, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2789, 12, 709, 12, 1651, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2766, 12, 20, 12, 1651, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 2766, 12, 709, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 772, 12, 20, 12, 1479, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1876, 12, 20, 12, 1465, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 1167, 1876, 12, 709, 12, 1479, 12, 22, 12, 16, 12, 16, 395, 199, 68, 8, 21740, 12, 20, 12, 1479, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 21740, 12, 709, 12, 821, 12, 22, 12, 16, 12, 16, 395, 199, 68, 8, 7968, 12, 20, 12, 18, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7968, 12, 709, 12, 1398, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 9488, 12, 19, 12, 845, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 9488, 12, 845, 12, 20, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 9300, 12, 19, 12, 25, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 9300, 12, 845, 12, 18, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 8664, 12, 19, 12, 24, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 8664, 12, 845, 12, 17, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 6542, 12, 19, 12, 1079, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 6542, 12, 845, 12, 23, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 8128, 12, 19, 12, 969, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 8128, 12, 845, 12, 22, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7409, 12, 19, 12, 845, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 7409, 12, 845, 12, 20, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 6965, 12, 19, 12, 709, 12, 24, 12, 16, 12, 16, 395, 199, 68, 8, 6965, 12, 845, 12, 19, 12, 23, 12, 16, 12, 16, 395, 199, 68, 8, 7280, 12, 19, 12, 25, 12,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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 ]
toshywoshy/ansible
lib/ansible/modules/cloud/huawei/hwc_vpc_security_group_rule.py
13
17745
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2019 Huawei # 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 ############################################################################### # Documentation ############################################################################### ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: hwc_vpc_security_group_rule description: - vpc security group management. short_description: Creates a resource of Vpc/SecurityGroupRule in Huawei Cloud notes: - If I(id) option is provided, it takes precedence over I(enterprise_project_id) for security group rule selection. - I(security_group_id) is used for security group rule selection. If more than one security group rule with this options exists, execution is aborted. - No parameter support updating. If one of option is changed, the module will create a new resource. version_added: '2.10' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 options: state: description: - Whether the given object should exist in Huawei Cloud. type: str choices: ['present', 'absent'] default: 'present' direction: description: - Specifies the direction of access control. The value can be egress or ingress. type: str required: true security_group_id: description: - Specifies the security group rule ID, which uniquely identifies the security group rule. type: str required: true description: description: - Provides supplementary information about the security group rule. The value is a string of no more than 255 characters that can contain letters and digits. type: str required: false ethertype: description: - Specifies the IP protocol version. The value can be IPv4 or IPv6. If you do not set this parameter, IPv4 is used by default. type: str required: false port_range_max: description: - Specifies the end port number. The value ranges from 1 to 65535. If the protocol is not icmp, the value cannot be smaller than the port_range_min value. An empty value indicates all ports. type: int required: false port_range_min: description: - Specifies the start port number. The value ranges from 1 to 65535. The value cannot be greater than the port_range_max value. An empty value indicates all ports. type: int required: false protocol: description: - Specifies the protocol type. The value can be icmp, tcp, or udp. If the parameter is left blank, the security group supports all protocols. type: str required: false remote_group_id: description: - Specifies the ID of the peer security group. The value is exclusive with parameter remote_ip_prefix. type: str required: false remote_ip_prefix: description: - Specifies the remote IP address. If the access control direction is set to egress, the parameter specifies the source IP address. If the access control direction is set to ingress, the parameter specifies the destination IP address. The value can be in the CIDR format or IP addresses. The parameter is exclusive with parameter remote_group_id. type: str required: false extends_documentation_fragment: hwc ''' EXAMPLES = ''' # create a security group rule - name: create a security group hwc_vpc_security_group: name: "ansible_network_security_group_test" register: sg - name: create a security group rule hwc_vpc_security_group_rule: direction: "ingress" protocol: "tcp" ethertype: "IPv4" port_range_max: 22 security_group_id: "{{ sg.id }}" port_range_min: 22 remote_ip_prefix: "0.0.0.0/0" ''' RETURN = ''' direction: description: - Specifies the direction of access control. The value can be egress or ingress. type: str returned: success security_group_id: description: - Specifies the security group rule ID, which uniquely identifies the security group rule. type: str returned: success description: description: - Provides supplementary information about the security group rule. The value is a string of no more than 255 characters that can contain letters and digits. type: str returned: success ethertype: description: - Specifies the IP protocol version. The value can be IPv4 or IPv6. If you do not set this parameter, IPv4 is used by default. type: str returned: success port_range_max: description: - Specifies the end port number. The value ranges from 1 to 65535. If the protocol is not icmp, the value cannot be smaller than the port_range_min value. An empty value indicates all ports. type: int returned: success port_range_min: description: - Specifies the start port number. The value ranges from 1 to 65535. The value cannot be greater than the port_range_max value. An empty value indicates all ports. type: int returned: success protocol: description: - Specifies the protocol type. The value can be icmp, tcp, or udp. If the parameter is left blank, the security group supports all protocols. type: str returned: success remote_group_id: description: - Specifies the ID of the peer security group. The value is exclusive with parameter remote_ip_prefix. type: str returned: success remote_ip_prefix: description: - Specifies the remote IP address. If the access control direction is set to egress, the parameter specifies the source IP address. If the access control direction is set to ingress, the parameter specifies the destination IP address. The value can be in the CIDR format or IP addresses. The parameter is exclusive with parameter remote_group_id. type: str returned: success ''' from ansible.module_utils.hwc_utils import ( Config, HwcClientException, HwcModule, are_different_dicts, build_path, get_region, is_empty_value, navigate_value) def build_module(): return HwcModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), direction=dict(type='str', required=True), security_group_id=dict(type='str', required=True), description=dict(type='str'), ethertype=dict(type='str'), port_range_max=dict(type='int'), port_range_min=dict(type='int'), protocol=dict(type='str'), remote_group_id=dict(type='str'), remote_ip_prefix=dict(type='str') ), supports_check_mode=True, ) def main(): """Main function""" module = build_module() config = Config(module, "vpc") try: resource = None if module.params['id']: resource = True else: v = search_resource(config) if len(v) > 1: raise Exception("Found more than one resource(%s)" % ", ".join([ navigate_value(i, ["id"]) for i in v])) if len(v) == 1: resource = v[0] module.params['id'] = navigate_value(resource, ["id"]) result = {} changed = False if module.params['state'] == 'present': if resource is None: if not module.check_mode: create(config) changed = True current = read_resource(config, exclude_output=True) expect = user_input_parameters(module) if are_different_dicts(expect, current): raise Exception( "Cannot change option from (%s) to (%s) for an" " existing security group(%s)." % (current, expect, module.params.get('id'))) result = read_resource(config) result['id'] = module.params.get('id') else: if resource: if not module.check_mode: delete(config) changed = True except Exception as ex: module.fail_json(msg=str(ex)) else: result['changed'] = changed module.exit_json(**result) def user_input_parameters(module): return { "description": module.params.get("description"), "direction": module.params.get("direction"), "ethertype": module.params.get("ethertype"), "port_range_max": module.params.get("port_range_max"), "port_range_min": module.params.get("port_range_min"), "protocol": module.params.get("protocol"), "remote_group_id": module.params.get("remote_group_id"), "remote_ip_prefix": module.params.get("remote_ip_prefix"), "security_group_id": module.params.get("security_group_id"), } def create(config): module = config.module client = config.client(get_region(module), "vpc", "project") opts = user_input_parameters(module) params = build_create_parameters(opts) r = send_create_request(module, params, client) module.params['id'] = navigate_value(r, ["security_group_rule", "id"]) def delete(config): module = config.module client = config.client(get_region(module), "vpc", "project") send_delete_request(module, None, client) def read_resource(config, exclude_output=False): module = config.module client = config.client(get_region(module), "vpc", "project") res = {} r = send_read_request(module, client) res["read"] = fill_read_resp_body(r) return update_properties(module, res, None, exclude_output) def _build_query_link(opts): query_link = "?marker={marker}&limit=10" v = navigate_value(opts, ["security_group_id"]) if v: query_link += "&security_group_id=" + str(v) return query_link def search_resource(config): module = config.module client = config.client(get_region(module), "vpc", "project") opts = user_input_parameters(module) identity_obj = _build_identity_object(opts) query_link = _build_query_link(opts) link = "security-group-rules" + query_link result = [] p = {'marker': ''} while True: url = link.format(**p) r = send_list_request(module, client, url) if not r: break for item in r: item = fill_list_resp_body(item) if not are_different_dicts(identity_obj, item): result.append(item) if len(result) > 1: break p['marker'] = r[-1].get('id') return result def build_create_parameters(opts): params = dict() v = navigate_value(opts, ["description"], None) if not is_empty_value(v): params["description"] = v v = navigate_value(opts, ["direction"], None) if not is_empty_value(v): params["direction"] = v v = navigate_value(opts, ["ethertype"], None) if not is_empty_value(v): params["ethertype"] = v v = navigate_value(opts, ["port_range_max"], None) if not is_empty_value(v): params["port_range_max"] = v v = navigate_value(opts, ["port_range_min"], None) if not is_empty_value(v): params["port_range_min"] = v v = navigate_value(opts, ["protocol"], None) if not is_empty_value(v): params["protocol"] = v v = navigate_value(opts, ["remote_group_id"], None) if not is_empty_value(v): params["remote_group_id"] = v v = navigate_value(opts, ["remote_ip_prefix"], None) if not is_empty_value(v): params["remote_ip_prefix"] = v v = navigate_value(opts, ["security_group_id"], None) if not is_empty_value(v): params["security_group_id"] = v if not params: return params params = {"security_group_rule": params} return params def send_create_request(module, params, client): url = "security-group-rules" try: r = client.post(url, params) except HwcClientException as ex: msg = ("module(hwc_vpc_security_group_rule): error running " "api(create), error: %s" % str(ex)) module.fail_json(msg=msg) return r def send_delete_request(module, params, client): url = build_path(module, "security-group-rules/{id}") try: r = client.delete(url, params) except HwcClientException as ex: msg = ("module(hwc_vpc_security_group_rule): error running " "api(delete), error: %s" % str(ex)) module.fail_json(msg=msg) return r def send_read_request(module, client): url = build_path(module, "security-group-rules/{id}") r = None try: r = client.get(url) except HwcClientException as ex: msg = ("module(hwc_vpc_security_group_rule): error running " "api(read), error: %s" % str(ex)) module.fail_json(msg=msg) return navigate_value(r, ["security_group_rule"], None) def fill_read_resp_body(body): result = dict() result["description"] = body.get("description") result["direction"] = body.get("direction") result["ethertype"] = body.get("ethertype") result["id"] = body.get("id") result["port_range_max"] = body.get("port_range_max") result["port_range_min"] = body.get("port_range_min") result["protocol"] = body.get("protocol") result["remote_address_group_id"] = body.get("remote_address_group_id") result["remote_group_id"] = body.get("remote_group_id") result["remote_ip_prefix"] = body.get("remote_ip_prefix") result["security_group_id"] = body.get("security_group_id") return result def update_properties(module, response, array_index, exclude_output=False): r = user_input_parameters(module) v = navigate_value(response, ["read", "description"], array_index) r["description"] = v v = navigate_value(response, ["read", "direction"], array_index) r["direction"] = v v = navigate_value(response, ["read", "ethertype"], array_index) r["ethertype"] = v v = navigate_value(response, ["read", "port_range_max"], array_index) r["port_range_max"] = v v = navigate_value(response, ["read", "port_range_min"], array_index) r["port_range_min"] = v v = navigate_value(response, ["read", "protocol"], array_index) r["protocol"] = v v = navigate_value(response, ["read", "remote_group_id"], array_index) r["remote_group_id"] = v v = navigate_value(response, ["read", "remote_ip_prefix"], array_index) r["remote_ip_prefix"] = v v = navigate_value(response, ["read", "security_group_id"], array_index) r["security_group_id"] = v return r def send_list_request(module, client, url): r = None try: r = client.get(url) except HwcClientException as ex: msg = ("module(hwc_vpc_security_group_rule): error running " "api(list), error: %s" % str(ex)) module.fail_json(msg=msg) return navigate_value(r, ["security_group_rules"], None) def _build_identity_object(all_opts): result = dict() v = navigate_value(all_opts, ["description"], None) result["description"] = v v = navigate_value(all_opts, ["direction"], None) result["direction"] = v v = navigate_value(all_opts, ["ethertype"], None) result["ethertype"] = v result["id"] = None v = navigate_value(all_opts, ["port_range_max"], None) result["port_range_max"] = v v = navigate_value(all_opts, ["port_range_min"], None) result["port_range_min"] = v v = navigate_value(all_opts, ["protocol"], None) result["protocol"] = v result["remote_address_group_id"] = None v = navigate_value(all_opts, ["remote_group_id"], None) result["remote_group_id"] = v v = navigate_value(all_opts, ["remote_ip_prefix"], None) result["remote_ip_prefix"] = v v = navigate_value(all_opts, ["security_group_id"], None) result["security_group_id"] = v return result def fill_list_resp_body(body): result = dict() result["description"] = body.get("description") result["direction"] = body.get("direction") result["ethertype"] = body.get("ethertype") result["id"] = body.get("id") result["port_range_max"] = body.get("port_range_max") result["port_range_min"] = body.get("port_range_min") result["protocol"] = body.get("protocol") result["remote_address_group_id"] = body.get("remote_address_group_id") result["remote_group_id"] = body.get("remote_group_id") result["remote_ip_prefix"] = body.get("remote_ip_prefix") result["security_group_id"] = body.get("security_group_id") return result if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 20312, 869, 1458, 21431, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 11490, 199, 3, 15249, 199, 11490, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 2097, 7780, 2255, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12073, 67, 63, 11742, 63, 4416, 63, 923, 63, 2200, 199, 1802, 26, 272, 446, 12830, 6391, 1572, 10041, 14, 199, 3612, 63, 1802, 26, 10560, 282, 2073, 402, 812, 2352, 15, 19280, 5065, 315, 869, 1458, 21431, 8142, 199, 5983, 26, 523, 446, 982, 473, 8, 344, 9, 945, 365, 2741, 12, 652, 6181, 13823, 1806, 272, 473, 8, 24375, 63, 1715, 63, 344, 9, 367, 6391, 1572, 2332, 7267, 14, 523, 446, 473, 8, 4416, 63, 923, 63, 344, 9, 365, 1202, 367, 6391, 1572, 2332, 7267, 14, 982, 1655, 272, 2419, 1373, 6391, 1572, 2332, 543, 642, 1511, 3495, 12, 6451, 365, 272, 26815, 14, 523, 446, 3091, 2725, 2291, 12928, 14, 982, 1373, 402, 945, 365, 2896, 12, 314, 859, 272, 911, 1218, 282, 892, 2073, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 709, 7, 199, 2502, 26, 869, 1458, 21431, 3277, 14, 8593, 27002, 1129, 530, 320, 1181, 9, 199, 7538, 26, 272, 446, 19395, 1178, 17, 2356, 650, 14, 22, 14, 16, 199, 1419, 26, 272, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 1627, 909, 1077, 2187, 315, 869, 1458, 21431, 8142, 14, 267, 730, 26, 620, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 283, 1881, 7, 272, 7581, 26, 267, 1369, 26, 288, 446, 11015, 314, 7581, 402, 2879, 3304, 14, 710, 574, 883, 506, 1598, 325, 3313, 503, 315, 3313, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 272, 6391, 63, 923, 63, 344, 26, 267, 1369, 26, 288, 446, 11015, 314, 6391, 1572, 2332, 2870, 12, 1314, 28727, 22975, 1598, 314, 6391, 1572, 2332, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 21552, 4973, 968, 695, 2556, 3595, 314, 6391, 1572, 2332, 14, 1598, 710, 574, 365, 282, 1059, 402, 949, 1655, 2419, 5450, 4110, 626, 883, 1598, 1395, 14435, 436, 7576, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 30201, 466, 26, 267, 1369, 26, 288, 446, 11015, 314, 3531, 4113, 1015, 14, 710, 574, 883, 506, 6509, 20, 503, 6509, 22, 14, 1598, 982, 1265, 886, 440, 663, 642, 2725, 12, 6509, 20, 365, 1202, 701, 849, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 1844, 63, 1842, 63, 988, 26, 267, 1369, 26, 288, 446, 11015, 314, 1284, 1844, 1329, 14, 710, 574, 12271, 687, 413, 370, 18247, 14, 1598, 982, 314, 4113, 365, 440, 20663, 12, 314, 574, 3913, 506, 12700, 2419, 314, 1598, 1844, 63, 1842, 63, 827, 574, 14, 1626, 2701, 574, 9126, 1006, 8873, 14, 267, 730, 26, 1109, 267, 1415, 26, 3055, 272, 1844, 63, 1842, 63, 827, 26, 267, 1369, 26, 288, 446, 11015, 314, 1343, 1844, 1329, 14, 710, 574, 12271, 687, 413, 370, 1598, 18247, 14, 710, 574, 3913, 506, 8932, 2419, 314, 1844, 63, 1842, 63, 988, 574, 14, 1598, 1626, 2701, 574, 9126, 1006, 8873, 14, 267, 730, 26, 1109, 267, 1415, 26, 3055, 272, 4113, 26, 267, 1369, 26, 288, 446, 11015, 314, 4113, 730, 14, 710, 574, 883, 506, 20663, 12, 14719, 12, 503, 18419, 14, 1598, 982, 314, 2725, 365, 3602, 4596, 12, 314, 6391, 1572, 5171, 1006, 1598, 19230, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3982, 63, 923, 63, 344, 26, 267, 1369, 26, 288, 446, 11015, 314, 2870, 402, 314, 9104, 6391, 1572, 14, 710, 574, 365, 1598, 13914, 543, 2725, 3982, 63, 711, 63, 1861, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3982, 63, 711, 63, 1861, 26, 267, 1369, 26, 288, 446, 11015, 314, 3982, 3531, 2287, 14, 982, 314, 2879, 3304, 7581, 1598, 365, 663, 370, 325, 3313, 12, 314, 2725, 9314, 314, 1350, 3531, 2287, 14, 1598, 982, 314, 2879, 3304, 7581, 365, 663, 370, 315, 3313, 12, 314, 2725, 1598, 9314, 314, 5724, 3531, 2287, 14, 710, 574, 883, 506, 315, 314, 1598, 29215, 1475, 503, 3531, 7149, 14, 710, 2725, 365, 13914, 543, 1598, 2725, 3982, 63, 923, 63, 344, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 199, 11036, 63, 9970, 63, 7677, 26, 12073, 67, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1218, 282, 6391, 1572, 2332, 199, 13, 536, 26, 1218, 282, 6391, 1572, 523, 12073, 67, 63, 11742, 63, 4416, 63, 923, 26, 272, 536, 26, 298, 4853, 63, 1200, 63, 4416, 63, 923, 63, 396, 2, 523, 2274, 26, 12578, 199, 13, 536, 26, 1218, 282, 6391, 1572, 2332, 523, 12073, 67, 63, 11742, 63, 4416, 63, 923, 63, 2200, 26, 272, 7581, 26, 298, 24390, 2, 272, 4113, 26, 298, 8815, 2, 272, 30201, 466, 26, 298, 12179, 20, 2, 272, 1844, 63, 1842, 63, 988, 26, 6928, 272, 6391, 63, 923, 63, 344, 26, 7370, 12578, 14, 344, 7820, 272, 1844, 63, 1842, 63, 827, 26, 6928, 272, 3982, 63, 711, 63, 1861, 26, 298, 16, 14, 16, 14, 16, 14, 16, 15, 16, 2, 199, 2344, 199, 199, 9677, 275, 1449, 272, 7581, 26, 267, 1369, 26, 288, 446, 11015, 314, 7581, 402, 2879, 3304, 14, 710, 574, 883, 506, 1598, 325, 3313, 503, 315, 3313, 14, 267, 730, 26, 620, 267, 2138, 26, 3182, 272, 6391, 63, 923, 63, 344, 26, 267, 1369, 26, 288, 446, 11015, 314, 6391, 1572, 2332, 2870, 12, 1314, 28727 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 20312, 869, 1458, 21431, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 11490, 199, 3, 15249, 199, 11490, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 2097, 7780, 2255, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12073, 67, 63, 11742, 63, 4416, 63, 923, 63, 2200, 199, 1802, 26, 272, 446, 12830, 6391, 1572, 10041, 14, 199, 3612, 63, 1802, 26, 10560, 282, 2073, 402, 812, 2352, 15, 19280, 5065, 315, 869, 1458, 21431, 8142, 199, 5983, 26, 523, 446, 982, 473, 8, 344, 9, 945, 365, 2741, 12, 652, 6181, 13823, 1806, 272, 473, 8, 24375, 63, 1715, 63, 344, 9, 367, 6391, 1572, 2332, 7267, 14, 523, 446, 473, 8, 4416, 63, 923, 63, 344, 9, 365, 1202, 367, 6391, 1572, 2332, 7267, 14, 982, 1655, 272, 2419, 1373, 6391, 1572, 2332, 543, 642, 1511, 3495, 12, 6451, 365, 272, 26815, 14, 523, 446, 3091, 2725, 2291, 12928, 14, 982, 1373, 402, 945, 365, 2896, 12, 314, 859, 272, 911, 1218, 282, 892, 2073, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 709, 7, 199, 2502, 26, 869, 1458, 21431, 3277, 14, 8593, 27002, 1129, 530, 320, 1181, 9, 199, 7538, 26, 272, 446, 19395, 1178, 17, 2356, 650, 14, 22, 14, 16, 199, 1419, 26, 272, 1174, 26, 267, 1369, 26, 288, 446, 7480, 314, 1627, 909, 1077, 2187, 315, 869, 1458, 21431, 8142, 14, 267, 730, 26, 620, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 283, 1881, 7, 272, 7581, 26, 267, 1369, 26, 288, 446, 11015, 314, 7581, 402, 2879, 3304, 14, 710, 574, 883, 506, 1598, 325, 3313, 503, 315, 3313, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 272, 6391, 63, 923, 63, 344, 26, 267, 1369, 26, 288, 446, 11015, 314, 6391, 1572, 2332, 2870, 12, 1314, 28727, 22975, 1598, 314, 6391, 1572, 2332, 14, 267, 730, 26, 620, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 21552, 4973, 968, 695, 2556, 3595, 314, 6391, 1572, 2332, 14, 1598, 710, 574, 365, 282, 1059, 402, 949, 1655, 2419, 5450, 4110, 626, 883, 1598, 1395, 14435, 436, 7576, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 30201, 466, 26, 267, 1369, 26, 288, 446, 11015, 314, 3531, 4113, 1015, 14, 710, 574, 883, 506, 6509, 20, 503, 6509, 22, 14, 1598, 982, 1265, 886, 440, 663, 642, 2725, 12, 6509, 20, 365, 1202, 701, 849, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 1844, 63, 1842, 63, 988, 26, 267, 1369, 26, 288, 446, 11015, 314, 1284, 1844, 1329, 14, 710, 574, 12271, 687, 413, 370, 18247, 14, 1598, 982, 314, 4113, 365, 440, 20663, 12, 314, 574, 3913, 506, 12700, 2419, 314, 1598, 1844, 63, 1842, 63, 827, 574, 14, 1626, 2701, 574, 9126, 1006, 8873, 14, 267, 730, 26, 1109, 267, 1415, 26, 3055, 272, 1844, 63, 1842, 63, 827, 26, 267, 1369, 26, 288, 446, 11015, 314, 1343, 1844, 1329, 14, 710, 574, 12271, 687, 413, 370, 1598, 18247, 14, 710, 574, 3913, 506, 8932, 2419, 314, 1844, 63, 1842, 63, 988, 574, 14, 1598, 1626, 2701, 574, 9126, 1006, 8873, 14, 267, 730, 26, 1109, 267, 1415, 26, 3055, 272, 4113, 26, 267, 1369, 26, 288, 446, 11015, 314, 4113, 730, 14, 710, 574, 883, 506, 20663, 12, 14719, 12, 503, 18419, 14, 1598, 982, 314, 2725, 365, 3602, 4596, 12, 314, 6391, 1572, 5171, 1006, 1598, 19230, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3982, 63, 923, 63, 344, 26, 267, 1369, 26, 288, 446, 11015, 314, 2870, 402, 314, 9104, 6391, 1572, 14, 710, 574, 365, 1598, 13914, 543, 2725, 3982, 63, 711, 63, 1861, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3982, 63, 711, 63, 1861, 26, 267, 1369, 26, 288, 446, 11015, 314, 3982, 3531, 2287, 14, 982, 314, 2879, 3304, 7581, 1598, 365, 663, 370, 325, 3313, 12, 314, 2725, 9314, 314, 1350, 3531, 2287, 14, 1598, 982, 314, 2879, 3304, 7581, 365, 663, 370, 315, 3313, 12, 314, 2725, 1598, 9314, 314, 5724, 3531, 2287, 14, 710, 574, 883, 506, 315, 314, 1598, 29215, 1475, 503, 3531, 7149, 14, 710, 2725, 365, 13914, 543, 1598, 2725, 3982, 63, 923, 63, 344, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 199, 11036, 63, 9970, 63, 7677, 26, 12073, 67, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1218, 282, 6391, 1572, 2332, 199, 13, 536, 26, 1218, 282, 6391, 1572, 523, 12073, 67, 63, 11742, 63, 4416, 63, 923, 26, 272, 536, 26, 298, 4853, 63, 1200, 63, 4416, 63, 923, 63, 396, 2, 523, 2274, 26, 12578, 199, 13, 536, 26, 1218, 282, 6391, 1572, 2332, 523, 12073, 67, 63, 11742, 63, 4416, 63, 923, 63, 2200, 26, 272, 7581, 26, 298, 24390, 2, 272, 4113, 26, 298, 8815, 2, 272, 30201, 466, 26, 298, 12179, 20, 2, 272, 1844, 63, 1842, 63, 988, 26, 6928, 272, 6391, 63, 923, 63, 344, 26, 7370, 12578, 14, 344, 7820, 272, 1844, 63, 1842, 63, 827, 26, 6928, 272, 3982, 63, 711, 63, 1861, 26, 298, 16, 14, 16, 14, 16, 14, 16, 15, 16, 2, 199, 2344, 199, 199, 9677, 275, 1449, 272, 7581, 26, 267, 1369, 26, 288, 446, 11015, 314, 7581, 402, 2879, 3304, 14, 710, 574, 883, 506, 1598, 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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 ]
Endika/OpenUpgrade
addons/mail/res_users.py
314
10337
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2009-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 fields, osv from openerp import api from openerp import SUPERUSER_ID from openerp.tools.translate import _ import openerp class res_users(osv.Model): """ Update of res.users class - add a preference about sending emails about notifications - make a new user follow itself - add a welcome message - add suggestion preference """ _name = 'res.users' _inherit = ['res.users'] _inherits = {'mail.alias': 'alias_id'} _columns = { 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="Email address internally associated with this user. Incoming "\ "emails will appear in the user's notifications.", copy=False, auto_join=True), 'display_groups_suggestions': fields.boolean("Display Groups Suggestions"), } _defaults = { 'display_groups_suggestions': True, } def __init__(self, pool, cr): """ Override of __init__ to add access rights on notification_email_send and alias fields. Access rights are disabled by default, but allowed on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS. """ init_res = super(res_users, self).__init__(pool, cr) # duplicate list to avoid modifying the original reference self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS) self.SELF_WRITEABLE_FIELDS.extend(['notify_email', 'display_groups_suggestions']) # duplicate list to avoid modifying the original reference self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS) self.SELF_READABLE_FIELDS.extend(['notify_email', 'alias_domain', 'alias_name', 'display_groups_suggestions']) return init_res def _auto_init(self, cr, context=None): """ Installation hook: aliases, partner following themselves """ # create aliases for all users and avoid constraint errors return self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(res_users, self)._auto_init, self._name, self._columns['alias_id'], 'login', alias_force_key='id', context=context) def create(self, cr, uid, data, context=None): if not data.get('login', False): model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base', 'action_res_users') msg = _("You cannot create a new user from here.\n To create new user please go to configuration panel.") raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) if context is None: context = {} create_context = dict(context, alias_model_name=self._name, alias_parent_model_name=self._name) user_id = super(res_users, self).create(cr, uid, data, context=create_context) user = self.browse(cr, uid, user_id, context=context) self.pool.get('mail.alias').write(cr, SUPERUSER_ID, [user.alias_id.id], {"alias_force_thread_id": user_id, "alias_parent_thread_id": user_id}, context) # create a welcome message self._create_welcome_message(cr, uid, user, context=context) return user_id def copy_data(self, *args, **kwargs): data = super(res_users, self).copy_data(*args, **kwargs) if data and data.get('alias_name'): data['alias_name'] = data['login'] return data def _create_welcome_message(self, cr, uid, user, context=None): if not self.has_group(cr, uid, 'base.group_user'): return False company_name = user.company_id.name if user.company_id else '' body = _('%s has joined the %s network.') % (user.name, company_name) # TODO change SUPERUSER_ID into user.id but catch errors return self.pool.get('res.partner').message_post(cr, SUPERUSER_ID, [user.partner_id.id], body=body, context=context) def unlink(self, cr, uid, ids, context=None): # Cascade-delete mail aliases as well, as they should not exist without the user. alias_pool = self.pool.get('mail.alias') alias_ids = [user.alias_id.id for user in self.browse(cr, uid, ids, context=context) if user.alias_id] res = super(res_users, self).unlink(cr, uid, ids, context=context) alias_pool.unlink(cr, uid, alias_ids, context=context) return res def _message_post_get_pid(self, cr, uid, thread_id, context=None): assert thread_id, "res.users does not support posting global messages" if context and 'thread_model' in context: context['thread_model'] = 'res.users' if isinstance(thread_id, (list, tuple)): thread_id = thread_id[0] return self.browse(cr, SUPERUSER_ID, thread_id).partner_id.id @api.cr_uid_ids_context def message_post(self, cr, uid, thread_id, context=None, **kwargs): """ Redirect the posting of message on res.users as a private discussion. This is done because when giving the context of Chatter on the various mailboxes, we do not have access to the current partner_id. """ if isinstance(thread_id, (list, tuple)): thread_id = thread_id[0] current_pids = [] partner_ids = kwargs.get('partner_ids', []) user_pid = self._message_post_get_pid(cr, uid, thread_id, context=context) for partner_id in partner_ids: if isinstance(partner_id, (list, tuple)) and partner_id[0] == 4 and len(partner_id) == 2: current_pids.append(partner_id[1]) elif isinstance(partner_id, (list, tuple)) and partner_id[0] == 6 and len(partner_id) == 3: current_pids.append(partner_id[2]) elif isinstance(partner_id, (int, long)): current_pids.append(partner_id) if user_pid not in current_pids: partner_ids.append(user_pid) kwargs['partner_ids'] = partner_ids if context and context.get('thread_model') == 'res.partner': return self.pool['res.partner'].message_post(cr, uid, user_pid, **kwargs) return self.pool['mail.thread'].message_post(cr, uid, uid, **kwargs) def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None): return True def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): return True def message_get_partner_info_from_emails(self, cr, uid, emails, link_mail=False, context=None): return self.pool.get('mail.thread').message_get_partner_info_from_emails(cr, uid, emails, link_mail=link_mail, context=context) def message_get_suggested_recipients(self, cr, uid, ids, context=None): return dict((res_id, list()) for res_id in ids) def stop_showing_groups_suggestions(self, cr, uid, user_id, context=None): """Update display_groups_suggestions value to False""" if context is None: context = {} self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context) class res_users_mail_group(osv.Model): """ Update of res.users class - if adding groups to an user, check mail.groups linked to this user group, and the user. This is done by overriding the write method. """ _name = 'res.users' _inherit = ['res.users'] # FP Note: to improve, post processing may be better ? def write(self, cr, uid, ids, vals, context=None): write_res = super(res_users_mail_group, self).write(cr, uid, ids, vals, context=context) if vals.get('groups_id'): # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4] user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]] mail_group_obj = self.pool.get('mail.group') mail_group_ids = mail_group_obj.search(cr, uid, [('group_ids', 'in', user_group_ids)], context=context) mail_group_obj.message_subscribe_users(cr, uid, mail_group_ids, ids, context=context) return write_res class res_groups_mail_group(osv.Model): """ Update of res.groups class - if adding users from a group, check mail.groups linked to this user group and subscribe them. This is done by overriding the write method. """ _name = 'res.groups' _inherit = 'res.groups' # FP Note: to improve, post processeing, after the super may be better def write(self, cr, uid, ids, vals, context=None): write_res = super(res_groups_mail_group, self).write(cr, uid, ids, vals, context=context) if vals.get('users'): # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} user_ids = [command[1] for command in vals['users'] if command[0] == 4] user_ids += [id for command in vals['users'] if command[0] == 6 for id in command[2]] mail_group_obj = self.pool.get('mail.group') mail_group_ids = mail_group_obj.search(cr, uid, [('group_ids', 'in', ids)], context=context) mail_group_obj.message_subscribe_users(cr, uid, mail_group_ids, user_ids, context=context) return write_res
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8937, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 492, 2986, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 5166, 421, 199, 533, 522, 63, 3707, 8, 4795, 14, 1685, 304, 272, 408, 6162, 402, 522, 14, 3707, 1021, 267, 446, 1050, 282, 16705, 3595, 10209, 14931, 3595, 13116, 267, 446, 1852, 282, 892, 922, 2035, 6337, 267, 446, 1050, 282, 336, 14628, 1245, 267, 446, 1050, 18453, 1636, 16705, 272, 408, 272, 485, 354, 275, 283, 470, 14, 3707, 7, 272, 485, 6486, 275, 788, 470, 14, 3707, 418, 272, 485, 20882, 275, 791, 1198, 14, 3620, 356, 283, 3620, 63, 344, 936, 339, 485, 3406, 275, 469, 267, 283, 3620, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 1198, 14, 3620, 297, 283, 14149, 297, 16549, 628, 22188, 401, 1415, 29, 549, 12, 288, 1720, 628, 7035, 2287, 14448, 4568, 543, 642, 922, 14, 1010, 7909, 1867, 326, 298, 14170, 911, 7468, 315, 314, 922, 1159, 13116, 4765, 1331, 29, 797, 12, 2599, 63, 904, 29, 549, 395, 267, 283, 2918, 63, 2634, 63, 19957, 15293, 356, 1504, 14, 4871, 480, 7687, 25031, 428, 11914, 15293, 1288, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 2918, 63, 2634, 63, 19957, 15293, 356, 715, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4203, 12, 2467, 304, 267, 408, 11041, 402, 636, 826, 363, 370, 1050, 2879, 4481, 641, 6955, 63, 2123, 63, 2254, 288, 436, 5162, 1504, 14, 11003, 4481, 787, 6980, 701, 849, 12, 1325, 4370, 288, 641, 2005, 2488, 1504, 3247, 315, 291, 14, 899, 15965, 7348, 5670, 15, 10387, 93, 2617, 63, 12767, 14, 267, 408, 267, 4205, 63, 470, 275, 1613, 8, 470, 63, 3707, 12, 291, 2843, 826, 721, 2293, 12, 2467, 9, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 14, 2880, 2941, 6814, 63, 2123, 297, 283, 2918, 63, 2634, 63, 19957, 15293, 1105, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 14, 2880, 2941, 6814, 63, 2123, 297, 283, 3620, 63, 2261, 297, 283, 3620, 63, 354, 297, 283, 2918, 63, 2634, 63, 19957, 15293, 1105, 267, 372, 4205, 63, 470, 339, 347, 485, 2495, 63, 826, 8, 277, 12, 2467, 12, 1067, 29, 403, 304, 267, 408, 26866, 5759, 26, 5481, 12, 5854, 2569, 17279, 408, 267, 327, 1218, 5481, 367, 1006, 4390, 436, 5126, 5828, 2552, 267, 372, 291, 14, 2293, 14, 362, 360, 1198, 14, 3620, 1959, 8462, 63, 475, 63, 3620, 8, 1556, 12, 291, 423, 354, 12, 291, 423, 1224, 12, 1613, 8, 470, 63, 3707, 12, 291, 10445, 2495, 63, 826, 12, 288, 291, 423, 354, 12, 291, 423, 3406, 459, 3620, 63, 344, 995, 283, 2886, 297, 5162, 63, 3990, 63, 498, 534, 344, 297, 1067, 29, 1100, 9, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 666, 12, 1067, 29, 403, 304, 267, 340, 440, 666, 14, 362, 360, 2886, 297, 756, 304, 288, 1402, 12, 1595, 63, 344, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 576, 2278, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 1287, 63, 470, 63, 3707, 358, 288, 1499, 275, 3824, 5556, 3913, 1218, 282, 892, 922, 687, 2348, 3134, 78, 4005, 1218, 892, 922, 8749, 2621, 370, 2897, 12748, 2685, 288, 746, 5166, 14, 3924, 14, 7071, 3849, 8, 1328, 12, 1595, 63, 344, 12, 4018, 7250, 370, 314, 2897, 12748, 1333, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 398, 1218, 63, 1100, 275, 1211, 8, 1100, 12, 5162, 63, 1238, 63, 354, 29, 277, 423, 354, 12, 5162, 63, 1708, 63, 1238, 63, 354, 29, 277, 423, 354, 9, 267, 922, 63, 344, 275, 1613, 8, 470, 63, 3707, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 666, 12, 1067, 29, 981, 63, 1100, 9, 267, 922, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 922, 63, 344, 12, 1067, 29, 1100, 9, 267, 291, 14, 2293, 14, 362, 360, 1198, 14, 3620, 1959, 952, 8, 1556, 12, 12824, 63, 998, 12, 359, 751, 14, 3620, 63, 344, 14, 344, 467, 2420, 3620, 63, 3990, 63, 2671, 63, 344, 582, 922, 63, 344, 12, 298, 3620, 63, 1708, 63, 2671, 63, 344, 582, 922, 63, 344, 1386, 1067, 9, 398, 327, 1218, 282, 336, 14628, 1245, 267, 291, 423, 981, 63, 28508, 63, 1188, 8, 1556, 12, 1747, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8937, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 492, 2986, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 5166, 421, 199, 533, 522, 63, 3707, 8, 4795, 14, 1685, 304, 272, 408, 6162, 402, 522, 14, 3707, 1021, 267, 446, 1050, 282, 16705, 3595, 10209, 14931, 3595, 13116, 267, 446, 1852, 282, 892, 922, 2035, 6337, 267, 446, 1050, 282, 336, 14628, 1245, 267, 446, 1050, 18453, 1636, 16705, 272, 408, 272, 485, 354, 275, 283, 470, 14, 3707, 7, 272, 485, 6486, 275, 788, 470, 14, 3707, 418, 272, 485, 20882, 275, 791, 1198, 14, 3620, 356, 283, 3620, 63, 344, 936, 339, 485, 3406, 275, 469, 267, 283, 3620, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 1198, 14, 3620, 297, 283, 14149, 297, 16549, 628, 22188, 401, 1415, 29, 549, 12, 288, 1720, 628, 7035, 2287, 14448, 4568, 543, 642, 922, 14, 1010, 7909, 1867, 326, 298, 14170, 911, 7468, 315, 314, 922, 1159, 13116, 4765, 1331, 29, 797, 12, 2599, 63, 904, 29, 549, 395, 267, 283, 2918, 63, 2634, 63, 19957, 15293, 356, 1504, 14, 4871, 480, 7687, 25031, 428, 11914, 15293, 1288, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 2918, 63, 2634, 63, 19957, 15293, 356, 715, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4203, 12, 2467, 304, 267, 408, 11041, 402, 636, 826, 363, 370, 1050, 2879, 4481, 641, 6955, 63, 2123, 63, 2254, 288, 436, 5162, 1504, 14, 11003, 4481, 787, 6980, 701, 849, 12, 1325, 4370, 288, 641, 2005, 2488, 1504, 3247, 315, 291, 14, 899, 15965, 7348, 5670, 15, 10387, 93, 2617, 63, 12767, 14, 267, 408, 267, 4205, 63, 470, 275, 1613, 8, 470, 63, 3707, 12, 291, 2843, 826, 721, 2293, 12, 2467, 9, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 14, 2880, 2941, 6814, 63, 2123, 297, 283, 2918, 63, 2634, 63, 19957, 15293, 1105, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 14, 2880, 2941, 6814, 63, 2123, 297, 283, 3620, 63, 2261, 297, 283, 3620, 63, 354, 297, 283, 2918, 63, 2634, 63, 19957, 15293, 1105, 267, 372, 4205, 63, 470, 339, 347, 485, 2495, 63, 826, 8, 277, 12, 2467, 12, 1067, 29, 403, 304, 267, 408, 26866, 5759, 26, 5481, 12, 5854, 2569, 17279, 408, 267, 327, 1218, 5481, 367, 1006, 4390, 436, 5126, 5828, 2552, 267, 372, 291, 14, 2293, 14, 362, 360, 1198, 14, 3620, 1959, 8462, 63, 475, 63, 3620, 8, 1556, 12, 291, 423, 354, 12, 291, 423, 1224, 12, 1613, 8, 470, 63, 3707, 12, 291, 10445, 2495, 63, 826, 12, 288, 291, 423, 354, 12, 291, 423, 3406, 459, 3620, 63, 344, 995, 283, 2886, 297, 5162, 63, 3990, 63, 498, 534, 344, 297, 1067, 29, 1100, 9, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 666, 12, 1067, 29, 403, 304, 267, 340, 440, 666, 14, 362, 360, 2886, 297, 756, 304, 288, 1402, 12, 1595, 63, 344, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 576, 2278, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 1287, 63, 470, 63, 3707, 358, 288, 1499, 275, 3824, 5556, 3913, 1218, 282, 892, 922, 687, 2348, 3134, 78, 4005, 1218, 892, 922, 8749, 2621, 370, 2897, 12748, 2685, 288, 746, 5166, 14, 3924, 14, 7071, 3849, 8, 1328, 12, 1595, 63, 344, 12, 4018, 7250, 370, 314, 2897, 12748, 1333, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 398, 1218, 63, 1100, 275, 1211, 8, 1100, 12, 5162, 63, 1238, 63, 354, 29, 277, 423, 354, 12, 5162, 63, 1708, 63, 1238, 63, 354, 29, 277, 423, 354, 9, 267, 922, 63, 344, 275, 1613, 8, 470, 63, 3707, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 666, 12, 1067, 29, 981, 63, 1100, 9, 267, 922, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 922, 63, 344, 12, 1067, 29, 1100, 9, 267, 291, 14, 2293, 14, 362, 360, 1198, 14, 3620, 1959, 952, 8, 1556, 12, 12824, 63, 998, 12, 359, 751, 14, 3620, 63, 344, 14, 344, 467, 2420, 3620, 63, 3990, 63, 2671, 63, 344, 582, 922, 63, 344, 12, 298, 3620, 63, 1708, 63, 2671, 63, 344, 582, 922, 63, 344, 1386, 1067, 9, 398, 327, 1218, 282, 336, 14628, 1245, 267, 291, 423, 981, 63, 28508, 63, 1188, 8, 1556, 12, 1747, 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,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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 ]
dpranke/typ
typ/tests/stats_test.py
84
2292
# Copyright 2014 Dirk Pranke. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import unittest from typ.stats import Stats class TestStats(unittest.TestCase): def test_basic(self): s = Stats('foo', lambda: 0, 32) self.assertEqual(s.format(), 'foo') def test_edges(self): s = Stats('[%s/%f/%t/%r/%p]', lambda: 0, 32) self.assertEqual(s.format(), '[0/0/0/0/-]') s.started = 3 s.total = 5 s.finished = 1 self.assertEqual(s.format(), '[3/1/5/2/ 60.0]') s.started = 5 s.finished = 5 self.assertEqual(s.format(), '[5/5/5/0/100.0]') def test_elapsed_time(self): times = [0.0, 0.4] s = Stats('[%e]', lambda: times.pop(0), 32) self.assertEqual(s.format(), '[0.400]') s = Stats('[%e]', lambda: 0, 32) self.assertEqual(s.format(), '[0.000]') def test_current_rate(self): times = [0.0, 0.1, 0.2] s = Stats('[%c]', lambda: times.pop(0), 1) self.assertEquals(s.format(), '[-]') s.add_time() s.add_time() self.assertEquals(s.format(), '[ 10.0]') def test_overall_rate(self): times = [0, 0, 5] s = Stats('[%o]', lambda: times.pop(0), 32) self.assertEqual(s.format(), '[-]') s.started = 3 s.finished = 1 s.total = 5 self.assertEqual(s.format(), '[ 0.2]') def test_escaped_percent(self): s = Stats('%%', lambda: 0, 32) self.assertEqual(s.format(), '%') def test_unrecognized_escape(self): s = Stats('%x', lambda: 0, 32) self.assertEqual(s.format(), '%x') def test_remaining(self): s = Stats('%u', lambda: 0, 32) s.total = 2 self.assertEqual(s.format(), '2')
apache-2.0
[ 3, 1898, 6927, 25866, 75, 510, 1312, 415, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 199, 504, 6211, 14, 3200, 492, 29062, 421, 199, 533, 1379, 8257, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 308, 275, 29062, 360, 1421, 297, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 283, 1421, 358, 339, 347, 511, 63, 6929, 8, 277, 304, 267, 308, 275, 29062, 360, 9722, 83, 3149, 70, 3149, 84, 3149, 82, 3149, 80, 4300, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 16, 15, 16, 15, 16, 15, 16, 22551, 10374, 267, 308, 14, 8924, 275, 650, 267, 308, 14, 2923, 275, 959, 267, 308, 14, 8669, 275, 413, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 19, 15, 17, 15, 21, 15, 18, 15, 5212, 14, 16, 10374, 398, 308, 14, 8924, 275, 959, 267, 308, 14, 8669, 275, 959, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 21, 15, 21, 15, 21, 15, 16, 15, 1960, 14, 16, 10374, 339, 347, 511, 63, 16691, 63, 521, 8, 277, 304, 267, 5431, 275, 359, 16, 14, 16, 12, 378, 14, 20, 61, 267, 308, 275, 29062, 360, 9722, 69, 4300, 2400, 26, 5431, 14, 1935, 8, 16, 395, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 16, 14, 5303, 10374, 398, 308, 275, 29062, 360, 9722, 69, 4300, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 16, 14, 1493, 10374, 339, 347, 511, 63, 1818, 63, 1866, 8, 277, 304, 267, 5431, 275, 359, 16, 14, 16, 12, 378, 14, 17, 12, 378, 14, 18, 61, 267, 308, 275, 29062, 360, 9722, 67, 4300, 2400, 26, 5431, 14, 1935, 8, 16, 395, 413, 9, 267, 291, 14, 2947, 8, 83, 14, 908, 1062, 283, 1988, 10374, 267, 308, 14, 525, 63, 521, 342, 267, 308, 14, 525, 63, 521, 342, 267, 291, 14, 2947, 8, 83, 14, 908, 1062, 6730, 1616, 14, 16, 10374, 339, 347, 511, 63, 1883, 452, 63, 1866, 8, 277, 304, 267, 5431, 275, 359, 16, 12, 378, 12, 959, 61, 267, 308, 275, 29062, 360, 9722, 79, 4300, 2400, 26, 5431, 14, 1935, 8, 16, 395, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 283, 1988, 10374, 267, 308, 14, 8924, 275, 650, 267, 308, 14, 8669, 275, 413, 267, 308, 14, 2923, 275, 959, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 221, 378, 14, 18, 10374, 339, 347, 511, 63, 13572, 63, 7045, 8, 277, 304, 267, 308, 275, 29062, 3508, 28575, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 1543, 358, 339, 347, 511, 63, 324, 13221, 63, 3765, 8, 277, 304, 267, 308, 275, 29062, 3508, 88, 297, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 1543, 88, 358, 339, 347, 511, 63, 11266, 8, 277, 304, 267, 308, 275, 29062, 3508, 85, 297, 2400, 26, 378, 12, 4337, 9, 267, 308, 14, 2923, 275, 499, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 283, 18, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 25866, 75, 510, 1312, 415, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 199, 504, 6211, 14, 3200, 492, 29062, 421, 199, 533, 1379, 8257, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 308, 275, 29062, 360, 1421, 297, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 283, 1421, 358, 339, 347, 511, 63, 6929, 8, 277, 304, 267, 308, 275, 29062, 360, 9722, 83, 3149, 70, 3149, 84, 3149, 82, 3149, 80, 4300, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 16, 15, 16, 15, 16, 15, 16, 22551, 10374, 267, 308, 14, 8924, 275, 650, 267, 308, 14, 2923, 275, 959, 267, 308, 14, 8669, 275, 413, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 19, 15, 17, 15, 21, 15, 18, 15, 5212, 14, 16, 10374, 398, 308, 14, 8924, 275, 959, 267, 308, 14, 8669, 275, 959, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 21, 15, 21, 15, 21, 15, 16, 15, 1960, 14, 16, 10374, 339, 347, 511, 63, 16691, 63, 521, 8, 277, 304, 267, 5431, 275, 359, 16, 14, 16, 12, 378, 14, 20, 61, 267, 308, 275, 29062, 360, 9722, 69, 4300, 2400, 26, 5431, 14, 1935, 8, 16, 395, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 16, 14, 5303, 10374, 398, 308, 275, 29062, 360, 9722, 69, 4300, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 16, 14, 1493, 10374, 339, 347, 511, 63, 1818, 63, 1866, 8, 277, 304, 267, 5431, 275, 359, 16, 14, 16, 12, 378, 14, 17, 12, 378, 14, 18, 61, 267, 308, 275, 29062, 360, 9722, 67, 4300, 2400, 26, 5431, 14, 1935, 8, 16, 395, 413, 9, 267, 291, 14, 2947, 8, 83, 14, 908, 1062, 283, 1988, 10374, 267, 308, 14, 525, 63, 521, 342, 267, 308, 14, 525, 63, 521, 342, 267, 291, 14, 2947, 8, 83, 14, 908, 1062, 6730, 1616, 14, 16, 10374, 339, 347, 511, 63, 1883, 452, 63, 1866, 8, 277, 304, 267, 5431, 275, 359, 16, 12, 378, 12, 959, 61, 267, 308, 275, 29062, 360, 9722, 79, 4300, 2400, 26, 5431, 14, 1935, 8, 16, 395, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 283, 1988, 10374, 267, 308, 14, 8924, 275, 650, 267, 308, 14, 8669, 275, 413, 267, 308, 14, 2923, 275, 959, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 6730, 221, 378, 14, 18, 10374, 339, 347, 511, 63, 13572, 63, 7045, 8, 277, 304, 267, 308, 275, 29062, 3508, 28575, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 1543, 358, 339, 347, 511, 63, 324, 13221, 63, 3765, 8, 277, 304, 267, 308, 275, 29062, 3508, 88, 297, 2400, 26, 378, 12, 4337, 9, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 1543, 88, 358, 339, 347, 511, 63, 11266, 8, 277, 304, 267, 308, 275, 29062, 3508, 85, 297, 2400, 26, 378, 12, 4337, 9, 267, 308, 14, 2923, 275, 499, 267, 291, 14, 629, 8, 83, 14, 908, 1062, 283, 18, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rohitwaghchaure/digitales_erpnext
erpnext/hr/doctype/leave_block_list/leave_block_list.py
40
2266
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt # For license information, please see license.txt from __future__ import unicode_literals import frappe from erpnext.accounts.utils import validate_fiscal_year from frappe import _ from frappe.model.document import Document class LeaveBlockList(Document): def validate(self): dates = [] for d in self.get("leave_block_list_dates"): # validate fiscal year validate_fiscal_year(d.block_date, self.year, _("Block Date")) # date is not repeated if d.block_date in dates: frappe.msgprint(_("Date is repeated") + ":" + d.block_date, raise_exception=1) dates.append(d.block_date) @frappe.whitelist() def get_applicable_block_dates(from_date, to_date, employee=None, company=None, all_lists=False): block_dates = [] for block_list in get_applicable_block_lists(employee, company, all_lists): block_dates.extend(frappe.db.sql("""select block_date, reason from `tabLeave Block List Date` where parent=%s and block_date between %s and %s""", (block_list, from_date, to_date), as_dict=1)) return block_dates def get_applicable_block_lists(employee=None, company=None, all_lists=False): block_lists = [] if not employee: employee = frappe.db.get_value("Employee", {"user_id":frappe.session.user}) if not employee: return [] if not company: company = frappe.db.get_value("Employee", employee, "company") def add_block_list(block_list): if block_list: if all_lists or not is_user_in_allow_list(block_list): block_lists.append(block_list) # per department department = frappe.db.get_value("Employee",employee, "department") if department: block_list = frappe.db.get_value("Department", department, "leave_block_list") add_block_list(block_list) # global for block_list in frappe.db.sql_list("""select name from `tabLeave Block List` where ifnull(applies_to_all_departments,0)=1 and company=%s""", company): add_block_list(block_list) return list(set(block_lists)) def is_user_in_allow_list(block_list): return frappe.session.user in frappe.db.sql_list("""select allow_user from `tabLeave Block List Allow` where parent=%s""", block_list)
agpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 29106, 14, 8370, 14, 1208, 492, 4107, 63, 18646, 63, 3403, 199, 504, 6950, 492, 485, 199, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 199, 533, 28015, 3142, 1296, 8, 5564, 304, 18118, 198, 318, 4107, 8, 277, 304, 507, 198, 9356, 275, 942, 507, 198, 509, 366, 315, 291, 14, 362, 480, 12422, 63, 1457, 63, 513, 63, 9356, 2349, 686, 198, 3, 4107, 18672, 5361, 686, 198, 3502, 63, 18646, 63, 3403, 8, 68, 14, 1457, 63, 602, 12, 291, 14, 3403, 12, 3824, 3142, 6148, 2237, 26140, 198, 3, 1434, 365, 440, 10877, 686, 198, 692, 366, 14, 1457, 63, 602, 315, 10831, 26, 1585, 198, 9098, 14, 1328, 1361, 6115, 2506, 365, 10877, 531, 435, 14725, 435, 366, 14, 1457, 63, 602, 12, 746, 63, 1971, 29, 17, 9, 686, 198, 9356, 14, 740, 8, 68, 14, 1457, 63, 602, 9, 199, 199, 32, 9098, 14, 14189, 342, 199, 318, 664, 63, 30002, 63, 1457, 63, 9356, 8, 504, 63, 602, 12, 370, 63, 602, 12, 15778, 29, 403, 12, 9948, 198, 4627, 29, 403, 12, 1006, 63, 6717, 29, 797, 304, 199, 198, 1457, 63, 9356, 275, 942, 199, 198, 509, 1853, 63, 513, 315, 664, 63, 30002, 63, 1457, 63, 6717, 8, 10103, 12, 7233, 12, 1006, 63, 6717, 304, 507, 198, 1457, 63, 9356, 14, 2880, 8, 9098, 14, 697, 14, 3009, 4852, 2416, 1853, 63, 602, 12, 4499, 20866, 198, 504, 658, 2902, 23679, 8651, 3820, 6148, 64, 2382, 1676, 2458, 83, 20866, 198, 460, 1853, 63, 602, 3382, 450, 83, 436, 450, 83, 7208, 334, 1457, 63, 513, 12, 687, 63, 602, 12, 370, 63, 602, 395, 20866, 198, 305, 63, 807, 29, 17, 430, 1585, 199, 198, 1107, 1853, 63, 9356, 686, 199, 318, 664, 63, 30002, 63, 1457, 63, 6717, 8, 10103, 29, 403, 12, 7233, 29, 403, 12, 1006, 63, 6717, 29, 797, 304, 199, 198, 1457, 63, 6717, 275, 942, 8299, 198, 692, 440, 15778, 26, 507, 198, 10103, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 22635, 401, 2420, 751, 63, 344, 582, 9098, 14, 1730, 14, 751, 1552, 507, 198, 692, 440, 15778, 26, 686, 198, 1107, 942, 8299, 198, 692, 440, 7233, 26, 507, 198, 4627, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 22635, 401, 15778, 12, 298, 4627, 531, 18118, 198, 318, 1050, 63, 1457, 63, 513, 8, 1457, 63, 513, 304, 507, 198, 692, 1853, 63, 513, 26, 686, 198, 692, 1006, 63, 6717, 503, 440, 365, 63, 751, 63, 262, 63, 3306, 63, 513, 8, 1457, 63, 513, 304, 1585, 198, 1457, 63, 6717, 14, 740, 8, 1457, 63, 513, 9, 421, 198, 3, 1126, 27669, 199, 198, 19623, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 22635, 401, 10103, 12, 298, 19623, 531, 199, 198, 692, 27669, 26, 507, 198, 1457, 63, 513, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 872, 12493, 401, 27669, 12, 298, 12422, 63, 1457, 63, 513, 531, 507, 198, 525, 63, 1457, 63, 513, 8, 1457, 63, 513, 9, 421, 198, 3, 2288, 199, 198, 509, 1853, 63, 513, 315, 6950, 14, 697, 14, 3009, 63, 513, 4852, 2416, 536, 687, 658, 2902, 23679, 8651, 3820, 64, 507, 198, 4509, 340, 2307, 8, 571, 6528, 63, 475, 63, 452, 63, 27532, 1470, 12, 16, 23397, 17, 436, 7233, 2458, 83, 7208, 7233, 304, 507, 198, 525, 63, 1457, 63, 513, 8, 1457, 63, 513, 9, 18118, 198, 1107, 769, 8, 409, 8, 1457, 63, 6717, 430, 507, 199, 318, 365, 63, 751, 63, 262, 63, 3306, 63, 513, 8, 1457, 63, 513, 304, 199, 198, 1107, 6950, 14, 1730, 14, 751, 315, 6950, 14, 697, 14, 3009, 63, 513, 4852, 2416, 2040, 63, 751, 507, 198, 504, 658, 2902, 23679, 8651, 3820, 9812, 64, 2382, 1676, 2458, 83, 7208, 1853, 63, 513, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 29106, 14, 8370, 14, 1208, 492, 4107, 63, 18646, 63, 3403, 199, 504, 6950, 492, 485, 199, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 199, 533, 28015, 3142, 1296, 8, 5564, 304, 18118, 198, 318, 4107, 8, 277, 304, 507, 198, 9356, 275, 942, 507, 198, 509, 366, 315, 291, 14, 362, 480, 12422, 63, 1457, 63, 513, 63, 9356, 2349, 686, 198, 3, 4107, 18672, 5361, 686, 198, 3502, 63, 18646, 63, 3403, 8, 68, 14, 1457, 63, 602, 12, 291, 14, 3403, 12, 3824, 3142, 6148, 2237, 26140, 198, 3, 1434, 365, 440, 10877, 686, 198, 692, 366, 14, 1457, 63, 602, 315, 10831, 26, 1585, 198, 9098, 14, 1328, 1361, 6115, 2506, 365, 10877, 531, 435, 14725, 435, 366, 14, 1457, 63, 602, 12, 746, 63, 1971, 29, 17, 9, 686, 198, 9356, 14, 740, 8, 68, 14, 1457, 63, 602, 9, 199, 199, 32, 9098, 14, 14189, 342, 199, 318, 664, 63, 30002, 63, 1457, 63, 9356, 8, 504, 63, 602, 12, 370, 63, 602, 12, 15778, 29, 403, 12, 9948, 198, 4627, 29, 403, 12, 1006, 63, 6717, 29, 797, 304, 199, 198, 1457, 63, 9356, 275, 942, 199, 198, 509, 1853, 63, 513, 315, 664, 63, 30002, 63, 1457, 63, 6717, 8, 10103, 12, 7233, 12, 1006, 63, 6717, 304, 507, 198, 1457, 63, 9356, 14, 2880, 8, 9098, 14, 697, 14, 3009, 4852, 2416, 1853, 63, 602, 12, 4499, 20866, 198, 504, 658, 2902, 23679, 8651, 3820, 6148, 64, 2382, 1676, 2458, 83, 20866, 198, 460, 1853, 63, 602, 3382, 450, 83, 436, 450, 83, 7208, 334, 1457, 63, 513, 12, 687, 63, 602, 12, 370, 63, 602, 395, 20866, 198, 305, 63, 807, 29, 17, 430, 1585, 199, 198, 1107, 1853, 63, 9356, 686, 199, 318, 664, 63, 30002, 63, 1457, 63, 6717, 8, 10103, 29, 403, 12, 7233, 29, 403, 12, 1006, 63, 6717, 29, 797, 304, 199, 198, 1457, 63, 6717, 275, 942, 8299, 198, 692, 440, 15778, 26, 507, 198, 10103, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 22635, 401, 2420, 751, 63, 344, 582, 9098, 14, 1730, 14, 751, 1552, 507, 198, 692, 440, 15778, 26, 686, 198, 1107, 942, 8299, 198, 692, 440, 7233, 26, 507, 198, 4627, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 22635, 401, 15778, 12, 298, 4627, 531, 18118, 198, 318, 1050, 63, 1457, 63, 513, 8, 1457, 63, 513, 304, 507, 198, 692, 1853, 63, 513, 26, 686, 198, 692, 1006, 63, 6717, 503, 440, 365, 63, 751, 63, 262, 63, 3306, 63, 513, 8, 1457, 63, 513, 304, 1585, 198, 1457, 63, 6717, 14, 740, 8, 1457, 63, 513, 9, 421, 198, 3, 1126, 27669, 199, 198, 19623, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 22635, 401, 10103, 12, 298, 19623, 531, 199, 198, 692, 27669, 26, 507, 198, 1457, 63, 513, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 872, 12493, 401, 27669, 12, 298, 12422, 63, 1457, 63, 513, 531, 507, 198, 525, 63, 1457, 63, 513, 8, 1457, 63, 513, 9, 421, 198, 3, 2288, 199, 198, 509, 1853, 63, 513, 315, 6950, 14, 697, 14, 3009, 63, 513, 4852, 2416, 536, 687, 658, 2902, 23679, 8651, 3820, 64, 507, 198, 4509, 340, 2307, 8, 571, 6528, 63, 475, 63, 452, 63, 27532, 1470, 12, 16, 23397, 17, 436, 7233, 2458, 83, 7208, 7233, 304, 507, 198, 525, 63, 1457, 63, 513, 8, 1457, 63, 513, 9, 18118, 198, 1107, 769, 8, 409, 8, 1457, 63, 6717, 430, 507, 199, 318, 365, 63, 751, 63, 262, 63, 3306, 63, 513, 8, 1457, 63, 513, 304, 199, 198, 1107, 6950, 14, 1730, 14, 751, 315, 6950, 14, 697, 14, 3009, 63, 513, 4852, 2416, 2040, 63, 751, 507, 198, 504, 658, 2902, 23679, 8651, 3820, 9812, 64, 2382, 1676, 2458, 83, 7208, 1853, 63, 513, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
carnotweat/cpupimp
libs/pyasn1/type/tagmap.py
200
1772
from pyasn1 import error class TagMap: def __init__(self, posMap={}, negMap={}, defType=None): self.__posMap = posMap.copy() self.__negMap = negMap.copy() self.__defType = defType def __contains__(self, tagSet): return tagSet in self.__posMap or \ self.__defType is not None and tagSet not in self.__negMap def __getitem__(self, tagSet): if tagSet in self.__posMap: return self.__posMap[tagSet] elif tagSet in self.__negMap: raise error.PyAsn1Error('Key in negative map') elif self.__defType is not None: return self.__defType else: raise KeyError() def __repr__(self): s = '%r/%r' % (self.__posMap, self.__negMap) if self.__defType is not None: s = s + '/%r' % (self.__defType,) return s def clone(self, parentType, tagMap, uniq=False): if self.__defType is not None and tagMap.getDef() is not None: raise error.PyAsn1Error('Duplicate default value at %s' % (self,)) if tagMap.getDef() is not None: defType = tagMap.getDef() else: defType = self.__defType posMap = self.__posMap.copy() for k in tagMap.getPosMap(): if uniq and k in posMap: raise error.PyAsn1Error('Duplicate positive key %s' % (k,)) posMap[k] = parentType negMap = self.__negMap.copy() negMap.update(tagMap.getNegMap()) return self.__class__( posMap, negMap, defType, ) def getPosMap(self): return self.__posMap.copy() def getNegMap(self): return self.__negMap.copy() def getDef(self): return self.__defType
gpl-3.0
[ 504, 1134, 6228, 17, 492, 1125, 199, 199, 533, 8053, 2956, 26, 272, 347, 636, 826, 721, 277, 12, 2086, 2956, 10324, 14158, 2956, 10324, 347, 804, 29, 403, 304, 267, 291, 855, 1712, 2956, 275, 2086, 2956, 14, 1574, 342, 267, 291, 855, 8705, 2956, 275, 14158, 2956, 14, 1574, 342, 267, 291, 855, 318, 804, 275, 347, 804, 5493, 347, 636, 6134, 721, 277, 12, 30050, 304, 267, 372, 30050, 315, 291, 855, 1712, 2956, 503, 971, 2049, 291, 855, 318, 804, 365, 440, 488, 436, 30050, 440, 315, 291, 855, 8705, 2956, 339, 347, 636, 6095, 721, 277, 12, 30050, 304, 267, 340, 30050, 315, 291, 855, 1712, 2956, 26, 288, 372, 291, 855, 1712, 2956, 59, 27420, 61, 267, 916, 30050, 315, 291, 855, 8705, 2956, 26, 288, 746, 1125, 14, 2713, 2822, 78, 17, 547, 360, 1197, 315, 6946, 2341, 358, 267, 916, 291, 855, 318, 804, 365, 440, 488, 26, 288, 372, 291, 855, 318, 804, 267, 587, 26, 288, 746, 4067, 342, 339, 347, 636, 2722, 721, 277, 304, 267, 308, 275, 1543, 82, 3149, 82, 7, 450, 334, 277, 855, 1712, 2956, 12, 291, 855, 8705, 2956, 9, 267, 340, 291, 855, 318, 804, 365, 440, 488, 26, 288, 308, 275, 308, 435, 1994, 5, 82, 7, 450, 334, 277, 855, 318, 804, 4258, 267, 372, 308, 339, 347, 7289, 8, 277, 12, 1676, 804, 12, 1947, 2956, 12, 625, 9962, 29, 797, 304, 267, 340, 291, 855, 318, 804, 365, 440, 488, 436, 1947, 2956, 14, 362, 6172, 342, 365, 440, 488, 26, 288, 746, 1125, 14, 2713, 2822, 78, 17, 547, 360, 14773, 849, 574, 737, 450, 83, 7, 450, 334, 277, 4641, 267, 340, 1947, 2956, 14, 362, 6172, 342, 365, 440, 488, 26, 288, 347, 804, 275, 1947, 2956, 14, 362, 6172, 342, 267, 587, 26, 288, 347, 804, 275, 291, 855, 318, 804, 10631, 2086, 2956, 275, 291, 855, 1712, 2956, 14, 1574, 342, 267, 367, 1022, 315, 1947, 2956, 14, 362, 6981, 2956, 837, 288, 340, 625, 9962, 436, 1022, 315, 2086, 2956, 26, 355, 746, 1125, 14, 2713, 2822, 78, 17, 547, 360, 14773, 7317, 790, 450, 83, 7, 450, 334, 75, 4641, 288, 2086, 2956, 59, 75, 61, 275, 1676, 804, 398, 14158, 2956, 275, 291, 855, 8705, 2956, 14, 1574, 342, 267, 14158, 2956, 14, 873, 8, 1450, 2956, 14, 362, 27814, 2956, 1012, 2728, 372, 291, 855, 533, 721, 288, 2086, 2956, 12, 14158, 2956, 12, 347, 804, 12, 288, 776, 339, 347, 664, 6981, 2956, 8, 277, 304, 372, 291, 855, 1712, 2956, 14, 1574, 342, 272, 347, 664, 27814, 2956, 8, 277, 304, 372, 291, 855, 8705, 2956, 14, 1574, 342, 272, 347, 664, 6172, 8, 277, 304, 372, 291, 855, 318, 804, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1134, 6228, 17, 492, 1125, 199, 199, 533, 8053, 2956, 26, 272, 347, 636, 826, 721, 277, 12, 2086, 2956, 10324, 14158, 2956, 10324, 347, 804, 29, 403, 304, 267, 291, 855, 1712, 2956, 275, 2086, 2956, 14, 1574, 342, 267, 291, 855, 8705, 2956, 275, 14158, 2956, 14, 1574, 342, 267, 291, 855, 318, 804, 275, 347, 804, 5493, 347, 636, 6134, 721, 277, 12, 30050, 304, 267, 372, 30050, 315, 291, 855, 1712, 2956, 503, 971, 2049, 291, 855, 318, 804, 365, 440, 488, 436, 30050, 440, 315, 291, 855, 8705, 2956, 339, 347, 636, 6095, 721, 277, 12, 30050, 304, 267, 340, 30050, 315, 291, 855, 1712, 2956, 26, 288, 372, 291, 855, 1712, 2956, 59, 27420, 61, 267, 916, 30050, 315, 291, 855, 8705, 2956, 26, 288, 746, 1125, 14, 2713, 2822, 78, 17, 547, 360, 1197, 315, 6946, 2341, 358, 267, 916, 291, 855, 318, 804, 365, 440, 488, 26, 288, 372, 291, 855, 318, 804, 267, 587, 26, 288, 746, 4067, 342, 339, 347, 636, 2722, 721, 277, 304, 267, 308, 275, 1543, 82, 3149, 82, 7, 450, 334, 277, 855, 1712, 2956, 12, 291, 855, 8705, 2956, 9, 267, 340, 291, 855, 318, 804, 365, 440, 488, 26, 288, 308, 275, 308, 435, 1994, 5, 82, 7, 450, 334, 277, 855, 318, 804, 4258, 267, 372, 308, 339, 347, 7289, 8, 277, 12, 1676, 804, 12, 1947, 2956, 12, 625, 9962, 29, 797, 304, 267, 340, 291, 855, 318, 804, 365, 440, 488, 436, 1947, 2956, 14, 362, 6172, 342, 365, 440, 488, 26, 288, 746, 1125, 14, 2713, 2822, 78, 17, 547, 360, 14773, 849, 574, 737, 450, 83, 7, 450, 334, 277, 4641, 267, 340, 1947, 2956, 14, 362, 6172, 342, 365, 440, 488, 26, 288, 347, 804, 275, 1947, 2956, 14, 362, 6172, 342, 267, 587, 26, 288, 347, 804, 275, 291, 855, 318, 804, 10631, 2086, 2956, 275, 291, 855, 1712, 2956, 14, 1574, 342, 267, 367, 1022, 315, 1947, 2956, 14, 362, 6981, 2956, 837, 288, 340, 625, 9962, 436, 1022, 315, 2086, 2956, 26, 355, 746, 1125, 14, 2713, 2822, 78, 17, 547, 360, 14773, 7317, 790, 450, 83, 7, 450, 334, 75, 4641, 288, 2086, 2956, 59, 75, 61, 275, 1676, 804, 398, 14158, 2956, 275, 291, 855, 8705, 2956, 14, 1574, 342, 267, 14158, 2956, 14, 873, 8, 1450, 2956, 14, 362, 27814, 2956, 1012, 2728, 372, 291, 855, 533, 721, 288, 2086, 2956, 12, 14158, 2956, 12, 347, 804, 12, 288, 776, 339, 347, 664, 6981, 2956, 8, 277, 304, 372, 291, 855, 1712, 2956, 14, 1574, 342, 272, 347, 664, 27814, 2956, 8, 277, 304, 372, 291, 855, 8705, 2956, 14, 1574, 342, 272, 347, 664, 6172, 8, 277, 304, 372, 291, 855, 318, 804, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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